"use client"; import React from 'react'; import { DashboardLayout } from "@/components/layout/dashboard-layout"; /** * Share (Invite) Page - Static UI with mocked data. * Sections: Invite Flow, My Invitation Code, Invite Records (with pagination) */ type InviteRecord = { id: string; invitedUsername: string; registeredAt: number; // epoch ms rewardA: string; // reward item 1 (content TBD) rewardB: string; // reward item 2 (content TBD) }; const PAGE_SIZE = 10; /** * Format epoch ms using browser preferred language. * @param {number} epochMs - timestamp in milliseconds * @returns {string} - localized date time string */ function formatLocalTime(epochMs: number): string { try { const locale = typeof navigator !== 'undefined' ? navigator.language : 'en-US'; const dtf = new Intl.DateTimeFormat(locale, { dateStyle: 'medium', timeStyle: 'medium', }); return dtf.format(new Date(epochMs)); } catch { return new Date(epochMs).toLocaleString(); } } /** * Generate mocked invite records for demo purpose only. * @param {number} count - number of items * @returns {InviteRecord[]} - mocked records */ function generateMockRecords(count: number): InviteRecord[] { const now = Date.now(); return Array.from({ length: count }).map((_, index) => ({ id: String(index + 1), invitedUsername: `user_${index + 1}`, registeredAt: now - index * 36_000, // different times rewardA: index % 3 === 0 ? '+100 points' : '—', rewardB: index % 5 === 0 ? '3-day membership' : '—', })); } export default function SharePage(): JSX.Element { // Mocked data (to be replaced by real API integration later) const [inviteCode] = React.useState('VF-ABCD-1234'); const [invitedCount] = React.useState(37); const [copyState, setCopyState] = React.useState<'idle' | 'copied' | 'error'>('idle'); const [records] = React.useState(() => generateMockRecords(47)); const [pageIndex, setPageIndex] = React.useState(0); const totalPages = Math.max(1, Math.ceil(records.length / PAGE_SIZE)); const pagedRecords = React.useMemo(() => { const start = pageIndex * PAGE_SIZE; return records.slice(start, start + PAGE_SIZE); }, [records, pageIndex]); const handleCopy = React.useCallback(async () => { try { await navigator.clipboard.writeText(inviteCode); setCopyState('copied'); window.setTimeout(() => setCopyState('idle'), 1600); } catch { setCopyState('error'); window.setTimeout(() => setCopyState('idle'), 1600); } }, [inviteCode]); const canPrev = pageIndex > 0; const canNext = pageIndex < totalPages - 1; return (

Invite Friends

Invite friends to join and earn rewards.

{/* Section 1: Invite Flow */}

Invitation Flow

  1. Step 1 Share

    Copy your invitation code and share it with friends.

  2. Step 2 Register

    Friends register and enter your invitation code.

  3. Step 3 Reward

    You both receive rewards after successful registration.

{/* Section 2: My Invitation Code */}

My Invitation Code

{inviteCode}

Share this code. Your friends can enter it during registration.

Invited Friends {invitedCount} Points detail will be available soon.
{/* Section 3: Invite Records */}

Invite Records

{pageIndex + 1} / {totalPages}
{pagedRecords.map((r) => ( ))}
Invited Username Registered At Registration Reward First Payment Reward
{r.invitedUsername} {formatLocalTime(r.registeredAt)} {r.rewardA} {r.rewardB}
); }