2026-04-30 18:15:40 +03:30
|
|
|
'use client';
|
|
|
|
|
|
2026-06-20 14:51:43 +03:30
|
|
|
import { useTranslations } from 'next-intl';
|
2026-06-20 12:37:38 +03:30
|
|
|
import { Link } from '@/i18n/navigation';
|
2026-04-30 18:15:40 +03:30
|
|
|
import { useAuth } from '@/lib/hooks/useAuth';
|
2026-07-11 00:07:48 +03:30
|
|
|
import { TodayKpiGrid } from '@/components/today/TodayKpiGrid';
|
2026-07-11 00:34:38 +03:30
|
|
|
import { TodayChartsSection } from '@/components/today/TodayChartsSection';
|
2026-07-11 00:07:48 +03:30
|
|
|
import { useTodaySummary } from '@/lib/hooks/useTodaySummary';
|
|
|
|
|
import { formatApiErrorMessage } from '@/components/shared/formatApiError';
|
2026-04-30 18:15:40 +03:30
|
|
|
|
2026-04-23 15:33:11 +03:30
|
|
|
export default function TodayPage() {
|
2026-06-20 14:51:43 +03:30
|
|
|
const t = useTranslations('today');
|
2026-04-30 18:15:40 +03:30
|
|
|
const { currentOrganization } = useAuth();
|
2026-07-11 00:07:48 +03:30
|
|
|
const { data, loading, error } = useTodaySummary(Boolean(currentOrganization?.id));
|
2026-04-30 18:15:40 +03:30
|
|
|
const showNoSubscriptionNotice =
|
|
|
|
|
Boolean(currentOrganization?.isOwner) && !currentOrganization?.plan;
|
|
|
|
|
|
2026-04-23 15:33:11 +03:30
|
|
|
return (
|
2026-07-11 00:07:48 +03:30
|
|
|
<div className="space-y-6">
|
|
|
|
|
<h1 className="text-2xl font-semibold">{t('welcomeBack')}</h1>
|
2026-04-23 15:33:11 +03:30
|
|
|
|
2026-04-30 18:15:40 +03:30
|
|
|
{showNoSubscriptionNotice && (
|
2026-07-11 00:07:48 +03:30
|
|
|
<div className="rounded-[var(--radius-md)] border border-amber-500/30 bg-amber-500/10 p-4">
|
2026-04-30 18:15:40 +03:30
|
|
|
<p className="text-sm text-amber-200">
|
2026-06-20 14:51:43 +03:30
|
|
|
{t('noSubscriptionNotice')}{' '}
|
2026-04-30 18:15:40 +03:30
|
|
|
<Link href="/settings/subscriptions" className="font-medium underline underline-offset-2">
|
2026-06-20 14:51:43 +03:30
|
|
|
{t('choosePlanLink')}
|
2026-04-30 18:15:40 +03:30
|
|
|
</Link>{' '}
|
2026-06-20 14:51:43 +03:30
|
|
|
{t('noSubscriptionCta')}
|
2026-04-30 18:15:40 +03:30
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-07-11 00:07:48 +03:30
|
|
|
{error ? (
|
|
|
|
|
<div className="rounded-[var(--radius-md)] border border-badge-danger-border bg-badge-danger-bg/40 p-4">
|
|
|
|
|
<p className="text-sm text-badge-danger-fg">
|
|
|
|
|
{formatApiErrorMessage(error, t('loadError'))}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
) : null}
|
|
|
|
|
|
|
|
|
|
<TodayKpiGrid widgets={data?.widgets ?? {}} loading={loading} />
|
2026-07-11 00:34:38 +03:30
|
|
|
|
|
|
|
|
<TodayChartsSection charts={data?.charts ?? {}} loading={loading} />
|
2026-04-23 15:33:11 +03:30
|
|
|
</div>
|
|
|
|
|
);
|
2026-06-20 14:51:43 +03:30
|
|
|
}
|