From 5b8b8f4cd415e42e06a05b2a524ebd0bb10d7c86 Mon Sep 17 00:00:00 2001 From: Amiram_se Date: Thu, 5 Nov 2026 19:01:42 +0400 Subject: [PATCH 01/11] fix(auth): ask for the 5-digit code the API sends The API sends a 5-digit sign-in code, but the code step drew six cells and its validation wanted six digits, so nobody could sign in or register. The admin panel keeps its 6-digit code. Co-Authored-By: Claude Opus 5.5 --- .../screens/(auth)/auth/organisms/code-step/CodeStep.tsx | 4 +++- platforms/market/src/features/auth/constants.ts | 6 +++--- platforms/market/src/shared/locales/fa/auth.json | 6 +++--- platforms/market/src/shared/validations/constants.ts | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/platforms/market/src/app/screens/(auth)/auth/organisms/code-step/CodeStep.tsx b/platforms/market/src/app/screens/(auth)/auth/organisms/code-step/CodeStep.tsx index 5104bfd..f417afa 100644 --- a/platforms/market/src/app/screens/(auth)/auth/organisms/code-step/CodeStep.tsx +++ b/platforms/market/src/app/screens/(auth)/auth/organisms/code-step/CodeStep.tsx @@ -11,12 +11,13 @@ 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 6-digit code step of login and registration: the number it went to, the cells, the resend + * The 5-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. @@ -78,6 +79,7 @@ export function CodeStep({ { diff --git a/platforms/market/src/features/auth/constants.ts b/platforms/market/src/features/auth/constants.ts index b700245..5156f09 100644 --- a/platforms/market/src/features/auth/constants.ts +++ b/platforms/market/src/features/auth/constants.ts @@ -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 (a code lives 10 minutes, the third wrong + * The code rules the pages show. The server owns them (5 digits, a code lives 2 minutes, the third wrong * code blocks the number for 10 minutes, at most 5 codes per number in an hour); the 2-minute - * resend wait is the product's, longer than the server's 60-second cooldown. + * resend opens when the code runs out. */ export const CODE_RULES = { - length: 6, + length: 5, resendWaitSeconds: 120, maxMisses: 3, blockSeconds: 600, diff --git a/platforms/market/src/shared/locales/fa/auth.json b/platforms/market/src/shared/locales/fa/auth.json index 97163cd..0a4c326 100644 --- a/platforms/market/src/shared/locales/fa/auth.json +++ b/platforms/market/src/shared/locales/fa/auth.json @@ -44,8 +44,8 @@ }, "code": { "title": "کد تأیید را وارد کنید", - "description": "کد 6 رقمی ارسال‌شده به {{phone}} را وارد کنید.", - "label": "کد تأیید 6 رقمی", + "description": "کد 5 رقمی ارسال‌شده به {{phone}} را وارد کنید.", + "label": "کد تأیید 5 رقمی", "edit-phone": "ویرایش شماره", "wrong": "کد وارد‌شده اشتباه است. لطفاً دوباره تلاش کنید.", "wrong-last": "کد وارد‌شده اشتباه است. یک تلاش دیگر باقی مانده است.", @@ -297,7 +297,7 @@ }, "validation": { "phone-invalid": "شماره موبایل وارد‌شده معتبر نیست.", - "code-length": "کد 6 رقمی را کامل وارد کنید.", + "code-length": "کد 5 رقمی را کامل وارد کنید.", "role-required": "نوع حساب را انتخاب کنید.", "required": "این فیلد الزامی است.", "first-name-persian": "لطفاً نام را به فارسی وارد کنید.", diff --git a/platforms/market/src/shared/validations/constants.ts b/platforms/market/src/shared/validations/constants.ts index 39c657d..adfb7db 100644 --- a/platforms/market/src/shared/validations/constants.ts +++ b/platforms/market/src/shared/validations/constants.ts @@ -22,7 +22,7 @@ export const ID_CARD_SIDES = [ export const ACCOUNT_TYPES = ['investor', 'creator'] as const; -export const CODE_PATTERN = /^\d{6}$/; +export const CODE_PATTERN = /^\d{5}$/; /** The server's creator profile rules (`CREATOR_PROFILE_LIMITS`), so forms reject what the API would. */ export const PROFILE_LIMITS = { From 5daff151962675c2c6ad6b37ab54509e753a993b Mon Sep 17 00:00:00 2001 From: Amiram_se Date: Thu, 5 Nov 2026 19:01:42 +0400 Subject: [PATCH 02/11] fix(signals): send the entry form when publishing a signal Without entryType the API reads an exact entry, so every range signal from the composer was refused with 422. Co-Authored-By: Claude Opus 5.5 --- .../post/repositories/post/mappers.test.ts | 42 +++++++++++++++++++ .../post/repositories/post/mappers.ts | 1 + .../features/post/repositories/post/types.ts | 3 ++ .../use-prediction-composer-page.test.tsx | 7 +++- .../use-prediction-composer-page.ts | 1 + 5 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 platforms/market/src/features/post/repositories/post/mappers.test.ts diff --git a/platforms/market/src/features/post/repositories/post/mappers.test.ts b/platforms/market/src/features/post/repositories/post/mappers.test.ts new file mode 100644 index 0000000..d4f106d --- /dev/null +++ b/platforms/market/src/features/post/repositories/post/mappers.test.ts @@ -0,0 +1,42 @@ +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, + }); + }); +}); diff --git a/platforms/market/src/features/post/repositories/post/mappers.ts b/platforms/market/src/features/post/repositories/post/mappers.ts index c4e7e6b..8248eb3 100644 --- a/platforms/market/src/features/post/repositories/post/mappers.ts +++ b/platforms/market/src/features/post/repositories/post/mappers.ts @@ -113,6 +113,7 @@ 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, diff --git a/platforms/market/src/features/post/repositories/post/types.ts b/platforms/market/src/features/post/repositories/post/types.ts index 6c83dce..005619b 100644 --- a/platforms/market/src/features/post/repositories/post/types.ts +++ b/platforms/market/src/features/post/repositories/post/types.ts @@ -154,6 +154,8 @@ 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; @@ -203,6 +205,7 @@ export type PredictionDto = { symbol: string; market: string; direction: PredictionDirection; + entryType?: 'exact' | 'range'; entryPrice?: number; entryLow?: number; entryHigh?: number; diff --git a/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.test.tsx b/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.test.tsx index 971bf9a..a2b043a 100644 --- a/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.test.tsx +++ b/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.test.tsx @@ -205,6 +205,7 @@ 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], @@ -231,7 +232,11 @@ describe('usePredictionComposerPage publishing', () => { await act(async () => result.current.publish()); const [args] = vi.mocked(publishPrediction).mock.calls[0]; - expect(args.prediction).toMatchObject({ entryLow: 98, entryHigh: 102 }); + expect(args.prediction).toMatchObject({ + entryType: 'range', + entryLow: 98, + entryHigh: 102, + }); expect(args.prediction.entryPrice).toBeUndefined(); }); diff --git a/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.ts b/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.ts index 5a7f4c9..d475c97 100644 --- a/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.ts +++ b/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.ts @@ -431,6 +431,7 @@ export function usePredictionComposerPage({ symbol: sent.symbol, market: sent.market, direction: sent.direction, + entryType: sent.entryMode, ...(sent.entryMode === 'range' ? { entryLow: sent.entryLow ?? undefined, From f111ee033adc7a9bc517d843a15658a158e2d9a8 Mon Sep 17 00:00:00 2001 From: Amiram_se Date: Thu, 5 Nov 2026 19:01:42 +0400 Subject: [PATCH 03/11] fix(signals): list each signal once before results are released Until results reach the analyst the API answers one list for every status and no per-status totals, so the signals tab drew each signal under both sections and the full list drew empty filter counts. Co-Authored-By: Claude Opus 5.5 --- .../prediction-list/PredictionList.tsx | 26 ++++++------ .../entities/own-predictions/types.ts | 11 ++++- .../use-own-prediction-count.test.tsx | 42 +++++++++++++++++++ .../use-own-prediction-count.ts | 5 ++- 4 files changed, 69 insertions(+), 15 deletions(-) create mode 100644 platforms/market/src/features/prediction/models/own-predictions/use-own-prediction-count.test.tsx diff --git a/platforms/market/src/app/screens/(main)/dashboard/predictions/all/organisms/prediction-list/PredictionList.tsx b/platforms/market/src/app/screens/(main)/dashboard/predictions/all/organisms/prediction-list/PredictionList.tsx index b75fdef..3708555 100644 --- a/platforms/market/src/app/screens/(main)/dashboard/predictions/all/organisms/prediction-list/PredictionList.tsx +++ b/platforms/market/src/app/screens/(main)/dashboard/predictions/all/organisms/prediction-list/PredictionList.tsx @@ -28,18 +28,20 @@ export function PredictionList({ layout }: PredictionListProps) { return ( - ({ - value: status, - label: t(`list.filters.${status}`, { - n: number(model.counts[status]), - }), - }))} - value={model.status} - onChange={model.setStatus} - /> + {model.counts.open !== null && ( + ({ + value: status, + label: t(`list.filters.${status}`, { + n: number(model.counts[status] ?? 0), + }), + }))} + value={model.status} + onChange={model.setStatus} + /> + )} {model.items.length === 0 ? ( model.counts.all === 0 ? ( ; +/** + * 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; +}; /** * `GET /posts/me/predictions`: one page of the creator's own published predictions, as owner diff --git a/platforms/market/src/features/prediction/models/own-predictions/use-own-prediction-count.test.tsx b/platforms/market/src/features/prediction/models/own-predictions/use-own-prediction-count.test.tsx new file mode 100644 index 0000000..7253525 --- /dev/null +++ b/platforms/market/src/features/prediction/models/own-predictions/use-own-prediction-count.test.tsx @@ -0,0 +1,42 @@ +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 }) => ( + {children} + ), + }); +} + +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)); + }); +}); diff --git a/platforms/market/src/features/prediction/models/own-predictions/use-own-prediction-count.ts b/platforms/market/src/features/prediction/models/own-predictions/use-own-prediction-count.ts index 3683991..8ce6081 100644 --- a/platforms/market/src/features/prediction/models/own-predictions/use-own-prediction-count.ts +++ b/platforms/market/src/features/prediction/models/own-predictions/use-own-prediction-count.ts @@ -6,6 +6,8 @@ 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, @@ -14,5 +16,6 @@ export function useOwnPredictionCount( ...ownSectionQueryOptions(section), throwOnError: false, }); - return data?.counts[section]; + if (!data) return undefined; + return data.counts[section] ?? (section === 'open' ? data.counts.all : 0); } From 96fb709505bfbede06661cd1fed823c3222fcb99 Mon Sep 17 00:00:00 2001 From: Amiram_se Date: Thu, 5 Nov 2026 19:01:42 +0400 Subject: [PATCH 04/11] fix(onboarding): require and send the consent at registration step 5 The API refuses the first profile completion without termsAccepted, and the web app never sent it, so no analyst could finish registering. The box now always shows, with or without a link, and completing sends the consent. Co-Authored-By: Claude Opus 5.5 --- .../components/ProfileForm.tsx | 59 +++++++++---------- .../complete-creator-profile/actions.test.ts | 26 ++++++++ .../complete-creator-profile/actions.ts | 4 +- .../use-creator-profile-page.ts | 4 +- .../profile/repositories/profile/profile.ts | 9 ++- .../profile/repositories/profile/types.ts | 3 + .../validations/profile-validations.test.ts | 25 ++++++++ .../shared/validations/profile-validations.ts | 37 +++++------- 8 files changed, 108 insertions(+), 59 deletions(-) create mode 100644 platforms/market/src/features/profile/actions/complete-creator-profile/actions.test.ts create mode 100644 platforms/market/src/shared/validations/profile-validations.test.ts diff --git a/platforms/market/src/app/screens/(onboarding)/onboarding/creator-profile/organisms/creator-profile-step/components/ProfileForm.tsx b/platforms/market/src/app/screens/(onboarding)/onboarding/creator-profile/organisms/creator-profile-step/components/ProfileForm.tsx index 38ed207..17918ce 100644 --- a/platforms/market/src/app/screens/(onboarding)/onboarding/creator-profile/organisms/creator-profile-step/components/ProfileForm.tsx +++ b/platforms/market/src/app/screens/(onboarding)/onboarding/creator-profile/organisms/creator-profile-step/components/ProfileForm.tsx @@ -37,9 +37,8 @@ import { SaveStatus } from './SaveStatus'; import { StepLayout } from './StepLayout'; /** - * 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. + * 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. */ export function ProfileForm({ page, @@ -210,34 +209,32 @@ export function ProfileForm({ layout={layout} optional /> - {links.rows.length > 0 && ( - ( - - field.onChange(event.target.checked)} - onBlur={field.onBlur} - invalid={fieldState.error != null} - aria-describedby={ - fieldState.error ? consentErrorId : undefined - } - > - {t('register.profile.links.consent')} - - {fieldState.error && ( - - {translateMessage(t, fieldState.error.message)} - - )} - - )} - /> - )} + ( + + field.onChange(event.target.checked)} + onBlur={field.onBlur} + invalid={fieldState.error != null} + aria-describedby={ + fieldState.error ? consentErrorId : undefined + } + > + {t('register.profile.links.consent')} + + {fieldState.error && ( + + {translateMessage(t, fieldState.error.message)} + + )} + + )} + /> + } + > + {t('overview.welcome.text')} + + + + ); +} diff --git a/platforms/market/src/app/screens/(main)/dashboard/overview/organisms/dashboard-overview/types.ts b/platforms/market/src/app/screens/(main)/dashboard/overview/organisms/dashboard-overview/types.ts index 1e4e687..cda2f1c 100644 --- a/platforms/market/src/app/screens/(main)/dashboard/overview/organisms/dashboard-overview/types.ts +++ b/platforms/market/src/app/screens/(main)/dashboard/overview/organisms/dashboard-overview/types.ts @@ -23,3 +23,5 @@ export type PlanBreakdownProps = { }; export type SignalSummaryProps = DashboardOverviewProps; + +export type WelcomeBannerProps = DashboardOverviewProps; diff --git a/platforms/market/src/shared/locales/fa/dashboard.json b/platforms/market/src/shared/locales/fa/dashboard.json index 373a168..ff83022 100644 --- a/platforms/market/src/shared/locales/fa/dashboard.json +++ b/platforms/market/src/shared/locales/fa/dashboard.json @@ -263,6 +263,11 @@ "details": "جزئیات در تب سیگنال‌ها", "error": "عملکرد سیگنال‌ها بارگذاری نشد.", "loading": "در حال بارگذاری عملکرد سیگنال‌ها…" + }, + "welcome": { + "title": "کانال خود را معرفی کنید", + "text": "لینک کانال را در تلگرام، اینستاگرام یا هر جای دیگری که مخاطب دارید بگذارید. هر دنبال‌کننده و مشترک تازه اینجا شمرده می‌شود.", + "action": "اشتراک‌گذاری لینک کانال" } } } From d56064fa2e333f666464f0fc610b761d72e8a0a5 Mon Sep 17 00:00:00 2001 From: Amiram_se Date: Thu, 5 Nov 2026 19:10:36 +0400 Subject: [PATCH 10/11] feat(dashboard): list subscribers and clean the plans tab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The plans tab loses «مخاطبان», whose figures now live on the overview, and shows the soonest-ending subscribers instead. /dashboard/subscribers lists them all with «همه» and «در حال انقضا»; notifications may now open it. Co-Authored-By: Claude Opus 5.5 --- .../dashboard/(creator)/plans/loading.tsx | 6 +- .../(main)/dashboard/(creator)/plans/page.tsx | 26 ++--- .../(main)/dashboard/subscribers/layout.tsx | 3 + .../(main)/dashboard/subscribers/loading.tsx | 27 ++++++ .../app/(main)/dashboard/subscribers/page.tsx | 53 ++++++++++ .../dashboard/(creator)/plans/loading.tsx | 6 +- .../(main)/dashboard/(creator)/plans/page.tsx | 26 ++--- .../(main)/dashboard/subscribers/layout.tsx | 3 + .../(main)/dashboard/subscribers/loading.tsx | 24 +++++ .../app/(main)/dashboard/subscribers/page.tsx | 50 ++++++++++ .../subscriber-row/SubscriberRow.tsx | 50 ++++++++++ .../organisms/subscriber-row/index.ts | 1 + .../organisms/subscriber-row/types.ts | 3 + .../audience-stats/AudienceStats.tsx | 49 ---------- .../audience-stats/AudienceStatsSkeleton.tsx | 33 ------- .../plans/organisms/audience-stats/index.ts | 3 - .../plans/organisms/audience-stats/types.ts | 6 -- .../SubscribersPreview.tsx | 55 +++++++++++ .../SubscribersPreviewSkeleton.tsx | 18 ++++ .../organisms/subscribers-preview/index.ts | 2 + .../organisms/subscribers-preview/types.ts | 6 ++ .../subscriber-list/SubscriberList.tsx | 96 +++++++++++++++++++ .../SubscriberListSkeleton.tsx | 21 ++++ .../organisms/subscriber-list/index.ts | 2 + .../organisms/subscriber-list/types.ts | 6 ++ .../market/src/features/overview/index.ts | 11 ++- .../overview/models/audience/index.ts | 2 - .../overview/models/audience/types.ts | 7 -- .../models/audience/use-audience-part.ts | 38 -------- .../overview/models/subscribers/constants.ts | 8 ++ .../overview/models/subscribers/index.ts | 7 ++ .../subscribers/subscriber-days.test.ts | 21 ++++ .../models/subscribers/subscriber-days.ts | 12 +++ .../overview/models/subscribers/types.ts | 25 +++++ .../subscribers/use-subscribers-page.ts | 69 +++++++++++++ .../use-subscribers-preview-part.ts | 21 ++++ platforms/market/src/index.ts | 2 - .../src/shared/locales/fa/dashboard.json | 32 +++++-- 38 files changed, 650 insertions(+), 180 deletions(-) create mode 100644 apps/bear/src/app/(main)/dashboard/subscribers/layout.tsx create mode 100644 apps/bear/src/app/(main)/dashboard/subscribers/loading.tsx create mode 100644 apps/bear/src/app/(main)/dashboard/subscribers/page.tsx create mode 100644 apps/bull/src/app/(main)/dashboard/subscribers/layout.tsx create mode 100644 apps/bull/src/app/(main)/dashboard/subscribers/loading.tsx create mode 100644 apps/bull/src/app/(main)/dashboard/subscribers/page.tsx create mode 100644 platforms/market/src/app/screens/(main)/dashboard/organisms/subscriber-row/SubscriberRow.tsx create mode 100644 platforms/market/src/app/screens/(main)/dashboard/organisms/subscriber-row/index.ts create mode 100644 platforms/market/src/app/screens/(main)/dashboard/organisms/subscriber-row/types.ts delete mode 100644 platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/AudienceStats.tsx delete mode 100644 platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/AudienceStatsSkeleton.tsx delete mode 100644 platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/index.ts delete mode 100644 platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/types.ts create mode 100644 platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/SubscribersPreview.tsx create mode 100644 platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/SubscribersPreviewSkeleton.tsx create mode 100644 platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/index.ts create mode 100644 platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/types.ts create mode 100644 platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/SubscriberList.tsx create mode 100644 platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/SubscriberListSkeleton.tsx create mode 100644 platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/index.ts create mode 100644 platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/types.ts delete mode 100644 platforms/market/src/features/overview/models/audience/index.ts delete mode 100644 platforms/market/src/features/overview/models/audience/types.ts delete mode 100644 platforms/market/src/features/overview/models/audience/use-audience-part.ts create mode 100644 platforms/market/src/features/overview/models/subscribers/constants.ts create mode 100644 platforms/market/src/features/overview/models/subscribers/index.ts create mode 100644 platforms/market/src/features/overview/models/subscribers/subscriber-days.test.ts create mode 100644 platforms/market/src/features/overview/models/subscribers/subscriber-days.ts create mode 100644 platforms/market/src/features/overview/models/subscribers/types.ts create mode 100644 platforms/market/src/features/overview/models/subscribers/use-subscribers-page.ts create mode 100644 platforms/market/src/features/overview/models/subscribers/use-subscribers-preview-part.ts diff --git a/apps/bear/src/app/(main)/dashboard/(creator)/plans/loading.tsx b/apps/bear/src/app/(main)/dashboard/(creator)/plans/loading.tsx index 18ae431..78e8e6e 100644 --- a/apps/bear/src/app/(main)/dashboard/(creator)/plans/loading.tsx +++ b/apps/bear/src/app/(main)/dashboard/(creator)/plans/loading.tsx @@ -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 /> - diff --git a/apps/bear/src/app/(main)/dashboard/(creator)/plans/page.tsx b/apps/bear/src/app/(main)/dashboard/(creator)/plans/page.tsx index a8711db..dcf80f6 100644 --- a/apps/bear/src/app/(main)/dashboard/(creator)/plans/page.tsx +++ b/apps/bear/src/app/(main)/dashboard/(creator)/plans/page.tsx @@ -1,10 +1,6 @@ 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, @@ -13,6 +9,10 @@ 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,8 +41,10 @@ export default function PlansPage() { label={i18n.t('dashboard:invite.loading')} /> ); - const audienceSkeleton = ( - + const subscribersSkeleton = ( + ); return ( @@ -52,7 +54,7 @@ export default function PlansPage() { {pricingSkeleton} {inviteSkeleton} - {audienceSkeleton} + {subscribersSkeleton} } > @@ -79,12 +81,12 @@ export default function PlansPage() { - - + + diff --git a/apps/bear/src/app/(main)/dashboard/subscribers/layout.tsx b/apps/bear/src/app/(main)/dashboard/subscribers/layout.tsx new file mode 100644 index 0000000..f671748 --- /dev/null +++ b/apps/bear/src/app/(main)/dashboard/subscribers/layout.tsx @@ -0,0 +1,3 @@ +// 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'; diff --git a/apps/bear/src/app/(main)/dashboard/subscribers/loading.tsx b/apps/bear/src/app/(main)/dashboard/subscribers/loading.tsx new file mode 100644 index 0000000..eb8b325 --- /dev/null +++ b/apps/bear/src/app/(main)/dashboard/subscribers/loading.tsx @@ -0,0 +1,27 @@ +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 ( + + + + + + + ); +} diff --git a/apps/bear/src/app/(main)/dashboard/subscribers/page.tsx b/apps/bear/src/app/(main)/dashboard/subscribers/page.tsx new file mode 100644 index 0000000..49235e2 --- /dev/null +++ b/apps/bear/src/app/(main)/dashboard/subscribers/page.tsx @@ -0,0 +1,53 @@ +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 = ( + + ); + + return ( + + + + + + + + + + + + + ); +} diff --git a/apps/bull/src/app/(main)/dashboard/(creator)/plans/loading.tsx b/apps/bull/src/app/(main)/dashboard/(creator)/plans/loading.tsx index 6c73174..bb8ed76 100644 --- a/apps/bull/src/app/(main)/dashboard/(creator)/plans/loading.tsx +++ b/apps/bull/src/app/(main)/dashboard/(creator)/plans/loading.tsx @@ -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 /> - diff --git a/apps/bull/src/app/(main)/dashboard/(creator)/plans/page.tsx b/apps/bull/src/app/(main)/dashboard/(creator)/plans/page.tsx index 1357868..a868449 100644 --- a/apps/bull/src/app/(main)/dashboard/(creator)/plans/page.tsx +++ b/apps/bull/src/app/(main)/dashboard/(creator)/plans/page.tsx @@ -1,10 +1,6 @@ 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, @@ -13,6 +9,10 @@ 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,8 +41,10 @@ export default function PlansPage() { label={i18n.t('dashboard:invite.loading')} /> ); - const audienceSkeleton = ( - + const subscribersSkeleton = ( + ); return ( @@ -52,7 +54,7 @@ export default function PlansPage() { {pricingSkeleton} {inviteSkeleton} - {audienceSkeleton} + {subscribersSkeleton} } > @@ -79,12 +81,12 @@ export default function PlansPage() { - - + + diff --git a/apps/bull/src/app/(main)/dashboard/subscribers/layout.tsx b/apps/bull/src/app/(main)/dashboard/subscribers/layout.tsx new file mode 100644 index 0000000..f671748 --- /dev/null +++ b/apps/bull/src/app/(main)/dashboard/subscribers/layout.tsx @@ -0,0 +1,3 @@ +// 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'; diff --git a/apps/bull/src/app/(main)/dashboard/subscribers/loading.tsx b/apps/bull/src/app/(main)/dashboard/subscribers/loading.tsx new file mode 100644 index 0000000..9adc0a7 --- /dev/null +++ b/apps/bull/src/app/(main)/dashboard/subscribers/loading.tsx @@ -0,0 +1,24 @@ +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 ( + <> + + + + + + ); +} diff --git a/apps/bull/src/app/(main)/dashboard/subscribers/page.tsx b/apps/bull/src/app/(main)/dashboard/subscribers/page.tsx new file mode 100644 index 0000000..b5387af --- /dev/null +++ b/apps/bull/src/app/(main)/dashboard/subscribers/page.tsx @@ -0,0 +1,50 @@ +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 = ( + + ); + + return ( + <> + + + + + + + + + + + + ); +} diff --git a/platforms/market/src/app/screens/(main)/dashboard/organisms/subscriber-row/SubscriberRow.tsx b/platforms/market/src/app/screens/(main)/dashboard/organisms/subscriber-row/SubscriberRow.tsx new file mode 100644 index 0000000..8c1ed37 --- /dev/null +++ b/platforms/market/src/app/screens/(main)/dashboard/organisms/subscriber-row/SubscriberRow.tsx @@ -0,0 +1,50 @@ +'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 ( + + } + title={ + + @{subscriber.username ?? '—'} + + } + subtitle={ + subscriber.tier + ? t('subscribers.until-plan', { + plan: t(`common:billing-periods.${subscriber.tier}`), + date: until, + }) + : t('subscribers.until', { date: until }) + } + end={ + daysLeft !== null && ( + + {t('subscribers.days-left', { n: number(daysLeft) })} + + ) + } + chevron={false} + /> + ); +} diff --git a/platforms/market/src/app/screens/(main)/dashboard/organisms/subscriber-row/index.ts b/platforms/market/src/app/screens/(main)/dashboard/organisms/subscriber-row/index.ts new file mode 100644 index 0000000..219f6a8 --- /dev/null +++ b/platforms/market/src/app/screens/(main)/dashboard/organisms/subscriber-row/index.ts @@ -0,0 +1 @@ +export { SubscriberRow } from './SubscriberRow'; diff --git a/platforms/market/src/app/screens/(main)/dashboard/organisms/subscriber-row/types.ts b/platforms/market/src/app/screens/(main)/dashboard/organisms/subscriber-row/types.ts new file mode 100644 index 0000000..1e85fca --- /dev/null +++ b/platforms/market/src/app/screens/(main)/dashboard/organisms/subscriber-row/types.ts @@ -0,0 +1,3 @@ +import type { OwnSubscriberPayload } from '../../../../../../features/overview'; + +export type SubscriberRowProps = { subscriber: OwnSubscriberPayload }; diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/AudienceStats.tsx b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/AudienceStats.tsx deleted file mode 100644 index 2a791de..0000000 --- a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/AudienceStats.tsx +++ /dev/null @@ -1,49 +0,0 @@ -'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 ( - - - {t('audience.title')} - - - - - - - {t('audience.note')} - - - ); -} diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/AudienceStatsSkeleton.tsx b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/AudienceStatsSkeleton.tsx deleted file mode 100644 index 567dfc5..0000000 --- a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/AudienceStatsSkeleton.tsx +++ /dev/null @@ -1,33 +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 { AudienceStatsSkeletonProps } from './types'; - -/** «مخاطبان» before it arrives: its title, the two tiles and the line under them. */ -export function AudienceStatsSkeleton({ - label, - delayed, -}: AudienceStatsSkeletonProps) { - return ( - - - - - {[0, 1].map((tile) => ( - - - - - ))} - - - - - ); -} diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/index.ts b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/index.ts deleted file mode 100644 index 59055f9..0000000 --- a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { AudienceStats } from './AudienceStats'; -export { AudienceStatsSkeleton } from './AudienceStatsSkeleton'; -export type { AudienceStatsSkeletonProps } from './types'; diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/types.ts b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/types.ts deleted file mode 100644 index db9ab5d..0000000 --- a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/audience-stats/types.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type AudienceStatsSkeletonProps = { - /** Hidden status text: «در حال بارگذاری مخاطبان…». */ - label: string; - /** Fades in after 300ms, so a fast route never flashes grey. loading.tsx only. */ - delayed?: boolean; -}; diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/SubscribersPreview.tsx b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/SubscribersPreview.tsx new file mode 100644 index 0000000..fe061f2 --- /dev/null +++ b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/SubscribersPreview.tsx @@ -0,0 +1,55 @@ +'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 ( + + 0 ? t('subscribers.view-all') : undefined} + actionHref={total > 0 ? ROUTES.dashboard.subscribers : undefined} + /> + {total > 0 ? ( + <> + + {items.map((subscriber) => ( + + ))} + + + {t('subscribers.privacy-short')} + + + ) : ( + + {t('subscribers.empty.all')} + + )} + + ); +} diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/SubscribersPreviewSkeleton.tsx b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/SubscribersPreviewSkeleton.tsx new file mode 100644 index 0000000..0da790d --- /dev/null +++ b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/SubscribersPreviewSkeleton.tsx @@ -0,0 +1,18 @@ +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 ( + + + + + ); +} diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/index.ts b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/index.ts new file mode 100644 index 0000000..cd6b7fc --- /dev/null +++ b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/index.ts @@ -0,0 +1,2 @@ +export { SubscribersPreview } from './SubscribersPreview'; +export { SubscribersPreviewSkeleton } from './SubscribersPreviewSkeleton'; diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/types.ts b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/types.ts new file mode 100644 index 0000000..4b7c3af --- /dev/null +++ b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/subscribers-preview/types.ts @@ -0,0 +1,6 @@ +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; +}; diff --git a/platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/SubscriberList.tsx b/platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/SubscriberList.tsx new file mode 100644 index 0000000..393ab31 --- /dev/null +++ b/platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/SubscriberList.tsx @@ -0,0 +1,96 @@ +'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 ( + + + {model.items.length === 0 ? ( + + ) : ( + + {model.items.map((subscriber) => ( + + ))} + + )} + {model.loadMoreError ? ( + + ) : ( + model.hasMore && ( + + ) + )} + {model.filter === 'expiring' && ( + + {t('subscribers.expiring-note')} + + )} + + {t('subscribers.privacy')} + + + ); +} diff --git a/platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/SubscriberListSkeleton.tsx b/platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/SubscriberListSkeleton.tsx new file mode 100644 index 0000000..1f12039 --- /dev/null +++ b/platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/SubscriberListSkeleton.tsx @@ -0,0 +1,21 @@ +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 ( + + + + + + + + ); +} diff --git a/platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/index.ts b/platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/index.ts new file mode 100644 index 0000000..d838720 --- /dev/null +++ b/platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/index.ts @@ -0,0 +1,2 @@ +export { SubscriberList } from './SubscriberList'; +export { SubscriberListSkeleton } from './SubscriberListSkeleton'; diff --git a/platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/types.ts b/platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/types.ts new file mode 100644 index 0000000..abc9b4f --- /dev/null +++ b/platforms/market/src/app/screens/(main)/dashboard/subscribers/organisms/subscriber-list/types.ts @@ -0,0 +1,6 @@ +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; +}; diff --git a/platforms/market/src/features/overview/index.ts b/platforms/market/src/features/overview/index.ts index 058db1a..1ea2017 100644 --- a/platforms/market/src/features/overview/index.ts +++ b/platforms/market/src/features/overview/index.ts @@ -1,5 +1,3 @@ -export { useAudiencePart } from './models/audience'; -export type { AudiencePartModel } from './models/audience'; export { planBreakdownRows, useDashboardOverviewPart, @@ -9,6 +7,15 @@ export type { PlanBreakdownMetric, PlanBreakdownRow, } from './models/dashboard-overview'; +export { + subscriberDaysLeft, + useSubscribersPage, + useSubscribersPreviewPart, +} from './models/subscribers'; +export type { + SubscribersPageModel, + SubscribersPreviewPartModel, +} from './models/subscribers'; export { useOwnSubscriberCount } from './models/own-subscriber-count'; export type { UseOwnSubscriberCountOptions } from './models/own-subscriber-count'; export { diff --git a/platforms/market/src/features/overview/models/audience/index.ts b/platforms/market/src/features/overview/models/audience/index.ts deleted file mode 100644 index 091a930..0000000 --- a/platforms/market/src/features/overview/models/audience/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { useAudiencePart } from './use-audience-part'; -export type { AudiencePartModel } from './types'; diff --git a/platforms/market/src/features/overview/models/audience/types.ts b/platforms/market/src/features/overview/models/audience/types.ts deleted file mode 100644 index 925bb52..0000000 --- a/platforms/market/src/features/overview/models/audience/types.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** طرح‌های اشتراک › «مخاطبان» (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; -}; diff --git a/platforms/market/src/features/overview/models/audience/use-audience-part.ts b/platforms/market/src/features/overview/models/audience/use-audience-part.ts deleted file mode 100644 index 16b7774..0000000 --- a/platforms/market/src/features/overview/models/audience/use-audience-part.ts +++ /dev/null @@ -1,38 +0,0 @@ -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, - }; -} diff --git a/platforms/market/src/features/overview/models/subscribers/constants.ts b/platforms/market/src/features/overview/models/subscribers/constants.ts new file mode 100644 index 0000000..e5cd281 --- /dev/null +++ b/platforms/market/src/features/overview/models/subscribers/constants.ts @@ -0,0 +1,8 @@ +/** 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; diff --git a/platforms/market/src/features/overview/models/subscribers/index.ts b/platforms/market/src/features/overview/models/subscribers/index.ts new file mode 100644 index 0000000..c6246a3 --- /dev/null +++ b/platforms/market/src/features/overview/models/subscribers/index.ts @@ -0,0 +1,7 @@ +export { subscriberDaysLeft } from './subscriber-days'; +export { useSubscribersPage } from './use-subscribers-page'; +export { useSubscribersPreviewPart } from './use-subscribers-preview-part'; +export type { + SubscribersPageModel, + SubscribersPreviewPartModel, +} from './types'; diff --git a/platforms/market/src/features/overview/models/subscribers/subscriber-days.test.ts b/platforms/market/src/features/overview/models/subscribers/subscriber-days.test.ts new file mode 100644 index 0000000..d3d7cb3 --- /dev/null +++ b/platforms/market/src/features/overview/models/subscribers/subscriber-days.test.ts @@ -0,0 +1,21 @@ +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); + }); +}); diff --git a/platforms/market/src/features/overview/models/subscribers/subscriber-days.ts b/platforms/market/src/features/overview/models/subscribers/subscriber-days.ts new file mode 100644 index 0000000..f0d0060 --- /dev/null +++ b/platforms/market/src/features/overview/models/subscribers/subscriber-days.ts @@ -0,0 +1,12 @@ +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); +} diff --git a/platforms/market/src/features/overview/models/subscribers/types.ts b/platforms/market/src/features/overview/models/subscribers/types.ts new file mode 100644 index 0000000..20b1830 --- /dev/null +++ b/platforms/market/src/features/overview/models/subscribers/types.ts @@ -0,0 +1,25 @@ +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; + 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[]; +}; diff --git a/platforms/market/src/features/overview/models/subscribers/use-subscribers-page.ts b/platforms/market/src/features/overview/models/subscribers/use-subscribers-page.ts new file mode 100644 index 0000000..1d4959d --- /dev/null +++ b/platforms/market/src/features/overview/models/subscribers/use-subscribers-page.ts @@ -0,0 +1,69 @@ +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, + }; +} diff --git a/platforms/market/src/features/overview/models/subscribers/use-subscribers-preview-part.ts b/platforms/market/src/features/overview/models/subscribers/use-subscribers-preview-part.ts new file mode 100644 index 0000000..4b4a093 --- /dev/null +++ b/platforms/market/src/features/overview/models/subscribers/use-subscribers-preview-part.ts @@ -0,0 +1,21 @@ +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), + }; +} diff --git a/platforms/market/src/index.ts b/platforms/market/src/index.ts index 68614ed..823b28a 100644 --- a/platforms/market/src/index.ts +++ b/platforms/market/src/index.ts @@ -343,11 +343,9 @@ export type { export { creatorDashboardRepository, overviewKeys, - useAudiencePart, useOwnSubscriberCount, } from './features/overview'; export type { - AudiencePartModel, CreatorDashboardPayload, CreatorTierPayload, RecentPaymentPayload, diff --git a/platforms/market/src/shared/locales/fa/dashboard.json b/platforms/market/src/shared/locales/fa/dashboard.json index ff83022..d341216 100644 --- a/platforms/market/src/shared/locales/fa/dashboard.json +++ b/platforms/market/src/shared/locales/fa/dashboard.json @@ -146,14 +146,6 @@ "finance": { "meta-title": "مالی" }, - "audience": { - "title": "مخاطبان", - "followers": "دنبال‌کنندگان", - "subscribers": "مشترکان فعال", - "note": "تعداد دنبال‌کنندگان برای همه دیده می‌شود؛ تعداد مشترکان فقط برای شما.", - "loading": "در حال بارگذاری مخاطبان…", - "error": "آمار مخاطبان بارگذاری نشد. دوباره تلاش کنید." - }, "invite": { "title": "کد دعوت", "loading": "در حال بارگذاری کد دعوت…", @@ -269,5 +261,29 @@ "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": "مشترکان بیشتر بارگذاری نشدند." } } From 1b8d1df265cd483379bb950107f0710511c2fe3b Mon Sep 17 00:00:00 2001 From: Amiram_se Date: Thu, 5 Nov 2026 19:19:20 +0400 Subject: [PATCH 11/11] feat(dashboard): finish the overview tab and document it Keeps tile tips on the label's line, moves the share button under the banner text on a phone, and records the new default tab, the overview and the subscriber list in the decisions and page docs. Co-Authored-By: Claude Opus 5.5 --- .../0034-creator-dashboard-routes.md | 2 +- ...072-analyst-overview-is-the-default-tab.md | 24 ++++++++++++ docs/decisions/README.md | 3 +- docs/pages/README.md | 4 +- docs/pages/market/dashboard-overview.md | 31 +++++++++++++++ docs/pages/market/dashboard-plans.md | 2 +- docs/pages/market/dashboard-subscribers.md | 24 ++++++++++++ docs/pages/market/layout-dashboard-creator.md | 18 ++++----- .../components/AudienceSection.tsx | 8 +++- .../components/IncomeSection.tsx | 8 +++- .../components/WelcomeBanner.tsx | 38 ++++++++++++------- 11 files changed, 131 insertions(+), 31 deletions(-) create mode 100644 docs/decisions/0072-analyst-overview-is-the-default-tab.md create mode 100644 docs/pages/market/dashboard-overview.md create mode 100644 docs/pages/market/dashboard-subscribers.md diff --git a/docs/decisions/0034-creator-dashboard-routes.md b/docs/decisions/0034-creator-dashboard-routes.md index 72e7219..e85e96e 100644 --- a/docs/decisions/0034-creator-dashboard-routes.md +++ b/docs/decisions/0034-creator-dashboard-routes.md @@ -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 · Decided by: agent +Status: Proposed · Area: architecture · Date: 2026-10-08, amended 2026-10-09, 0072 makes «نمای کلی» the default tab · Decided by: agent ## Context diff --git a/docs/decisions/0072-analyst-overview-is-the-default-tab.md b/docs/decisions/0072-analyst-overview-is-the-default-tab.md new file mode 100644 index 0000000..95b33ba --- /dev/null +++ b/docs/decisions/0072-analyst-overview-is-the-default-tab.md @@ -0,0 +1,24 @@ +# 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. diff --git a/docs/decisions/README.md b/docs/decisions/README.md index fea1f0b..65755c2 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -29,6 +29,7 @@ - 0068 Keep the previous release as a stopped `-` container with its env folder; `tools/rollback.sh ` 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 @@ -48,7 +49,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` (default), `/dashboard/predictions` and `/dashboard/finance`, 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`, `/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. - 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. diff --git a/docs/pages/README.md b/docs/pages/README.md index 77289b6..2e1654c 100644 --- a/docs/pages/README.md +++ b/docs/pages/README.md @@ -32,7 +32,9 @@ 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/plans` · [dashboard-plans.md](market/dashboard-plans.md) · noindex · none · browser: PricingCard, InviteCodeCard, InviteShareSheet, CapacityRequestDialog, AudienceStats +- `/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/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 diff --git a/docs/pages/market/dashboard-overview.md b/docs/pages/market/dashboard-overview.md new file mode 100644 index 0000000..415d9dc --- /dev/null +++ b/docs/pages/market/dashboard-overview.md @@ -0,0 +1,31 @@ +# 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 `` | + +## 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. diff --git a/docs/pages/market/dashboard-plans.md b/docs/pages/market/dashboard-plans.md index 63798c0..1f152fc 100644 --- a/docs/pages/market/dashboard-plans.md +++ b/docs/pages/market/dashboard-plans.md @@ -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 `` (`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 `` | | ↳ InviteShareSheet, CapacityRequestDialog | viewer | none | hydrate | no | mount when opened; bull: share opens a bottom sheet; bear: a popover beside the link field | -| AudienceStats | viewer | skeleton | hydrate | no | «مخاطبان»: follower count and active subscriptions, two browser reads; either failing fails the part | +| SubscribersPreview | viewer | skeleton | hydrate | no | «مشترکان»: the total and the three who end soonest, with «مشاهده همه» to `/dashboard/subscribers`; own `PartBoundary` and `` | ## Notes diff --git a/docs/pages/market/dashboard-subscribers.md b/docs/pages/market/dashboard-subscribers.md new file mode 100644 index 0000000..a6645f1 --- /dev/null +++ b/docs/pages/market/dashboard-subscribers.md @@ -0,0 +1,24 @@ +# 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). diff --git a/docs/pages/market/layout-dashboard-creator.md b/docs/pages/market/layout-dashboard-creator.md index 0042270..6177921 100644 --- a/docs/pages/market/layout-dashboard-creator.md +++ b/docs/pages/market/layout-dashboard-creator.md @@ -1,19 +1,19 @@ # Layout: dashboard (creator) -`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 +`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 -| 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 ``; 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 | -| «داشبورد» `

` (bear) | config | first flush | none | no | at the top of the 640 column | -| DashboardTabs | config | first flush | hydrate | no | `role="creator"`: island `TabLinks`, an `` per tab «طرح‌های اشتراک» · «سیگنال‌ها» · «مالی» (0034); 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 ``; 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 | +| «داشبورد» `

` (bear) | config | first flush | none | no | at the top of the 640 column | +| DashboardTabs | config | first flush | hydrate | no | `role="creator"`: island `TabLinks`, an `` per tab «نمای کلی» · «طرح‌های اشتراک» · «سیگنال‌ها» · «مالی» (0034, 0072); 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 `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 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 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 `

` (the bar's «داشبورد» is a ``), bear has one, `apps/bull/src/app/(main)/dashboard/(creator)/layout.tsx:22`. Make the bar's tab title an `

` on tab screens, or add a visually hidden `

` in the bull layout. diff --git a/platforms/market/src/app/screens/(main)/dashboard/overview/organisms/dashboard-overview/components/AudienceSection.tsx b/platforms/market/src/app/screens/(main)/dashboard/overview/organisms/dashboard-overview/components/AudienceSection.tsx index 4d91d2d..3d63bc6 100644 --- a/platforms/market/src/app/screens/(main)/dashboard/overview/organisms/dashboard-overview/components/AudienceSection.tsx +++ b/platforms/market/src/app/screens/(main)/dashboard/overview/organisms/dashboard-overview/components/AudienceSection.tsx @@ -5,6 +5,7 @@ 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'; @@ -31,12 +32,15 @@ export function AudienceSection({ overview, cols }: OverviewSectionProps) { + {t('overview.audience.followers')} {t('overview.audience.followers-tip')} - + } value={number(overview.followers)} /> diff --git a/platforms/market/src/app/screens/(main)/dashboard/overview/organisms/dashboard-overview/components/IncomeSection.tsx b/platforms/market/src/app/screens/(main)/dashboard/overview/organisms/dashboard-overview/components/IncomeSection.tsx index c270427..dd59543 100644 --- a/platforms/market/src/app/screens/(main)/dashboard/overview/organisms/dashboard-overview/components/IncomeSection.tsx +++ b/platforms/market/src/app/screens/(main)/dashboard/overview/organisms/dashboard-overview/components/IncomeSection.tsx @@ -6,6 +6,7 @@ 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'; @@ -33,12 +34,15 @@ export function IncomeSection({ overview, cols }: OverviewSectionProps) { + {t('overview.income.total')} {t('overview.income.total-tip')} - + } value={ + {t('overview.welcome.action')} + + ); + return ( - {t('overview.welcome.action')} - - } + action={layout === 'desktop' ? share : undefined} > - {t('overview.welcome.text')} + {layout === 'desktop' ? ( + t('overview.welcome.text') + ) : ( + // A phone has no room beside the text, so the button goes under it. + + {t('overview.welcome.text')} + {share} + + )}