Skip to content

Commit

Permalink
Merge pull request #115 from TrustlessComputer/feat/whitelist_munual
Browse files Browse the repository at this point in the history
Feat/whitelist munual
  • Loading branch information
0xmegalodon authored Jan 29, 2024
2 parents 863533d + 419c230 commit c910ff9
Showing 11 changed files with 101 additions and 49 deletions.
11 changes: 7 additions & 4 deletions src/app/allowlist/page.tsx
Original file line number Diff line number Diff line change
@@ -10,12 +10,15 @@ const dayjs = require('dayjs');
const utc = require('dayjs/plugin/utc');
dayjs.extend(utc);

export const checkIsPublicSale = () => {
return dayjs
.utc(PUBLIC_SALE_START, 'YYYY-MM-DD HH:mm:ss')
.isBefore(dayjs().utc().format());
}

const Whitelist = () => {
const onRedirect = () => {
const PUBLIC_SALE_TIME = isProduction ? PUBLIC_SALE_START : '2024-01-29 04:00:00';
const isPublicSale = dayjs
.utc(PUBLIC_SALE_TIME, 'YYYY-MM-DD HH:mm:ss')
.isBefore(dayjs().utc().format());
const isPublicSale = checkIsPublicSale();
if (isPublicSale) redirect('public-sale');
}
React.useEffect(() => {
4 changes: 0 additions & 4 deletions src/modules/PublicSale/BuyForm/index.tsx
Original file line number Diff line number Diff line change
@@ -70,10 +70,6 @@ const PrivateSaleForm = ({ vcInfo }: { vcInfo?: VCInfo }) => {
useState<ILeaderBoardPoint>();
const token = AuthenStorage.getAuthenKey() || AuthenStorage.getGuestAuthenKey();

console.log('contributeInfo', contributeInfo);
console.log('userContributeInfo', userContributeInfo);
console.log('=======');

useEffect(() => {
getContributeInfo();

2 changes: 1 addition & 1 deletion src/modules/PublicSale/aboveTheFold/index.tsx
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ const AboveTheFold = () => {

return (
<Flex direction={"column"} justifyContent={"space-between"} className={s.container} bgImg={`/private-sale/bg.webp`}>
<SimpleGrid className={`${s.content}`} gridTemplateColumns={["1fr", "1fr 1fr"]} gap={[0, 0]}>
<SimpleGrid className={`${s.content}`} gridTemplateColumns={{ lg: "1fr", xl: "1fr 1fr" }} gap={[0, 0]}>
<Flex className={s.leftSection} direction={"column"} justifyContent={"flex-start"}>
<TopHeader />
<LeaderBoardVisual />
4 changes: 4 additions & 0 deletions src/modules/PublicSale/aboveTheFold/styles.module.scss
Original file line number Diff line number Diff line change
@@ -26,6 +26,10 @@
-ms-overflow-style: none; /* Internet Explorer 10+ */
scrollbar-width: none; /* Firefox */

@include w-max(768px) {
height: unset;
}

&::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}
17 changes: 13 additions & 4 deletions src/modules/PublicSale/leaderBoardVisual/index.tsx
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ const LeaderBoardVisual = (props: IProps) => {
const needReload = useAppSelector(commonSelector).needReload;
const dispatch = useAppDispatch();
const leaderBoardMode = useSelector(commonSelector).leaderBoardMode;
const [latestContributors, setLatestContributors] = useState<ILeaderBoardPoint[]>([]);
const latestContributors = useRef<ILeaderBoardPoint[]>([]);
const user = useAppSelector(userSelector);

const hasIncrementedPageRef = useRef(false);
@@ -38,6 +38,7 @@ const LeaderBoardVisual = (props: IProps) => {
const refInitial = useRef(false);

useEffect(() => {
fetchLatestData();
const interval = setInterval(() => {
fetchLatestData();
}, 10000);
@@ -100,8 +101,16 @@ const LeaderBoardVisual = (props: IProps) => {
};

const fetchLatestData = async () => {
const res = await getPublicSaleContributionLatest();
setLatestContributors(res);
let res = await getPublicSaleContributionLatest();
const oldContributors = latestContributors?.current;

const newRes = res.filter( function( el ) {
return oldContributors?.findIndex(a => a.twitter_id === el.twitter_id) < 0;
});

if(newRes?.length > 0) {
latestContributors.current = newRes;
}
};

useEffect(() => {
@@ -161,7 +170,7 @@ const LeaderBoardVisual = (props: IProps) => {
})
}
</ScrollWrapper>
<AnimatedText latestContributors={latestContributors} />
<AnimatedText latestContributors={latestContributors?.current} />
</div>
);
};
15 changes: 14 additions & 1 deletion src/modules/PublicSale/playGame/index.tsx
Original file line number Diff line number Diff line change
@@ -3,6 +3,11 @@ import s from './styles.module.scss';
import EternalAi from './VideoFrame';
import React, { useState } from 'react';
import cx from 'clsx';
import dayjs from 'dayjs';
import { PUBLIC_SALE_START } from '@/modules/Whitelist';
import BigNumber from 'bignumber.js';

const TIME_DAY = 1000 * 60 * 60 * 24;

const Playgame = () => {
const DAYS = React.useMemo(() => {
@@ -17,7 +22,15 @@ const Playgame = () => {
]
}, [])

const [selectedDay, setSelectedDay] = useState(DAYS[0]);
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 [selectedDay, setSelectedDay] = useState(currentDay.step);

return (
<Flex className={s.container} direction={"column"}>
2 changes: 1 addition & 1 deletion src/modules/PublicSale/playGame/styles.module.scss
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
.content {
max-width: 826px;
margin: 0 auto;
padding: 0 24px;
padding: 0 24px 24px 24px;
margin-top: 60px;

&_inner {
36 changes: 30 additions & 6 deletions src/modules/PublicSale/raffleButton/index.tsx
Original file line number Diff line number Diff line change
@@ -54,12 +54,36 @@ const RaffleButton = ({className}: any) => {
<Popover>
<PopoverTrigger>
<Flex className={cx(s.container, className)}>
<Countdown
className={s.time}
expiredTime={dayjs.utc(programeInfo?.end_date, 'YYYY-MM-DD HH:mm:ss').toString()}
hideIcon={true}
onRefreshEnd={() => setIsEnd(true)}
/>
<Flex gap={"6px"} className={s.timeWrapper}>
<svg width="13" height="12" viewBox="0 0 13 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3.8336 3.81861C3.78016 4.38861 3.74266 5.39736 4.07923 5.82674C4.07923 5.82674 3.92079 4.71861 5.3411 3.3283C5.91298 2.76861 6.04516 2.00736 5.84548 1.43642C5.73204 1.11299 5.52485 0.845799 5.34485 0.659236C5.23985 0.549549 5.32048 0.368611 5.47329 0.375174C6.39766 0.416424 7.89579 0.673298 8.53235 2.2708C8.81173 2.97205 8.83235 3.69674 8.69923 4.43361C8.61485 4.90424 8.31485 5.95049 8.99923 6.07892C9.48766 6.1708 9.72391 5.78267 9.82985 5.5033C9.87391 5.38705 10.0267 5.35799 10.1092 5.4508C10.9342 6.38924 11.0045 7.49455 10.8339 8.44611C10.5039 10.2855 8.6411 11.6242 6.79048 11.6242C4.4786 11.6242 2.63829 10.3014 2.1611 7.90705C1.96891 6.94049 2.06641 5.02799 3.55704 3.67799C3.66766 3.57674 3.8486 3.66674 3.8336 3.81861Z" fill="url(#paint0_radial_30141_6168)"/>
<path d="M7.63538 7.25774C6.78319 6.16086 7.16475 4.9093 7.37381 4.41055C7.40194 4.34493 7.32694 4.28305 7.26788 4.32336C6.90131 4.57274 6.15038 5.15961 5.80069 5.98555C5.32725 7.10211 5.361 7.64868 5.64131 8.31618C5.81006 8.71836 5.61413 8.80368 5.51569 8.81868C5.42006 8.83368 5.33194 8.76993 5.26163 8.70336C5.05935 8.50917 4.91521 8.26244 4.84538 7.99086C4.83038 7.93274 4.75444 7.9168 4.71975 7.96461C4.45725 8.32743 4.32131 8.90961 4.31475 9.32118C4.29413 10.5934 5.34506 11.6246 6.61631 11.6246C8.2185 11.6246 9.38569 9.85274 8.46506 8.37149C8.19788 7.94024 7.94663 7.65805 7.63538 7.25774Z" fill="url(#paint1_radial_30141_6168)"/>
<defs>
<radialGradient id="paint0_radial_30141_6168" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(6.33258 11.6534) rotate(-179.751) scale(6.61759 10.8581)">
<stop offset="0.314" stop-color="#FF9800"/>
<stop offset="0.662" stop-color="#FF6D00"/>
<stop offset="0.972" stop-color="#F44336"/>
</radialGradient>
<radialGradient id="paint1_radial_30141_6168" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(6.70443 5.06759) rotate(90.5787) scale(6.92404 5.21086)">
<stop offset="0.214" stop-color="#FFF176"/>
<stop offset="0.328" stop-color="#FFF27D"/>
<stop offset="0.487" stop-color="#FFF48F"/>
<stop offset="0.672" stop-color="#FFF7AD"/>
<stop offset="0.793" stop-color="#FFF9C4"/>
<stop offset="0.822" stop-color="#FFF8BD" stop-opacity="0.804"/>
<stop offset="0.863" stop-color="#FFF6AB" stop-opacity="0.529"/>
<stop offset="0.91" stop-color="#FFF38D" stop-opacity="0.209"/>
<stop offset="0.941" stop-color="#FFF176" stop-opacity="0"/>
</radialGradient>
</defs>
</svg>
<Countdown
className={s.time}
expiredTime={dayjs.utc(programeInfo?.end_date, 'YYYY-MM-DD HH:mm:ss').toString()}
hideIcon={true}
onRefreshEnd={() => setIsEnd(true)}
/>
</Flex>
</Flex>
</PopoverTrigger>
<PopoverContent className={cx(s.menuContent)}>
12 changes: 8 additions & 4 deletions src/modules/PublicSale/raffleButton/styles.module.scss
Original file line number Diff line number Diff line change
@@ -15,12 +15,16 @@
height: 80px;
}

.time {
margin-top: 10px;
font-size: 16px;
font-weight: 500;
.timeWrapper {
position: absolute;
bottom: -10px;
}

.time {
//margin-top: 10px;
font-size: 12px;
font-weight: 500;
text-transform: uppercase;

p {
font-size: inherit !important;
4 changes: 3 additions & 1 deletion src/modules/Whitelist/index.tsx
Original file line number Diff line number Diff line change
@@ -20,10 +20,12 @@ import useAllowEVM from '@/modules/Whitelist/AllowEVMMessage/useAllowEVM';
import dayjs from 'dayjs';
import Countdown from '@/modules/Whitelist/stepAirdrop/Countdown';
import ArcadeBanner from '@/modules/Whitelist/ArcadeBanner';
import { isProduction } from '@/config';

const CONTAINER_ID = 'WHITE_LIST_CONTAINER_ID';

export const PUBLIC_SALE_START = '2024-01-30 03:30:00'
export const PUBLIC_SALE_START = isProduction ? '2024-01-30 03:30:00' : '2024-01-29 04:00:00'
export const PUBLIC_SALE_END = '2024-02-06 03:30:00'

const Whitelist = () => {
useAllowBTC();
43 changes: 20 additions & 23 deletions src/modules/landing/Componets/Hero/JoinAllowList/index.tsx
Original file line number Diff line number Diff line change
@@ -10,9 +10,10 @@ import Image from 'next/image';
import { formatCurrency } from '@/utils/format';
import Countdown from '@/modules/Whitelist/stepAirdrop/Countdown';
import dayjs from 'dayjs';
import { PUBLIC_SALE_START } from '@/modules/Whitelist';
import { PUBLIC_SALE_END, PUBLIC_SALE_START } from '@/modules/Whitelist';
import { CDN_URL_ICONS } from '@/config';

import { getPublicSaleSummary } from '@/services/public-sale';
import { checkIsPublicSale } from '@/app/allowlist/page';

const DELAY = 2;
const JoinAllowList = ({isFooter}: {isFooter?: boolean}) => {
@@ -21,20 +22,27 @@ const JoinAllowList = ({isFooter}: {isFooter?: boolean}) => {
const [totalUser, setTotalUser] = useState<string>('');
const [listUser, setListUser] = useState<ILeaderBoardPoint[]>([]);

const isPublicSale = React.useMemo(() => checkIsPublicSale(), [])

const getCount = async () => {
try {
const response = await getTopLeaderBoards({ page: 1, limit: 20 });
const topWhiteList = response.data.filter((item, index) => index < 5);
setTotalUser(response.count);
setListUser(topWhiteList);
if (isPublicSale) {
const response = await getPublicSaleSummary();
setTotalUser(response.total_user.toString());
} else {
const response = await getTopLeaderBoards({ page: 1, limit: 20 });
const topWhiteList = response.data.filter((item, index) => index < 5);
setTotalUser(response.count);
setListUser(topWhiteList);
}
} catch (e) {
console.log(e);
}
};

React.useEffect(() => {
getCount();
}, []);
}, [isPublicSale]);

const delay = isFooter ? 0 : DELAY;

@@ -66,38 +74,27 @@ const JoinAllowList = ({isFooter}: {isFooter?: boolean}) => {
loadingText={'Submitting...'}
className={s.button}
onClick={() => {
if (isPublicSale) return router.push('/public-sale')
router.push('/allowlist');
}}
>
Get on the allowlist
Get on the {isPublicSale ? 'public sale' : 'allowlist'}
</Button>
<div className={s.whiteList}>
<div className={s.whiteList_users}>
<Image src={'/landing/allow-avatars.png'} quality={100} width={88} height={24}
alt={'allow-avatars'} />
{/*{listUser.map((item) => {*/}
{/* return (*/}
{/* <figure className={s.whiteList_users_avatar} key={item.id}>*/}
{/* <Image*/}
{/* src={item.twitter_avatar}*/}
{/* width={23}*/}
{/* height={23}*/}
{/* alt={item.twitter_name}*/}
{/* />*/}
{/* </figure>*/}
{/* );*/}
{/*})}*/}
</div>
<div className={s.whiteList_total}>
<span>{formatCurrency(totalUser, 0,0)}&nbsp;people</span>&nbsp;are on the allowlist
<span>{formatCurrency(totalUser, 0,0)}&nbsp;people</span>&nbsp;are on the {isPublicSale ? "public sale" : "allowlist"}
</div>
</div>
<Flex gap="8px" className={s.countDown_wrapper}>
<img style={{ width: 18 }} src={`${CDN_URL_ICONS}/hourglass.png`}/>
<p className={s.countDown_title}>Public sale starting in</p>
<p className={s.countDown_title}>Public sale {isPublicSale ? 'ending' : 'starting'} in</p>
<Countdown
className={s.countDown_time}
expiredTime={dayjs.utc(PUBLIC_SALE_START, 'YYYY-MM-DD HH:mm:ss').toString()}
expiredTime={dayjs.utc(isPublicSale ? PUBLIC_SALE_END : PUBLIC_SALE_START, 'YYYY-MM-DD HH:mm:ss').toString()}
hideIcon={true}
/>
</Flex>

0 comments on commit c910ff9

Please sign in to comment.