From 51ec799c0c47189f9388dd6b19ca3329a55cf653 Mon Sep 17 00:00:00 2001 From: Fringg Date: Tue, 10 Mar 2026 06:39:50 +0300 Subject: [PATCH] feat: split my gifts into Active/Activated/Received sections Sent gifts are now sorted into "Active gifts" (awaiting activation) and "Activated" (already used). Received gifts remain separate. --- src/locales/en.json | 2 ++ src/locales/ru.json | 2 ++ src/pages/GiftSubscription.tsx | 38 ++++++++++++++++++++++++++++------ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index e5b53d8..268b2c1 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -4221,6 +4221,8 @@ "myGiftsEmpty": "No gifts yet", "myGiftsEmptyDesc": "Buy a gift for a friend or activate a received code", "sentGiftsTitle": "Sent", + "activeGiftsTitle": "Active gifts", + "activatedGiftsTitle": "Activated", "receivedGiftsTitle": "Received", "statusAvailable": "AVAILABLE", "statusActivated": "ACTIVATED", diff --git a/src/locales/ru.json b/src/locales/ru.json index 0e12e78..55be595 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -4785,6 +4785,8 @@ "myGiftsEmpty": "У вас пока нет подарков", "myGiftsEmptyDesc": "Купите подарок для друга или активируйте полученный код", "sentGiftsTitle": "Отправленные", + "activeGiftsTitle": "Активные подарки", + "activatedGiftsTitle": "Активированные", "receivedGiftsTitle": "Полученные", "statusAvailable": "ДОСТУПЕН", "statusActivated": "АКТИВИРОВАН", diff --git a/src/pages/GiftSubscription.tsx b/src/pages/GiftSubscription.tsx index 3cd4bbe..2a23153 100644 --- a/src/pages/GiftSubscription.tsx +++ b/src/pages/GiftSubscription.tsx @@ -1280,9 +1280,21 @@ function MyGiftsTabContent() { }); const isLoading = sentLoading || receivedLoading; - const hasSent = sentGifts && sentGifts.length > 0; + + // Split sent gifts into active (awaiting activation) and activated + const activeGifts = useMemo( + () => (sentGifts ?? []).filter((g) => !isGiftActivated(g)), + [sentGifts], + ); + const activatedGifts = useMemo( + () => (sentGifts ?? []).filter((g) => isGiftActivated(g)), + [sentGifts], + ); + + const hasActive = activeGifts.length > 0; + const hasActivated = activatedGifts.length > 0; const hasReceived = receivedGifts && receivedGifts.length > 0; - const isEmpty = !hasSent && !hasReceived; + const isEmpty = !hasActive && !hasActivated && !hasReceived; if (isLoading) { return ( @@ -1314,14 +1326,28 @@ function MyGiftsTabContent() { return (
- {/* Sent gifts */} - {hasSent && ( + {/* Active gifts (awaiting activation) */} + {hasActive && (

- {t('gift.sentGiftsTitle')} + {t('gift.activeGiftsTitle')}

- {sentGifts!.map((gift) => ( + {activeGifts.map((gift) => ( + + ))} +
+
+ )} + + {/* Activated gifts */} + {hasActivated && ( +
+

+ {t('gift.activatedGiftsTitle')} +

+
+ {activatedGifts.map((gift) => ( ))}