-
-
-
-
-
-
- {t('gift.shareModalTitle')}
-
-
{t('gift.shareModalDesc')}
-
-
-
+
+
+ {t('gift.shareToastCopied')}
+ {t('gift.shareToastTapCopy')}
-
- {/* Message preview */}
-
-
-
{t('gift.shareText')}
-
- {botLink && (
-
- )}
-
-
-
-
-
- {/* Actions */}
-
-
-
-
+
{message}
+
);
}
function SentGiftCard({ gift }: { gift: SentGift }) {
const { t } = useTranslation();
- const [showShareModal, setShowShareModal] = useState(false);
+ const [showToast, setShowToast] = useState(false);
- const giftCode = `GIFT-${gift.token.slice(0, 12)}`;
+ const shortCode = gift.token.slice(0, 12);
+ const giftCode = `GIFT-${shortCode}`;
const isActivated = isGiftActivated(gift);
const isAvailable = !isActivated && isGiftAvailable(gift.status);
@@ -1146,6 +1009,28 @@ function SentGiftCard({ gift }: { gift: SentGift }) {
? t('gift.statusAvailable')
: t(getGiftStatusKey(gift.status));
+ const buildShareMessage = useCallback(() => {
+ const botUsername = import.meta.env.VITE_TELEGRAM_BOT_USERNAME as string | undefined;
+ const botLink = botUsername ? `https://t.me/${botUsername}?start=GIFT_${shortCode}` : null;
+ const cabinetLink = `${window.location.origin}/gift?tab=activate&code=${shortCode}`;
+ return [
+ t('gift.shareText'),
+ '',
+ botLink ? `${t('gift.shareModalActivateVia')} ${botLink}` : null,
+ `${t('gift.shareModalActivateViaCabinet')} ${cabinetLink}`,
+ ]
+ .filter(Boolean)
+ .join('\n');
+ }, [shortCode, t]);
+
+ const handleShare = useCallback(async () => {
+ const message = buildShareMessage();
+ await copyToClipboard(message);
+ setShowToast(true);
+ }, [buildShareMessage]);
+
+ const handleDismissToast = useCallback(() => setShowToast(false), []);
+
return (
{/* Header: tariff name + status badge */}
@@ -1184,10 +1069,10 @@ function SentGiftCard({ gift }: { gift: SentGift }) {
- {/* Share button — opens modal */}
+ {/* Share button — copies message and shows toast */}
);