From 263f2904acd2d8db7663113016beac99de10dc72 Mon Sep 17 00:00:00 2001 From: 2712 <2712@trustless.computer> Date: Fri, 19 Jan 2024 17:29:50 +0700 Subject: [PATCH] update code --- src/modules/Whitelist/leaderBoard/index.tsx | 170 +++++++++++++------- 1 file changed, 108 insertions(+), 62 deletions(-) diff --git a/src/modules/Whitelist/leaderBoard/index.tsx b/src/modules/Whitelist/leaderBoard/index.tsx index 27985e4fa..e37832854 100644 --- a/src/modules/Whitelist/leaderBoard/index.tsx +++ b/src/modules/Whitelist/leaderBoard/index.tsx @@ -33,14 +33,14 @@ const valueToImage: any = { '30': 'flash_supper.svg', }; -export const LEADER_BOARD_ID = 'LEADER_BOARD_ID' +export const LEADER_BOARD_ID = 'LEADER_BOARD_ID'; const LeaderBoard = () => { const { list } = useAppSelector(leaderBoardSelector); const [isFetching, setIsFetching] = useState(true); const [refreshing, setRefreshing] = useState(false); const needReload = useAppSelector(commonSelector).needReload; - const dispatch = useAppDispatch() + const dispatch = useAppDispatch(); const hasIncrementedPageRef = useRef(false); const refParams = useRef({ @@ -50,7 +50,7 @@ const LeaderBoard = () => { const refInitial = useRef(false); useEffect(() => { - fetchData(true); + fetchData(true); }, [needReload]); const removeOwnerRecord = (arr: ILeaderBoardPoint[] = []) => { @@ -60,10 +60,12 @@ const LeaderBoard = () => { const fetchData = async (isNew?: boolean) => { try { - const sortList = (arr: ILeaderBoardPoint[]) => { - return uniqBy(orderBy(arr, item => Number(item.need_active || false), 'desc'), (item: ILeaderBoardPoint) => item.twitter_id) - } + return uniqBy( + orderBy(arr, (item) => Number(item.need_active || false), 'desc'), + (item: ILeaderBoardPoint) => item.twitter_id, + ); + }; const { data: response, count } = await getTopLeaderBoards({ ...refParams.current, }); @@ -77,18 +79,22 @@ const LeaderBoard = () => { page: 1, }; const reArr = removeOwnerRecord(response); - const arr = sortList(response2.concat(reArr)) - dispatch(setLeaderBoard({ - list: arr, - count - })); + const arr = sortList(response2.concat(reArr)); + dispatch( + setLeaderBoard({ + list: arr, + count, + }), + ); } else { const reArr = removeOwnerRecord(response); const arr = sortList([...reArr]); - dispatch(setLeaderBoard({ - list: arr, - count - })); + dispatch( + setLeaderBoard({ + list: arr, + count, + }), + ); } } catch (error) { } finally { @@ -122,10 +128,9 @@ const LeaderBoard = () => { fontSize: '12px', letterSpacing: '-0.5px', borderBottom: '1px solid #FFFFFF33', - textTransform: 'uppercase' + textTransform: 'uppercase', }; - const columns: ColumnProp[] = useMemo(() => { return [ { @@ -138,7 +143,7 @@ const LeaderBoard = () => { fontWeight: 500, verticalAlign: 'middle', letterSpacing: '-0.5px', - color: 'black !important' + color: 'black !important', }, render(data: ILeaderBoardPoint) { return ( @@ -149,7 +154,7 @@ const LeaderBoard = () => { justifyContent={'space-between'} paddingLeft={'16px'} > - {data.ranking} + {data.ranking} ); }, @@ -174,28 +179,24 @@ const LeaderBoard = () => { justifyContent={'space-between'} cursor="pointer" onClick={() => { - window.open(`https://twitter.com/${data?.twitter_username}`) + window.open(`https://twitter.com/${data?.twitter_username}`); }} > -

- {data?.twitter_name || ""} -

- {data?.need_active && ( - - YOU - - )} +

{data?.twitter_name || ''}

+ {data?.need_active && ( + YOU + )}
@@ -210,7 +211,7 @@ const LeaderBoard = () => { style={{ justifyContent: 'center', width: '100%', - textTransform: 'uppercase' + textTransform: 'uppercase', }} > BOOST @@ -230,17 +231,24 @@ const LeaderBoard = () => { flexDirection="row" gap="4px" alignItems="center" - className={clsx( - styles.tagBoost, - )} + className={clsx(styles.tagBoost)} > - - {data?.boost || 0}% + + + {data?.boost || 0}% + ); @@ -254,7 +262,7 @@ const LeaderBoard = () => { justifyContent: 'center', alignSelf: 'center', width: '100%', - textTransform: 'uppercase' + textTransform: 'uppercase', }} > TOTAL @@ -278,7 +286,11 @@ const LeaderBoard = () => { > - {formatCurrency(new BigNumber(data?.point || '0').toNumber(), 0, 0)} + {formatCurrency( + new BigNumber(data?.point || '0').toNumber(), + 0, + 0, + )} @@ -297,7 +309,7 @@ const LeaderBoard = () => { }} gap="3px" > -

INVITE POINTS

+

INVITE PTS

{ padding="8px" label={ -

Referral points are calculated based on the total number of friends you refer to the allowlist.

+

+ Referral points are calculated based on the total number of + friends you refer to the allowlist. +

} > - +
), @@ -351,7 +369,7 @@ const LeaderBoard = () => { }} gap="3px" > -

BITCOIN OG POINTS

+

BITCOIN PTS

{ padding="8px" label={ -

Bitcoin OG is calculated from total gas fees paid on Bitcoin.

+

+ Bitcoin OG is calculated from total gas fees paid on + Bitcoin. +

} > - +
), @@ -405,7 +429,7 @@ const LeaderBoard = () => { gap: '4px', }} > -

MODULAR POINTS

+

MODULAR PTS

{ padding="8px" label={ -

Modular Points are calculated from your holding & staking TIA

+

+ Modular Points are calculated from your holding & staking{' '} + TIA +

} > - +
), @@ -459,7 +489,7 @@ const LeaderBoard = () => { gap: '4px', }} > -

TWEET POINTS

+

TWEET PTS

{ padding="8px" label={ -

Content Points are calculated based on the performance of your posts on X, including Views. - Note: To be qualified, you must tag:
@BVMnetwork

+

+ Content Points are calculated based on the performance of + your posts on X, including Views. Note: To be qualified, you + must tag:
+ @BVMnetwork +

} > - +
), @@ -497,7 +534,7 @@ const LeaderBoard = () => { {formatCurrency(data?.content_point, 0, 0)} - {data.need_active ? + {data.need_active ? ( { } >
- +
- : } + ) : ( + + )} ); @@ -527,7 +570,6 @@ const LeaderBoard = () => { ]; }, []); - // const remainingTime = () => { // const now = dayjs(); @@ -559,11 +601,15 @@ const LeaderBoard = () => { const renderTimeLine = (params: { content: React.ReactNode }) => { return ( - ic-dot + ic-dot {params.content} - ) - } + ); + }; return (