Compare commits
No commits in common. "main" and "feat/pre-launch-4-overview" have entirely different histories.
main
...
feat/pre-l
|
|
@ -8,7 +8,7 @@ import { i18n } from '../../../../i18n';
|
|||
|
||||
/**
|
||||
* The creator's داشبورد on desktop (Creator Dashboard ۵.۱): the 640 column under the header, with
|
||||
* the «داشبورد» heading, the four tabs «نمای کلی» · «طرحهای اشتراک» · «سیگنالها» · «مالی», then the tab. Each tab is its own
|
||||
* the «داشبورد» heading, the three tabs «طرحهای اشتراک» · «سیگنالها» · «مالی», then the tab. Each tab is its own
|
||||
* route with its own loading, so the heading and the tabs stay while one loads. Locked until
|
||||
* registration step 5 is done (0016).
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
import { DashboardOverviewSkeleton } from '@lumina/market/app/screens/(main)/dashboard/overview/organisms/dashboard-overview';
|
||||
|
||||
import { i18n } from '../../../../../i18n';
|
||||
|
||||
/** نمای کلی before it arrives; the layout keeps the bar and the tabs. */
|
||||
export default function Loading() {
|
||||
return (
|
||||
<DashboardOverviewSkeleton
|
||||
layout="desktop"
|
||||
label={i18n.t('dashboard:overview.loading')}
|
||||
delayed
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
||||
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
|
||||
import {
|
||||
DashboardOverview,
|
||||
DashboardOverviewSkeleton,
|
||||
} from '@lumina/market/app/screens/(main)/dashboard/overview/organisms/dashboard-overview';
|
||||
import type { Metadata } from 'next';
|
||||
import { Suspense } from 'react';
|
||||
|
||||
import { i18n } from '../../../../../i18n';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: i18n.t('dashboard:overview.meta-title'),
|
||||
robots: { index: false },
|
||||
};
|
||||
|
||||
/**
|
||||
* داشبورد › نمای کلی (J10-0), the creator's default tab: audience, income, the split by plan and
|
||||
* the signals' summary, the creator's own, in the browser only. The tabs stay while it loads.
|
||||
*/
|
||||
export default function OverviewPage() {
|
||||
const skeleton = (
|
||||
<DashboardOverviewSkeleton
|
||||
layout="desktop"
|
||||
label={i18n.t('dashboard:overview.loading')}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<AuthGuard role="creator" fallback={skeleton}>
|
||||
<PartBoundary
|
||||
name="dashboard-overview"
|
||||
description={i18n.t('dashboard:overview.error')}
|
||||
framed
|
||||
>
|
||||
<Suspense fallback={skeleton}>
|
||||
<DashboardOverview layout="desktop" />
|
||||
</Suspense>
|
||||
</PartBoundary>
|
||||
</AuthGuard>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { AudienceStatsSkeleton } from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/audience-stats';
|
||||
import { InviteCodeCardSkeleton } from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/invite-code-card';
|
||||
import { PricingCardSkeleton } from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/pricing-card';
|
||||
import { SubscribersPreviewSkeleton } from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/subscribers-preview';
|
||||
|
||||
import { i18n } from '../../../../../i18n';
|
||||
|
||||
|
|
@ -19,8 +19,8 @@ export default function Loading() {
|
|||
label={i18n.t('dashboard:invite.loading')}
|
||||
delayed
|
||||
/>
|
||||
<SubscribersPreviewSkeleton
|
||||
label={i18n.t('dashboard:subscribers.loading')}
|
||||
<AudienceStatsSkeleton
|
||||
label={i18n.t('dashboard:audience.loading')}
|
||||
delayed
|
||||
/>
|
||||
</FlexBox>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
||||
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
|
||||
import {
|
||||
AudienceStats,
|
||||
AudienceStatsSkeleton,
|
||||
} from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/audience-stats';
|
||||
import {
|
||||
InviteCodeCard,
|
||||
InviteCodeCardSkeleton,
|
||||
|
|
@ -9,10 +13,6 @@ import {
|
|||
PricingCard,
|
||||
PricingCardSkeleton,
|
||||
} from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/pricing-card';
|
||||
import {
|
||||
SubscribersPreview,
|
||||
SubscribersPreviewSkeleton,
|
||||
} from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/subscribers-preview';
|
||||
import type { Metadata } from 'next';
|
||||
import { Suspense } from 'react';
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ export const metadata: Metadata = {
|
|||
};
|
||||
|
||||
/**
|
||||
* داشبورد › طرحهای اشتراک (J10-1): «قیمت طرحها», «کد دعوت» (only once approved) and «مشترکان»,
|
||||
* داشبورد › طرحهای اشتراک (J10-1): «قیمت طرحها», «کد دعوت» (only once approved) and «مخاطبان»,
|
||||
* the creator's own, in the browser only. Each block loads and fails on its own; the tabs stay.
|
||||
*/
|
||||
export default function PlansPage() {
|
||||
|
|
@ -41,10 +41,8 @@ export default function PlansPage() {
|
|||
label={i18n.t('dashboard:invite.loading')}
|
||||
/>
|
||||
);
|
||||
const subscribersSkeleton = (
|
||||
<SubscribersPreviewSkeleton
|
||||
label={i18n.t('dashboard:subscribers.loading')}
|
||||
/>
|
||||
const audienceSkeleton = (
|
||||
<AudienceStatsSkeleton label={i18n.t('dashboard:audience.loading')} />
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
@ -54,7 +52,7 @@ export default function PlansPage() {
|
|||
<FlexBox direction="flex-col" gap="gap-4">
|
||||
{pricingSkeleton}
|
||||
{inviteSkeleton}
|
||||
{subscribersSkeleton}
|
||||
{audienceSkeleton}
|
||||
</FlexBox>
|
||||
}
|
||||
>
|
||||
|
|
@ -81,12 +79,12 @@ export default function PlansPage() {
|
|||
</Suspense>
|
||||
</PartBoundary>
|
||||
<PartBoundary
|
||||
name="subscribers-preview"
|
||||
description={i18n.t('dashboard:subscribers.error')}
|
||||
name="audience-stats"
|
||||
description={i18n.t('dashboard:audience.error')}
|
||||
framed
|
||||
>
|
||||
<Suspense fallback={subscribersSkeleton}>
|
||||
<SubscribersPreview />
|
||||
<Suspense fallback={audienceSkeleton}>
|
||||
<AudienceStats />
|
||||
</Suspense>
|
||||
</PartBoundary>
|
||||
</FlexBox>
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
// Locked until a creator finishes registration step 5 (0016), as the tab is; the guard renders
|
||||
// the page as is.
|
||||
export { OnboardingGuard as default } from '@lumina/market/app/guards/onboarding-guard';
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { DesktopPageTitle, ROUTES } from '@lumina/market/app/navigation';
|
||||
import { SubscriberListSkeleton } from '@lumina/market/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list';
|
||||
|
||||
import { i18n } from '../../../../i18n';
|
||||
|
||||
/** «مشترکان» before it arrives, under its real title. */
|
||||
export default function Loading() {
|
||||
return (
|
||||
<FlexBox tag="main" justifyContent="justify-center" className="px-8 py-10">
|
||||
<FlexBox
|
||||
direction="flex-col"
|
||||
gap="gap-4"
|
||||
className="w-full max-w-content"
|
||||
>
|
||||
<DesktopPageTitle
|
||||
title={i18n.t('dashboard:subscribers.title')}
|
||||
parentHref={ROUTES.dashboard.overview}
|
||||
/>
|
||||
<SubscriberListSkeleton
|
||||
label={i18n.t('dashboard:subscribers.loading')}
|
||||
delayed
|
||||
/>
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
||||
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
|
||||
import { DesktopPageTitle, ROUTES } from '@lumina/market/app/navigation';
|
||||
import {
|
||||
SubscriberList,
|
||||
SubscriberListSkeleton,
|
||||
} from '@lumina/market/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list';
|
||||
import type { Metadata } from 'next';
|
||||
import { Suspense } from 'react';
|
||||
|
||||
import { i18n } from '../../../../i18n';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: i18n.t('dashboard:subscribers.meta-title'),
|
||||
robots: { index: false },
|
||||
};
|
||||
|
||||
/**
|
||||
* «مشترکان» on desktop (J10-1f, J10-1g): the same list in the 640 column, «بازگشت» over its title
|
||||
* back to نمای کلی. The creator's own, in the browser only.
|
||||
*/
|
||||
export default function SubscribersPage() {
|
||||
const skeleton = (
|
||||
<SubscriberListSkeleton label={i18n.t('dashboard:subscribers.loading')} />
|
||||
);
|
||||
|
||||
return (
|
||||
<FlexBox tag="main" justifyContent="justify-center" className="px-8 py-10">
|
||||
<FlexBox
|
||||
direction="flex-col"
|
||||
gap="gap-4"
|
||||
className="w-full max-w-content"
|
||||
>
|
||||
<DesktopPageTitle
|
||||
title={i18n.t('dashboard:subscribers.title')}
|
||||
parentHref={ROUTES.dashboard.overview}
|
||||
/>
|
||||
<PartBoundary
|
||||
name="subscriber-list"
|
||||
description={i18n.t('dashboard:subscribers.error')}
|
||||
framed
|
||||
>
|
||||
<AuthGuard role="creator" fallback={skeleton}>
|
||||
<Suspense fallback={skeleton}>
|
||||
<SubscriberList />
|
||||
</Suspense>
|
||||
</AuthGuard>
|
||||
</PartBoundary>
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -7,8 +7,8 @@ import type { ReactNode } from 'react';
|
|||
import { i18n } from '../../../../i18n';
|
||||
|
||||
/**
|
||||
* The creator's داشبورد on mobile (Creator Dashboard ۱.۱, 0034): the tab bar «داشبورد», the four
|
||||
* tabs «نمای کلی» · «طرحهای اشتراک» · «سیگنالها» · «مالی», then the tab. Each tab is its own route with its own loading, so the
|
||||
* The creator's داشبورد on mobile (Creator Dashboard ۱.۱, 0034): the tab bar «داشبورد», the three
|
||||
* tabs «طرحهای اشتراک» · «سیگنالها» · «مالی», then the tab. Each tab is its own route with its own loading, so the
|
||||
* bar and the tabs stay while one loads. Locked until registration step 5 is done (0016).
|
||||
*/
|
||||
export default function CreatorDashboardLayout({
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
import { DashboardOverviewSkeleton } from '@lumina/market/app/screens/(main)/dashboard/overview/organisms/dashboard-overview';
|
||||
|
||||
import { i18n } from '../../../../../i18n';
|
||||
|
||||
/** نمای کلی before it arrives; the layout keeps the bar and the tabs. */
|
||||
export default function Loading() {
|
||||
return (
|
||||
<DashboardOverviewSkeleton
|
||||
layout="mobile"
|
||||
label={i18n.t('dashboard:overview.loading')}
|
||||
delayed
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
||||
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
|
||||
import {
|
||||
DashboardOverview,
|
||||
DashboardOverviewSkeleton,
|
||||
} from '@lumina/market/app/screens/(main)/dashboard/overview/organisms/dashboard-overview';
|
||||
import type { Metadata } from 'next';
|
||||
import { Suspense } from 'react';
|
||||
|
||||
import { i18n } from '../../../../../i18n';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: i18n.t('dashboard:overview.meta-title'),
|
||||
robots: { index: false },
|
||||
};
|
||||
|
||||
/**
|
||||
* داشبورد › نمای کلی (J10-0), the creator's default tab: audience, income, the split by plan and
|
||||
* the signals' summary, the creator's own, in the browser only. The tabs stay while it loads.
|
||||
*/
|
||||
export default function OverviewPage() {
|
||||
const skeleton = (
|
||||
<DashboardOverviewSkeleton
|
||||
layout="mobile"
|
||||
label={i18n.t('dashboard:overview.loading')}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<AuthGuard role="creator" fallback={skeleton}>
|
||||
<PartBoundary
|
||||
name="dashboard-overview"
|
||||
description={i18n.t('dashboard:overview.error')}
|
||||
framed
|
||||
>
|
||||
<Suspense fallback={skeleton}>
|
||||
<DashboardOverview layout="mobile" />
|
||||
</Suspense>
|
||||
</PartBoundary>
|
||||
</AuthGuard>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { AudienceStatsSkeleton } from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/audience-stats';
|
||||
import { InviteCodeCardSkeleton } from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/invite-code-card';
|
||||
import { PricingCardSkeleton } from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/pricing-card';
|
||||
import { SubscribersPreviewSkeleton } from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/subscribers-preview';
|
||||
|
||||
import { i18n } from '../../../../../i18n';
|
||||
|
||||
|
|
@ -19,8 +19,8 @@ export default function Loading() {
|
|||
label={i18n.t('dashboard:invite.loading')}
|
||||
delayed
|
||||
/>
|
||||
<SubscribersPreviewSkeleton
|
||||
label={i18n.t('dashboard:subscribers.loading')}
|
||||
<AudienceStatsSkeleton
|
||||
label={i18n.t('dashboard:audience.loading')}
|
||||
delayed
|
||||
/>
|
||||
</FlexBox>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
||||
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
|
||||
import {
|
||||
AudienceStats,
|
||||
AudienceStatsSkeleton,
|
||||
} from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/audience-stats';
|
||||
import {
|
||||
InviteCodeCard,
|
||||
InviteCodeCardSkeleton,
|
||||
|
|
@ -9,10 +13,6 @@ import {
|
|||
PricingCard,
|
||||
PricingCardSkeleton,
|
||||
} from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/pricing-card';
|
||||
import {
|
||||
SubscribersPreview,
|
||||
SubscribersPreviewSkeleton,
|
||||
} from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/subscribers-preview';
|
||||
import type { Metadata } from 'next';
|
||||
import { Suspense } from 'react';
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ export const metadata: Metadata = {
|
|||
};
|
||||
|
||||
/**
|
||||
* داشبورد › طرحهای اشتراک (J10-1): «قیمت طرحها», «کد دعوت» (only once approved) and «مشترکان»,
|
||||
* داشبورد › طرحهای اشتراک (J10-1): «قیمت طرحها», «کد دعوت» (only once approved) and «مخاطبان»,
|
||||
* the creator's own, in the browser only. Each block loads and fails on its own; the tabs stay.
|
||||
*/
|
||||
export default function PlansPage() {
|
||||
|
|
@ -41,10 +41,8 @@ export default function PlansPage() {
|
|||
label={i18n.t('dashboard:invite.loading')}
|
||||
/>
|
||||
);
|
||||
const subscribersSkeleton = (
|
||||
<SubscribersPreviewSkeleton
|
||||
label={i18n.t('dashboard:subscribers.loading')}
|
||||
/>
|
||||
const audienceSkeleton = (
|
||||
<AudienceStatsSkeleton label={i18n.t('dashboard:audience.loading')} />
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
@ -54,7 +52,7 @@ export default function PlansPage() {
|
|||
<FlexBox direction="flex-col" gap="gap-3">
|
||||
{pricingSkeleton}
|
||||
{inviteSkeleton}
|
||||
{subscribersSkeleton}
|
||||
{audienceSkeleton}
|
||||
</FlexBox>
|
||||
}
|
||||
>
|
||||
|
|
@ -81,12 +79,12 @@ export default function PlansPage() {
|
|||
</Suspense>
|
||||
</PartBoundary>
|
||||
<PartBoundary
|
||||
name="subscribers-preview"
|
||||
description={i18n.t('dashboard:subscribers.error')}
|
||||
name="audience-stats"
|
||||
description={i18n.t('dashboard:audience.error')}
|
||||
framed
|
||||
>
|
||||
<Suspense fallback={subscribersSkeleton}>
|
||||
<SubscribersPreview />
|
||||
<Suspense fallback={audienceSkeleton}>
|
||||
<AudienceStats />
|
||||
</Suspense>
|
||||
</PartBoundary>
|
||||
</FlexBox>
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
// Locked until a creator finishes registration step 5 (0016), as the tab is; the guard renders
|
||||
// the page as is.
|
||||
export { OnboardingGuard as default } from '@lumina/market/app/guards/onboarding-guard';
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { MobileTopBar, ROUTES } from '@lumina/market/app/navigation';
|
||||
import { SubscriberListSkeleton } from '@lumina/market/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list';
|
||||
|
||||
import { i18n } from '../../../../i18n';
|
||||
|
||||
/** «مشترکان» before it arrives, under its real bar. */
|
||||
export default function Loading() {
|
||||
return (
|
||||
<>
|
||||
<MobileTopBar
|
||||
title={i18n.t('dashboard:subscribers.title')}
|
||||
parentHref={ROUTES.dashboard.overview}
|
||||
backToPrevious
|
||||
/>
|
||||
<FlexBox tag="main" direction="flex-col" className="flex-1 p-4">
|
||||
<SubscriberListSkeleton
|
||||
label={i18n.t('dashboard:subscribers.loading')}
|
||||
delayed
|
||||
/>
|
||||
</FlexBox>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
||||
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
|
||||
import { MobileTopBar, ROUTES } from '@lumina/market/app/navigation';
|
||||
import {
|
||||
SubscriberList,
|
||||
SubscriberListSkeleton,
|
||||
} from '@lumina/market/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list';
|
||||
import type { Metadata } from 'next';
|
||||
import { Suspense } from 'react';
|
||||
|
||||
import { i18n } from '../../../../i18n';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: i18n.t('dashboard:subscribers.meta-title'),
|
||||
robots: { index: false },
|
||||
};
|
||||
|
||||
/**
|
||||
* «مشترکان» on mobile (J10-1f, J10-1g): a page pushed from نمای کلی or طرحهای اشتراک, back ·
|
||||
* «مشترکان» · support, with the nav kept on داشبورد. The creator's own, in the browser only;
|
||||
* opened on its own, back goes to نمای کلی.
|
||||
*/
|
||||
export default function SubscribersPage() {
|
||||
const skeleton = (
|
||||
<SubscriberListSkeleton label={i18n.t('dashboard:subscribers.loading')} />
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<MobileTopBar
|
||||
title={i18n.t('dashboard:subscribers.title')}
|
||||
parentHref={ROUTES.dashboard.overview}
|
||||
backToPrevious
|
||||
/>
|
||||
<FlexBox tag="main" direction="flex-col" className="flex-1 p-4">
|
||||
<PartBoundary
|
||||
name="subscriber-list"
|
||||
description={i18n.t('dashboard:subscribers.error')}
|
||||
>
|
||||
<AuthGuard role="creator" fallback={skeleton}>
|
||||
<Suspense fallback={skeleton}>
|
||||
<SubscriberList />
|
||||
</Suspense>
|
||||
</AuthGuard>
|
||||
</PartBoundary>
|
||||
</FlexBox>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# 0034 The creator's داشبورد is three tab routes, C7 a pushed page
|
||||
|
||||
Status: Proposed · Area: architecture · Date: 2026-10-08, amended 2026-10-09, 0072 makes «نمای کلی» the default tab · Decided by: agent
|
||||
Status: Proposed · Area: architecture · Date: 2026-10-08, amended 2026-10-09 · Decided by: agent
|
||||
|
||||
## Context
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
# 0072 The analyst's overview is the default dashboard tab
|
||||
|
||||
Status: Accepted · Area: architecture · Date: 2026-11-05 · Decided by: user · Amends: 0034
|
||||
|
||||
## Context
|
||||
|
||||
The analyst's figures were spread over the plans tab, and the user asked for one place with audience, income, the split by plan and signal performance. The back end already answers `GET /me/dashboard/overview` and `GET /me/subscribers`.
|
||||
|
||||
## Decision
|
||||
|
||||
- `/dashboard/overview` in `dashboard/(creator)` is the first tab and the default: the nav's داشبورد opens it for a creator. The tabs are «نمای کلی» · «طرحهای اشتراک» · «سیگنالها» · «مالی», as in the design (J10-0); the request named three, and the signals tab stays because the same request adds to it.
|
||||
- The plans tab keeps prices and the invite code, loses «مخاطبان», and shows the soonest-ending subscribers. Its followers count moved to the overview, where only the analyst sees it, with no list of who follows.
|
||||
- `/dashboard/subscribers?filter=expiring` is a pushed page outside `(creator)`, with «همه» and «در حال انقضا» from the API's totals.
|
||||
- The signal summary reads the snapshot the signals tab reads (`useSignalStatsPart`), so the two can't disagree, and shows the same message before the first evaluation.
|
||||
|
||||
## Alternatives
|
||||
|
||||
- Three tabs, with signals under the overview: the request also adds a block to the signals tab, so that tab has to exist.
|
||||
- Keeping the figures on the plans tab with a strip above the tabs: the request removes it.
|
||||
|
||||
## Consequences
|
||||
|
||||
- The bar has four tabs on a phone; they fit at 375px with no scrolling.
|
||||
- Everything but the signal summary is one read, so it loads and fails as one part. The summary loads and fails on its own.
|
||||
|
|
@ -29,7 +29,6 @@
|
|||
- 0068 Keep the previous release as a stopped `<app>-<UTC time>` container with its env folder; `tools/rollback.sh <app>` starts it in place of the serving one.
|
||||
- 0070 Render every page except the landing in the browser: the server reads no data and sends the frame, a skeleton and metadata; channel and post are `noindex`, their metadata from params only.
|
||||
- 0071 Index only the landing in bull and bear; every other page is `noindex` with no canonical or JSON-LD, new pages included.
|
||||
- 0072 Make `/dashboard/overview` the analyst's default tab, «نمای کلی» · «طرحهای اشتراک» · «سیگنالها» · «مالی»; the plans tab lists subscribers instead of audience counts, and `/dashboard/subscribers` lists them all.
|
||||
|
||||
## Proposed
|
||||
|
||||
|
|
@ -49,7 +48,7 @@
|
|||
- 0030 architecture: Keep the last checkout's period, invite code and bank payment in the persisted `session.checkout-draft` store from payment start until success, and restore them on the same creator's checkout.
|
||||
- 0031 design: List renew and reactivate periods as island `TierOption` cards, as checkout does, instead of R3's chip grid.
|
||||
- 0033 architecture: Keep the payment sent to the bank in the checkout draft and settle it through `POST /subscriptions/payments/:id/abandon` only on the page that came back from the bank (bfcache or a history load), triggered by the app shell and awaited by checkout's screen read.
|
||||
- 0034 architecture: Serve the creator's داشبورد from `dashboard/(creator)` as `/dashboard/plans`, `/dashboard/predictions` and `/dashboard/finance` (0072 adds the default, `/dashboard/overview`), and C7 at `/dashboard/pricing` in `(flow)`; the شبا form and ledger details open in place.
|
||||
- 0034 architecture: Serve the creator's داشبورد from `dashboard/(creator)` as `/dashboard/plans` (default), `/dashboard/predictions` and `/dashboard/finance`, and C7 at `/dashboard/pricing` in `(flow)`; the شبا form and ledger details open in place.
|
||||
- 0035 design: Pick a promotion's Shamsi date and time with island `Select`s in a sheet or modal, not a drawn wheel.
|
||||
- 0036 architecture: During the 7-day lock the save button reads «ذخیره تخفیف» and saves promotion changes; standing prices and period switches stay read-only.
|
||||
- 0037 architecture: Open payout receipts from the API's session-authorized `/payouts/me/payouts/:id/receipt` through `/api`, not signed expiring URLs.
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ Rendered on the server:
|
|||
- `/account` · [account.md](market/account.md) · noindex · none · browser: top-bar title/login, AccountOverview (identity, lists, sign-out), SupportDialog, SignOutConfirm
|
||||
- `/account/install` · [account-install.md](market/account-install.md) · noindex · none · browser: top-bar title/login, InstallApp
|
||||
- `/account/notifications` · [account-notifications.md](market/account-notifications.md) · noindex · none · browser: top-bar title/login, NotificationSettings, offline banner
|
||||
- `/dashboard/overview` · [dashboard-overview.md](market/dashboard-overview.md) · noindex · none · browser: DashboardOverview (WelcomeBanner, audience, income, PlanBreakdown), SignalSummary
|
||||
- `/dashboard/plans` · [dashboard-plans.md](market/dashboard-plans.md) · noindex · none · browser: PricingCard, InviteCodeCard, InviteShareSheet, CapacityRequestDialog, SubscribersPreview
|
||||
- `/dashboard/subscribers` · [dashboard-subscribers.md](market/dashboard-subscribers.md) · noindex · none · browser: SubscriberList
|
||||
- `/dashboard/plans` · [dashboard-plans.md](market/dashboard-plans.md) · noindex · none · browser: PricingCard, InviteCodeCard, InviteShareSheet, CapacityRequestDialog, AudienceStats
|
||||
- `/dashboard/predictions` · [dashboard-predictions.md](market/dashboard-predictions.md) · noindex · none · browser: PredictionsTab, TrackRecord, open and recently closed PredictionSections, ClosePredictionSheet
|
||||
- `/dashboard/finance` · [dashboard-finance.md](market/dashboard-finance.md) · noindex · none · browser: BalanceSummary, PayoutAccount, ReadBackDialog, Ledger, LedgerDetail, receipt Lightbox
|
||||
- `/dashboard/predictions/all` · [dashboard-predictions-all.md](market/dashboard-predictions-all.md) · noindex · none · browser: page name (bull), PredictionList, ClosePredictionSheet
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
# Dashboard: overview
|
||||
|
||||
`/dashboard/overview` · `apps/{bull,bear}/src/app/(main)/dashboard/(creator)/overview/page.tsx` · Type: account · Layout: [layout-dashboard-creator.md](layout-dashboard-creator.md), [layout-main.md](layout-main.md), [layout.md](layout.md)
|
||||
|
||||
| Field | Value |
|
||||
| ----------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Robots | `noindex` (page `metadata`) |
|
||||
| Status | `200` for every viewer: a guest is sent to login in the browser, an investor sees `AuthGuard`'s page-size no-access state |
|
||||
| loading.tsx | `(creator)/overview/loading.tsx`: the page's skeleton, `delayed` |
|
||||
| First flush | none |
|
||||
| Canonical | none: `noindex` |
|
||||
| H1 | bull: none (see the layout doc); bear: «داشبورد» in the layout |
|
||||
| JSON-LD | none |
|
||||
| Scripts | none beyond the layout's |
|
||||
|
||||
## Sections
|
||||
|
||||
The creator's default tab (0072). Everything sits in `AuthGuard role="creator"`, whose fallback is the skeleton, so the server HTML is only the skeleton.
|
||||
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| --------------- | ------ | -------- | ------- | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| WelcomeBanner | viewer | skeleton | hydrate | no | only with no audience and no income (J10-0b): shares the channel through `OwnerShareSheet`, frozen with the reason until the channel is public |
|
||||
| AudienceSection | viewer | skeleton | hydrate | no | «مخاطبان»: followers (ⓘ subscribers included), active subscribers, ending within 7 days with a link to `/dashboard/subscribers?filter=expiring` |
|
||||
| IncomeSection | viewer | skeleton | hydrate | no | «درآمد»: total (ⓘ net), this Shamsi month, payable with a link to مالی |
|
||||
| PlanBreakdown | viewer | skeleton | hydrate | no | «تفکیک طرحها»: chips «مشترکان فعال» · «کل خریدها» · «درآمد», one bar per plan with count and share; a creator with no plan sees the four periods at zero |
|
||||
| SignalSummary | viewer | skeleton | hydrate | no | the four numbers and the way to a public record, or the message before the first evaluation; its own `PartBoundary` and `<Suspense>` |
|
||||
|
||||
## Notes
|
||||
|
||||
- The first four share one read, `GET /me/dashboard/overview`, under one `PartBoundary`. `SignalSummary` reads `GET /me/signal-stats` with the signals tab's query, so the two tabs can't disagree.
|
||||
- bull: tiles two to a row; bear: three to a row, signal tiles four to a row. Same sections in both apps.
|
||||
|
|
@ -22,7 +22,7 @@ In bull's document order. Everything sits in `AuthGuard role="creator"`, whose f
|
|||
| PricingCard | viewer | skeleton | hydrate | no | «قیمت طرحها»: its own `PartBoundary` and `<Suspense>` (`useSuspenseQuery` in the browser); links to `/dashboard/pricing` |
|
||||
| InviteCodeCard | viewer | skeleton | hydrate | no | «کد دعوت»: renders nothing until the creator is approved (J10-1e); the invite link is built from `NEXT_PUBLIC_SITE_URL`; own `PartBoundary` and `<Suspense>` |
|
||||
| ↳ InviteShareSheet, CapacityRequestDialog | viewer | none | hydrate | no | mount when opened; bull: share opens a bottom sheet; bear: a popover beside the link field |
|
||||
| SubscribersPreview | viewer | skeleton | hydrate | no | «مشترکان»: the total and the three who end soonest, with «مشاهده همه» to `/dashboard/subscribers`; own `PartBoundary` and `<Suspense>` |
|
||||
| AudienceStats | viewer | skeleton | hydrate | no | «مخاطبان»: follower count and active subscriptions, two browser reads; either failing fails the part |
|
||||
|
||||
## Notes
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
# Dashboard: subscribers
|
||||
|
||||
`/dashboard/subscribers` · `apps/{bull,bear}/src/app/(main)/dashboard/subscribers/page.tsx` · Type: account · Layout: [layout-main.md](layout-main.md), [layout.md](layout.md)
|
||||
|
||||
| Field | Value |
|
||||
| ----------- | --------------------------------------------------------------------------------------------------------------- |
|
||||
| Robots | `noindex` (page `metadata`) |
|
||||
| Status | `200` for every viewer: a guest is sent to login in the browser, an investor sees `AuthGuard`'s no-access state |
|
||||
| loading.tsx | `subscribers/loading.tsx`: the bar or title over the chips and rows, `delayed` |
|
||||
| First flush | none |
|
||||
| Canonical | none: `noindex` |
|
||||
| H1 | bull: the bar's title; bear: `DesktopPageTitle` |
|
||||
| JSON-LD | none |
|
||||
| Scripts | none beyond the layout's |
|
||||
|
||||
## Sections
|
||||
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| -------------- | ------ | -------- | ------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| SubscriberList | viewer | skeleton | hydrate | no | «همه» · «در حال انقضا» from the API's totals, the chip in `?filter=`; soonest-ending first, «نمایش مشترکان بیشتر» by cursor; only the @username shows |
|
||||
|
||||
## Notes
|
||||
|
||||
- Pushed from نمای کلی and طرحهای اشتراک; opened on its own, back goes to نمای کلی. Locked until registration step 5 is done (0016).
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
# Layout: dashboard (creator)
|
||||
|
||||
`apps/{bull,bear}/src/app/(main)/dashboard/(creator)/layout.tsx` · wraps `/dashboard/overview`, `/dashboard/plans`, `/dashboard/predictions` and `/dashboard/finance` · it awaits no read, so it adds nothing to any page's first flush; it sits outside each tab's `loading.tsx`, so the bar and the tabs stay while a tab loads
|
||||
`apps/{bull,bear}/src/app/(main)/dashboard/(creator)/layout.tsx` · wraps `/dashboard/plans`, `/dashboard/predictions` and `/dashboard/finance` · it awaits no read, so it adds nothing to any page's first flush; it sits outside each tab's `loading.tsx`, so the bar and the tabs stay while a tab loads
|
||||
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| -------------------------------------------- | ------ | ----------- | ------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| OnboardingGuard | viewer | none | hydrate | no | renders its children unchanged; once the browser knows the viewer, a creator who hasn't finished step 5 is sent to `/onboarding/creator-profile` with a return path (0016) |
|
||||
| MobileTopBar (bull) | config | first flush | hydrate | no | `isTab`: the brand and «داشبورد» centred, in a `<span>`; support entry; the connection bar under it (0040) |
|
||||
| ↳ NotificationBell and account avatar (bull) | viewer | none | hydrate | no | member only; while the viewer is unknown, the guest's «ورود/ثبتنام» holds the end of the bar, invisible |
|
||||
| «داشبورد» `<h1>` (bear) | config | first flush | none | no | at the top of the 640 column |
|
||||
| DashboardTabs | config | first flush | hydrate | no | `role="creator"`: island `TabLinks`, an `<a href>` per tab «نمای کلی» · «طرحهای اشتراک» · «سیگنالها» · «مالی» (0034, 0072); the active tab comes from `usePathname`, so the server HTML already marks it |
|
||||
| Section | Data | HTML | JS | Index | Notes |
|
||||
| -------------------------------------------- | ------ | ----------- | ------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| OnboardingGuard | viewer | none | hydrate | no | renders its children unchanged; once the browser knows the viewer, a creator who hasn't finished step 5 is sent to `/onboarding/creator-profile` with a return path (0016) |
|
||||
| MobileTopBar (bull) | config | first flush | hydrate | no | `isTab`: the brand and «داشبورد» centred, in a `<span>`; support entry; the connection bar under it (0040) |
|
||||
| ↳ NotificationBell and account avatar (bull) | viewer | none | hydrate | no | member only; while the viewer is unknown, the guest's «ورود/ثبتنام» holds the end of the bar, invisible |
|
||||
| «داشبورد» `<h1>` (bear) | config | first flush | none | no | at the top of the 640 column |
|
||||
| DashboardTabs | config | first flush | hydrate | no | `role="creator"`: island `TabLinks`, an `<a href>` per tab «طرحهای اشتراک» · «سیگنالها» · «مالی» (0034); the active tab comes from `usePathname`, so the server HTML already marks it |
|
||||
|
||||
Scripts: none beyond the root layout's.
|
||||
|
||||
## Notes
|
||||
|
||||
- The tabs' URLs don't overlap the investor group's: `(creator)` owns `overview`, `plans`, `predictions` and `finance`, `(investor)` owns `subscriptions`, `transactions` and `following`. There is no `/dashboard` page, so `/dashboard` answers the root not-found. The bottom nav (bull) and the header (bear) link a creator to `/dashboard/overview` and an investor to `/dashboard/subscriptions`.
|
||||
- The tabs' URLs don't overlap the investor group's: `(creator)` owns `plans`, `predictions` and `finance`, `(investor)` owns `subscriptions`, `transactions` and `following`. There is no `/dashboard` page, so `/dashboard` answers the root not-found. The bottom nav (bull) and the header (bear) link a creator to `/dashboard/plans` and an investor to `/dashboard/subscriptions`.
|
||||
- The layout doesn't check the role: each page's `AuthGuard role="creator"` shows an investor the page-size no-access state, under these tabs.
|
||||
- Debt: bull has no `<h1>` (the bar's «داشبورد» is a `<span>`), bear has one, `apps/bull/src/app/(main)/dashboard/(creator)/layout.tsx:22`. Make the bar's tab title an `<h1>` on tab screens, or add a visually hidden `<h1>` in the bull layout.
|
||||
|
|
|
|||
|
|
@ -31,11 +31,6 @@ const dateFormatter = new Intl.DateTimeFormat(LOCALE, {
|
|||
month: 'long',
|
||||
year: 'numeric',
|
||||
});
|
||||
const monthFormatter = new Intl.DateTimeFormat(LOCALE, {
|
||||
timeZone: TIME_ZONE,
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
});
|
||||
const timeFormatter = new Intl.DateTimeFormat(LOCALE, {
|
||||
timeZone: TIME_ZONE,
|
||||
hour: '2-digit',
|
||||
|
|
@ -176,15 +171,6 @@ export function date(
|
|||
return time ? `${day}${DATE_TIME_JOINER}${timeFormatter.format(at)}` : day;
|
||||
}
|
||||
|
||||
/** The Shamsi month and year in Tehran: `مهر 1405`. */
|
||||
export function month(value: DateInput): string {
|
||||
// Intl writes the year first in Persian.
|
||||
const parts = monthFormatter.formatToParts(toDate(value));
|
||||
const part = (type: Intl.DateTimeFormatPartTypes) =>
|
||||
parts.find((item) => item.type === type)?.value ?? '';
|
||||
return `${part('month')} ${part('year')}`;
|
||||
}
|
||||
|
||||
/** Time of day in Tehran: `14:05`, such as when a draft was last saved. */
|
||||
export function time(value: DateInput): string {
|
||||
return timeFormatter.format(toDate(value));
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ export {
|
|||
iso,
|
||||
latinDigits,
|
||||
list,
|
||||
month,
|
||||
number,
|
||||
percent,
|
||||
price,
|
||||
|
|
|
|||
|
|
@ -74,9 +74,7 @@ export function BottomNav() {
|
|||
)}
|
||||
<NavTab
|
||||
href={
|
||||
isCreator
|
||||
? ROUTES.dashboard.overview
|
||||
: ROUTES.dashboard.subscriptions
|
||||
isCreator ? ROUTES.dashboard.plans : ROUTES.dashboard.subscriptions
|
||||
}
|
||||
icon="dashboard"
|
||||
label={t('nav.dashboard')}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ export function DesktopHeader() {
|
|||
<HeaderNavLink
|
||||
href={
|
||||
isCreator
|
||||
? ROUTES.dashboard.overview
|
||||
? ROUTES.dashboard.plans
|
||||
: ROUTES.dashboard.subscriptions
|
||||
}
|
||||
label={t('nav.dashboard')}
|
||||
|
|
|
|||
|
|
@ -57,11 +57,8 @@ export const ROUTES = {
|
|||
subscriptions: '/dashboard/subscriptions',
|
||||
transactions: '/dashboard/transactions',
|
||||
following: '/dashboard/following',
|
||||
/** The creator's داشبورد: «نمای کلی» (the default tab), «طرحهای اشتراک», «سیگنالها» and «مالی». */
|
||||
overview: '/dashboard/overview',
|
||||
/** The creator's داشبورد: «طرحهای اشتراک» (the default tab), «سیگنالها» and «مالی». */
|
||||
plans: '/dashboard/plans',
|
||||
/** «مشترکان», pushed from نمای کلی and طرحهای اشتراک; `?filter=expiring`. */
|
||||
subscribers: '/dashboard/subscribers',
|
||||
predictions: '/dashboard/predictions',
|
||||
/** «همه سیگنالها», pushed from the «سیگنالها» tab; `?status=closed|all`. */
|
||||
predictionsAll: '/dashboard/predictions/all',
|
||||
|
|
|
|||
|
|
@ -11,13 +11,12 @@ import type { FormEvent } from 'react';
|
|||
import { Controller } from 'react-hook-form';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { CODE_RULES } from '../../../../../../features/auth';
|
||||
import { formatMobile, translateMessage } from '../../../../../../shared/utils';
|
||||
import { SupportEntry } from '../../../../organisms/support-entry';
|
||||
import type { CodeStepProps } from './types';
|
||||
|
||||
/**
|
||||
* The 5-digit code step of login and registration: the number it went to, the cells, the resend
|
||||
* The 6-digit code step of login and registration: the number it went to, the cells, the resend
|
||||
* wait and the submit button under them. Blocked, the cells and the button rest and the wait
|
||||
* counts to the moment a new code may be asked for; «ویرایش شماره» stays live. Limited (too many
|
||||
* codes in an hour), only the wait is amber: the last code can still be typed.
|
||||
|
|
@ -79,7 +78,6 @@ export function CodeStep({
|
|||
<OtpInput
|
||||
// A new key empties the cells' own state and focuses the first cell again.
|
||||
key={attempt}
|
||||
length={CODE_RULES.length}
|
||||
name={field.name}
|
||||
value={field.value}
|
||||
onChange={(value: string) => {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
export { ChannelShare } from './ChannelShare';
|
||||
export { OwnerShareSheet } from './components/OwnerShareSheet';
|
||||
export type { ChannelShareProps } from './types';
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import type { DashboardTabsProps } from './types';
|
|||
|
||||
/**
|
||||
* The داشبورد's section row, full width, the current one underlined: the investor's «اشتراکها» ·
|
||||
* «تراکنشها» · «دنبالشدهها» (U8 ۴.۱, ۶.۱; U8 ۵.۲), or the creator's «نمای کلی» ·
|
||||
* «طرحهای اشتراک» · «سیگنالها» · «مالی» (J10-0, 0034, 0072). The dashboard layout renders it once, so it stays put while a section
|
||||
* «تراکنشها» · «دنبالشدهها» (U8 ۴.۱, ۶.۱; U8 ۵.۲), or the creator's «طرحهای اشتراک» ·
|
||||
* «سیگنالها» · «مالی» (Creator Dashboard ۱.۱, J10-0, 0034). The dashboard layout renders it once, so it stays put while a section
|
||||
* loads; the current one comes from the URL, which the server render already knows.
|
||||
*/
|
||||
export function DashboardTabs({
|
||||
|
|
|
|||
|
|
@ -7,9 +7,8 @@ export const INVESTOR_TABS = [
|
|||
{ href: ROUTES.dashboard.following, label: 'tabs.following' },
|
||||
] as const;
|
||||
|
||||
/** The creator's four tabs, «نمای کلی» first (J10-0). */
|
||||
/** The creator's three tabs, «طرحهای اشتراک» first (Creator Dashboard ۱.۱, J10-0). */
|
||||
export const CREATOR_TABS = [
|
||||
{ href: ROUTES.dashboard.overview, label: 'creator-tabs.overview' },
|
||||
{ href: ROUTES.dashboard.plans, label: 'creator-tabs.plans' },
|
||||
{ href: ROUTES.dashboard.predictions, label: 'creator-tabs.predictions' },
|
||||
{ href: ROUTES.dashboard.finance, label: 'creator-tabs.finance' },
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import { Avatar } from '@lumina/island/atoms/avatar';
|
||||
import { StatusBadge } from '@lumina/island/atoms/status-badge';
|
||||
import { ListRow } from '@lumina/island/molecules/list-row';
|
||||
import { Element } from '@lumina/island/primitives/element';
|
||||
import { date, number } from '@lumina/tools/format';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { subscriberDaysLeft } from '../../../../../../features/overview';
|
||||
import type { SubscriberRowProps } from './types';
|
||||
|
||||
/**
|
||||
* One subscriber: the @username, plan and end date, with how long is left in its last week. Only
|
||||
* the @username ever shows, never a phone or a name.
|
||||
*/
|
||||
export function SubscriberRow({ subscriber }: SubscriberRowProps) {
|
||||
const { t } = useTranslation(['dashboard', 'common']);
|
||||
const daysLeft = subscriberDaysLeft(subscriber.endsAt);
|
||||
const until = date(subscriber.endsAt, { time: false });
|
||||
|
||||
return (
|
||||
<ListRow
|
||||
leading={
|
||||
<Avatar name={subscriber.username ?? '?'} src={subscriber.avatarUrl} />
|
||||
}
|
||||
title={
|
||||
<Element tag="bdi" dir="ltr">
|
||||
@{subscriber.username ?? '—'}
|
||||
</Element>
|
||||
}
|
||||
subtitle={
|
||||
subscriber.tier
|
||||
? t('subscribers.until-plan', {
|
||||
plan: t(`common:billing-periods.${subscriber.tier}`),
|
||||
date: until,
|
||||
})
|
||||
: t('subscribers.until', { date: until })
|
||||
}
|
||||
end={
|
||||
daysLeft !== null && (
|
||||
<StatusBadge tone="warning" icon={null}>
|
||||
{t('subscribers.days-left', { n: number(daysLeft) })}
|
||||
</StatusBadge>
|
||||
)
|
||||
}
|
||||
chevron={false}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
export { SubscriberRow } from './SubscriberRow';
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
import type { OwnSubscriberPayload } from '../../../../../../features/overview';
|
||||
|
||||
export type SubscriberRowProps = { subscriber: OwnSubscriberPayload };
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
|
||||
import { useDashboardOverviewPart } from '../../../../../../../features/overview';
|
||||
import { AudienceSection } from './components/AudienceSection';
|
||||
import { IncomeSection } from './components/IncomeSection';
|
||||
import { PlanBreakdown } from './components/PlanBreakdown';
|
||||
import { SignalSummary } from './components/SignalSummary';
|
||||
import { WelcomeBanner } from './components/WelcomeBanner';
|
||||
import type { DashboardOverviewProps } from './types';
|
||||
|
||||
/** داشبورد › نمای کلی (J10-0), the creator's default tab. Loads and fails as one. */
|
||||
export function DashboardOverview({ layout }: DashboardOverviewProps) {
|
||||
const overview = useDashboardOverviewPart();
|
||||
const cols = layout === 'desktop' ? 'grid-cols-3' : 'grid-cols-2';
|
||||
|
||||
return (
|
||||
<FlexBox direction="flex-col" gap="gap-6">
|
||||
{overview.isNewcomer && <WelcomeBanner layout={layout} />}
|
||||
<AudienceSection overview={overview} cols={cols} />
|
||||
<IncomeSection overview={overview} cols={cols} />
|
||||
<PlanBreakdown plans={overview.plans} />
|
||||
<SignalSummary layout={layout} />
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { GridBox } from '@lumina/island/atoms/grid-box';
|
||||
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
|
||||
|
||||
import type { DashboardOverviewSkeletonProps } from './types';
|
||||
|
||||
/** «نمای کلی» before it arrives: each section's title over its tiles, the plans' card under them. */
|
||||
export function DashboardOverviewSkeleton({
|
||||
layout,
|
||||
label,
|
||||
delayed,
|
||||
}: DashboardOverviewSkeletonProps) {
|
||||
const cols = layout === 'desktop' ? 'grid-cols-3' : 'grid-cols-2';
|
||||
|
||||
return (
|
||||
<SkeletonRegion label={label} delayed={delayed}>
|
||||
<FlexBox direction="flex-col" gap="gap-6">
|
||||
{[0, 1].map((section) => (
|
||||
<FlexBox key={section} direction="flex-col" gap="gap-3">
|
||||
<Skeleton width="25%" />
|
||||
<GridBox cols={cols} gap="gap-2">
|
||||
{[0, 1, 2].map((tile) => (
|
||||
<FlexBox
|
||||
key={tile}
|
||||
direction="flex-col"
|
||||
gap="gap-2"
|
||||
className="rounded-lg border border-border-subtle p-4"
|
||||
>
|
||||
<Skeleton width="60%" />
|
||||
<Skeleton width="35%" height={36} />
|
||||
</FlexBox>
|
||||
))}
|
||||
</GridBox>
|
||||
</FlexBox>
|
||||
))}
|
||||
<FlexBox direction="flex-col" gap="gap-3">
|
||||
<Skeleton width="25%" />
|
||||
<Skeleton height={160} />
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
</SkeletonRegion>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
import { GridBox } from '@lumina/island/atoms/grid-box';
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { Link } from '@lumina/island/atoms/link';
|
||||
import { InfoTip } from '@lumina/island/molecules/info-tip';
|
||||
import { SectionTitle } from '@lumina/island/molecules/section-title';
|
||||
import { StatTile } from '@lumina/island/molecules/stat-tile';
|
||||
import { number } from '@lumina/tools/format';
|
||||
import { Element } from '@lumina/island/primitives/element';
|
||||
import { useId } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { SUBSCRIBERS_EXPIRING_HREF } from '../constants';
|
||||
import type { OverviewSectionProps } from '../types';
|
||||
|
||||
/**
|
||||
* «مخاطبان»: followers (the creator's own figure, subscribers included), who subscribes now and
|
||||
* who ends within a week, with the way to see them. Counts only, never a list of people here.
|
||||
*/
|
||||
export function AudienceSection({ overview, cols }: OverviewSectionProps) {
|
||||
const { t } = useTranslation('dashboard');
|
||||
const titleId = useId();
|
||||
|
||||
return (
|
||||
<FlexBox
|
||||
tag="section"
|
||||
aria-labelledby={titleId}
|
||||
direction="flex-col"
|
||||
gap="gap-3"
|
||||
>
|
||||
<SectionTitle title={t('overview.audience.title')} titleId={titleId} />
|
||||
<GridBox cols={cols} gap="gap-2">
|
||||
<StatTile
|
||||
icon="users"
|
||||
label={
|
||||
<Element
|
||||
tag="span"
|
||||
className="inline-flex items-center whitespace-nowrap"
|
||||
>
|
||||
{t('overview.audience.followers')}
|
||||
<InfoTip label={t('overview.audience.followers-tip-label')}>
|
||||
{t('overview.audience.followers-tip')}
|
||||
</InfoTip>
|
||||
</Element>
|
||||
}
|
||||
value={number(overview.followers)}
|
||||
/>
|
||||
<StatTile
|
||||
icon="star"
|
||||
label={t('overview.audience.subscribers')}
|
||||
value={number(overview.activeSubscribers)}
|
||||
hint={
|
||||
overview.activeSubscribers === 0
|
||||
? t('overview.audience.subscribers-none')
|
||||
: t('overview.audience.subscribers-plans', {
|
||||
n: number(overview.plansWithSubscribers),
|
||||
})
|
||||
}
|
||||
/>
|
||||
<StatTile
|
||||
icon="clock"
|
||||
label={t('overview.audience.expiring')}
|
||||
value={number(overview.expiringIn7d)}
|
||||
hint={t('overview.audience.expiring-hint')}
|
||||
footer={
|
||||
overview.expiringIn7d > 0 && (
|
||||
<FlexBox>
|
||||
<Link
|
||||
href={SUBSCRIBERS_EXPIRING_HREF}
|
||||
icon="chevron-left"
|
||||
standalone
|
||||
>
|
||||
{t('overview.audience.expiring-link')}
|
||||
</Link>
|
||||
</FlexBox>
|
||||
)
|
||||
}
|
||||
/>
|
||||
</GridBox>
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
import { Amount } from '@lumina/island/atoms/amount';
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { GridBox } from '@lumina/island/atoms/grid-box';
|
||||
import { Link } from '@lumina/island/atoms/link';
|
||||
import { InfoTip } from '@lumina/island/molecules/info-tip';
|
||||
import { SectionTitle } from '@lumina/island/molecules/section-title';
|
||||
import { StatTile } from '@lumina/island/molecules/stat-tile';
|
||||
import { month } from '@lumina/tools/format';
|
||||
import { Element } from '@lumina/island/primitives/element';
|
||||
import { useId } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { ROUTES } from '../../../../../../../navigation/navigation';
|
||||
import type { OverviewSectionProps } from '../types';
|
||||
|
||||
/**
|
||||
* «درآمد»: everything earned, net of commission and refunds, this Shamsi month's part of it, and
|
||||
* what can be paid out, with the way to مالی.
|
||||
*/
|
||||
export function IncomeSection({ overview, cols }: OverviewSectionProps) {
|
||||
const { t } = useTranslation(['dashboard', 'common']);
|
||||
const titleId = useId();
|
||||
const currency = t('common:currency');
|
||||
|
||||
return (
|
||||
<FlexBox
|
||||
tag="section"
|
||||
aria-labelledby={titleId}
|
||||
direction="flex-col"
|
||||
gap="gap-3"
|
||||
>
|
||||
<SectionTitle title={t('overview.income.title')} titleId={titleId} />
|
||||
<GridBox cols={cols} gap="gap-2">
|
||||
<StatTile
|
||||
icon="wallet"
|
||||
label={
|
||||
<Element
|
||||
tag="span"
|
||||
className="inline-flex items-center whitespace-nowrap"
|
||||
>
|
||||
{t('overview.income.total')}
|
||||
<InfoTip label={t('overview.income.total-tip-label')}>
|
||||
{t('overview.income.total-tip')}
|
||||
</InfoTip>
|
||||
</Element>
|
||||
}
|
||||
value={
|
||||
<Amount
|
||||
value={overview.income.total}
|
||||
size="title"
|
||||
currency={currency}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<StatTile
|
||||
icon="calendar"
|
||||
label={t('overview.income.month')}
|
||||
value={
|
||||
<Amount
|
||||
value={overview.income.thisMonth}
|
||||
size="title"
|
||||
currency={currency}
|
||||
/>
|
||||
}
|
||||
hint={month(new Date())}
|
||||
/>
|
||||
<StatTile
|
||||
icon="receipt"
|
||||
label={t('overview.income.payable')}
|
||||
value={
|
||||
<Amount
|
||||
value={overview.income.payable}
|
||||
size="title"
|
||||
currency={currency}
|
||||
/>
|
||||
}
|
||||
footer={
|
||||
<FlexBox>
|
||||
<Link
|
||||
href={ROUTES.dashboard.finance}
|
||||
icon="chevron-left"
|
||||
standalone
|
||||
>
|
||||
{t('overview.income.payable-link')}
|
||||
</Link>
|
||||
</FlexBox>
|
||||
}
|
||||
/>
|
||||
</GridBox>
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { Typography } from '@lumina/island/atoms/typography';
|
||||
import { Card } from '@lumina/island/molecules/card';
|
||||
import { FilterChips } from '@lumina/island/molecules/filter-chips';
|
||||
import { Meter } from '@lumina/island/molecules/meter';
|
||||
import { SectionTitle } from '@lumina/island/molecules/section-title';
|
||||
import { number, percent } from '@lumina/tools/format';
|
||||
import { useId, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { planBreakdownRows } from '../../../../../../../../features/overview';
|
||||
import type { PlanBreakdownMetric } from '../../../../../../../../features/overview';
|
||||
import { PLAN_BREAKDOWN_METRICS } from '../constants';
|
||||
import type { PlanBreakdownProps } from '../types';
|
||||
|
||||
/**
|
||||
* «تفکیک طرحها»: one bar per plan, by active subscribers, every purchase or income, the chips
|
||||
* choosing which. The note says what «کل خریدها» counts.
|
||||
*/
|
||||
export function PlanBreakdown({ plans }: PlanBreakdownProps) {
|
||||
const { t } = useTranslation(['dashboard', 'common']);
|
||||
const [metric, setMetric] = useState<PlanBreakdownMetric>('active');
|
||||
const titleId = useId();
|
||||
|
||||
return (
|
||||
<FlexBox
|
||||
tag="section"
|
||||
aria-labelledby={titleId}
|
||||
direction="flex-col"
|
||||
gap="gap-3"
|
||||
>
|
||||
<SectionTitle title={t('overview.plans.title')} titleId={titleId} />
|
||||
<FilterChips
|
||||
label={t('overview.plans.metric')}
|
||||
size="sm"
|
||||
scroll
|
||||
options={PLAN_BREAKDOWN_METRICS.map((value) => ({
|
||||
value,
|
||||
label: t(`overview.plans.metrics.${value}`),
|
||||
}))}
|
||||
value={metric}
|
||||
onChange={setMetric}
|
||||
/>
|
||||
<Card padding="md">
|
||||
<FlexBox direction="flex-col" gap="gap-3">
|
||||
{planBreakdownRows(plans, metric).map((row) => (
|
||||
<Meter
|
||||
key={row.tier}
|
||||
label={t(`common:billing-periods.${row.tier}`)}
|
||||
value={Math.max(row.value, 0)}
|
||||
max={row.total || 1}
|
||||
caption={t(`overview.plans.caption.${metric}`, {
|
||||
n: number(row.value),
|
||||
share: percent(row.sharePercent, 0),
|
||||
currency: t('common:currency'),
|
||||
})}
|
||||
/>
|
||||
))}
|
||||
</FlexBox>
|
||||
</Card>
|
||||
<Typography variant="caption" color="secondary">
|
||||
{t('overview.plans.note')}
|
||||
</Typography>
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { SectionTitle } from '@lumina/island/molecules/section-title';
|
||||
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||
import { Suspense, useId } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useSignalStatsPart } from '../../../../../../../../features/prediction';
|
||||
import { PartBoundary } from '../../../../../../../error-boundaries';
|
||||
import { ROUTES } from '../../../../../../../navigation/navigation';
|
||||
import { SignalProgress } from '../../../../organisms/signal-progress';
|
||||
import { SignalStatTiles } from '../../../../organisms/signal-stat-tiles';
|
||||
import { SignalStatsPending } from '../../../../organisms/signal-stats-pending';
|
||||
import type { SignalSummaryProps } from '../types';
|
||||
|
||||
/** The same four numbers as the سیگنالها tab, from the same snapshot, or the message before it. */
|
||||
function SignalSummaryBody({ layout }: SignalSummaryProps) {
|
||||
const performance = useSignalStatsPart();
|
||||
|
||||
if (performance.status === 'pending') return <SignalStatsPending />;
|
||||
return (
|
||||
<FlexBox direction="flex-col" gap="gap-3">
|
||||
<SignalStatTiles stats={performance.stats} layout={layout} />
|
||||
<SignalProgress progress={performance.progress} />
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* «عملکرد سیگنالها» in short, with the way to the tab that explains it. It loads and fails on its
|
||||
* own, so the rest of the page stands without it.
|
||||
*/
|
||||
export function SignalSummary({ layout }: SignalSummaryProps) {
|
||||
const { t } = useTranslation('dashboard');
|
||||
const titleId = useId();
|
||||
|
||||
return (
|
||||
<FlexBox
|
||||
tag="section"
|
||||
aria-labelledby={titleId}
|
||||
direction="flex-col"
|
||||
gap="gap-3"
|
||||
>
|
||||
<SectionTitle
|
||||
title={t('overview.signals.title')}
|
||||
titleId={titleId}
|
||||
actionLabel={t('overview.signals.details')}
|
||||
actionHref={ROUTES.dashboard.predictions}
|
||||
/>
|
||||
<PartBoundary
|
||||
name="overview-signals"
|
||||
description={t('overview.signals.error')}
|
||||
framed
|
||||
>
|
||||
<Suspense
|
||||
fallback={
|
||||
<SkeletonPreset
|
||||
preset="stats"
|
||||
label={t('overview.signals.loading')}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<SignalSummaryBody layout={layout} />
|
||||
</Suspense>
|
||||
</PartBoundary>
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from '@lumina/island/atoms/button';
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { Banner } from '@lumina/island/molecules/banner';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import {
|
||||
useChannelShareSheet,
|
||||
useDisplayLink,
|
||||
useOwnChannel,
|
||||
} from '../../../../../../../../features/channel';
|
||||
import { useCurrentAccount } from '../../../../../../../../stores/auth';
|
||||
import { ROUTES } from '../../../../../../../navigation/navigation';
|
||||
import { OwnerShareSheet } from '../../../../../channels/[username]/organisms/channel-share';
|
||||
import type { WelcomeBannerProps } from '../types';
|
||||
|
||||
/**
|
||||
* A new analyst's next step (J10-0b): share the channel, with the caption sheet the channel's own
|
||||
* share uses. A channel that isn't public yet has nothing to share, so the button says why.
|
||||
*/
|
||||
export function WelcomeBanner({ layout }: WelcomeBannerProps) {
|
||||
const { t } = useTranslation(['dashboard', 'channel']);
|
||||
const account = useCurrentAccount();
|
||||
const own = useOwnChannel();
|
||||
const path = ROUTES.channel(account?.username ?? '');
|
||||
const channelUrl = useDisplayLink(path) ?? path;
|
||||
const sheet = useChannelShareSheet({ path, native: layout === 'mobile' });
|
||||
const isSuspended = own.status === 'ready' && own.channel.suspended;
|
||||
const isVerified = own.status === 'ready' && own.standing === 'verified';
|
||||
const frozenReason = isSuspended
|
||||
? t('channel:share.owner.suspended')
|
||||
: isVerified
|
||||
? undefined
|
||||
: t('channel:share.owner.pending');
|
||||
|
||||
const share = (
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
aria-haspopup="dialog"
|
||||
aria-expanded={sheet.isOpen}
|
||||
frozen={frozenReason !== undefined}
|
||||
frozenReason={frozenReason}
|
||||
onClick={sheet.open}
|
||||
>
|
||||
{t('overview.welcome.action')}
|
||||
</Button>
|
||||
);
|
||||
|
||||
return (
|
||||
<FlexBox direction="flex-col" className="relative">
|
||||
<Banner
|
||||
tone="info"
|
||||
icon="share"
|
||||
title={t('overview.welcome.title')}
|
||||
action={layout === 'desktop' ? share : undefined}
|
||||
>
|
||||
{layout === 'desktop' ? (
|
||||
t('overview.welcome.text')
|
||||
) : (
|
||||
// A phone has no room beside the text, so the button goes under it.
|
||||
<FlexBox direction="flex-col" alignItems="items-start" gap="gap-3">
|
||||
{t('overview.welcome.text')}
|
||||
{share}
|
||||
</FlexBox>
|
||||
)}
|
||||
</Banner>
|
||||
<OwnerShareSheet model={sheet} channelUrl={channelUrl} layout={layout} />
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
import type { PlanBreakdownMetric } from '../../../../../../../features/overview';
|
||||
import { ROUTES } from '../../../../../../navigation/navigation';
|
||||
|
||||
/** «مشترکان» opened on who ends within a week (J10-1g). */
|
||||
export const SUBSCRIBERS_EXPIRING_HREF = `${ROUTES.dashboard.subscribers}?filter=expiring`;
|
||||
|
||||
export const PLAN_BREAKDOWN_METRICS: readonly PlanBreakdownMetric[] = [
|
||||
'active',
|
||||
'purchases',
|
||||
'income',
|
||||
];
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
export { DashboardOverview } from './DashboardOverview';
|
||||
export { DashboardOverviewSkeleton } from './DashboardOverviewSkeleton';
|
||||
export type { DashboardOverviewSkeletonProps } from './types';
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
import type { DashboardOverviewPartModel } from '../../../../../../../features/overview';
|
||||
|
||||
export type DashboardOverviewLayout = 'mobile' | 'desktop';
|
||||
|
||||
export type DashboardOverviewProps = { layout: DashboardOverviewLayout };
|
||||
|
||||
export type OverviewSectionProps = {
|
||||
overview: DashboardOverviewPartModel;
|
||||
/** Three tiles in a row on desktop, two on mobile. */
|
||||
cols: 'grid-cols-2' | 'grid-cols-3';
|
||||
};
|
||||
|
||||
export type DashboardOverviewSkeletonProps = {
|
||||
layout: DashboardOverviewLayout;
|
||||
/** Hidden status text: «در حال بارگذاری نمای کلی…». */
|
||||
label: string;
|
||||
/** Fades in after 300 ms, so a fast route never flashes it (`loading.tsx` only, G-3d). */
|
||||
delayed?: boolean;
|
||||
};
|
||||
|
||||
export type PlanBreakdownProps = {
|
||||
plans: DashboardOverviewPartModel['plans'];
|
||||
};
|
||||
|
||||
export type SignalSummaryProps = DashboardOverviewProps;
|
||||
|
||||
export type WelcomeBannerProps = DashboardOverviewProps;
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { GridBox } from '@lumina/island/atoms/grid-box';
|
||||
import { Typography } from '@lumina/island/atoms/typography';
|
||||
import { StatTile } from '@lumina/island/molecules/stat-tile';
|
||||
import { number } from '@lumina/tools/format';
|
||||
import { useId } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useAudiencePart } from '../../../../../../../features/overview';
|
||||
|
||||
/**
|
||||
* طرحهای اشتراک › «مخاطبان» (J10-1): two tiles, «دنبالکنندگان» and «مشترکان فعال», then who can
|
||||
* see which. Counts only, never a list of people. A section on the page, not a card.
|
||||
*/
|
||||
export function AudienceStats() {
|
||||
const { t } = useTranslation('dashboard');
|
||||
const model = useAudiencePart();
|
||||
const headingId = useId();
|
||||
|
||||
return (
|
||||
<FlexBox
|
||||
tag="section"
|
||||
aria-labelledby={headingId}
|
||||
direction="flex-col"
|
||||
gap="gap-3"
|
||||
>
|
||||
<Typography tag="h2" id={headingId} variant="heading-sm">
|
||||
{t('audience.title')}
|
||||
</Typography>
|
||||
<GridBox cols="grid-cols-2" gap="gap-2">
|
||||
<StatTile
|
||||
label={t('audience.followers')}
|
||||
icon="users"
|
||||
value={number(model.followers)}
|
||||
/>
|
||||
<StatTile
|
||||
label={t('audience.subscribers')}
|
||||
icon="star"
|
||||
value={number(model.activeSubscribers)}
|
||||
/>
|
||||
</GridBox>
|
||||
<Typography variant="caption" color="secondary">
|
||||
{t('audience.note')}
|
||||
</Typography>
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { GridBox } from '@lumina/island/atoms/grid-box';
|
||||
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
|
||||
|
||||
import type { AudienceStatsSkeletonProps } from './types';
|
||||
|
||||
/** «مخاطبان» before it arrives: its title, the two tiles and the line under them. */
|
||||
export function AudienceStatsSkeleton({
|
||||
label,
|
||||
delayed,
|
||||
}: AudienceStatsSkeletonProps) {
|
||||
return (
|
||||
<SkeletonRegion label={label} delayed={delayed}>
|
||||
<FlexBox direction="flex-col" gap="gap-3">
|
||||
<Skeleton width="25%" />
|
||||
<GridBox cols="grid-cols-2" gap="gap-2">
|
||||
{[0, 1].map((tile) => (
|
||||
<FlexBox
|
||||
key={tile}
|
||||
direction="flex-col"
|
||||
gap="gap-2"
|
||||
className="rounded-lg border border-border-subtle p-4"
|
||||
>
|
||||
<Skeleton width="60%" />
|
||||
<Skeleton width="35%" height={36} />
|
||||
</FlexBox>
|
||||
))}
|
||||
</GridBox>
|
||||
<Skeleton width="80%" />
|
||||
</FlexBox>
|
||||
</SkeletonRegion>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
export { AudienceStats } from './AudienceStats';
|
||||
export { AudienceStatsSkeleton } from './AudienceStatsSkeleton';
|
||||
export type { AudienceStatsSkeletonProps } from './types';
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
export type AudienceStatsSkeletonProps = {
|
||||
/** Hidden status text: «در حال بارگذاری مخاطبان…». */
|
||||
label: string;
|
||||
/** Fades in after 300ms, so a fast route never flashes grey. loading.tsx only. */
|
||||
delayed?: boolean;
|
||||
};
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { Typography } from '@lumina/island/atoms/typography';
|
||||
import { List } from '@lumina/island/molecules/list-row';
|
||||
import { SectionTitle } from '@lumina/island/molecules/section-title';
|
||||
import { useId } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useSubscribersPreviewPart } from '../../../../../../../features/overview';
|
||||
import { ROUTES } from '../../../../../../navigation/navigation';
|
||||
import { SubscriberRow } from '../../../organisms/subscriber-row';
|
||||
|
||||
/** طرحهای اشتراک › «مشترکان» (J10-1): the soonest-ending few, then the whole list a tap away. */
|
||||
export function SubscribersPreview() {
|
||||
const { t } = useTranslation('dashboard');
|
||||
const { total, items } = useSubscribersPreviewPart();
|
||||
const titleId = useId();
|
||||
|
||||
return (
|
||||
<FlexBox
|
||||
tag="section"
|
||||
aria-labelledby={titleId}
|
||||
direction="flex-col"
|
||||
gap="gap-3"
|
||||
>
|
||||
<SectionTitle
|
||||
title={t('subscribers.title')}
|
||||
titleId={titleId}
|
||||
count={total}
|
||||
actionLabel={total > 0 ? t('subscribers.view-all') : undefined}
|
||||
actionHref={total > 0 ? ROUTES.dashboard.subscribers : undefined}
|
||||
/>
|
||||
{total > 0 ? (
|
||||
<>
|
||||
<List>
|
||||
{items.map((subscriber) => (
|
||||
<SubscriberRow
|
||||
key={`${subscriber.username}:${subscriber.endsAt}`}
|
||||
subscriber={subscriber}
|
||||
/>
|
||||
))}
|
||||
</List>
|
||||
<Typography variant="caption" color="secondary">
|
||||
{t('subscribers.privacy-short')}
|
||||
</Typography>
|
||||
</>
|
||||
) : (
|
||||
<Typography variant="body-sm" color="secondary">
|
||||
{t('subscribers.empty.all')}
|
||||
</Typography>
|
||||
)}
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { Skeleton } from '@lumina/island/atoms/skeleton';
|
||||
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||
|
||||
import type { SubscribersPreviewSkeletonProps } from './types';
|
||||
|
||||
/** «مشترکان» before it arrives: its title over the rows. */
|
||||
export function SubscribersPreviewSkeleton({
|
||||
label,
|
||||
delayed,
|
||||
}: SubscribersPreviewSkeletonProps) {
|
||||
return (
|
||||
<FlexBox direction="flex-col" gap="gap-3">
|
||||
<Skeleton width="25%" />
|
||||
<SkeletonPreset preset="list" count={3} label={label} delayed={delayed} />
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
export { SubscribersPreview } from './SubscribersPreview';
|
||||
export { SubscribersPreviewSkeleton } from './SubscribersPreviewSkeleton';
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
export type SubscribersPreviewSkeletonProps = {
|
||||
/** Hidden status text: «در حال بارگذاری مشترکان…». */
|
||||
label: string;
|
||||
/** Fades in after 300 ms, so a fast route never flashes it (`loading.tsx` only, G-3d). */
|
||||
delayed?: boolean;
|
||||
};
|
||||
|
|
@ -28,20 +28,18 @@ export function PredictionList({ layout }: PredictionListProps) {
|
|||
|
||||
return (
|
||||
<FlexBox direction="flex-col" gap="gap-4" aria-busy={model.isFiltering}>
|
||||
{model.counts.open !== null && (
|
||||
<FilterChips
|
||||
label={t('list.filter')}
|
||||
scroll
|
||||
options={FILTERS.map((status) => ({
|
||||
value: status,
|
||||
label: t(`list.filters.${status}`, {
|
||||
n: number(model.counts[status] ?? 0),
|
||||
}),
|
||||
}))}
|
||||
value={model.status}
|
||||
onChange={model.setStatus}
|
||||
/>
|
||||
)}
|
||||
<FilterChips
|
||||
label={t('list.filter')}
|
||||
scroll
|
||||
options={FILTERS.map((status) => ({
|
||||
value: status,
|
||||
label: t(`list.filters.${status}`, {
|
||||
n: number(model.counts[status]),
|
||||
}),
|
||||
}))}
|
||||
value={model.status}
|
||||
onChange={model.setStatus}
|
||||
/>
|
||||
{model.items.length === 0 ? (
|
||||
model.counts.all === 0 ? (
|
||||
<EmptyState
|
||||
|
|
|
|||
|
|
@ -1,96 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from '@lumina/island/atoms/button';
|
||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { Typography } from '@lumina/island/atoms/typography';
|
||||
import { EmptyState } from '@lumina/island/molecules/empty-state';
|
||||
import { ErrorState } from '@lumina/island/molecules/error-state';
|
||||
import { FilterChips } from '@lumina/island/molecules/filter-chips';
|
||||
import { List } from '@lumina/island/molecules/list-row';
|
||||
import { number } from '@lumina/tools/format';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useSubscribersPage } from '../../../../../../../features/overview';
|
||||
import { SubscriberRow } from '../../../organisms/subscriber-row';
|
||||
|
||||
/**
|
||||
* «مشترکان» (J10-1f, J10-1g): «همه» · «در حال انقضا», soonest-ending first, «نمایش بیشتر» for the
|
||||
* next page. The rows stay while another chip's list loads; a failed page says so in its place.
|
||||
*/
|
||||
export function SubscriberList() {
|
||||
const { t } = useTranslation(['dashboard', 'errors']);
|
||||
const model = useSubscribersPage();
|
||||
|
||||
return (
|
||||
<FlexBox direction="flex-col" gap="gap-4" aria-busy={model.isFiltering}>
|
||||
<FilterChips
|
||||
label={t('subscribers.filter')}
|
||||
size="sm"
|
||||
options={[
|
||||
{
|
||||
value: 'all' as const,
|
||||
label: t('subscribers.filters.all', {
|
||||
n: number(model.counts.all),
|
||||
}),
|
||||
},
|
||||
{
|
||||
value: 'expiring' as const,
|
||||
label: t('subscribers.filters.expiring', {
|
||||
n: number(model.counts.expiring),
|
||||
}),
|
||||
},
|
||||
]}
|
||||
value={model.filter}
|
||||
onChange={model.setFilter}
|
||||
/>
|
||||
{model.items.length === 0 ? (
|
||||
<EmptyState
|
||||
tone="neutral"
|
||||
size="section"
|
||||
icon="users"
|
||||
title={t(`subscribers.empty.${model.filter}`)}
|
||||
/>
|
||||
) : (
|
||||
<List>
|
||||
{model.items.map((subscriber) => (
|
||||
<SubscriberRow
|
||||
key={`${subscriber.username}:${subscriber.endsAt}`}
|
||||
subscriber={subscriber}
|
||||
/>
|
||||
))}
|
||||
</List>
|
||||
)}
|
||||
{model.loadMoreError ? (
|
||||
<ErrorState
|
||||
kind={model.loadMoreError}
|
||||
size="inline"
|
||||
title={t(`errors:fallback.${model.loadMoreError}.title`)}
|
||||
description={t('subscribers.more-failed')}
|
||||
onRetry={model.loadMore}
|
||||
retryLabel={t('errors:fallback.retry')}
|
||||
retryingLabel={t('errors:fallback.retrying')}
|
||||
retrying={model.isLoadingMore}
|
||||
/>
|
||||
) : (
|
||||
model.hasMore && (
|
||||
<Button
|
||||
variant="secondary"
|
||||
block
|
||||
onClick={model.loadMore}
|
||||
isLoading={model.isLoadingMore}
|
||||
>
|
||||
{t('subscribers.more')}
|
||||
</Button>
|
||||
)
|
||||
)}
|
||||
{model.filter === 'expiring' && (
|
||||
<Typography variant="caption" color="secondary">
|
||||
{t('subscribers.expiring-note')}
|
||||
</Typography>
|
||||
)}
|
||||
<Typography variant="caption" color="secondary">
|
||||
{t('subscribers.privacy')}
|
||||
</Typography>
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||
import { Skeleton } from '@lumina/island/atoms/skeleton';
|
||||
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||
|
||||
import type { SubscriberListSkeletonProps } from './types';
|
||||
|
||||
/** «مشترکان» before it arrives: the chips' row, then the rows. */
|
||||
export function SubscriberListSkeleton({
|
||||
label,
|
||||
delayed,
|
||||
}: SubscriberListSkeletonProps) {
|
||||
return (
|
||||
<FlexBox direction="flex-col" gap="gap-4">
|
||||
<FlexBox gap="gap-2" aria-hidden>
|
||||
<Skeleton shape="pill" width={88} height={36} />
|
||||
<Skeleton shape="pill" width={128} height={36} />
|
||||
</FlexBox>
|
||||
<SkeletonPreset preset="list" count={4} label={label} delayed={delayed} />
|
||||
</FlexBox>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
export { SubscriberList } from './SubscriberList';
|
||||
export { SubscriberListSkeleton } from './SubscriberListSkeleton';
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
export type SubscriberListSkeletonProps = {
|
||||
/** Hidden status text: «در حال بارگذاری مشترکان…». */
|
||||
label: string;
|
||||
/** Fades in after 300 ms, so a fast route never flashes it (`loading.tsx` only, G-3d). */
|
||||
delayed?: boolean;
|
||||
};
|
||||
|
|
@ -37,8 +37,9 @@ import { SaveStatus } from './SaveStatus';
|
|||
import { StepLayout } from './StepLayout';
|
||||
|
||||
/**
|
||||
* Step 5's form for a creator, top to bottom: photo, bio, markets, links and the consent;
|
||||
* «تکمیل ثبتنام» under it with the autosave line. Leaving a field saves at once. The preview opens in a sheet on mobile and stays beside the form on desktop.
|
||||
* Step 5's form for a creator, top to bottom: photo, bio, markets, links and, once there is a
|
||||
* link, the consent; «تکمیل ثبتنام» under it with the autosave line. Leaving a field saves at
|
||||
* once. The preview opens in a sheet on mobile and stays beside the form on desktop.
|
||||
*/
|
||||
export function ProfileForm({
|
||||
page,
|
||||
|
|
@ -209,32 +210,34 @@ export function ProfileForm({
|
|||
layout={layout}
|
||||
optional
|
||||
/>
|
||||
<Controller
|
||||
name="consent"
|
||||
control={form.control}
|
||||
render={({ field, fieldState }) => (
|
||||
<FlexBox direction="flex-col" gap="gap-1">
|
||||
<Checkbox
|
||||
ref={field.ref}
|
||||
name={field.name}
|
||||
checked={field.value}
|
||||
onChange={(event) => field.onChange(event.target.checked)}
|
||||
onBlur={field.onBlur}
|
||||
invalid={fieldState.error != null}
|
||||
aria-describedby={
|
||||
fieldState.error ? consentErrorId : undefined
|
||||
}
|
||||
>
|
||||
{t('register.profile.links.consent')}
|
||||
</Checkbox>
|
||||
{fieldState.error && (
|
||||
<FieldError id={consentErrorId}>
|
||||
{translateMessage(t, fieldState.error.message)}
|
||||
</FieldError>
|
||||
)}
|
||||
</FlexBox>
|
||||
)}
|
||||
/>
|
||||
{links.rows.length > 0 && (
|
||||
<Controller
|
||||
name="consent"
|
||||
control={form.control}
|
||||
render={({ field, fieldState }) => (
|
||||
<FlexBox direction="flex-col" gap="gap-1">
|
||||
<Checkbox
|
||||
ref={field.ref}
|
||||
name={field.name}
|
||||
checked={field.value}
|
||||
onChange={(event) => field.onChange(event.target.checked)}
|
||||
onBlur={field.onBlur}
|
||||
invalid={fieldState.error != null}
|
||||
aria-describedby={
|
||||
fieldState.error ? consentErrorId : undefined
|
||||
}
|
||||
>
|
||||
{t('register.profile.links.consent')}
|
||||
</Checkbox>
|
||||
{fieldState.error && (
|
||||
<FieldError id={consentErrorId}>
|
||||
{translateMessage(t, fieldState.error.message)}
|
||||
</FieldError>
|
||||
)}
|
||||
</FlexBox>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<FlexBox direction="flex-col" gap="gap-3">
|
||||
<Button
|
||||
type="submit"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ export const TAB_BARS: Record<string, PageBar> = {
|
|||
[ROUTES.dashboard.subscriptions]: { kind: 'tab', title: 'nav.dashboard' },
|
||||
[ROUTES.dashboard.transactions]: { kind: 'tab', title: 'nav.dashboard' },
|
||||
[ROUTES.dashboard.following]: { kind: 'tab', title: 'nav.dashboard' },
|
||||
[ROUTES.dashboard.overview]: { kind: 'tab', title: 'nav.dashboard' },
|
||||
[ROUTES.dashboard.plans]: { kind: 'tab', title: 'nav.dashboard' },
|
||||
[ROUTES.dashboard.finance]: { kind: 'tab', title: 'nav.dashboard' },
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ export const AUTH_EVENTS = {
|
|||
export const AUTH_PURPOSES = ['login', 'register'] as const;
|
||||
|
||||
/**
|
||||
* The code rules the pages show. The server owns them (5 digits, a code lives 2 minutes, the third wrong
|
||||
* The code rules the pages show. The server owns them (a code lives 10 minutes, the third wrong
|
||||
* code blocks the number for 10 minutes, at most 5 codes per number in an hour); the 2-minute
|
||||
* resend opens when the code runs out.
|
||||
* resend wait is the product's, longer than the server's 60-second cooldown.
|
||||
*/
|
||||
export const CODE_RULES = {
|
||||
length: 5,
|
||||
length: 6,
|
||||
resendWaitSeconds: 120,
|
||||
maxMisses: 3,
|
||||
blockSeconds: 600,
|
||||
|
|
|
|||
|
|
@ -29,13 +29,12 @@ const CREATOR_LINK = /^\/traders\/([^/?#]+)/;
|
|||
|
||||
// The app pages a notification may open; a channel and its posts (a closed prediction) and a
|
||||
// channel's checkout (a payment the bank never confirmed, capacity opened with the code) open too.
|
||||
// Any other link, such as another site, leaves the item plain rather than leading to not-found.
|
||||
// Any other link, such as a page not built yet (the creator's /dashboard/subscribers) or another
|
||||
// site, leaves the item plain rather than leading to not-found.
|
||||
const IN_APP_PATHS: ReadonlySet<string> = new Set([
|
||||
ROUTES.dashboard.subscriptions,
|
||||
ROUTES.dashboard.transactions,
|
||||
ROUTES.dashboard.overview,
|
||||
ROUTES.dashboard.plans,
|
||||
ROUTES.dashboard.subscribers,
|
||||
ROUTES.dashboard.finance,
|
||||
ROUTES.account.profile,
|
||||
ROUTES.notifications,
|
||||
|
|
|
|||
|
|
@ -1,21 +1,5 @@
|
|||
export {
|
||||
planBreakdownRows,
|
||||
useDashboardOverviewPart,
|
||||
} from './models/dashboard-overview';
|
||||
export type {
|
||||
DashboardOverviewPartModel,
|
||||
PlanBreakdownMetric,
|
||||
PlanBreakdownRow,
|
||||
} from './models/dashboard-overview';
|
||||
export {
|
||||
subscriberDaysLeft,
|
||||
useSubscribersPage,
|
||||
useSubscribersPreviewPart,
|
||||
} from './models/subscribers';
|
||||
export type {
|
||||
SubscribersPageModel,
|
||||
SubscribersPreviewPartModel,
|
||||
} from './models/subscribers';
|
||||
export { useAudiencePart } from './models/audience';
|
||||
export type { AudiencePartModel } from './models/audience';
|
||||
export { useOwnSubscriberCount } from './models/own-subscriber-count';
|
||||
export type { UseOwnSubscriberCountOptions } from './models/own-subscriber-count';
|
||||
export {
|
||||
|
|
@ -25,10 +9,5 @@ export {
|
|||
export type {
|
||||
CreatorDashboardPayload,
|
||||
CreatorTierPayload,
|
||||
DashboardOverviewPayload,
|
||||
DashboardOverviewPlan,
|
||||
OwnSubscriberPayload,
|
||||
OwnSubscribersFilter,
|
||||
OwnSubscribersPagePayload,
|
||||
RecentPaymentPayload,
|
||||
} from './repositories/creator-dashboard';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
export { useAudiencePart } from './use-audience-part';
|
||||
export type { AudiencePartModel } from './types';
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
/** طرحهای اشتراک › «مخاطبان» (J10-1): counts only, never a list of people. */
|
||||
export type AudiencePartModel = {
|
||||
/** «دنبالکنندگان»: public, the same figure the channel shows everyone. */
|
||||
followers: number;
|
||||
/** «مشترکان فعال»: subscriptions running now; only the creator sees it. */
|
||||
activeSubscribers: number;
|
||||
};
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
import { useSuspenseQueries } from '@tanstack/react-query';
|
||||
|
||||
import { useCurrentAccount } from '../../../../stores/auth';
|
||||
import { channelKeys, channelRepository } from '../../../channel';
|
||||
import {
|
||||
creatorDashboardRepository,
|
||||
overviewKeys,
|
||||
} from '../../repositories/creator-dashboard';
|
||||
import type { AudiencePartModel } from './types';
|
||||
|
||||
/**
|
||||
* طرحهای اشتراک › «مخاطبان» (J10-1): how many follow the creator (the channel's public count, so
|
||||
* a follow anywhere moves it) and how many subscriptions run now (from the creator's dashboard
|
||||
* figures). Counts only: the design shows no list of people. Read in the browser for the signed-in
|
||||
* creator; either read failing fails the part.
|
||||
*/
|
||||
export function useAudiencePart(): AudiencePartModel {
|
||||
const creatorId = useCurrentAccount()?.id ?? '';
|
||||
const [followers, dashboard] = useSuspenseQueries({
|
||||
queries: [
|
||||
{
|
||||
queryKey: channelKeys.followerCount(creatorId),
|
||||
queryFn: ({ signal }: { signal: AbortSignal }) =>
|
||||
channelRepository.getFollowerCount({ creatorId }, { signal }),
|
||||
},
|
||||
{
|
||||
queryKey: overviewKeys.dashboard(),
|
||||
queryFn: ({ signal }: { signal: AbortSignal }) =>
|
||||
creatorDashboardRepository.get({ signal }),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
return {
|
||||
followers: followers.data,
|
||||
activeSubscribers: dashboard.data.activeSubscribers,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
export { planBreakdownRows } from './plan-breakdown';
|
||||
export { useDashboardOverviewPart } from './use-dashboard-overview-part';
|
||||
export type {
|
||||
DashboardOverviewPartModel,
|
||||
PlanBreakdownMetric,
|
||||
PlanBreakdownRow,
|
||||
} from './types';
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { planBreakdownRows } from './plan-breakdown';
|
||||
|
||||
const plan = (
|
||||
tier: 'monthly' | 'quarterly',
|
||||
activeSubscribers: number,
|
||||
income = 0,
|
||||
) => ({ tier, activeSubscribers, totalPurchases: 0, income });
|
||||
|
||||
describe('planBreakdownRows', () => {
|
||||
it('gives each plan its share of the chosen figure', () => {
|
||||
const rows = planBreakdownRows(
|
||||
[plan('monthly', 3), plan('quarterly', 1)],
|
||||
'active',
|
||||
);
|
||||
expect(rows.map((row) => row.sharePercent)).toEqual([75, 25]);
|
||||
expect(rows[0].total).toBe(4);
|
||||
});
|
||||
|
||||
it('shows zero shares when nothing has happened yet', () => {
|
||||
const rows = planBreakdownRows([plan('monthly', 0)], 'purchases');
|
||||
expect(rows[0]).toMatchObject({ value: 0, total: 0, sharePercent: 0 });
|
||||
});
|
||||
|
||||
it('keeps a refunded plan out of the others’ shares', () => {
|
||||
const rows = planBreakdownRows(
|
||||
[plan('monthly', 0, 1000), plan('quarterly', 0, -500)],
|
||||
'income',
|
||||
);
|
||||
expect(rows[0].sharePercent).toBe(100);
|
||||
expect(rows[1]).toMatchObject({ value: -500, sharePercent: 0 });
|
||||
});
|
||||
});
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
import type { DashboardOverviewPlan } from '../../repositories/creator-dashboard';
|
||||
import type { PlanBreakdownMetric, PlanBreakdownRow } from './types';
|
||||
|
||||
const VALUE_OF: Record<
|
||||
PlanBreakdownMetric,
|
||||
(plan: DashboardOverviewPlan) => number
|
||||
> = {
|
||||
active: (plan) => plan.activeSubscribers,
|
||||
purchases: (plan) => plan.totalPurchases,
|
||||
income: (plan) => plan.income,
|
||||
};
|
||||
|
||||
/**
|
||||
* Each plan's part of the chosen figure, as «تفکیک طرحها» draws it. A refund can leave a plan's
|
||||
* income below zero: that plan's bar is empty and it takes no share from the others.
|
||||
*/
|
||||
export function planBreakdownRows(
|
||||
plans: DashboardOverviewPlan[],
|
||||
metric: PlanBreakdownMetric,
|
||||
): PlanBreakdownRow[] {
|
||||
const valueOf = VALUE_OF[metric];
|
||||
const total = plans.reduce(
|
||||
(sum, plan) => sum + Math.max(valueOf(plan), 0),
|
||||
0,
|
||||
);
|
||||
return plans.map((plan) => {
|
||||
const value = valueOf(plan);
|
||||
return {
|
||||
tier: plan.tier,
|
||||
value,
|
||||
total,
|
||||
sharePercent: total > 0 ? (Math.max(value, 0) / total) * 100 : 0,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
import type { BillingPeriod } from '../../../../shared/constants';
|
||||
import type { DashboardOverviewPayload } from '../../repositories/creator-dashboard';
|
||||
|
||||
/** «نمای کلی» (J10-0): the API's figures, read once for the whole tab. */
|
||||
export type DashboardOverviewPartModel = DashboardOverviewPayload & {
|
||||
/** Plans with someone on them now, for «در {n} طرح». */
|
||||
plansWithSubscribers: number;
|
||||
/** No audience and no income yet: the page says how to start (J10-0b). */
|
||||
isNewcomer: boolean;
|
||||
};
|
||||
|
||||
/** What «تفکیک طرحها» splits by: «مشترکان فعال» · «کل خریدها» · «درآمد». */
|
||||
export type PlanBreakdownMetric = 'active' | 'purchases' | 'income';
|
||||
|
||||
export type PlanBreakdownRow = {
|
||||
tier: BillingPeriod;
|
||||
value: number;
|
||||
/** Every plan's figure together, a refunded plan's negative income left out. */
|
||||
total: number;
|
||||
/** 0 to 100. */
|
||||
sharePercent: number;
|
||||
};
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
import { useSuspenseQuery } from '@tanstack/react-query';
|
||||
|
||||
import { BILLING_PERIODS } from '../../../../shared/constants';
|
||||
import {
|
||||
creatorDashboardRepository,
|
||||
overviewKeys,
|
||||
} from '../../repositories/creator-dashboard';
|
||||
import type { DashboardOverviewPartModel } from './types';
|
||||
|
||||
/**
|
||||
* داشبورد › نمای کلی (J10-0): audience, income and the split by plan, in the browser only. A creator
|
||||
* with no plan yet still sees the four periods at zero (J10-0b).
|
||||
*/
|
||||
export function useDashboardOverviewPart(): DashboardOverviewPartModel {
|
||||
const { data } = useSuspenseQuery({
|
||||
queryKey: overviewKeys.overview(),
|
||||
queryFn: ({ signal }) => creatorDashboardRepository.getOverview({ signal }),
|
||||
});
|
||||
return {
|
||||
...data,
|
||||
plans:
|
||||
data.plans.length > 0
|
||||
? data.plans
|
||||
: BILLING_PERIODS.map((tier) => ({
|
||||
tier,
|
||||
activeSubscribers: 0,
|
||||
totalPurchases: 0,
|
||||
income: 0,
|
||||
})),
|
||||
plansWithSubscribers: data.plans.filter(
|
||||
(plan) => plan.activeSubscribers > 0,
|
||||
).length,
|
||||
isNewcomer:
|
||||
data.followers === 0 &&
|
||||
data.activeSubscribers === 0 &&
|
||||
data.income.total === 0,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
/** The filter's place in the URL, so back and a reload keep it, and نمای کلی can link to it. */
|
||||
export const SUBSCRIBERS_FILTER_PARAM = 'filter';
|
||||
|
||||
/** Rows طرحهای اشتراک shows before «مشاهده همه» (J10-1). */
|
||||
export const SUBSCRIBERS_PREVIEW_COUNT = 3;
|
||||
|
||||
/** From here a row says how long it has left, as «در حال انقضا» counts them. */
|
||||
export const SUBSCRIBER_EXPIRING_DAYS = 7;
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
export { subscriberDaysLeft } from './subscriber-days';
|
||||
export { useSubscribersPage } from './use-subscribers-page';
|
||||
export { useSubscribersPreviewPart } from './use-subscribers-preview-part';
|
||||
export type {
|
||||
SubscribersPageModel,
|
||||
SubscribersPreviewPartModel,
|
||||
} from './types';
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { subscriberDaysLeft } from './subscriber-days';
|
||||
|
||||
const now = Date.parse('2026-11-05T12:00:00Z');
|
||||
const inDays = (days: number) => new Date(now + days * 86400000).toISOString();
|
||||
|
||||
describe('subscriberDaysLeft', () => {
|
||||
it('counts a started day', () => {
|
||||
expect(subscriberDaysLeft(inDays(3.5), now)).toBe(4);
|
||||
});
|
||||
|
||||
it('stays quiet beyond a week', () => {
|
||||
expect(subscriberDaysLeft(inDays(7), now)).toBe(7);
|
||||
expect(subscriberDaysLeft(inDays(7.5), now)).toBeNull();
|
||||
});
|
||||
|
||||
it('never says less than a day', () => {
|
||||
expect(subscriberDaysLeft(inDays(0.1), now)).toBe(1);
|
||||
});
|
||||
});
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
import { SUBSCRIBER_EXPIRING_DAYS } from './constants';
|
||||
|
||||
const DAY_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
/** Whole days left, a started day counted, for a subscription ending soon; `null` otherwise. */
|
||||
export function subscriberDaysLeft(
|
||||
endsAt: string,
|
||||
now = Date.now(),
|
||||
): number | null {
|
||||
const days = Math.ceil((new Date(endsAt).getTime() - now) / DAY_MS);
|
||||
return days > SUBSCRIBER_EXPIRING_DAYS ? null : Math.max(days, 1);
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
import type { LoadMoreErrorKind } from '../../../../shared/utils';
|
||||
import type {
|
||||
OwnSubscriberPayload,
|
||||
OwnSubscribersFilter,
|
||||
} from '../../repositories/creator-dashboard';
|
||||
|
||||
export type SubscribersPageModel = {
|
||||
filter: OwnSubscribersFilter;
|
||||
setFilter: (filter: OwnSubscribersFilter) => void;
|
||||
isFiltering: boolean;
|
||||
counts: Record<OwnSubscribersFilter, number>;
|
||||
items: OwnSubscriberPayload[];
|
||||
hasMore: boolean;
|
||||
loadMore: () => void;
|
||||
isLoadingMore: boolean;
|
||||
/** The next page failed: which message says so in place of «more». */
|
||||
loadMoreError: LoadMoreErrorKind | null;
|
||||
};
|
||||
|
||||
export type SubscribersPreviewPartModel = {
|
||||
/** Who subscribes now, in all. */
|
||||
total: number;
|
||||
/** The soonest-ending few. */
|
||||
items: OwnSubscriberPayload[];
|
||||
};
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
import { useSuspenseInfiniteQuery } from '@tanstack/react-query';
|
||||
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
||||
import { useTransition } from 'react';
|
||||
|
||||
import { firstOfEach, loadMoreErrorKind } from '../../../../shared/utils';
|
||||
import {
|
||||
creatorDashboardRepository,
|
||||
overviewKeys,
|
||||
} from '../../repositories/creator-dashboard';
|
||||
import { SUBSCRIBERS_FILTER_PARAM } from './constants';
|
||||
import type { SubscribersPageModel } from './types';
|
||||
|
||||
/**
|
||||
* «مشترکان» (J10-1f, J10-1g): «همه» · «در حال انقضا» with the API's totals, the chip in the URL so
|
||||
* back and a reload keep it, soonest-ending first, 20 a page by cursor.
|
||||
*/
|
||||
export function useSubscribersPage(): SubscribersPageModel {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
const [isFiltering, startFiltering] = useTransition();
|
||||
const filter =
|
||||
searchParams.get(SUBSCRIBERS_FILTER_PARAM) === 'expiring'
|
||||
? 'expiring'
|
||||
: 'all';
|
||||
|
||||
const list = useSuspenseInfiniteQuery({
|
||||
queryKey: overviewKeys.subscribers(filter),
|
||||
queryFn: ({ pageParam, signal }) =>
|
||||
creatorDashboardRepository.listSubscribers(
|
||||
{ filter, cursor: pageParam },
|
||||
{ signal },
|
||||
),
|
||||
initialPageParam: undefined as string | undefined,
|
||||
getNextPageParam: (last) => last.nextCursor ?? undefined,
|
||||
});
|
||||
|
||||
return {
|
||||
filter,
|
||||
setFilter: (next) => {
|
||||
if (next === filter) return;
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
if (next === 'all') params.delete(SUBSCRIBERS_FILTER_PARAM);
|
||||
else params.set(SUBSCRIBERS_FILTER_PARAM, next);
|
||||
const query = params.toString();
|
||||
// In place: the page keeps its scroll, and the chip replaces the entry.
|
||||
startFiltering(() => {
|
||||
router.replace(query ? `${pathname}?${query}` : pathname, {
|
||||
scroll: false,
|
||||
});
|
||||
});
|
||||
},
|
||||
isFiltering,
|
||||
counts: list.data.pages[0].counts,
|
||||
items: firstOfEach(
|
||||
list.data.pages.flatMap((page) => page.items),
|
||||
(item) => `${item.username}:${item.endsAt}`,
|
||||
),
|
||||
hasMore: list.hasNextPage,
|
||||
loadMore: () => {
|
||||
// fetchNextPage would cancel a read of every page on its way and skip or repeat rows.
|
||||
if (!list.isFetching) void list.fetchNextPage();
|
||||
},
|
||||
isLoadingMore: list.isFetchingNextPage,
|
||||
loadMoreError: list.isFetchNextPageError
|
||||
? loadMoreErrorKind(list.error)
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
import { useSuspenseQuery } from '@tanstack/react-query';
|
||||
|
||||
import {
|
||||
creatorDashboardRepository,
|
||||
overviewKeys,
|
||||
} from '../../repositories/creator-dashboard';
|
||||
import { SUBSCRIBERS_PREVIEW_COUNT } from './constants';
|
||||
import type { SubscribersPreviewPartModel } from './types';
|
||||
|
||||
/** طرحهای اشتراک › «مشترکان» (J10-1): how many, and the few who end soonest. */
|
||||
export function useSubscribersPreviewPart(): SubscribersPreviewPartModel {
|
||||
const { data } = useSuspenseQuery({
|
||||
queryKey: [...overviewKeys.subscribers('all'), 'preview'],
|
||||
queryFn: ({ signal }) =>
|
||||
creatorDashboardRepository.listSubscribers({ filter: 'all' }, { signal }),
|
||||
});
|
||||
return {
|
||||
total: data.counts.all,
|
||||
items: data.items.slice(0, SUBSCRIBERS_PREVIEW_COUNT),
|
||||
};
|
||||
}
|
||||
|
|
@ -1,13 +1,6 @@
|
|||
import type { OwnSubscribersFilter } from './types';
|
||||
|
||||
export const CREATOR_DASHBOARD_ENDPOINT = '/subscriptions/me/dashboard';
|
||||
export const DASHBOARD_OVERVIEW_ENDPOINT = '/me/dashboard/overview';
|
||||
export const OWN_SUBSCRIBERS_ENDPOINT = '/me/subscribers';
|
||||
|
||||
export const overviewKeys = {
|
||||
all: ['overview'] as const,
|
||||
dashboard: () => [...overviewKeys.all, 'dashboard'] as const,
|
||||
overview: () => [...overviewKeys.all, 'overview'] as const,
|
||||
subscribers: (filter: OwnSubscribersFilter) =>
|
||||
[...overviewKeys.all, 'subscribers', filter] as const,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,20 +1,9 @@
|
|||
import { overviewHttp } from '../../http';
|
||||
import {
|
||||
CREATOR_DASHBOARD_ENDPOINT,
|
||||
DASHBOARD_OVERVIEW_ENDPOINT,
|
||||
OWN_SUBSCRIBERS_ENDPOINT,
|
||||
} from './constants';
|
||||
import {
|
||||
toCreatorDashboardPayload,
|
||||
toOwnSubscribersPagePayload,
|
||||
} from './mappers';
|
||||
import { CREATOR_DASHBOARD_ENDPOINT } from './constants';
|
||||
import { toCreatorDashboardPayload } from './mappers';
|
||||
import type {
|
||||
CreatorDashboardPayload,
|
||||
CreatorDashboardResponseDto,
|
||||
DashboardOverviewPayload,
|
||||
OwnSubscribersFilter,
|
||||
OwnSubscribersPagePayload,
|
||||
OwnSubscribersPageResponseDto,
|
||||
} from './types';
|
||||
|
||||
/** The signed-in creator's subscription figures. Creator session only: an investor gets 403. */
|
||||
|
|
@ -28,26 +17,4 @@ export const creatorDashboardRepository = {
|
|||
);
|
||||
return toCreatorDashboardPayload(response);
|
||||
},
|
||||
|
||||
/** «نمای کلی»: audience, income and the split by plan. */
|
||||
getOverview({
|
||||
signal,
|
||||
}: { signal?: AbortSignal } = {}): Promise<DashboardOverviewPayload> {
|
||||
return overviewHttp.get<DashboardOverviewPayload>(
|
||||
DASHBOARD_OVERVIEW_ENDPOINT,
|
||||
{ signal },
|
||||
);
|
||||
},
|
||||
|
||||
/** A page of who subscribes now, soonest-ending first. */
|
||||
async listSubscribers(
|
||||
{ filter, cursor }: { filter: OwnSubscribersFilter; cursor?: string },
|
||||
{ signal }: { signal?: AbortSignal } = {},
|
||||
): Promise<OwnSubscribersPagePayload> {
|
||||
const response = await overviewHttp.get<OwnSubscribersPageResponseDto>(
|
||||
OWN_SUBSCRIBERS_ENDPOINT,
|
||||
{ params: { filter, cursor }, signal },
|
||||
);
|
||||
return toOwnSubscribersPagePayload(response);
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,10 +3,5 @@ export { creatorDashboardRepository } from './creator-dashboard';
|
|||
export type {
|
||||
CreatorDashboardPayload,
|
||||
CreatorTierPayload,
|
||||
DashboardOverviewPayload,
|
||||
DashboardOverviewPlan,
|
||||
OwnSubscriberPayload,
|
||||
OwnSubscribersFilter,
|
||||
OwnSubscribersPagePayload,
|
||||
RecentPaymentPayload,
|
||||
} from './types';
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
import { toApiUrl } from '../../../../shared/utils';
|
||||
import type {
|
||||
CreatorDashboardPayload,
|
||||
CreatorDashboardResponseDto,
|
||||
OwnSubscribersPagePayload,
|
||||
OwnSubscribersPageResponseDto,
|
||||
} from './types';
|
||||
|
||||
export function toCreatorDashboardPayload(
|
||||
|
|
@ -29,15 +26,3 @@ export function toCreatorDashboardPayload(
|
|||
})),
|
||||
};
|
||||
}
|
||||
|
||||
export function toOwnSubscribersPagePayload(
|
||||
dto: OwnSubscribersPageResponseDto,
|
||||
): OwnSubscribersPagePayload {
|
||||
return {
|
||||
...dto,
|
||||
items: dto.items.map((item) => ({
|
||||
...item,
|
||||
avatarUrl: toApiUrl(item.avatarUrl),
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,49 +46,3 @@ export type CreatorDashboardResponseDto = {
|
|||
tiers: CreatorTierEntity[];
|
||||
recentTransactions: PaymentEntity[];
|
||||
};
|
||||
|
||||
/** One plan in «تفکیک طرحها». */
|
||||
export type DashboardOverviewPlan = {
|
||||
tier: BillingPeriod;
|
||||
/** Running now on this plan. */
|
||||
activeSubscribers: number;
|
||||
/** Every purchase since the start, renewals included, minus refunded ones. */
|
||||
totalPurchases: number;
|
||||
/** Whole Toman, net of commission and refunds. */
|
||||
income: number;
|
||||
};
|
||||
|
||||
/** `GET /me/dashboard/overview`, «نمای کلی» (J10-0). Income is whole Toman, net. */
|
||||
export type DashboardOverviewPayload = {
|
||||
/** Subscribers included; only the creator sees it. */
|
||||
followers: number;
|
||||
activeSubscribers: number;
|
||||
/** Ending within the next 7 days. */
|
||||
expiringIn7d: number;
|
||||
income: {
|
||||
total: number;
|
||||
/** The current Shamsi month, in Tehran. */
|
||||
thisMonth: number;
|
||||
payable: number;
|
||||
};
|
||||
plans: DashboardOverviewPlan[];
|
||||
};
|
||||
|
||||
export type OwnSubscribersFilter = 'all' | 'expiring';
|
||||
|
||||
/** One running subscription. Only the @username and avatar ever leave the API, never a phone. */
|
||||
export type OwnSubscriberPayload = {
|
||||
username: string | null;
|
||||
avatarUrl: string | null;
|
||||
tier: BillingPeriod | null;
|
||||
endsAt: string;
|
||||
};
|
||||
|
||||
/** `GET /me/subscribers`: soonest-ending first, 20 a page. */
|
||||
export type OwnSubscribersPagePayload = {
|
||||
items: OwnSubscriberPayload[];
|
||||
counts: Record<OwnSubscribersFilter, number>;
|
||||
nextCursor: string | null;
|
||||
};
|
||||
|
||||
export type OwnSubscribersPageResponseDto = OwnSubscribersPagePayload;
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { toCreatePostDto } from './mappers';
|
||||
|
||||
const prediction = {
|
||||
symbol: 'btc-usdt',
|
||||
market: 'crypto',
|
||||
direction: 'long' as const,
|
||||
targetPrices: [75000],
|
||||
stopLoss: 65000,
|
||||
horizon: '1w',
|
||||
};
|
||||
|
||||
describe('toCreatePostDto', () => {
|
||||
it('sends a range with its entry form, or the API reads an exact entry', () => {
|
||||
const dto = toCreatePostDto({
|
||||
type: 'prediction',
|
||||
prediction: {
|
||||
...prediction,
|
||||
entryType: 'range',
|
||||
entryLow: 69000,
|
||||
entryHigh: 70000,
|
||||
},
|
||||
});
|
||||
expect(dto.prediction).toMatchObject({
|
||||
entryType: 'range',
|
||||
entryLow: 69000,
|
||||
entryHigh: 70000,
|
||||
});
|
||||
});
|
||||
|
||||
it('sends an exact entry with its entry form', () => {
|
||||
const dto = toCreatePostDto({
|
||||
type: 'prediction',
|
||||
prediction: { ...prediction, entryType: 'exact', entryPrice: 69500 },
|
||||
});
|
||||
expect(dto.prediction).toMatchObject({
|
||||
entryType: 'exact',
|
||||
entryPrice: 69500,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -113,7 +113,6 @@ function toPredictionDto(args: PredictionArgs): PredictionDto {
|
|||
market: args.market.trim(),
|
||||
direction: args.direction,
|
||||
entryPrice: args.entryPrice ?? undefined,
|
||||
entryType: args.entryType,
|
||||
entryLow: args.entryLow ?? undefined,
|
||||
entryHigh: args.entryHigh ?? undefined,
|
||||
targetPrices: args.targetPrices,
|
||||
|
|
|
|||
|
|
@ -154,8 +154,6 @@ export type PredictionArgs = {
|
|||
symbol: string;
|
||||
market: string;
|
||||
direction: PredictionDirection;
|
||||
/** Which entry form the API reads; it takes `exact` when this is left out. */
|
||||
entryType?: 'exact' | 'range';
|
||||
/** Exactly one form to publish: this, or `entryLow` with `entryHigh`. */
|
||||
entryPrice?: number;
|
||||
entryLow?: number;
|
||||
|
|
@ -205,7 +203,6 @@ export type PredictionDto = {
|
|||
symbol: string;
|
||||
market: string;
|
||||
direction: PredictionDirection;
|
||||
entryType?: 'exact' | 'range';
|
||||
entryPrice?: number;
|
||||
entryLow?: number;
|
||||
entryHigh?: number;
|
||||
|
|
|
|||
|
|
@ -3,15 +3,8 @@ import type { PostEntity } from '../../../post';
|
|||
/** Which of the creator's published predictions a list holds. */
|
||||
export type OwnPredictionsStatus = 'open' | 'closed' | 'all';
|
||||
|
||||
/**
|
||||
* Totals whatever the filter or page: the client never counts. `open` and `closed` are null until
|
||||
* results reach the creator, when both filters answer the same list.
|
||||
*/
|
||||
export type OwnPredictionCountsEntity = {
|
||||
all: number;
|
||||
open: number | null;
|
||||
closed: number | null;
|
||||
};
|
||||
/** Totals whatever the filter or page: the client never counts. */
|
||||
export type OwnPredictionCountsEntity = Record<OwnPredictionsStatus, number>;
|
||||
|
||||
/**
|
||||
* `GET /posts/me/predictions`: one page of the creator's own published predictions, as owner
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { renderHook, waitFor } from '@testing-library/react';
|
||||
import type { ReactNode } from 'react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { ownSectionQueryOptions } from './queries';
|
||||
import type { OwnPredictionSection } from './types';
|
||||
import { useOwnPredictionCount } from './use-own-prediction-count';
|
||||
|
||||
vi.mock('./queries', () => ({ ownSectionQueryOptions: vi.fn() }));
|
||||
|
||||
function countOf(
|
||||
section: OwnPredictionSection,
|
||||
counts: { all: number; open: number | null; closed: number | null },
|
||||
) {
|
||||
vi.mocked(ownSectionQueryOptions).mockReturnValue({
|
||||
queryKey: ['own', section],
|
||||
queryFn: async () => ({ items: [], counts }),
|
||||
} as never);
|
||||
const client = new QueryClient();
|
||||
return renderHook(() => useOwnPredictionCount(section), {
|
||||
wrapper: ({ children }: { children: ReactNode }) => (
|
||||
<QueryClientProvider client={client}>{children}</QueryClientProvider>
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
describe('useOwnPredictionCount', () => {
|
||||
it('holds every signal under «باز» before results are released', async () => {
|
||||
const counts = { all: 2, open: null, closed: null };
|
||||
const open = countOf('open', counts);
|
||||
await waitFor(() => expect(open.result.current).toBe(2));
|
||||
const closed = countOf('closed', counts);
|
||||
await waitFor(() => expect(closed.result.current).toBe(0));
|
||||
});
|
||||
|
||||
it('answers each section its own total once released', async () => {
|
||||
const counts = { all: 5, open: 3, closed: 2 };
|
||||
const closed = countOf('closed', counts);
|
||||
await waitFor(() => expect(closed.result.current).toBe(2));
|
||||
});
|
||||
});
|
||||
|
|
@ -6,8 +6,6 @@ import type { OwnPredictionSection } from './types';
|
|||
/**
|
||||
* A section's total for its title, «سیگنالهای باز (۳)», from the API's counts; `undefined`
|
||||
* while loading or failed, so the title stands without it over the section's error (J10-3e).
|
||||
* Before results are released the API answers no per-status totals and the same list for both
|
||||
* sections, since whether a signal closed is itself a result: it all sits under «باز».
|
||||
*/
|
||||
export function useOwnPredictionCount(
|
||||
section: OwnPredictionSection,
|
||||
|
|
@ -16,6 +14,5 @@ export function useOwnPredictionCount(
|
|||
...ownSectionQueryOptions(section),
|
||||
throwOnError: false,
|
||||
});
|
||||
if (!data) return undefined;
|
||||
return data.counts[section] ?? (section === 'open' ? data.counts.all : 0);
|
||||
return data?.counts[section];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,7 +205,6 @@ describe('usePredictionComposerPage publishing', () => {
|
|||
await act(async () => result.current.publish());
|
||||
const [args] = vi.mocked(publishPrediction).mock.calls[0];
|
||||
expect(args.prediction).toMatchObject({
|
||||
entryType: 'exact',
|
||||
entryPrice: 100,
|
||||
stopLoss: 90,
|
||||
targetPrices: [120],
|
||||
|
|
@ -232,11 +231,7 @@ describe('usePredictionComposerPage publishing', () => {
|
|||
|
||||
await act(async () => result.current.publish());
|
||||
const [args] = vi.mocked(publishPrediction).mock.calls[0];
|
||||
expect(args.prediction).toMatchObject({
|
||||
entryType: 'range',
|
||||
entryLow: 98,
|
||||
entryHigh: 102,
|
||||
});
|
||||
expect(args.prediction).toMatchObject({ entryLow: 98, entryHigh: 102 });
|
||||
expect(args.prediction.entryPrice).toBeUndefined();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -431,7 +431,6 @@ export function usePredictionComposerPage({
|
|||
symbol: sent.symbol,
|
||||
market: sent.market,
|
||||
direction: sent.direction,
|
||||
entryType: sent.entryMode,
|
||||
...(sent.entryMode === 'range'
|
||||
? {
|
||||
entryLow: sent.entryLow ?? undefined,
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { profileRepository } from '../../repositories/profile';
|
||||
import { completeCreatorProfile } from './actions';
|
||||
|
||||
vi.mock('../../repositories/profile', () => ({
|
||||
profileRepository: { saveDraft: vi.fn(), complete: vi.fn() },
|
||||
}));
|
||||
vi.mock('../../../../stores/auth', () => ({
|
||||
useAuthStore: { getState: () => ({ profileCompleted: vi.fn() }) },
|
||||
}));
|
||||
|
||||
describe('completeCreatorProfile', () => {
|
||||
beforeEach(() => vi.clearAllMocks());
|
||||
|
||||
it('saves the form, then completes with the consent the API asks for', async () => {
|
||||
vi.mocked(profileRepository.complete).mockResolvedValue({
|
||||
creatorId: 'c1',
|
||||
} as never);
|
||||
await completeCreatorProfile({} as never, { emit: false });
|
||||
expect(profileRepository.saveDraft).toHaveBeenCalledOnce();
|
||||
expect(profileRepository.complete).toHaveBeenCalledWith({
|
||||
termsAccepted: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -10,7 +10,7 @@ import type {
|
|||
|
||||
/**
|
||||
* Ends registration step 5 for a creator: saves the form as it stands, then completes the
|
||||
* profile, which needs at least one market and the consent the form has checked. Nothing is public before this; after it the creator
|
||||
* profile, which needs at least one market. Nothing is public before this; after it the creator
|
||||
* may use the rest of the app (the session stops sending them back to step 5). Emits
|
||||
* `profile.complete`.
|
||||
*/
|
||||
|
|
@ -19,7 +19,7 @@ export async function completeCreatorProfile(
|
|||
{ emit = true }: { emit?: boolean } = {},
|
||||
): Promise<CreatorProfilePayload> {
|
||||
await profileRepository.saveDraft(args);
|
||||
const profile = await profileRepository.complete({ termsAccepted: true });
|
||||
const profile = await profileRepository.complete();
|
||||
useAuthStore.getState().profileCompleted();
|
||||
if (emit) {
|
||||
eventEmitter.emit(PROFILE_EVENTS.complete, {
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ import { useSessionFollowsProfile } from './use-session-follows-profile';
|
|||
/**
|
||||
* Registration step 5 for a creator, on the normal session: the public profile (photo, bio,
|
||||
* markets, links) that investors see before subscribing. It starts from the saved draft, saves as
|
||||
* it is typed, and «تکمیل ثبتنام» completes it (at least one market and the consent), then the
|
||||
* end of registration opens. A creator who already finished goes on instead of
|
||||
* it is typed, and «تکمیل ثبتنام» completes it (at least one market; the consent once there is a
|
||||
* link), then the end of registration opens. A creator who already finished goes on instead of
|
||||
* seeing the form again. A failed first read throws to the page boundary.
|
||||
*/
|
||||
export function useCreatorProfilePage({
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import {
|
|||
toUpdateProfileDto,
|
||||
} from './mappers';
|
||||
import type {
|
||||
CompleteProfileArgs,
|
||||
CreatorProfilePayload,
|
||||
CreatorProfileResponseDto,
|
||||
SaveProfileDraftArgs,
|
||||
|
|
@ -62,14 +61,10 @@ export const profileRepository = {
|
|||
return toCreatorProfilePayload(response);
|
||||
},
|
||||
|
||||
/**
|
||||
* Ends registration step 5. A 400 when no market is saved yet, or at the first completion
|
||||
* without the consent (`PROFILE_TERMS_REQUIRED`).
|
||||
*/
|
||||
async complete(args: CompleteProfileArgs): Promise<CreatorProfilePayload> {
|
||||
/** Ends registration step 5. A 400 when no market is saved yet. */
|
||||
async complete(): Promise<CreatorProfilePayload> {
|
||||
const response = await profileHttp.post<CreatorProfileResponseDto>(
|
||||
PROFILE_ENDPOINTS.complete,
|
||||
args,
|
||||
);
|
||||
return toCreatorProfilePayload(response);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -85,9 +85,6 @@ export type UploadAvatarArgs = { avatar: File };
|
|||
* Registration step 5's autosave. Only the fields sent change; `markets` may be empty and nothing
|
||||
* counts as complete until `complete` runs.
|
||||
*/
|
||||
/** `POST /traders/me/profile/complete`: the consent the form asks for at step 5. */
|
||||
export type CompleteProfileArgs = { termsAccepted: boolean };
|
||||
|
||||
export type SaveProfileDraftArgs = {
|
||||
bio?: string;
|
||||
markets?: Market[];
|
||||
|
|
|
|||
|
|
@ -343,9 +343,11 @@ export type {
|
|||
export {
|
||||
creatorDashboardRepository,
|
||||
overviewKeys,
|
||||
useAudiencePart,
|
||||
useOwnSubscriberCount,
|
||||
} from './features/overview';
|
||||
export type {
|
||||
AudiencePartModel,
|
||||
CreatorDashboardPayload,
|
||||
CreatorTierPayload,
|
||||
RecentPaymentPayload,
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@
|
|||
},
|
||||
"code": {
|
||||
"title": "کد تأیید را وارد کنید",
|
||||
"description": "کد 5 رقمی ارسالشده به {{phone}} را وارد کنید.",
|
||||
"label": "کد تأیید 5 رقمی",
|
||||
"description": "کد 6 رقمی ارسالشده به {{phone}} را وارد کنید.",
|
||||
"label": "کد تأیید 6 رقمی",
|
||||
"edit-phone": "ویرایش شماره",
|
||||
"wrong": "کد واردشده اشتباه است. لطفاً دوباره تلاش کنید.",
|
||||
"wrong-last": "کد واردشده اشتباه است. یک تلاش دیگر باقی مانده است.",
|
||||
|
|
@ -297,7 +297,7 @@
|
|||
},
|
||||
"validation": {
|
||||
"phone-invalid": "شماره موبایل واردشده معتبر نیست.",
|
||||
"code-length": "کد 5 رقمی را کامل وارد کنید.",
|
||||
"code-length": "کد 6 رقمی را کامل وارد کنید.",
|
||||
"role-required": "نوع حساب را انتخاب کنید.",
|
||||
"required": "این فیلد الزامی است.",
|
||||
"first-name-persian": "لطفاً نام را به فارسی وارد کنید.",
|
||||
|
|
|
|||
|
|
@ -135,7 +135,6 @@
|
|||
"subscription-value": "{{period}} — {{name}}"
|
||||
},
|
||||
"creator-tabs": {
|
||||
"overview": "نمای کلی",
|
||||
"plans": "طرحهای اشتراک",
|
||||
"predictions": "سیگنالها",
|
||||
"finance": "مالی"
|
||||
|
|
@ -146,6 +145,14 @@
|
|||
"finance": {
|
||||
"meta-title": "مالی"
|
||||
},
|
||||
"audience": {
|
||||
"title": "مخاطبان",
|
||||
"followers": "دنبالکنندگان",
|
||||
"subscribers": "مشترکان فعال",
|
||||
"note": "تعداد دنبالکنندگان برای همه دیده میشود؛ تعداد مشترکان فقط برای شما.",
|
||||
"loading": "در حال بارگذاری مخاطبان…",
|
||||
"error": "آمار مخاطبان بارگذاری نشد. دوباره تلاش کنید."
|
||||
},
|
||||
"invite": {
|
||||
"title": "کد دعوت",
|
||||
"loading": "در حال بارگذاری کد دعوت…",
|
||||
|
|
@ -209,81 +216,5 @@
|
|||
"sent": "درخواست شما ثبت شد.",
|
||||
"failed": "درخواست افزایش ظرفیت ثبت نشد"
|
||||
}
|
||||
},
|
||||
"overview": {
|
||||
"meta-title": "نمای کلی",
|
||||
"loading": "در حال بارگذاری نمای کلی…",
|
||||
"error": "نمای کلی بارگذاری نشد. دوباره تلاش کنید.",
|
||||
"audience": {
|
||||
"title": "مخاطبان",
|
||||
"followers": "دنبالکنندگان",
|
||||
"followers-tip": "شامل مشترکان هم میشود.",
|
||||
"followers-tip-label": "توضیح دنبالکنندگان",
|
||||
"subscribers": "مشترکان فعال",
|
||||
"subscribers-plans": "در {{n}} طرح",
|
||||
"subscribers-none": "هنوز مشترکی ندارید",
|
||||
"expiring": "در حال انقضا",
|
||||
"expiring-hint": "7 روز آینده",
|
||||
"expiring-link": "مشاهده مشترکان"
|
||||
},
|
||||
"income": {
|
||||
"title": "درآمد",
|
||||
"total": "درآمد کل",
|
||||
"total-tip": "از ابتدا، خالص بعد از کمیسیون لومینا و بازگشت وجهها.",
|
||||
"total-tip-label": "توضیح درآمد کل",
|
||||
"month": "درآمد این ماه",
|
||||
"payable": "قابل واریز",
|
||||
"payable-link": "رفتن به مالی"
|
||||
},
|
||||
"plans": {
|
||||
"title": "تفکیک طرحها",
|
||||
"metric": "معیار تفکیک",
|
||||
"metrics": {
|
||||
"active": "مشترکان فعال",
|
||||
"purchases": "کل خریدها",
|
||||
"income": "درآمد"
|
||||
},
|
||||
"caption": {
|
||||
"active": "{{n}} نفر · {{share}}",
|
||||
"purchases": "{{n}} خرید · {{share}}",
|
||||
"income": "{{n}} {{currency}} · {{share}}"
|
||||
},
|
||||
"note": "«کل خریدها» همه خریدها از ابتدا است، با تمدید و فعالسازی مجدد و منهای بازگشت وجهها."
|
||||
},
|
||||
"signals": {
|
||||
"title": "عملکرد سیگنالها",
|
||||
"details": "جزئیات در تب سیگنالها",
|
||||
"error": "عملکرد سیگنالها بارگذاری نشد.",
|
||||
"loading": "در حال بارگذاری عملکرد سیگنالها…"
|
||||
},
|
||||
"welcome": {
|
||||
"title": "کانال خود را معرفی کنید",
|
||||
"text": "لینک کانال را در تلگرام، اینستاگرام یا هر جای دیگری که مخاطب دارید بگذارید. هر دنبالکننده و مشترک تازه اینجا شمرده میشود.",
|
||||
"action": "اشتراکگذاری لینک کانال"
|
||||
}
|
||||
},
|
||||
"subscribers": {
|
||||
"meta-title": "مشترکان",
|
||||
"title": "مشترکان",
|
||||
"view-all": "مشاهده همه",
|
||||
"loading": "در حال بارگذاری مشترکان…",
|
||||
"error": "مشترکان بارگذاری نشدند. دوباره تلاش کنید.",
|
||||
"filter": "فیلتر مشترکان",
|
||||
"filters": {
|
||||
"all": "همه ({{n}})",
|
||||
"expiring": "در حال انقضا ({{n}})"
|
||||
},
|
||||
"until-plan": "{{plan}} · تا {{date}}",
|
||||
"until": "تا {{date}}",
|
||||
"days-left": "{{n}} روز مانده",
|
||||
"expiring-note": "مشترکانی که اشتراکشان در 7 روز آینده تمام میشود.",
|
||||
"privacy-short": "فقط نام کاربری مشترکان نمایش داده میشود.",
|
||||
"privacy": "فقط نام کاربری مشترکان نمایش داده میشود؛ شماره موبایل و نام آنها هرگز.",
|
||||
"empty": {
|
||||
"all": "هنوز مشترکی ندارید.",
|
||||
"expiring": "در 7 روز آینده اشتراکی تمام نمیشود."
|
||||
},
|
||||
"more": "نمایش مشترکان بیشتر",
|
||||
"more-failed": "مشترکان بیشتر بارگذاری نشدند."
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue