diff --git a/packages/extension-koni-ui/src/Popup/Home/Leaderboard/index.tsx b/packages/extension-koni-ui/src/Popup/Home/Leaderboard/index.tsx index 886c0008da..87bb1a7d6f 100644 --- a/packages/extension-koni-ui/src/Popup/Home/Leaderboard/index.tsx +++ b/packages/extension-koni-ui/src/Popup/Home/Leaderboard/index.tsx @@ -19,7 +19,7 @@ const apiSDK = BookaSdk.instance; enum TabType { WEEKLY = 'weekly', - DED_PLAYDROP = 'ded_playdrop', + INVITE_TO_PLAY = 'invite_to_play', VARA_PLAYDROP = 'vara_playdrop', } @@ -91,10 +91,10 @@ const Component = ({ className }: Props): React.ReactElement => { } }, { - label: t('DED'), - value: TabType.DED_PLAYDROP, + label: t('Invite to Play'), + value: TabType.INVITE_TO_PLAY, leaderboardInfo: { - onClickShare: onClickShare(TabType.DED_PLAYDROP) + onClickShare: onClickShare(TabType.INVITE_TO_PLAY) } }, { @@ -108,13 +108,22 @@ const Component = ({ className }: Props): React.ReactElement => { return baseItems.map((item) => { const { end: endDate, start: startDate } = calculateStartAndEnd(item.value); + let type = 'all'; + let gameId = 0; + + if (item.value === TabType.INVITE_TO_PLAY){ + type = 'inviteToPlay'; + gameId = 5; + } return { ...item, leaderboardInfo: { ...item.leaderboardInfo, startDate, - endDate + endDate, + type, + gameId } }; }); diff --git a/packages/extension-koni-ui/src/components/Leaderboard/LeaderboardContent.tsx b/packages/extension-koni-ui/src/components/Leaderboard/LeaderboardContent.tsx index 89d0c98d5b..b62ebedca5 100644 --- a/packages/extension-koni-ui/src/components/Leaderboard/LeaderboardContent.tsx +++ b/packages/extension-koni-ui/src/components/Leaderboard/LeaderboardContent.tsx @@ -21,6 +21,7 @@ export type LeaderboardTabGroupItemType = TabGroupItemType & { startDate?: string; endDate?: string; type?: string; + gameId?: number; } } @@ -83,7 +84,7 @@ const Component = ({ className, defaultSelectedTab, gameId, tabGroupItems }: Pro leaderboardSub = apiSDK.subscribeLeaderboard( currentTabInfo.leaderboardInfo.startDate, currentTabInfo.leaderboardInfo.endDate, - gameId || 0, 100, + gameId || currentTabInfo.leaderboardInfo.gameId || 0, 100, currentTabInfo.leaderboardInfo.type).subscribe((data) => { setLeaderboardItems(data); }); diff --git a/packages/extension-koni-ui/src/utils/date/index.ts b/packages/extension-koni-ui/src/utils/date/index.ts index c3e7978270..155935063a 100644 --- a/packages/extension-koni-ui/src/utils/date/index.ts +++ b/packages/extension-koni-ui/src/utils/date/index.ts @@ -73,6 +73,14 @@ export function calculateStartAndEnd (key: string) { return { start: formatFully(startDate), end: formatFully(endDate) }; } + case 'invite_to_play': { + const dayOfWeek = today.getUTCDay(); // 0 (Chủ Nhật) đến 6 (Thứ Bảy) + const start = new Date(Date.UTC(year, month, day - dayOfWeek + (dayOfWeek === 0 ? -6 : 1))); // Adjust if today is Sunday + const end = new Date(Date.UTC(start.getUTCFullYear(), start.getUTCMonth(), start.getUTCDate() + 6)); + + return { start: formatDate(start, false), end: formatDate(end, true) }; + } + default: throw new Error('Invalid key. Must be "weekly", "monthly", or "yearly".'); }