You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

622 lines
33 KiB

import { useNavigate } from 'react-router-dom'
import { Ic } from '@/icons'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { Shimmer } from '@/components/shared/shimmer_frontend'
import { useAuthStore } from '@/stores/auth'
import { useTranslation } from '@/i18n'
import { toFa } from '@/lib/utils'
import { useLiveDashboard } from './hooks/useLiveDashboard'
import type { DashboardTimeRange } from './services/dashboard-api'
const TIME_RANGES: { id: DashboardTimeRange; labelKey: string }[] = [
{ id: 'all', labelKey: 'dashboard.rangeAll' },
{ id: '6m', labelKey: 'dashboard.range6m' },
{ id: '30d', labelKey: 'dashboard.range30d' },
{ id: '7d', labelKey: 'dashboard.range7d' },
{ id: '24h', labelKey: 'dashboard.range24h' },
]
export default function DashboardHome() {
const user = useAuthStore((s) => s.user)
const { t } = useTranslation()
const navigate = useNavigate()
const { data, isLoading, isRefreshing, range, setRange, manualRefresh } = useLiveDashboard('all')
if (isLoading && !data) {
return (
<div className="space-y-6 pt-2">
<div className="rounded-3xl border border-border-soft bg-card/60 p-6">
<div className="space-y-3">
<Shimmer className="h-7 w-64 rounded-xl" />
<Shimmer className="h-4 w-96 rounded-lg" />
</div>
</div>
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
{[1, 2, 3, 4].map((i) => (
<div key={i} className="rounded-3xl border border-border-soft bg-card/50 p-6 space-y-4">
<div className="flex items-center justify-between">
<Shimmer className="h-4 w-24 rounded" />
<Shimmer className="size-11 rounded-2xl" />
</div>
<Shimmer className="h-9 w-36 rounded-lg" />
<Shimmer className="h-3 w-48 rounded" />
</div>
))}
</div>
<div className="grid grid-cols-1 gap-6 lg:grid-cols-2">
<div className="rounded-3xl border border-border-soft bg-card/50 p-6 space-y-4">
<Shimmer className="h-6 w-48 rounded" />
<Shimmer className="h-48 w-full rounded-2xl" />
</div>
<div className="rounded-3xl border border-border-soft bg-card/50 p-6 space-y-4">
<Shimmer className="h-6 w-48 rounded" />
<Shimmer className="h-48 w-full rounded-2xl" />
</div>
</div>
</div>
)
}
const d = data!
return (
<div className="space-y-6 pt-2 pb-12">
{/* ========================================================================= */}
{/* 1. سربرگ اصلی داشبورد: طراحی مینیمال، وزین و بدون شلوغی بصری */}
{/* ========================================================================= */}
<div className="relative overflow-hidden rounded-3xl border border-border-soft/80 bg-gradient-to-br from-card via-card to-primary/[0.04] p-5 sm:p-6 shadow-sm">
{/* هاله نور پس‌زمینه لطیف */}
<div className="pointer-events-none absolute -end-24 -top-24 size-72 rounded-full bg-primary/10 blur-3xl" />
<div className="pointer-events-none absolute start-1/3 -bottom-24 size-64 rounded-full bg-emerald-500/5 blur-3xl" />
<div className="relative z-10 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
<div className="flex items-center gap-3.5">
<div className="flex size-11 items-center justify-center rounded-2xl bg-primary/10 text-primary ring-1 ring-primary/25 shadow-xs shrink-0">
<Ic name="layoutDashboard" className="size-5.5" />
</div>
<div className="space-y-0.5">
<h1 className="text-xl font-black text-foreground sm:text-2xl tracking-tight">
{t('dashboard.welcome', { name: user?.name || t('navigation.adminRole') })}
</h1>
<p className="text-xs text-muted-foreground sm:text-sm">
{t('dashboard.welcomeSubtitle')}
</p>
</div>
</div>
{/* گوشه کناری: دراپ‌داون بازه زمانی + دکمه رفرش */}
<div className="flex items-center gap-2.5 self-start sm:self-auto shrink-0">
<div className="relative">
<select
value={range || 'all'}
onChange={(e) => setRange(e.target.value as DashboardTimeRange)}
className="h-10 pe-9 ps-3.5 text-xs font-bold rounded-2xl bg-surface-base/90 border border-border-soft text-foreground shadow-2xs hover:border-border cursor-pointer focus:outline-none focus:ring-1 focus:ring-primary appearance-none transition-colors"
>
{TIME_RANGES.map((r) => (
<option key={r.id} value={r.id} className="bg-card text-foreground py-1.5 font-medium">
{t(r.labelKey)}
</option>
))}
</select>
<div className="pointer-events-none absolute end-3 top-1/2 -translate-y-1/2 text-muted-foreground">
<Ic name="chevDown" className="size-3.5" />
</div>
</div>
<Button
variant="outline"
size="sm"
onClick={manualRefresh}
disabled={isRefreshing}
className="size-10 p-0 rounded-2xl border-border-soft bg-surface-base/90 hover:bg-muted text-muted-foreground hover:text-foreground cursor-pointer shadow-2xs shrink-0 transition-colors"
title={t('dashboard.refreshData')}
>
<Ic
name="refresh"
className={`size-4 ${isRefreshing ? 'animate-spin text-primary' : ''}`}
/>
</Button>
</div>
</div>
</div>
{/* ========================================================================= */}
{/* 2. کارت‌های کلان شاخص‌های کلیدی عملکرد (4 Top KPI Cards - با ترنزیشن و هاله) */}
{/* ========================================================================= */}
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4">
{/* ۱. کل کاربران و زائران */}
<div
onClick={() => navigate('/users')}
className="group relative flex flex-col justify-between overflow-hidden rounded-3xl border border-border-soft bg-card p-6 shadow-xs transition-all duration-300 hover:-translate-y-1 hover:border-primary/40 hover:shadow-lg cursor-pointer"
>
<div className="flex items-start justify-between">
<span className="text-xs font-bold text-muted-foreground">
{t('dashboard.totalUsersTitle')}
</span>
<div className="flex size-11 items-center justify-center rounded-2xl bg-blue-500/10 text-blue-500 ring-1 ring-blue-500/20 shadow-xs transition-transform group-hover:scale-110 duration-300">
<Ic name="users" className="size-5" />
</div>
</div>
<div className="mt-4 flex items-baseline gap-2">
<span className="font-mono text-3xl sm:text-4xl font-black text-foreground tracking-tight tabular-nums" dir="ltr">
{Number(d.users.total).toLocaleString('en-US')}
</span>
<span className="text-xs text-muted-foreground font-medium">
{t('dashboard.activeUsersBadge', { count: toFa(d.users.active) })}
</span>
</div>
<div className="mt-4 flex items-center justify-between border-t border-border-soft/60 pt-3 text-[11px]">
<span className="inline-flex items-center gap-1 text-emerald-600 dark:text-emerald-400 font-bold bg-emerald-500/10 px-2 py-0.5 rounded-lg">
<span>↑</span>
<span>{t('dashboard.newUsersInRange', { count: toFa(d.users.newInRange) })}</span>
</span>
<span className="text-muted-foreground font-mono font-bold">{d.users.growthRate} {t('dashboard.growthLabel')}</span>
</div>
{/* نوار گرادینت پایین کارت */}
<div className="absolute bottom-0 inset-x-0 h-1 bg-gradient-to-r from-blue-500/40 via-blue-500 to-blue-500/40 opacity-0 group-hover:opacity-100 transition-opacity" />
</div>
{/* ۲. مجموع واریزی‌های قطعی (درآمد کل) */}
<div
onClick={() => navigate('/billing')}
className="group relative flex flex-col justify-between overflow-hidden rounded-3xl border border-border-soft bg-card p-6 shadow-xs transition-all duration-300 hover:-translate-y-1 hover:border-emerald-500/40 hover:shadow-lg cursor-pointer"
>
<div className="flex items-start justify-between">
<span className="text-xs font-bold text-muted-foreground">
{t('dashboard.totalRevenueTitle')}
</span>
<div className="flex size-11 items-center justify-center rounded-2xl bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 ring-1 ring-emerald-500/20 shadow-xs transition-transform group-hover:scale-110 duration-300">
<Ic name="dollarSign" className="size-5" />
</div>
</div>
<div className="mt-4 flex items-baseline gap-2">
<span className="font-mono text-3xl sm:text-4xl font-black text-emerald-600 dark:text-emerald-400 tracking-tight tabular-nums" dir="ltr">
${d.billing.paidAmountUsd.toLocaleString('en-US')}
</span>
</div>
<div className="mt-4 flex items-center justify-between border-t border-border-soft/60 pt-3 text-[11px]">
<span className="text-muted-foreground font-medium">
{t('dashboard.paidFactorsCount', { count: toFa(d.billing.paidCount) })}
</span>
<span className="inline-flex items-center gap-1 font-bold text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 px-2 py-0.5 rounded-lg">
<Ic name="checkCircle" className="size-3" />
<span>{t('dashboard.finalSettlement')}</span>
</span>
</div>
<div className="absolute bottom-0 inset-x-0 h-1 bg-gradient-to-r from-emerald-500/40 via-emerald-500 to-emerald-500/40 opacity-0 group-hover:opacity-100 transition-opacity" />
</div>
{/* ۳. مطالبات در انتظار وصول */}
<div
onClick={() => navigate('/billing')}
className="group relative flex flex-col justify-between overflow-hidden rounded-3xl border border-border-soft bg-card p-6 shadow-xs transition-all duration-300 hover:-translate-y-1 hover:border-amber-500/40 hover:shadow-lg cursor-pointer"
>
<div className="flex items-start justify-between">
<span className="text-xs font-bold text-muted-foreground">
{t('dashboard.pendingCollectionTitle')}
</span>
<div className="flex size-11 items-center justify-center rounded-2xl bg-amber-500/10 text-amber-600 dark:text-amber-400 ring-1 ring-amber-500/20 shadow-xs transition-transform group-hover:scale-110 duration-300">
<Ic name="clock" className="size-5" />
</div>
</div>
<div className="mt-4 flex items-baseline gap-2">
<span className="font-mono text-3xl sm:text-4xl font-black text-amber-600 dark:text-amber-400 tracking-tight tabular-nums" dir="ltr">
${Math.round(d.billing.pendingAmountUsd).toLocaleString('en-US')}
</span>
</div>
<div className="mt-4 flex items-center justify-between border-t border-border-soft/60 pt-3 text-[11px]">
<span className="text-muted-foreground font-medium">
{t('dashboard.pendingFactorsCount', { count: toFa(d.billing.pendingCount) })}
</span>
<span className="inline-flex items-center gap-1.5 font-bold text-amber-600 dark:text-amber-400 bg-amber-500/10 px-2 py-0.5 rounded-lg">
<span className="size-1.5 rounded-full bg-amber-500 animate-pulse" />
<span>{t('dashboard.needsFollowUp')}</span>
</span>
</div>
<div className="absolute bottom-0 inset-x-0 h-1 bg-gradient-to-r from-amber-500/40 via-amber-500 to-amber-500/40 opacity-0 group-hover:opacity-100 transition-opacity" />
</div>
{/* ۴. کل تعاملات و سفارشات */}
<div
onClick={() => navigate('/custom-trip/orders')}
className="group relative flex flex-col justify-between overflow-hidden rounded-3xl border border-border-soft bg-card p-6 shadow-xs transition-all duration-300 hover:-translate-y-1 hover:border-primary/40 hover:shadow-lg cursor-pointer"
>
<div className="flex items-start justify-between">
<span className="text-xs font-bold text-muted-foreground">
{t('dashboard.totalOrdersTitle')}
</span>
<div className="flex size-11 items-center justify-center rounded-2xl bg-primary/10 text-primary ring-1 ring-primary/20 shadow-xs transition-transform group-hover:scale-110 duration-300">
<Ic name="clipboardCheck" className="size-5" />
</div>
</div>
<div className="mt-4 flex items-baseline gap-2">
<span className="font-mono text-3xl sm:text-4xl font-black text-foreground tracking-tight tabular-nums" dir="ltr">
{toFa(d.customTrips.totalCount + d.tours.totalCount)}
</span>
<span className="text-xs text-muted-foreground font-medium">{t('dashboard.pilgrimageDossiers')}</span>
</div>
<div className="mt-4 flex items-center justify-between border-t border-border-soft/60 pt-3 text-[11px]">
<span className="text-muted-foreground font-medium">
{t('dashboard.customTripsCount', { count: toFa(d.customTrips.totalCount) })}
</span>
<span className="text-primary font-bold bg-primary/10 px-2 py-0.5 rounded-lg">
{t('dashboard.toursCount', { count: toFa(d.tours.totalCount) })}
</span>
</div>
<div className="absolute bottom-0 inset-x-0 h-1 bg-gradient-to-r from-primary/40 via-primary to-primary/40 opacity-0 group-hover:opacity-100 transition-opacity" />
</div>
</div>
{/* ========================================================================= */}
{/* 3. شبکه تحلیل تفصیلی: امور مالی در برابر کاروان‌ها و سفرهای اختصاصی */}
{/* ========================================================================= */}
<div className="grid grid-cols-1 gap-6 lg:grid-cols-2">
{/* بلوک ۱: صورت‌حساب‌ها و پایش مالی */}
<div className="flex flex-col rounded-3xl border border-border-soft bg-card p-6 shadow-xs">
<div className="flex items-center justify-between border-b border-border-soft/70 pb-4">
<div className="flex items-center gap-3">
<div className="flex size-10 items-center justify-center rounded-2xl bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 ring-1 ring-emerald-500/20">
<Ic name="receipt" className="size-5" />
</div>
<div>
<h2 className="text-base font-bold text-foreground">
{t('dashboard.billingSectionTitle')}
</h2>
<p className="text-xs text-muted-foreground mt-0.5">
{t('dashboard.billingSectionDesc')}
</p>
</div>
</div>
<Button
variant="ghost"
size="sm"
onClick={() => navigate('/billing')}
className="text-xs text-primary font-bold hover:bg-primary/10 rounded-xl"
>
{t('dashboard.viewAllBilling')}
<span className="ms-1">←</span>
</Button>
</div>
{/* ۳ تایل آماری فاکتورها */}
<div className="grid grid-cols-1 sm:grid-cols-3 gap-3 pt-5">
<div className="relative overflow-hidden rounded-2xl border border-emerald-500/20 bg-gradient-to-b from-emerald-500/[0.06] to-transparent p-4 text-start">
<span className="text-[11px] font-bold text-muted-foreground block">
{t('dashboard.paidInvoices')}
</span>
<span className="font-mono text-xl font-black text-emerald-600 dark:text-emerald-400 block mt-1">
${d.billing.paidAmountUsd.toLocaleString('en-US')}
</span>
<span className="inline-flex items-center gap-1 text-[10px] text-emerald-600 font-bold bg-emerald-500/10 px-2 py-0.5 rounded-full mt-2">
<Ic name="checkCircle" className="size-2.5" />
<span>{t('dashboard.paidCountBadge', { count: toFa(d.billing.paidCount) })}</span>
</span>
</div>
<div className="relative overflow-hidden rounded-2xl border border-amber-500/20 bg-gradient-to-b from-amber-500/[0.06] to-transparent p-4 text-start">
<span className="text-[11px] font-bold text-muted-foreground block">
{t('dashboard.pendingInvoices')}
</span>
<span className="font-mono text-xl font-black text-amber-600 dark:text-amber-400 block mt-1">
${Math.round(d.billing.pendingAmountUsd).toLocaleString('en-US')}
</span>
<span className="inline-flex items-center gap-1 text-[10px] text-amber-600 font-bold bg-amber-500/10 px-2 py-0.5 rounded-full mt-2">
<span className="size-1.5 rounded-full bg-amber-500 animate-pulse" />
<span>{t('dashboard.pendingCountBadge', { count: toFa(d.billing.pendingCount) })}</span>
</span>
</div>
<div className="relative overflow-hidden rounded-2xl border border-border-soft bg-muted/20 p-4 text-start">
<span className="text-[11px] font-bold text-muted-foreground block">
{t('dashboard.rejectedInvoices')}
</span>
<span className="font-mono text-xl font-black text-muted-foreground block mt-1">
{toFa(d.billing.rejectedCount + d.billing.expiredCount)}
</span>
<span className="inline-flex items-center text-[10px] text-muted-foreground font-bold bg-muted/40 px-2 py-0.5 rounded-full mt-2">
{t('dashboard.closedOrExpiredBadge')}
</span>
</div>
</div>
{/* نوار گرادینت شاخص نرخ وصول مطالبات */}
<div className="mt-5 rounded-2xl border border-border-soft/70 bg-surface-base/60 p-4">
<div className="flex items-center justify-between text-xs mb-2.5">
<span className="font-bold text-foreground flex items-center gap-1.5">
<Ic name="chart" className="size-3.5 text-emerald-500" />
<span>{t('dashboard.collectionRate')}</span>
</span>
<span className="font-mono font-black text-emerald-600 dark:text-emerald-400 text-sm">
{toFa(d.billing.collectionRate)}%
</span>
</div>
<div className="h-2.5 w-full rounded-full bg-border-soft overflow-hidden p-0.5">
<div
className="h-full rounded-full bg-gradient-to-r from-emerald-500 to-teal-400 transition-all duration-1000 shadow-xs"
style={{ width: `${d.billing.collectionRate}%` }}
/>
</div>
<div className="flex items-center justify-between text-[10px] text-muted-foreground mt-1.5 font-mono">
<span>0%</span>
<span>۵۰٪</span>
<span>100%</span>
</div>
</div>
{/* جدول فشرده آخرین تراکنش‌ها */}
<div className="mt-5 flex-1">
<span className="text-xs font-black text-foreground block mb-2.5">
{t('dashboard.recentTransactions')}
</span>
<div className="divide-y divide-border-soft/70 rounded-2xl border border-border-soft overflow-hidden bg-surface-base/30">
{d.billing.recentFactors.slice(0, 4).map((f) => {
const isApproved = f.status === 'approved'
return (
<div
key={f.id}
onClick={() => navigate('/billing')}
className="flex items-center justify-between p-3 text-xs hover:bg-muted/40 transition-colors cursor-pointer"
>
<div className="flex items-center gap-3">
<div
className={`flex size-8 items-center justify-center rounded-xl font-mono font-bold text-xs ${
isApproved ? 'bg-emerald-500/15 text-emerald-600 dark:text-emerald-400' : 'bg-amber-500/15 text-amber-600'
}`}
>
{isApproved ? '✓' : '⏳'}
</div>
<div>
<span className="font-bold text-foreground block">
{t('dashboard.invoicePrefix', { id: f.factor_number || f.id })}
</span>
<span className="text-[11px] text-muted-foreground">
{f.user_info?.fullname || f.user_info?.phone_number || t('dashboard.platformUser')}
</span>
</div>
</div>
<div className="text-end">
<span className="font-mono font-black text-foreground block text-xs" dir="ltr">
${Number(f.amount || 0).toLocaleString('en-US')}
</span>
<span
className={`inline-block text-[10px] font-bold px-2 py-0.2 rounded-md mt-0.5 ${
isApproved
? 'bg-emerald-500/10 text-emerald-600 dark:text-emerald-400'
: 'bg-amber-500/10 text-amber-600'
}`}
>
{isApproved ? t('dashboard.settledStatus') : t('dashboard.awaitingPaymentStatus')}
</span>
</div>
</div>
)
})}
</div>
</div>
</div>
{/* بلوک ۲: تورهای گروهی و سفرهای اختصاصی */}
<div className="flex flex-col rounded-3xl border border-border-soft bg-card p-6 shadow-xs">
<div className="flex items-center justify-between border-b border-border-soft/70 pb-4">
<div className="flex items-center gap-3">
<div className="flex size-10 items-center justify-center rounded-2xl bg-primary/10 text-primary ring-1 ring-primary/20">
<Ic name="map" className="size-5" />
</div>
<div>
<h2 className="text-base font-bold text-foreground">
{t('dashboard.toursSectionTitle')} و {t('dashboard.customTripSectionTitle')}
</h2>
<p className="text-xs text-muted-foreground mt-0.5">
{t('dashboard.toursAndCustomSubtitle')}
</p>
</div>
</div>
</div>
{/* آمار تورهای گروهی زیارتی */}
<div className="mt-5 rounded-2xl border border-border-soft bg-surface-base/50 p-4 space-y-3.5">
<div className="flex items-center justify-between">
<span className="text-xs font-black text-foreground flex items-center gap-2">
<span>🕋</span>
<span>{t('dashboard.toursSectionTitle')}</span>
</span>
<Button
variant="ghost"
size="sm"
onClick={() => navigate('/tours')}
className="h-7 text-xs text-primary font-bold hover:bg-primary/10 rounded-lg px-2"
>
{t('dashboard.viewAllTours')}
<span className="ms-1">←</span>
</Button>
</div>
<div className="grid grid-cols-3 gap-2.5 text-center text-xs">
<div className="p-3 rounded-xl bg-emerald-500/10 border border-emerald-500/20">
<span className="font-mono text-xl font-black text-emerald-600 dark:text-emerald-400 block">
{toFa(d.tours.activeCount)}
</span>
<span className="text-[10px] text-muted-foreground font-semibold block mt-0.5">{t('dashboard.activeToursCard')}</span>
</div>
<div className="p-3 rounded-xl bg-primary/10 border border-primary/20">
<span className="font-mono text-xl font-black text-primary block">
{toFa(d.tours.travelingCount)}
</span>
<span className="text-[10px] text-muted-foreground font-semibold block mt-0.5">{t('dashboard.travelingToursCard')}</span>
</div>
<div className="p-3 rounded-xl bg-muted/40 border border-border-soft">
<span className="font-mono text-xl font-black text-muted-foreground block">
{toFa(d.tours.soldOutCount)}
</span>
<span className="text-[10px] text-muted-foreground font-semibold block mt-0.5">{t('dashboard.soldOutToursCard')}</span>
</div>
</div>
</div>
{/* آمار سفرهای اختصاصی */}
<div className="mt-4 rounded-2xl border border-border-soft bg-surface-base/50 p-4 space-y-3.5">
<div className="flex items-center justify-between">
<span className="text-xs font-black text-foreground flex items-center gap-2">
<Ic name="route" className="size-4 text-primary" />
<span>{t('dashboard.customTripSectionTitle')}</span>
</span>
<Button
variant="ghost"
size="sm"
onClick={() => navigate('/custom-trip/orders')}
className="h-7 text-xs text-primary font-bold hover:bg-primary/10 rounded-lg px-2"
>
{t('dashboard.viewAllCustomTrips')}
<span className="ms-1">←</span>
</Button>
</div>
<div className="grid grid-cols-3 gap-2.5 text-center text-xs">
<div className="p-3 rounded-xl bg-amber-500/10 border border-amber-500/25">
<span className="font-mono text-xl font-black text-amber-600 dark:text-amber-400 block">
{toFa(d.customTrips.pendingReviewCount)}
</span>
<span className="text-[10px] text-amber-600 dark:text-amber-400 font-bold block mt-0.5">
{t('dashboard.adminReviewCard')}
</span>
</div>
<div className="p-3 rounded-xl bg-surface-base border border-border-soft">
<span className="font-mono text-xl font-black text-foreground block">
{toFa(d.customTrips.awaitingPaymentCount)}
</span>
<span className="text-[10px] text-muted-foreground font-semibold block mt-0.5">{t('dashboard.awaitingPaymentCard')}</span>
</div>
<div className="p-3 rounded-xl bg-emerald-500/10 border border-emerald-500/20">
<span className="font-mono text-xl font-black text-emerald-600 dark:text-emerald-400 block">
{toFa(d.customTrips.approvedCount)}
</span>
<span className="text-[10px] text-emerald-600 dark:text-emerald-400 font-bold block mt-0.5">
{t('dashboard.finalApprovedCard')}
</span>
</div>
</div>
{/* سهم مقاصد پرتقاضای سفر اختصاصی */}
<div className="pt-3 border-t border-border-soft/70">
<span className="text-[11px] font-bold text-muted-foreground block mb-2.5">
{t('dashboard.popularDestinations')}
</span>
<div className="space-y-2">
{d.customTrips.popularDestinations.map((dest) => (
<div key={dest.city} className="flex items-center justify-between text-xs">
<span className="inline-flex items-center gap-2 text-foreground font-medium">
<span className="text-base">{dest.flag}</span>
<span>{dest.city}</span>
</span>
<div className="flex items-center gap-3">
<div className="w-24 sm:w-36 h-2 rounded-full bg-border-soft overflow-hidden p-0.5">
<div
className="h-full rounded-full bg-gradient-to-r from-primary/70 to-primary transition-all duration-700"
style={{ width: `${dest.percent}%` }}
/>
</div>
<span className="font-mono text-[11px] font-black text-foreground w-9 text-end">
{toFa(dest.percent)}%
</span>
</div>
</div>
))}
</div>
</div>
</div>
</div>
</div>
{/* ========================================================================= */}
{/* 4. خط زمانی رویدادهای زنده سیستم (Live Activity Timeline) */}
{/* ========================================================================= */}
<div className="rounded-3xl border border-border-soft bg-card p-6 sm:p-7 shadow-xs">
<div className="flex items-center justify-between border-b border-border-soft/70 pb-4 mb-4">
<div className="flex items-center gap-3">
<div className="relative flex size-3">
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75" />
<span className="relative inline-flex rounded-full size-3 bg-emerald-500" />
</div>
<div>
<h2 className="text-base font-bold text-foreground">
{t('dashboard.activityFeedTitle')}
</h2>
<p className="text-xs text-muted-foreground mt-0.5">
{t('dashboard.activityFeedDesc')}
</p>
</div>
</div>
</div>
<div className="relative divide-y divide-border-soft/60">
{d.activityFeed.length === 0 ? (
<p className="py-6 text-center text-xs text-muted-foreground">
{t('dashboard.noActivity')}
</p>
) : (
d.activityFeed.map((act) => (
<div
key={act.id}
className="flex items-center justify-between py-3.5 text-xs transition-colors hover:bg-muted/20 px-3 rounded-2xl"
>
<div className="flex items-center gap-3.5">
<div
className={`flex size-9 shrink-0 items-center justify-center rounded-2xl ring-1 shadow-2xs ${
act.statusVariant === 'success'
? 'bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 ring-emerald-500/20'
: act.statusVariant === 'warning'
? 'bg-amber-500/10 text-amber-600 dark:text-amber-400 ring-amber-500/20'
: 'bg-primary/10 text-primary ring-primary/20'
}`}
>
<Ic
name={
act.type === 'factor'
? 'receipt'
: act.type === 'custom_trip'
? 'route'
: act.type === 'tour'
? 'ticket'
: 'users'
}
className="size-4.5"
/>
</div>
<div>
<span className="font-bold text-foreground block text-xs sm:text-sm">
{act.title}
</span>
<span className="text-[11px] text-muted-foreground font-medium">
{act.subtitle}
</span>
</div>
</div>
<div className="flex items-center gap-3 text-end">
{act.amount && (
<span className="font-mono font-black text-foreground hidden sm:inline text-xs sm:text-sm" dir="ltr">
{act.amount}
</span>
)}
<Badge
variant="outline"
className={`text-[10px] sm:text-[11px] font-bold px-2.5 py-0.5 rounded-lg ${
act.statusVariant === 'success'
? 'border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400'
: act.statusVariant === 'warning'
? 'border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400'
: 'border-border-soft bg-muted/40 text-muted-foreground'
}`}
>
{act.badgeText}
</Badge>
</div>
</div>
))
)}
</div>
</div>
</div>
)
}