Skip to content

Commit

Permalink
Merge pull request #187 from TrustlessComputer/daily_reward
Browse files Browse the repository at this point in the history
update
  • Loading branch information
0xmegalodon authored Jan 31, 2024
2 parents 0c85258 + 4278dde commit 4103dcb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
29 changes: 17 additions & 12 deletions src/modules/PublicSale/raffleButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from '@chakra-ui/react';
import s from './styles.module.scss';
import dayjs from 'dayjs';
import Countdown from '@/modules/Whitelist/stepAirdrop/Countdown';
import React, { useEffect, useState } from 'react';
import cx from 'clsx';
import { useAppSelector } from '@/stores/hooks';
Expand All @@ -24,10 +23,10 @@ import {
IPublicSalePrograme,
joinRafflePrograme,
} from '@/services/public-sale';
import AuthenStorage from '@/utils/storage/authen.storage';
import { formatCurrency } from '@/utils/format';
import BigNumber from 'bignumber.js';
import { PUBLIC_SALE_START } from '@/modules/Whitelist';
import useWindowSize from '@/hooks/useWindowSize';

const RaffleButton = ({ className }: any) => {
const { isOpen, onOpen, onClose } = useDisclosure();
Expand All @@ -36,8 +35,7 @@ const RaffleButton = ({ className }: any) => {
const [programeInfo, setProgrameInfo] = useState<IPublicSalePrograme>();
const [isLoading, setIsLoading] = useState(true);
const [raffleCode, setRaffleCode] = useState();
const token =
AuthenStorage.getAuthenKey() || AuthenStorage.getGuestAuthenKey();
const { mobileScreen } = useWindowSize();

const handleShareTw = () => {
const url = `https://twitter.com/BVMnetwork/status/1752550686095798386`;
Expand Down Expand Up @@ -91,12 +89,15 @@ const RaffleButton = ({ className }: any) => {
'BTC',
true,
)} to building Bitcoin's future with @BVMnetwork\n\n`;
return window.open(
`https://twitter.com/intent/tweet?url=${shareUrl}&text=${encodeURIComponent(
content,
)}`,
'_blank',
);

setTimeout(() => {
return window.open(
`https://twitter.com/intent/tweet?url=${shareUrl}&text=${encodeURIComponent(
content,
)}`,
'_blank',
);
}, 300);
};

const currentDay = React.useMemo(() => {
Expand All @@ -116,7 +117,7 @@ const RaffleButton = ({ className }: any) => {
<Popover onClose={onClose} isOpen={isOpen}>
<PopoverTrigger>
<Flex className={cx(s.container, className)}>
<Flex onMouseOver={onOpen} gap={'8px'} alignItems={'flex-start'}>
<Flex onMouseOver={mobileScreen ? undefined : onOpen} onClick={mobileScreen ? onOpen : undefined} gap={'8px'} alignItems={'flex-start'}>
<Center
cursor={programeInfo?.link ? 'pointer' : 'default'}
className={s.raffleBgIcon}
Expand Down Expand Up @@ -212,7 +213,11 @@ const RaffleButton = ({ className }: any) => {
<Flex
className={cx(s.learnMoreWrapper)}
gap={2}
onClick={onShareNow}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
onShareNow();
}}
cursor="pointer"
w={"100%"}
>
Expand Down
11 changes: 8 additions & 3 deletions src/modules/PublicSale/rewardButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import BigNumber from 'bignumber.js';
import dayjs from 'dayjs';
import { PUBLIC_SALE_START } from '@/modules/Whitelist';
import { commonSelector } from '@/stores/states/common/selector';
import useWindowSize from '@/hooks/useWindowSize';

const REWARD_DAILY = JSON.parse("{\"2024-01-30\":100000,\"2024-01-31\":50000,\"2024-02-01\":50000,\"2024-02-02\":50000,\"2024-02-03\":50000,\"2024-02-04\":50000,\"2024-02-05\":50000}");

Expand All @@ -44,14 +45,14 @@ const RaffleButton = ({ className }: any) => {
const [dailyReward
, setDailyReward] = useState<IPublicSaleDailyReward | null>();
const [isLoading, setIsLoading] = useState(true);
const [raffleCode, setRaffleCode] = useState();
const token =
AuthenStorage.getAuthenKey() || AuthenStorage.getGuestAuthenKey();
const refInterval = useRef<any>(undefined);
const dispatch = useDispatch();
const [authenCode, setAuthenCode] = useState<IAuthenCode>();
const [showManualCheck, setShowManualCheck] = useState(false);
const needReload = useAppSelector(commonSelector).needReload;
const { mobileScreen } = useWindowSize();

const currentDay = React.useMemo(() => {
const diffDay = new BigNumber(
Expand Down Expand Up @@ -216,7 +217,7 @@ const RaffleButton = ({ className }: any) => {
<Popover onClose={onClose} isOpen={isOpen}>
<PopoverTrigger>
<Flex className={cx(s.container, className)}>
<Flex onMouseOver={onOpen} gap={'8px'} alignItems={'center'}>
<Flex onMouseOver={mobileScreen ? undefined : onOpen} onClick={mobileScreen ? onOpen : undefined} gap={'8px'} alignItems={'center'}>
<Center
className={s.raffleBgIcon}
>
Expand All @@ -240,7 +241,11 @@ const RaffleButton = ({ className }: any) => {
<Flex
className={cx(s.learnMoreWrapper)}
gap={2}
onClick={rewardValue > 0 ? handleShareTw : onShareNow}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
rewardValue > 0 ? handleShareTw() : onShareNow()
}}
cursor="pointer"
bg={rewardValue > 0 ? "#FA4E0E" : '#FFFFFF'}
>
Expand Down

0 comments on commit 4103dcb

Please sign in to comment.