-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from TrustlessComputer/daily_reward
Daily reward
- Loading branch information
Showing
18 changed files
with
570 additions
and
49 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
width: 100%; | ||
|
||
:global { | ||
--top-spacing: 24px; | ||
--top-spacing: 20px; | ||
--item-spacing: 12px; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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 { getPublicSaleProgram, IPublicSalePrograme } from '@/services/public-sale'; | ||
import HourlyRewardButton from '@/modules/PublicSale/hourlyRewardButton'; | ||
import { useAppSelector } from '@/stores/hooks'; | ||
import { commonSelector } from '@/stores/states/common/selector'; | ||
import BigNumber from 'bignumber.js'; | ||
import { PUBLIC_SALE_START } from '@/modules/Whitelist'; | ||
import { formatCurrency } from '@/utils/format'; | ||
import { MIN_DECIMAL } from '@/constants/constants'; | ||
|
||
const HourlyReward = () => { | ||
const [isLoading, setIsLoading] = useState(true); | ||
const [isEnd, setIsEnd] = React.useState(false); | ||
const [programeInfo, setProgrameInfo] = useState<IPublicSalePrograme>(); | ||
const configs = useAppSelector(commonSelector).configs; | ||
|
||
useEffect(() => { | ||
getProgramInfo(); | ||
}, []); | ||
|
||
const getProgramInfo = async () => { | ||
try { | ||
const res = await getPublicSaleProgram(); | ||
setProgrameInfo(res); | ||
} catch (e) { | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
const currentDay = React.useMemo(() => { | ||
const diffDay = new BigNumber( | ||
dayjs.utc(PUBLIC_SALE_START).diff(dayjs.utc(), 'days'), | ||
) | ||
.absoluteValue() | ||
.toNumber(); | ||
return { | ||
// step: DAYS.length > diffDay ? DAYS[diffDay] : DAYS[DAYS.length - 1], | ||
diffDay, | ||
}; | ||
}, []); | ||
|
||
const REWARDS = useMemo(() => { | ||
if(configs) { | ||
if(configs['naka']?.bvm_halvings) { | ||
const res = JSON.parse(configs['naka']?.bvm_halvings); | ||
return Object.values(res); | ||
} | ||
} | ||
return []; | ||
}, [configs]); | ||
|
||
const currentHourReward: number = useMemo(() => { | ||
return (REWARDS[currentDay.diffDay] as number) / 24; | ||
}, [currentDay, REWARDS]) | ||
|
||
return ( | ||
<Flex className={s.container}> | ||
<Flex justifyContent={"space-between"} alignItems={"center"} gap={"6px"}> | ||
<Text className={s.title}>Hourly Reward</Text> | ||
<Flex className={s.timeWrapper}> | ||
<Text className={s.time}>{formatCurrency(currentHourReward, 0, 0, 'BTC', false)} BVM</Text> | ||
</Flex> | ||
</Flex> | ||
<HourlyRewardButton /> | ||
</Flex> | ||
) | ||
} | ||
|
||
export default HourlyReward; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
.container { | ||
position: absolute; | ||
flex-direction: column; | ||
top: var(--top-spacing); | ||
right: 20px; | ||
gap: 16px; | ||
//min-width: 280px; | ||
//max-width: 280px; | ||
//border: 1px solid #ffffff1a; | ||
background: linear-gradient(180deg, #FDF6EA 0%, #FCF2DC 27%, #FBECC9 72.17%, #FBECC9 100%); | ||
padding: 12px; | ||
width: fit-content; | ||
|
||
.title { | ||
font-size: 12px; | ||
line-height: 100%; | ||
font-weight: 400; | ||
color: #894D1C; | ||
padding-top: 1px; | ||
} | ||
|
||
.time { | ||
//margin-top: 10px; | ||
font-size: 14px; | ||
line-height: 100%; | ||
font-weight: 500; | ||
text-transform: uppercase; | ||
background: linear-gradient(180deg, #DF7E2E -12.5%, #894D1C 100%); | ||
-webkit-background-clip: text; | ||
-webkit-text-fill-color: transparent; | ||
background-clip: text; | ||
|
||
p { | ||
font-size: inherit !important; | ||
font-weight: inherit !important; | ||
white-space: pre; | ||
} | ||
|
||
@include is-mobile { | ||
font-size: 14px; | ||
} | ||
} | ||
|
||
@include is-mobile { | ||
max-width: unset; | ||
width: calc(100% - 50px); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Center, Flex, Text } from '@chakra-ui/react'; | ||
import s from './styles.module.scss'; | ||
import React, { useMemo } from 'react'; | ||
import cx from 'clsx'; | ||
import dayjs from 'dayjs'; | ||
import Countdown from '@/modules/Whitelist/stepAirdrop/Countdown'; | ||
|
||
const HourlyRewardButton = ({ className }: any) => { | ||
const [isEnd, setIsEnd] = React.useState(false); | ||
|
||
const hourlyEndTime = useMemo(() => { | ||
let res = dayjs.utc().set('minute', 30); | ||
res = res.set('second', 0); | ||
if (dayjs().utc().isAfter(res)) { | ||
res = res.set('hour', res.get('hour') + 1); | ||
} | ||
if(isEnd) { | ||
setIsEnd(false); | ||
} | ||
|
||
return res.toString(); | ||
}, [isEnd]); | ||
|
||
// console.log('dayjs.utc()', dayjs.utc().toString()); | ||
// console.log('hourlyEndTime', hourlyEndTime); | ||
|
||
return ( | ||
<Flex className={cx(s.container, className)}> | ||
<Flex direction={"column"} justifyContent={"space-between"} flex={1}> | ||
<Center className={s.hourglassWrapper}> | ||
<div className="hourglass"> | ||
<div className="top"></div> | ||
<div className="bottom"></div> | ||
</div> | ||
</Center> | ||
|
||
<Flex gap={'6px'} className={s.timeWrapper}> | ||
<Text className={s.title}>End in</Text> | ||
<Countdown | ||
className={s.time} | ||
expiredTime={dayjs | ||
.utc(hourlyEndTime, 'YYYY-MM-DD HH:mm:ss') | ||
.toString()} | ||
hideIcon={true} | ||
onRefreshEnd={() => setIsEnd(true)} | ||
type={"column"} | ||
showColon={true} | ||
/> | ||
</Flex> | ||
</Flex> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default HourlyRewardButton; |
Oops, something went wrong.