Skip to content

Commit

Permalink
add luckey money
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmegalodon committed Feb 2, 2024
1 parent acf4627 commit 054dc56
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/modules/PublicSale/LuckyMoneyWinner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import s from './styles.module.scss';
import { Flex, Text } from '@chakra-ui/react';
import dayjs from 'dayjs';
import React, { useEffect, useMemo, useState } from 'react';
import {
getLuckyMoneyLastWinner,
LuckyMoneyWinner,
} from '@/services/public-sale';
import HourlyRewardButton from '@/modules/PublicSale/hourlyRewardButton';
import { formatCurrency } from '@/utils/format';
import React, { useEffect, useState } from 'react';
import { getLuckyMoneyLastWinner, LuckyMoneyWinner } from '@/services/public-sale';
import { useAppSelector } from '@/stores/hooks';
import { commonSelector } from '@/stores/states/common/selector';
import background from '@/public/images/lucky-money-envelops/lucky-money-winner-background.png';
import Avatar from '@/components/Avatar';
import relativeTime from 'dayjs/plugin/relativeTime';
import { settingMomentFromNow } from '@/utils/helpers';

dayjs.extend(relativeTime);

settingMomentFromNow();

const LuckyMoneyWinner = () => {
const currentLuckyMoney = useAppSelector(commonSelector).currentLuckyMoney;
const [winner, setWinner] = useState<LuckyMoneyWinner>();
Expand Down Expand Up @@ -47,12 +44,12 @@ const LuckyMoneyWinner = () => {
<div>
<div className={s.textMessage}>
<strong>{winner?.user.twitter_name || '---'}</strong> just snatched
a red packet successfully and got{' '}
<strong>{winner?.bvm_amount} BVM</strong>.
a red packet successfully and{' '}
<strong>got {winner?.bvm_amount} BVM</strong>.
</div>
<div className={s.time}>
{winner?.updated_at
? dayjs(winner?.updated_at).fromNow(true)
? `${dayjs(winner?.updated_at).fromNow(true)} ago`
: '--:--'}
</div>
</div>
Expand Down
21 changes: 21 additions & 0 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UUID } from '@/constants/storage-key';
import { APP_ENV } from '@/config';
import { formatCurrency } from '@/utils/format';
import BigNumber from 'bignumber.js';
import dayjs from 'dayjs';

export const getUuid = (): string => {
let uuidText = window.localStorage.getItem(UUID) as string;
Expand Down Expand Up @@ -122,3 +123,23 @@ export const getAvatarName = (name: string): string => {
}
return words;
};

export const settingMomentFromNow = () => {
dayjs.locale('en', {
relativeTime: {
future: 'in %s',
past: '%s',
s: '%ds',
m: '1m',
mm: '%dm',
h: '1h',
hh: '%dh',
d: '1d',
dd: '%dd',
M: '1M',
MM: '%dM',
y: '1Y',
yy: '%dY',
},
});
};

0 comments on commit 054dc56

Please sign in to comment.