Skip to content

Commit

Permalink
chore: Update MainRewards component to show rewards notification when…
Browse files Browse the repository at this point in the history
… earned
  • Loading branch information
mohandast52 committed May 23, 2024
1 parent 1dab9a1 commit 7f8f4aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
35 changes: 12 additions & 23 deletions frontend/components/Main/MainRewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Button, Col, Flex, Modal, Row, Skeleton, Tag, Typography } from 'antd';
import Image from 'next/image';
import { useEffect, useState } from 'react';
import styled from 'styled-components';
import { useTimeout } from 'usehooks-ts';

import { balanceFormat } from '@/common-util';
import { COLOR } from '@/constants';
Expand Down Expand Up @@ -81,15 +82,18 @@ const NotifyRewards = () => {
const { totalOlasBalance } = useBalance();
const { showNotification } = useElectronApi();

const [canShowNotification, setCanShowNotification] = useState(true);
const [canShowNotification, setCanShowNotification] = useState(false);

useTimeout(() => setCanShowNotification(true), 1000);

useEffect(() => {
// const hasAlreadyNotified = false; // TODO: Implement this once state persistence is available
// if (!isEligibleForRewards) return;
// if (hasAlreadyNotified) return;
// setCanShowNotification(
// isEligibleForRewards && !!availableRewardsForEpochEther,
// );
// TODO: Implement this once state persistence is available
const hasAlreadyNotified = false;

if (!isEligibleForRewards) return;
if (hasAlreadyNotified) return;

setCanShowNotification(!!availableRewardsForEpochEther);
}, [isEligibleForRewards, availableRewardsForEpochEther, showNotification]);

useEffect(() => {
Expand All @@ -111,14 +115,7 @@ const NotifyRewards = () => {
width={400}
onCancel={() => setCanShowNotification(false)}
footer={[
<Button
key="back"
// disabled
type="primary"
block
size="large"
style={{ marginTop: 16 }}
>
<Button key="back" type="primary" block size="large" className="mt-8">
<Flex align="center" justify="center" gap={2}>
Share on
<Image src="/twitter.svg" width={24} height={24} alt="OLAS logo" />
Expand Down Expand Up @@ -167,11 +164,3 @@ export const MainRewards = () => (
<NotifyRewards />
</>
);

/**
* animation
* - https://lottiefiles.com/animations/success-icon-iY8xKnizbH
* - https://www.npmjs.com/package/react-confetti-explosion
* - https://fireworks.js.org/
* - https://www.codewithrandom.com/2023/11/21/confetti-effects-using-css/
*/
4 changes: 4 additions & 0 deletions frontend/styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ button, input, select, textarea, .ant-input-suffix {
margin-bottom: auto !important;
}

.mt-8 {
margin-top: 8px !important;
}

.mt-12 {
margin-top: 12px !important;
}
Expand Down

0 comments on commit 7f8f4aa

Please sign in to comment.