Compare commits

...

4 Commits

322 changed files with 4956 additions and 1264 deletions

View File

@ -1,4 +1,5 @@
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { ROUTES } from '@lumina/market/app/navigation';
import { i18n } from '../../../../../i18n';
import { AuthTemplate } from '../../../../templates/auth-template';
@ -6,7 +7,7 @@ import { AuthTemplate } from '../../../../templates/auth-template';
/** Registration step 4, before its frame arrives. The same frame and skeleton as the page, so nothing moves when it arrives. */
export default function Loading() {
return (
<AuthTemplate>
<AuthTemplate back={ROUTES.landing}>
<SkeletonPreset
preset="form"
count={3}

View File

@ -1,5 +1,14 @@
// First: the rules sheet reads a server-only namespace, which the server bootstrap adds to i18n
// when this module loads (0055).
import '../../../../../bootstrap/bootstrap.server';
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { GuestGuard } from '@lumina/market/app/guards/guest-guard';
import { ROUTES } from '@lumina/market/app/navigation';
import {
GeneralRules,
generalRulesLabels,
} from '@lumina/market/app/screens/organisms/general-rules';
import { RegisterDetailsStep } from '@lumina/market/app/screens/(auth)/auth/register/details/organisms/register-details-step';
import type { Metadata } from 'next';
@ -14,7 +23,7 @@ export const metadata: Metadata = {
/** Registration step 4, account details or identity. The frame renders on the server; the step only in the browser (0013). */
export default function RegisterDetailsPage() {
return (
<AuthTemplate>
<AuthTemplate back={ROUTES.landing}>
<GuestGuard
fallback={
<SkeletonPreset
@ -28,6 +37,12 @@ export default function RegisterDetailsPage() {
size="md"
supportPlacement="popover"
haltPlacement="modal"
rules={
<GeneralRules
layout="sheet"
labels={generalRulesLabels(i18n.getFixedT(null, 'rules'))}
/>
}
/>
</GuestGuard>
</AuthTemplate>

View File

@ -22,6 +22,7 @@ export default function Loading() {
>
<DesktopPageTitle title={i18n.t('payment:checkout.title')} />
<CheckoutSkeleton
delayed
layout="desktop"
creator={<CheckoutCreatorSkeleton />}
label={i18n.t('payment:checkout.loading')}

View File

@ -45,6 +45,8 @@ export function CheckoutTemplate({ channel }: CheckoutTemplateProps) {
channelHref={ROUTES.channel(channel.username)}
layout="desktop"
creator={<CheckoutCreator creator={channel} />}
creatorName={channel.displayName ?? channel.username}
creatorLinks={channel.socialLinks}
/>
</PartBoundary>
</FlexBox>

View File

@ -1,17 +1,7 @@
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 {
DesktopHeader,
DesktopPageTitle,
ROUTES,
} from '@lumina/market/app/navigation';
import {
PricingForm,
PricingFormSkeleton,
} from '@lumina/market/app/screens/(flow)/dashboard/pricing/organisms/pricing-form';
import { DesktopHeader } from '@lumina/market/app/navigation';
import { PricingEditor } from '@lumina/market/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor';
import type { Metadata } from 'next';
import { Suspense } from 'react';
import { i18n } from '../../../../i18n';
@ -22,14 +12,11 @@ export const metadata: Metadata = {
/**
* C7, «ویرایش قیمت‌ها» on desktop (C7 ۸.۱): the creator header with داشبورد on, «بازگشت» above
* the title (to طرح‌های اشتراک when opened on its own, R14), and the form in the 560 column. The form is the creator's own, so it renders in the
* browser behind cards of the same size.
* the title (to طرح‌های اشتراک when opened on its own, R14), and the form in the 560 column; with
* unsaved changes, leaving asks first (J10-4n). The form is the creator's own, so it renders in
* the browser behind cards of the same size.
*/
export default function PricingPage() {
const skeleton = (
<PricingFormSkeleton layout="desktop" label={i18n.t('pricing:loading')} />
);
return (
<FlexBox direction="flex-col" className="min-h-dvh bg-bg-page">
<DesktopHeader />
@ -38,22 +25,8 @@ export default function PricingPage() {
justifyContent="justify-center"
className="px-8 py-10"
>
<FlexBox direction="flex-col" gap="gap-4" className="w-full max-w-form">
<DesktopPageTitle
title={i18n.t('pricing:title')}
parentHref={ROUTES.dashboard.plans}
/>
<PartBoundary
name="pricing-form"
description={i18n.t('pricing:error')}
framed
>
<AuthGuard role="creator" fallback={skeleton}>
<Suspense fallback={skeleton}>
<PricingForm layout="desktop" />
</Suspense>
</AuthGuard>
</PartBoundary>
<FlexBox direction="flex-col" className="w-full max-w-form">
<PricingEditor layout="desktop" />
</FlexBox>
</FlexBox>
</FlexBox>

View File

@ -22,6 +22,7 @@ export default function Loading() {
{/* To the channel paid for once the payment loads (R14), never to the bank. */}
<DeskBack href={ROUTES.dashboard.subscriptions} />
<PaymentResultSkeleton
delayed
layout="desktop"
label={i18n.t('payment:result.loading')}
/>

View File

@ -0,0 +1,54 @@
// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
// adds to i18n when this module loads, whichever module Next loads first (0055).
import '../../../bootstrap/bootstrap.server';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { DesktopHeader, DesktopPageTitle } from '@lumina/market/app/navigation';
import { RulesTabs } from '@lumina/market/app/screens/(flow)/terms/organisms/rules-tabs';
import type { Metadata } from 'next';
import type { ReactNode } from 'react';
import { i18n } from '../../../i18n';
export const metadata: Metadata = {
title: i18n.t('rules:meta-title'),
description: i18n.t('rules:meta-description'),
};
/**
* «قوانین لومینا» on desktop (G-2r): the 640 column under the header, with back beside the title
* «قوانین لومینا» and the tab row «قوانین عمومی» · «شرایط اشتراک»; each tab's text sits in a panel.
* Each tab is its own route with its own loading, so the title and the row stay while one loads;
* back returns to where the rules were opened. No nav item is active.
*/
export default function RulesLayout({ children }: { children: ReactNode }) {
const t = i18n.getFixedT(null, 'rules');
return (
<FlexBox direction="flex-col" className="min-h-dvh bg-bg-page">
<DesktopHeader />
<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={t('title')} />
<RulesTabs
layout="desktop"
labels={{
label: t('tabs.label'),
general: t('tabs.general'),
subscription: t('tabs.subscription'),
}}
/>
{children}
</FlexBox>
</FlexBox>
</FlexBox>
);
}

View File

@ -0,0 +1,20 @@
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
import { Card } from '@lumina/island/molecules/card';
import { i18n } from '../../../i18n';
/** «قوانین عمومی» before it arrives, under the section's title and tabs: its panel of lines. */
export default function Loading() {
return (
<SkeletonRegion delayed label={i18n.t('rules:meta-title')}>
<Card padding="lg">
<Skeleton width="40%" height="1.25rem" className="mb-3" />
<Skeleton lines={3} />
<Skeleton width="35%" height="1.25rem" className="mt-6 mb-3" />
<Skeleton lines={3} />
<Skeleton width="45%" height="1.25rem" className="mt-6 mb-3" />
<Skeleton lines={4} />
</Card>
</SkeletonRegion>
);
}

View File

@ -1,10 +1,29 @@
import { ROUTES } from '@lumina/market/app/navigation';
import { redirect } from 'next/navigation';
// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
// adds to i18n when this module loads, whichever module Next loads first (0055).
import '../../../bootstrap/bootstrap.server';
/**
* `/terms`, the address the boards give «شرایط اشتراک» (G-2), sends on to the page at its own
* address. Temporary, so `/terms` can become a page of its own later.
*/
export default function TermsPage(): never {
redirect(ROUTES.terms);
import { Card } from '@lumina/island/molecules/card';
import {
GeneralRules,
generalRulesLabels,
} from '@lumina/market/app/screens/organisms/general-rules';
import type { Metadata } from 'next';
import { i18n } from '../../../i18n';
export const metadata: Metadata = {
title: i18n.t('rules:meta-title'),
description: i18n.t('rules:meta-description'),
};
/** «قوانین عمومی», the first tab of «قوانین لومینا» on desktop (G-2r): the text in a panel. */
export default function GeneralRulesPage() {
return (
<Card padding="lg">
<GeneralRules
layout="desktop"
labels={generalRulesLabels(i18n.getFixedT(null, 'rules'))}
/>
</Card>
);
}

View File

@ -1,19 +1,18 @@
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
import { Card } from '@lumina/island/molecules/card';
import { i18n } from '../../../../i18n';
/** The terms before they arrive: a few paragraphs' worth of lines. */
/** The terms before they arrive, under the section's title and tabs: their panel of lines. */
export default function Loading() {
return (
<SkeletonRegion
delayed
label={i18n.t('terms:meta-title')}
className="mx-auto w-full max-w-content p-4"
>
<Skeleton width="40%" height="1.25rem" className="mb-3" />
<Skeleton lines={4} />
<Skeleton width="35%" height="1.25rem" className="mt-6 mb-3" />
<Skeleton lines={5} />
<SkeletonRegion delayed label={i18n.t('terms:meta-title')}>
<Card padding="lg">
<Skeleton width="40%" height="1.25rem" className="mb-3" />
<Skeleton lines={4} />
<Skeleton width="35%" height="1.25rem" className="mt-6 mb-3" />
<Skeleton lines={5} />
</Card>
</SkeletonRegion>
);
}

View File

@ -2,9 +2,7 @@
// adds to i18n when this module loads, whichever module Next loads first (0055).
import '../../../../bootstrap/bootstrap.server';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Card } from '@lumina/island/molecules/card';
import { DesktopHeader, DesktopPageTitle } from '@lumina/market/app/navigation';
import {
SubscriptionTerms,
subscriptionTermsLabels,
@ -21,8 +19,8 @@ export const metadata: Metadata = {
};
/**
* «شرایط اشتراک» on desktop (S5 ۲.۱): the text in a panel of the 640 column under the header,
* about 75 characters a line, with back beside the title.
* «شرایط اشتراک», the second tab of «قوانین لومینا» on desktop (S5 ۲.۱, G-2): the text in a panel
* of the section's 640 column, about 75 characters a line; the title and tabs come from the layout.
*/
export default function SubscriptionTermsPage() {
const labels = subscriptionTermsLabels(
@ -32,28 +30,12 @@ export default function SubscriptionTermsPage() {
);
return (
<FlexBox direction="flex-col" className="min-h-dvh bg-bg-page">
<DesktopHeader />
<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={labels.title} />
<Card padding="lg">
<SubscriptionTerms
layout="desktop"
chats={supportChatUrls()}
labels={labels}
/>
</Card>
</FlexBox>
</FlexBox>
</FlexBox>
<Card padding="lg">
<SubscriptionTerms
layout="desktop"
chats={supportChatUrls()}
labels={labels}
/>
</Card>
);
}

View File

@ -49,6 +49,7 @@ export function PostTemplate({
username={channel.username}
channelUrl={channelUrl}
layout="desktop"
saleOpen={channel.saleOpen}
/>
</PartBoundary>
}

View File

@ -1,6 +1,7 @@
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { PartBoundary } from '@lumina/market/app/error-boundaries';
import { ApprovedWelcome } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/approved-welcome';
import { ChannelActions } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-actions';
import { ChannelDeskBack } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-desk-back';
import { ChannelFeed } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-feed/server';
@ -8,6 +9,7 @@ import {
ChannelHeader,
channelHeaderLabels,
} from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-header';
import { PendingChannelGate } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-not-found';
import { ChannelShare } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-share';
import { ChannelStats } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-stats/server';
import { ChannelUnavailable } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-unavailable';
@ -56,6 +58,69 @@ export function ChannelTemplate({
);
}
const publicChannel = (
<>
<ApprovedWelcome creatorId={channel.creatorId} layout="desktop" />
<ChannelHeader
channel={channel}
layout="desktop"
share={
<ChannelShare
creatorId={channel.creatorId}
username={channel.username}
channelUrl={channelUrl}
layout="desktop"
/>
}
stats={
<>
<FollowNotice creatorId={channel.creatorId} />
<PartBoundary
name="channel-stats"
title={t('stats.error-title')}
description={t('stats.error-description')}
framed
>
<Suspense
fallback={
<SkeletonPreset preset="stats" label={t('stats.loading')} />
}
>
<ChannelStats
creatorId={channel.creatorId}
labels={creatorStatsLabels(i18n.getFixedT(null, 'content'))}
/>
</Suspense>
</PartBoundary>
</>
}
actions={
<PartBoundary name="channel-actions">
<ChannelActions
creatorId={channel.creatorId}
username={channel.username}
channelUrl={channelUrl}
layout="desktop"
saleOpen={channel.saleOpen}
inviteNoteName={channel.displayName}
/>
</PartBoundary>
}
labels={channelHeaderLabels(t, i18n.getFixedT(null, 'common'))}
verified={!channel.verificationPending}
/>
<PartBoundary name="channel-feed">
<Suspense
fallback={
<SkeletonPreset preset="post" count={2} label={t('feed.loading')} />
}
>
<ChannelFeed channel={channel} now={now} layout="desktop" />
</Suspense>
</PartBoundary>
</>
);
return (
<FlexBox tag="main" justifyContent="justify-center" className="px-8 py-10">
<FlexBox
@ -64,64 +129,13 @@ export function ChannelTemplate({
className="w-full max-w-content"
>
<ChannelDeskBack creatorId={channel.creatorId} />
<ChannelHeader
channel={channel}
layout="desktop"
share={
<ChannelShare
creatorId={channel.creatorId}
username={channel.username}
channelUrl={channelUrl}
layout="desktop"
/>
}
stats={
<>
<FollowNotice creatorId={channel.creatorId} />
<PartBoundary
name="channel-stats"
title={t('stats.error-title')}
description={t('stats.error-description')}
framed
>
<Suspense
fallback={
<SkeletonPreset preset="stats" label={t('stats.loading')} />
}
>
<ChannelStats
creatorId={channel.creatorId}
labels={creatorStatsLabels(i18n.getFixedT(null, 'content'))}
/>
</Suspense>
</PartBoundary>
</>
}
actions={
<PartBoundary name="channel-actions">
<ChannelActions
creatorId={channel.creatorId}
username={channel.username}
channelUrl={channelUrl}
layout="desktop"
/>
</PartBoundary>
}
labels={channelHeaderLabels(t, i18n.getFixedT(null, 'common'))}
/>
<PartBoundary name="channel-feed">
<Suspense
fallback={
<SkeletonPreset
preset="post"
count={2}
label={t('feed.loading')}
/>
}
>
<ChannelFeed channel={channel} now={now} layout="desktop" />
</Suspense>
</PartBoundary>
{channel.verificationPending ? (
<PendingChannelGate layout="desktop" channelUrl={channelUrl}>
{publicChannel}
</PendingChannelGate>
) : (
publicChannel
)}
</FlexBox>
</FlexBox>
);

View File

@ -26,11 +26,7 @@ export default function SubscriptionsPage() {
);
return (
<PartBoundary
name="subscription-list"
description={i18n.t('dashboard:subscriptions.error')}
framed
>
<PartBoundary name="subscription-list" size="page">
<AuthGuard role="investor" fallback={skeleton}>
<Suspense fallback={skeleton}>
<SubscriptionList layout="desktop" />

View File

@ -26,11 +26,7 @@ export default function TransactionsPage() {
);
return (
<PartBoundary
name="transaction-list"
description={i18n.t('dashboard:transactions.error')}
framed
>
<PartBoundary name="transaction-list" size="page">
<AuthGuard role="investor" fallback={skeleton}>
<Suspense fallback={skeleton}>
<TransactionList layout="desktop" />

View File

@ -9,6 +9,7 @@ export default function Loading() {
return (
<AuthTemplate brandHref={ROUTES.home} framed={false}>
<CreatorProfileStepSkeleton
delayed
layout="desktop"
label={i18n.t('auth:loading')}
/>

View File

@ -8,7 +8,7 @@ import { AuthTemplate } from '../../../../templates/auth-template';
export default function Loading() {
return (
<AuthTemplate brandHref={ROUTES.home}>
<CreatorProfileDoneStepSkeleton label={i18n.t('auth:loading')} />
<CreatorProfileDoneStepSkeleton delayed label={i18n.t('auth:loading')} />
</AuthTemplate>
);
}

View File

@ -8,7 +8,7 @@ import { AuthTemplate } from '../../../templates/auth-template';
export default function Loading() {
return (
<AuthTemplate brandHref={ROUTES.home}>
<InvestorProfileStepSkeleton label={i18n.t('auth:loading')} />
<InvestorProfileStepSkeleton delayed label={i18n.t('auth:loading')} />
</AuthTemplate>
);
}

View File

@ -4,7 +4,13 @@ import { http } from '@lumina/libs/http';
import { captureInstallPrompt, configureServiceWorker } from '@lumina/libs/pwa';
import { mapApiErrorBody } from '@lumina/market/app/http';
import { setEnv as setMarketEnv } from '@lumina/market/env';
import { AUTH_ENDPOINTS, AUTH_EVENTS } from '@lumina/market/features/auth';
import {
AUTH_ENDPOINTS,
AUTH_EVENTS,
endSuspendedSession,
isSessionSuspended,
suspendedSessionOf,
} from '@lumina/market/features/auth';
import { API_PROXY_PATH, API_VERSION_PATH } from '../constants';
import { clientEnv } from '../env';
@ -20,16 +26,27 @@ setMarketEnv({
});
// The browser calls the API on this site's origin, proxied to the gateway (0018). The session
// lives in HttpOnly cookies the browser sends itself. A 401 runs one refresh for the whole app;
// when that fails the session is over and the shell signs the user out.
// when that fails the session is over and the shell signs the user out. A 401 `ACCOUNT_SUSPENDED`
// never refreshes: the account was suspended mid-session, so the session ends and the page halts
// (J01-3d), once, whichever request learns it first.
http.configure({
baseUrl: `${API_PROXY_PATH}${API_VERSION_PATH}`,
refresh: {
endpoint: AUTH_ENDPOINTS.refresh,
onFailure: () =>
eventEmitter.emit(AUTH_EVENTS.logout, { reason: 'session-ended' }),
shouldRefresh: (error) =>
error.status === 401 && suspendedSessionOf(error) === null,
onFailure: () => {
if (isSessionSuspended()) return;
eventEmitter.emit(AUTH_EVENTS.logout, { reason: 'session-ended' });
},
},
mapErrorBody: mapApiErrorBody,
});
http.interceptors.response.use(undefined, (error) => {
const suspension = suspendedSessionOf(error);
if (suspension) endSuspendedSession(suspension);
return error;
});
configureErrorHandler(ERROR_HANDLER_CONFIG);
// The service worker stores only JS, CSS, fonts and the icon sprite (pwa lib); the AppShell
// registers it when this flag is on, and turning the flag off unregisters it for every visitor.

View File

@ -1,4 +1,5 @@
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { ROUTES } from '@lumina/market/app/navigation';
import { i18n } from '../../../../../i18n';
import { AuthTopBar } from '../../../../organisms/auth-top-bar';
@ -8,7 +9,12 @@ import { AuthTemplate } from '../../../../templates/auth-template';
export default function Loading() {
return (
<AuthTemplate
header={<AuthTopBar title={i18n.t('auth:register.header')} />}
header={
<AuthTopBar
title={i18n.t('auth:register.header')}
back={ROUTES.landing}
/>
}
>
<SkeletonPreset
preset="form"

View File

@ -1,5 +1,14 @@
// First: the rules sheet reads a server-only namespace, which the server bootstrap adds to i18n
// when this module loads (0055).
import '../../../../../bootstrap/bootstrap.server';
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { GuestGuard } from '@lumina/market/app/guards/guest-guard';
import { ROUTES } from '@lumina/market/app/navigation';
import {
GeneralRules,
generalRulesLabels,
} from '@lumina/market/app/screens/organisms/general-rules';
import { RegisterDetailsStep } from '@lumina/market/app/screens/(auth)/auth/register/details/organisms/register-details-step';
import type { Metadata } from 'next';
@ -16,7 +25,12 @@ export const metadata: Metadata = {
export default function RegisterDetailsPage() {
return (
<AuthTemplate
header={<AuthTopBar title={i18n.t('auth:register.header')} />}
header={
<AuthTopBar
title={i18n.t('auth:register.header')}
back={ROUTES.landing}
/>
}
>
<GuestGuard
fallback={
@ -31,6 +45,12 @@ export default function RegisterDetailsPage() {
size="lg"
supportPlacement="bottom"
haltPlacement="sheet"
rules={
<GeneralRules
layout="sheet"
labels={generalRulesLabels(i18n.getFixedT(null, 'rules'))}
/>
}
/>
</GuestGuard>
</AuthTemplate>

View File

@ -12,6 +12,7 @@ export default function Loading() {
<MobileTopBar title={i18n.t('payment:checkout.title')} />
<FlexBox tag="main" direction="flex-col" className="flex-1">
<CheckoutSkeleton
delayed
layout="mobile"
creator={<CheckoutCreatorSkeleton />}
label={i18n.t('payment:checkout.loading')}

View File

@ -27,6 +27,8 @@ export function CheckoutTemplate({ channel }: CheckoutTemplateProps) {
channelHref={ROUTES.channel(channel.username)}
layout="mobile"
creator={<CheckoutCreator creator={channel} />}
creatorName={channel.displayName ?? channel.username}
creatorLinks={channel.socialLinks}
/>
</PartBoundary>
</FlexBox>

View File

@ -1,13 +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 { MobileTopBar, ROUTES } from '@lumina/market/app/navigation';
import {
PricingForm,
PricingFormSkeleton,
} from '@lumina/market/app/screens/(flow)/dashboard/pricing/organisms/pricing-form';
import { PricingEditor } from '@lumina/market/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor';
import type { Metadata } from 'next';
import { Suspense } from 'react';
import { i18n } from '../../../../i18n';
@ -19,33 +12,14 @@ export const metadata: Metadata = {
/**
* C7, «ویرایش قیمت‌ها» on mobile: a task page pushed from the «قیمت طرح‌ها» card, back · title ·
* support and no bottom nav (Creator Dashboard ۴.۱; consistency rules R7, R8); opened on its own,
* back goes to طرح‌های اشتراک (R14). The form pads itself and pins its save to the bottom. It is
* the creator's own, so it renders in the browser behind cards of the same size.
* back goes to طرح‌های اشتراک (R14), and with unsaved changes it asks first (J10-4n). The form
* pads itself and pins its save to the bottom. It is the creator's own, so it renders in the
* browser behind cards of the same size.
*/
export default function PricingPage() {
const skeleton = (
<PricingFormSkeleton layout="mobile" label={i18n.t('pricing:loading')} />
);
return (
<FlexBox direction="flex-col" className="min-h-dvh bg-bg-page">
<MobileTopBar
title={i18n.t('pricing:title')}
parentHref={ROUTES.dashboard.plans}
/>
<FlexBox tag="main" direction="flex-col" className="flex-1">
<PartBoundary
name="pricing-form"
description={i18n.t('pricing:error')}
framed
>
<AuthGuard role="creator" fallback={skeleton}>
<Suspense fallback={skeleton}>
<PricingForm layout="mobile" />
</Suspense>
</AuthGuard>
</PartBoundary>
</FlexBox>
<PricingEditor layout="mobile" />
</FlexBox>
);
}

View File

@ -15,6 +15,7 @@ export default function Loading() {
/>
<FlexBox tag="main" direction="flex-col" className="flex-1">
<PaymentResultSkeleton
delayed
layout="mobile"
label={i18n.t('payment:result.loading')}
/>

View File

@ -0,0 +1,47 @@
// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
// adds to i18n when this module loads, whichever module Next loads first (0055).
import '../../../bootstrap/bootstrap.server';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { MobileTopBar } from '@lumina/market/app/navigation';
import { RulesTabs } from '@lumina/market/app/screens/(flow)/terms/organisms/rules-tabs';
import type { Metadata } from 'next';
import type { ReactNode } from 'react';
import { i18n } from '../../../i18n';
export const metadata: Metadata = {
title: i18n.t('rules:meta-title'),
description: i18n.t('rules:meta-description'),
};
/**
* «قوانین لومینا» on mobile (G-2r): a task page pushed from حساب کاربری, checkout, a suspended card
* or the support sheet: back · «قوانین لومینا» · support, no bottom nav, then the tab row
* «قوانین عمومی» · «شرایط اشتراک». Each tab is its own route with its own loading, so the bar and
* the row stay while one loads; back returns to where the rules were opened.
*/
export default function RulesLayout({ children }: { children: ReactNode }) {
const t = i18n.getFixedT(null, 'rules');
return (
<FlexBox direction="flex-col" className="min-h-dvh bg-surface">
<MobileTopBar title={t('title')} />
<RulesTabs
layout="mobile"
labels={{
label: t('tabs.label'),
general: t('tabs.general'),
subscription: t('tabs.subscription'),
}}
/>
<FlexBox
tag="main"
direction="flex-col"
className="flex-1 px-4 pt-4 pb-8"
>
{children}
</FlexBox>
</FlexBox>
);
}

View File

@ -0,0 +1,17 @@
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
import { i18n } from '../../../i18n';
/** «قوانین عمومی» before it arrives, under the section's bar and tabs: a few sections' worth of lines. */
export default function Loading() {
return (
<SkeletonRegion delayed label={i18n.t('rules:meta-title')}>
<Skeleton width="40%" height="1.25rem" className="mb-3" />
<Skeleton lines={3} />
<Skeleton width="35%" height="1.25rem" className="mt-6 mb-3" />
<Skeleton lines={3} />
<Skeleton width="45%" height="1.25rem" className="mt-6 mb-3" />
<Skeleton lines={4} />
</SkeletonRegion>
);
}

View File

@ -1,10 +1,26 @@
import { ROUTES } from '@lumina/market/app/navigation';
import { redirect } from 'next/navigation';
// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
// adds to i18n when this module loads, whichever module Next loads first (0055).
import '../../../bootstrap/bootstrap.server';
/**
* `/terms`, the address the boards give «شرایط اشتراک» (G-2), sends on to the page at its own
* address. Temporary, so `/terms` can become a page of its own later.
*/
export default function TermsPage(): never {
redirect(ROUTES.terms);
import {
GeneralRules,
generalRulesLabels,
} from '@lumina/market/app/screens/organisms/general-rules';
import type { Metadata } from 'next';
import { i18n } from '../../../i18n';
export const metadata: Metadata = {
title: i18n.t('rules:meta-title'),
description: i18n.t('rules:meta-description'),
};
/** «قوانین عمومی», the first tab of «قوانین لومینا» on mobile (G-2r), under the section's bar. */
export default function GeneralRulesPage() {
return (
<GeneralRules
layout="mobile"
labels={generalRulesLabels(i18n.getFixedT(null, 'rules'))}
/>
);
}

View File

@ -2,14 +2,10 @@ import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
import { i18n } from '../../../../i18n';
/** The terms before they arrive: a few paragraphs' worth of lines. */
/** The terms before they arrive, under the section's bar and tabs: a few paragraphs' worth of lines. */
export default function Loading() {
return (
<SkeletonRegion
delayed
label={i18n.t('terms:meta-title')}
className="mx-auto w-full max-w-content p-4"
>
<SkeletonRegion delayed label={i18n.t('terms:meta-title')}>
<Skeleton width="40%" height="1.25rem" className="mb-3" />
<Skeleton lines={4} />
<Skeleton width="35%" height="1.25rem" className="mt-6 mb-3" />

View File

@ -2,8 +2,6 @@
// adds to i18n when this module loads, whichever module Next loads first (0055).
import '../../../../bootstrap/bootstrap.server';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { MobileTopBar } from '@lumina/market/app/navigation';
import {
SubscriptionTerms,
subscriptionTermsLabels,
@ -20,8 +18,9 @@ export const metadata: Metadata = {
};
/**
* «شرایط اشتراک» on mobile (S5 ۱.۱): a task page pushed from checkout, a suspended card or the
* support sheet, back · title · support and no bottom nav; back returns to where it was opened.
* «شرایط اشتراک», the second tab of «قوانین لومینا» on mobile (S5 ۱.۱, G-2): the section's bar and
* tabs come from its layout; back returns to where the rules were opened (checkout, a suspended
* card, the support sheet).
*/
export default function SubscriptionTermsPage() {
const labels = subscriptionTermsLabels(
@ -31,19 +30,10 @@ export default function SubscriptionTermsPage() {
);
return (
<FlexBox direction="flex-col" className="min-h-dvh bg-surface">
<MobileTopBar title={labels.title} />
<FlexBox
tag="main"
direction="flex-col"
className="flex-1 px-4 pt-4 pb-8"
>
<SubscriptionTerms
layout="mobile"
chats={supportChatUrls()}
labels={labels}
/>
</FlexBox>
</FlexBox>
<SubscriptionTerms
layout="mobile"
chats={supportChatUrls()}
labels={labels}
/>
);
}

View File

@ -46,6 +46,7 @@ export function PostTemplate({
username={channel.username}
channelUrl={channelUrl}
layout="mobile"
saleOpen={channel.saleOpen}
/>
</PartBoundary>
}

View File

@ -2,12 +2,14 @@ import { FlexBox } from '@lumina/island/atoms/flex-box';
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { PartBoundary } from '@lumina/market/app/error-boundaries';
import { MobileTopBar } from '@lumina/market/app/navigation';
import { ApprovedWelcome } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/approved-welcome';
import { ChannelActions } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-actions';
import { ChannelFeed } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-feed/server';
import {
ChannelHeader,
channelHeaderLabels,
} from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-header';
import { PendingChannelGate } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-not-found';
import { ChannelShare } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-share';
import { ChannelStats } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-stats/server';
import { ChannelUnavailable } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-unavailable';
@ -52,6 +54,75 @@ export function ChannelTemplate({
);
}
const publicChannel = (
<>
<ApprovedWelcome creatorId={channel.creatorId} layout="mobile" />
<ChannelHeader
channel={channel}
layout="mobile"
share={
<ChannelShare
creatorId={channel.creatorId}
username={channel.username}
channelUrl={channelUrl}
layout="mobile"
/>
}
stats={
<>
<FollowNotice creatorId={channel.creatorId} />
<PartBoundary
name="channel-stats"
title={t('stats.error-title')}
description={t('stats.error-description')}
framed
>
<Suspense
fallback={
<SkeletonPreset preset="stats" label={t('stats.loading')} />
}
>
<ChannelStats
creatorId={channel.creatorId}
labels={creatorStatsLabels(i18n.getFixedT(null, 'content'))}
/>
</Suspense>
</PartBoundary>
</>
}
actions={
<PartBoundary name="channel-actions">
<ChannelActions
creatorId={channel.creatorId}
username={channel.username}
channelUrl={channelUrl}
layout="mobile"
saleOpen={channel.saleOpen}
inviteNoteName={channel.displayName}
/>
</PartBoundary>
}
labels={channelHeaderLabels(t, i18n.getFixedT(null, 'common'))}
verified={!channel.verificationPending}
/>
<FlexBox direction="flex-col" className="p-4">
<PartBoundary name="channel-feed">
<Suspense
fallback={
<SkeletonPreset
preset="post"
count={2}
label={t('feed.loading')}
/>
}
>
<ChannelFeed channel={channel} now={now} layout="mobile" />
</Suspense>
</PartBoundary>
</FlexBox>
</>
);
return (
<>
<MobileTopBar
@ -59,66 +130,13 @@ export function ChannelTemplate({
tabOwnerId={channel.creatorId}
/>
<FlexBox tag="main" direction="flex-col" className="flex-1">
<ChannelHeader
channel={channel}
layout="mobile"
share={
<ChannelShare
creatorId={channel.creatorId}
username={channel.username}
channelUrl={channelUrl}
layout="mobile"
/>
}
stats={
<>
<FollowNotice creatorId={channel.creatorId} />
<PartBoundary
name="channel-stats"
title={t('stats.error-title')}
description={t('stats.error-description')}
framed
>
<Suspense
fallback={
<SkeletonPreset preset="stats" label={t('stats.loading')} />
}
>
<ChannelStats
creatorId={channel.creatorId}
labels={creatorStatsLabels(i18n.getFixedT(null, 'content'))}
/>
</Suspense>
</PartBoundary>
</>
}
actions={
<PartBoundary name="channel-actions">
<ChannelActions
creatorId={channel.creatorId}
username={channel.username}
channelUrl={channelUrl}
layout="mobile"
/>
</PartBoundary>
}
labels={channelHeaderLabels(t, i18n.getFixedT(null, 'common'))}
/>
<FlexBox direction="flex-col" className="p-4">
<PartBoundary name="channel-feed">
<Suspense
fallback={
<SkeletonPreset
preset="post"
count={2}
label={t('feed.loading')}
/>
}
>
<ChannelFeed channel={channel} now={now} layout="mobile" />
</Suspense>
</PartBoundary>
</FlexBox>
{channel.verificationPending ? (
<PendingChannelGate layout="mobile" channelUrl={channelUrl}>
{publicChannel}
</PendingChannelGate>
) : (
publicChannel
)}
</FlexBox>
</>
);

View File

@ -26,11 +26,7 @@ export default function SubscriptionsPage() {
);
return (
<PartBoundary
name="subscription-list"
description={i18n.t('dashboard:subscriptions.error')}
framed
>
<PartBoundary name="subscription-list" size="page">
<AuthGuard role="investor" fallback={skeleton}>
<Suspense fallback={skeleton}>
<SubscriptionList layout="mobile" />

View File

@ -26,11 +26,7 @@ export default function TransactionsPage() {
);
return (
<PartBoundary
name="transaction-list"
description={i18n.t('dashboard:transactions.error')}
framed
>
<PartBoundary name="transaction-list" size="page">
<AuthGuard role="investor" fallback={skeleton}>
<Suspense fallback={skeleton}>
<TransactionList layout="mobile" />

View File

@ -11,6 +11,7 @@ export default function Loading() {
header={<AuthTopBar title={i18n.t('auth:register.header')} />}
>
<CreatorProfileStepSkeleton
delayed
layout="mobile"
label={i18n.t('auth:loading')}
/>

View File

@ -9,7 +9,7 @@ import { AuthTemplate } from '../../../../templates/auth-template';
export default function Loading() {
return (
<AuthTemplate header={<AuthTopBar brandHref={ROUTES.home} />}>
<CreatorProfileDoneStepSkeleton label={i18n.t('auth:loading')} />
<CreatorProfileDoneStepSkeleton delayed label={i18n.t('auth:loading')} />
</AuthTemplate>
);
}

View File

@ -10,7 +10,7 @@ export default function Loading() {
<AuthTemplate
header={<AuthTopBar title={i18n.t('auth:register.header')} />}
>
<InvestorProfileStepSkeleton label={i18n.t('auth:loading')} />
<InvestorProfileStepSkeleton delayed label={i18n.t('auth:loading')} />
</AuthTemplate>
);
}

View File

@ -4,7 +4,13 @@ import { http } from '@lumina/libs/http';
import { captureInstallPrompt, configureServiceWorker } from '@lumina/libs/pwa';
import { mapApiErrorBody } from '@lumina/market/app/http';
import { setEnv as setMarketEnv } from '@lumina/market/env';
import { AUTH_ENDPOINTS, AUTH_EVENTS } from '@lumina/market/features/auth';
import {
AUTH_ENDPOINTS,
AUTH_EVENTS,
endSuspendedSession,
isSessionSuspended,
suspendedSessionOf,
} from '@lumina/market/features/auth';
import { API_PROXY_PATH, API_VERSION_PATH } from '../constants';
import { clientEnv } from '../env';
@ -20,16 +26,27 @@ setMarketEnv({
});
// The browser calls the API on this site's origin, proxied to the gateway (0018). The session
// lives in HttpOnly cookies the browser sends itself. A 401 runs one refresh for the whole app;
// when that fails the session is over and the shell signs the user out.
// when that fails the session is over and the shell signs the user out. A 401 `ACCOUNT_SUSPENDED`
// never refreshes: the account was suspended mid-session, so the session ends and the page halts
// (J01-3d), once, whichever request learns it first.
http.configure({
baseUrl: `${API_PROXY_PATH}${API_VERSION_PATH}`,
refresh: {
endpoint: AUTH_ENDPOINTS.refresh,
onFailure: () =>
eventEmitter.emit(AUTH_EVENTS.logout, { reason: 'session-ended' }),
shouldRefresh: (error) =>
error.status === 401 && suspendedSessionOf(error) === null,
onFailure: () => {
if (isSessionSuspended()) return;
eventEmitter.emit(AUTH_EVENTS.logout, { reason: 'session-ended' });
},
},
mapErrorBody: mapApiErrorBody,
});
http.interceptors.response.use(undefined, (error) => {
const suspension = suspendedSessionOf(error);
if (suspension) endSuspendedSession(suspension);
return error;
});
configureErrorHandler(ERROR_HANDLER_CONFIG);
// The service worker stores only JS, CSS, fonts and the icon sprite (pwa lib); the AppShell
// registers it when this flag is on, and turning the flag off unregisters it for every visitor.

View File

@ -1,6 +1,6 @@
# 0032 The notification centre is a page on mobile and a panel on desktop
Status: Proposed · Area: architecture · Date: 2026-10-08 · Decided by: agent
Status: Superseded by 0058 · Area: architecture · Date: 2026-10-08 · Decided by: agent
## Context

View File

@ -8,7 +8,7 @@ C7 ۶.۲ removes «ذخیره قیمت‌گذاری» during the lock while prom
## Decision
During the lock, standing prices and period switches are read-only (50%), promotions stay editable, and the save button stays, so promotion changes go through the same check and confirmation as any save.
During the lock, standing prices and period switches are read-only (50%), promotions stay editable, and the save button stays as «ذخیره تخفیف», so promotion changes go through the promotion check and confirmation (J10-4m).
## Alternatives

View File

@ -1,6 +1,6 @@
# 0044 An invite link's code is kept per creator in the checkout draft
Status: Proposed · Area: architecture · Date: 2026-10-09 · Decided by: agent
Status: Superseded by 0059 · Area: architecture · Date: 2026-10-09 · Decided by: agent
## Context
Creators share `/@username?code=…` (J10-2). The code must survive a guest's login and reach that creator's checkout (J06-1b/1c, 2n/2o). 0030 keeps checkout state out of the URL.

View File

@ -1,6 +1,6 @@
# 0048 Composers check publish standing and publish idempotently
Status: Proposed · Area: architecture · Date: 2026-10-09 · Decided by: agent
Status: Superseded by 0060 · Area: architecture · Date: 2026-10-09 · Decided by: agent
## Context
A pending, rejected or suspended creator could open a composer by URL and fail only on publish. A retried publish could duplicate a post.

View File

@ -0,0 +1,18 @@
# 0058 Opening notifications clears the bell; a row is read when tapped
Status: Accepted · Area: architecture · Date: 2026-10-10 · Decided by: user · Supersedes: 0032
## Context
The new canvas (J07-5h, A9) keeps an unread dot on each row until it is tapped, while opening the list clears the bell count. 0032 marked everything read on open.
## Decision
- `ROUTES.notifications` (`/notifications`) is a `(main)` page in both apps; bull's bell links there, bear's header bell opens the 400px side panel, loaded on the first click; a direct visit renders the page.
- Opening the list records "seen" (`POST /v1/notifications/seen`), which zeroes the bell count. A row stays unread, with its dot, until it is tapped (`POST /v1/notifications/:id/read`).
- Creators get one list with filter chips «همه · پیش‌بینی‌ها · مالی · حساب» that filter in place; categories come from the notification type.
- The bell shows for a member of either role on every tab bar and the desktop header.
## Alternatives
- Mark all read on open (0032): loses which rows the person never looked at.
## Consequences
The API keeps `seenAt` per user beside each row's `readAt`.

View File

@ -0,0 +1,17 @@
# 0059 Checkout takes an invite code from its link once, then forgets the URL
Status: Accepted · Area: architecture · Date: 2026-10-10 · Decided by: user · Supersedes: 0044
## Context
J06-7: the capacity-opened alert and SMS open `/checkout/@user?code=…` with the investor's code applied. 0044 kept the code out of checkout's URL.
## Decision
- The channel reads `?code=` and checkout reads `?code=` on arrival. Either one saves it in the persisted `session.checkout-draft` store under `inviteCodes[creatorId]`, written only after the draft is restored.
- Checkout then removes `code` from the address bar with `router.replace`, fills the field, marks it as from the link and checks it.
- The code is dropped after a paid subscription to that creator or on sign-out.
## Alternatives
- Link the alert to the channel (0044): one extra tap before paying while capacity lasts.
## Consequences
A shared checkout link carries a code only until it is opened.

View File

@ -0,0 +1,16 @@
# 0060 An analyst who can't publish sees the reason on their own channel
Status: Accepted · Area: architecture · Date: 2026-10-10 · Decided by: user · Supersedes: 0048
## Context
J09-1e draws «پیش‌بینی جدید» for a pending, rejected or suspended analyst as the locked dialog over their own channel. 0048 rendered a locked page on `/compose/*`.
## Decision
- `/compose/post` and `/compose/prediction` read the creator's standing in the browser; when publishing is blocked they replace the route with the creator's own channel and open the locked dialog there (`?locked=post|prediction`, removed once shown). A 403 on publish re-reads the standing and does the same.
- Every publish sends an `Idempotency-Key` that stays the same while the body is unchanged and is renewed after any change or `IDEMPOTENCY_KEY_REUSED`.
## Alternatives
- A locked page on the composer route (0048): a second place for the same message.
## Consequences
Published predictions can't be edited or deleted (API `PREDICTION_LOCKED`).

View File

@ -21,6 +21,9 @@
- 0054 Set `htmlLimitedBots: /.*/` in both apps' `next.config.ts`, so every visitor gets metadata in `<head>`.
- 0055 Export static `metadata` from every layout and page; only the channel and post pages use `generateMetadata`, through the page's cached read.
- 0057 Back links to `parentHref` and traverses history only when that is the previous entry; `backToPrevious` pages (and pages without `parentHref`) accept any previous page.
- 0058 Opening notifications records "seen" and clears the bell; a row stays unread until tapped; creators filter one list by «همه · پیش‌بینی‌ها · مالی · حساب».
- 0059 Checkout and the channel save `?code=` into the per-creator checkout draft on arrival; checkout then strips it from the URL.
- 0060 Composers send a creator who can't publish to their own channel with the locked dialog; every publish carries a stable `Idempotency-Key`.
## Proposed
@ -40,21 +43,18 @@
- 0029 architecture: End every payment on `/payment/result/[paymentId]`; the API's bank callback returns to `/payment/return`, which polls the payment until settled (30 s at most) and replaces itself.
- 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.
- 0032 architecture: Serve the notification centre at `/notifications` on mobile and as a lazily loaded side panel from bear's header bell; opening it marks all read.
- 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.
- 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: Keep «ذخیره قیمت‌گذاری» live during the 7-day lock so promotion changes save; standing prices and period switches stay read-only.
- 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.
- 0039 design: Place toasts above whatever draws the bottom edge, declared by that part (nav 80, pinned footer 152, desktop 32, low in sheets).
- 0040 architecture: Render the connection bar under the sticky bars, inside their sticky box, never above or over content.
- 0041 architecture: Confirm sign-out, call `auth.logout`, then reload to the landing.
- 0042 architecture: When a session ends mid-use, show the session-ended state and keep drafts; only an explicit sign-out clears drafts and `session.*` keys.
- 0043 architecture: Freeze every network action offline with island `useOfflineFreeze`, showing the reason.
- 0044 architecture: Keep an invite link's `?code=` per creator in the persisted checkout draft, applied by that creator's checkout; never put it in checkout's URL.
- 0045 architecture: The channel's server read carries the public follower count; the browser keeps it live and shows «مشترک فعال» only to the owner.
- 0046 architecture: Serve `/account/profile` in `(flow)` for both roles, switching investor form and creator profile edit in the browser.
- 0047 architecture: The pwa lib keeps the browser's install offer; offer install at `/account/install` and once on bull's خانه with a 30-day snooze; the manifest starts at `/feed`.
- 0048 architecture: Composer routes check publish standing and render the locked state; every publish sends an Idempotency-Key stable while the body is unchanged.
- 0049 design: A page error keeps the page's own bar, derived from the path; route groups without a frame pass `standalone`.
- 0050 design: A post being read shows an info toast when the reader's access ends mid-read (J05-4f), the one toast not tied to the reader's own action.

View File

@ -5,6 +5,7 @@ import { useId, useState } from 'react';
import { Button } from '../../atoms/button';
import { FlexBox } from '../../atoms/flex-box';
import { Icon } from '../../atoms/icon';
import { LinkButton } from '../../atoms/link-button';
import { Typography } from '../../atoms/typography';
import { Element } from '../../primitives/element';
import { cn } from '../../tools/cn';
@ -16,8 +17,9 @@ import { codeInputButtonVariants } from './variants';
/**
* An invite code with its own «ثبت» (DS CodeInput): left to right, the button checks the code and
* so does Enter, which never submits the outer form. Checking locks the field with a spinner;
* a valid code turns green and read-only, and the button becomes «تغییر». The status and every
* text come from the caller.
* a valid code turns green and read-only, and the button becomes «تغییر». Given `onNoCode`, the
* message row ends with «کد ندارم» while the code can still change. The status and every text come
* from the caller.
*/
export function CodeInput({
label,
@ -30,6 +32,7 @@ export function CodeInput({
onCheck,
onEdit,
onBlur,
onNoCode,
hint,
message,
placeholder,
@ -58,6 +61,13 @@ export function CodeInput({
? hint
: labels[status]);
const showsNoCode =
onNoCode !== undefined &&
labels.noCode != null &&
!isValid &&
!isChecking &&
!isLocked;
const check = () => {
if (!isFixed && !frozen && code !== '') onCheck(code);
};
@ -147,16 +157,37 @@ export function CodeInput({
)
)}
</FlexBox>
{shown != null && (
<Typography
tag="span"
variant="caption"
id={messageId}
role={isError ? 'alert' : status !== 'idle' ? 'status' : undefined}
color={isError ? 'danger' : isValid ? 'success' : 'secondary'}
{(shown != null || showsNoCode) && (
<FlexBox
alignItems="items-start"
justifyContent="justify-between"
gap="gap-3"
>
{shown}
</Typography>
{shown != null ? (
<Typography
tag="span"
variant="caption"
id={messageId}
role={
isError ? 'alert' : status !== 'idle' ? 'status' : undefined
}
color={isError ? 'danger' : isValid ? 'success' : 'secondary'}
>
{shown}
</Typography>
) : (
<Element tag="span" />
)}
{showsNoCode && (
<LinkButton
aria-haspopup="dialog"
onClick={onNoCode}
className="flex-none text-caption"
>
{labels.noCode}
</LinkButton>
)}
</FlexBox>
)}
</FlexBox>
);

View File

@ -33,6 +33,8 @@ export type CodeInputLabels = {
error?: ReactNode;
/** Why a locked code can't change. */
locked?: ReactNode;
/** The link at the end of the message row that helps without a code: «کد ندارم». */
noCode?: ReactNode;
};
export type CodeInputProps = {
@ -51,6 +53,11 @@ export type CodeInputProps = {
onEdit?: () => void;
/** Leaving the field, with the trimmed code, such as for a quiet check. */
onBlur?: (code: string) => void;
/**
* «کد ندارم» (`labels.noCode`) at the end of the message row, opening help as a dialog; shown
* while the code isn't valid, checking or locked. Leave it out for no link.
*/
onNoCode?: () => void;
/** Under the field while idle. */
hint?: ReactNode;
/** Replaces the status's text. */

View File

@ -12,8 +12,8 @@ import { listRowIconVariants, listRowVariants } from './variants';
/**
* One row of a List (DS ListRow): a lead (avatar or a 40px icon tile), the title with an optional
* subtitle and meta, an end column (an Amount, a StatusBadge, a caption) and a chevron for a link.
* With `href` the whole row is a link, with `onClick` a button (such as one that opens a detail
* sheet), otherwise a plain row. Renders its own `li`, so it always sits in a List. Every text
* With `href` the whole row is a link (`external`: to another site, in a new tab), with `onClick` a
* button (such as one that opens a detail sheet), otherwise a plain row. Renders its own `li`, so it always sits in a List. Every text
* comes from the caller.
*/
export function ListRow(props: ListRowProps) {
@ -134,7 +134,21 @@ export function ListRow(props: ListRowProps) {
);
let row;
if (props.href !== undefined && !disabled) {
if (props.href !== undefined && !disabled && props.external) {
row = (
<FlexBox
tag="a"
href={props.href}
target="_blank"
rel="noopener noreferrer"
onClick={props.onClick}
{...layout}
className={classes}
>
{content}
</FlexBox>
);
} else if (props.href !== undefined && !disabled) {
row = (
<FlexBox
tag={NextLink}

View File

@ -64,12 +64,18 @@ type ListRowBaseProps = {
/** A link row: the whole row goes to `href`. */
export type ListRowAsLinkProps = ListRowBaseProps & {
href: string;
/**
* Another site, such as a creator's channel link: a plain `<a>` that opens in a new tab, with no
* opener or referrer, instead of the app's client navigation.
*/
external?: boolean;
onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
};
/** A button row, such as one that opens a detail sheet; a plain row when `onClick` is absent too. */
export type ListRowAsButtonProps = ListRowBaseProps & {
href?: undefined;
external?: undefined;
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
};

View File

@ -87,6 +87,7 @@ export function PostCard(props: PostCardProps) {
now={now}
premium={premium}
onClosePrediction={owner?.onClosePrediction}
pendingClose={owner?.pendingClose}
predictionLabels={predictionLabels}
labels={labels}
/>

View File

@ -21,6 +21,7 @@ export function PostContent({
now,
premium,
onClosePrediction,
pendingClose,
predictionLabels,
labels,
}: PostContentProps) {
@ -61,6 +62,7 @@ export function PostContent({
publishedAt={publishedAt}
now={now}
onClosePrediction={onClosePrediction}
pendingClose={pendingClose}
labels={predictionLabels}
className={EMBEDDED_PREDICTION_CLASS}
/>

View File

@ -39,6 +39,11 @@ export type PostCardOwner = {
onPreview?: () => void;
/** The embedded open prediction's «بستن پیش‌بینی». */
onClosePrediction?: () => void;
/**
* The embedded open prediction's close waiting for ops (J09-5): PredictionCard's `pendingClose`
* detail, which freezes «بستن پیش‌بینی».
*/
pendingClose?: ReactNode;
/** 15 minutes after publishing: the edit icon stays, frozen, and explains itself. */
editFrozen?: boolean;
/** Replaces `labels.owner.editFrozen` as the frozen edit's reason. */
@ -240,6 +245,7 @@ export type PostContentProps = Pick<
variant: 'compact' | 'expanded';
premium: boolean;
onClosePrediction?: () => void;
pendingClose?: ReactNode;
};
export type PostLockedProps = Pick<

View File

@ -28,6 +28,7 @@ export function PredictionCard(props: PredictionCardProps) {
publishedAt,
now,
onClosePrediction,
pendingClose,
preview = false,
labels,
className,
@ -65,6 +66,7 @@ export function PredictionCard(props: PredictionCardProps) {
) : (
<PredictionBody
prediction={props.prediction}
pendingClose={preview ? undefined : pendingClose}
href={href}
expanded={expanded}
premium={showPremium}
@ -84,6 +86,10 @@ export function PredictionCard(props: PredictionCardProps) {
variant="secondary"
icon="flag"
onClick={onClosePrediction}
// An automatic close is waiting for ops (J10-3f).
frozen={pendingClose != null}
frozenReason={labels.closeFrozen}
frozenAlign="end"
// Above a PostCard's stretched link.
className="relative ms-auto"
>

View File

@ -0,0 +1,27 @@
import { FlexBox } from '../../../atoms/flex-box';
import { Icon } from '../../../atoms/icon';
import { Typography } from '../../../atoms/typography';
import type { PendingCloseRowProps } from '../types';
/**
* The owner's open card whose automatic close waits for ops (J09-5, J10-3f): a warning row under
* the head, a clock, «در انتظار تأیید بسته‌شدن» in bold, then what triggered it, at what price and
* when. Investors see the card as open until ops confirm.
*/
export function PendingCloseRow({ title, children }: PendingCloseRowProps) {
return (
<FlexBox
alignItems="items-start"
className="gap-1.5 rounded-md bg-warning-subtle px-2.5 py-2 text-warning-text"
>
<Icon name="clock" size={16} className="mt-0.5 flex-none" />
<Typography tag="p" variant="caption" color="inherit">
<Typography tag="strong" variant="inherit" className="font-semibold">
{title}
</Typography>
{' · '}
{children}
</Typography>
</FlexBox>
);
}

View File

@ -15,11 +15,13 @@ import { PredictionHead } from './PredictionHead';
import { PredictionLadder } from './PredictionLadder';
import { PredictionLevels } from './PredictionLevels';
import { PredictionMeta } from './PredictionMeta';
import { PendingCloseRow } from './PendingCloseRow';
import { PredictionRange } from './PredictionRange';
/** Header, hero, range bar, then the levels (compact) or the ladder, progress and caption (expanded). */
export function PredictionBody({
prediction: data,
pendingClose,
href,
expanded,
premium,
@ -74,6 +76,11 @@ export function PredictionBody({
/>
}
/>
{isOpen && pendingClose != null && labels.pendingClose != null && (
<PendingCloseRow title={labels.pendingClose}>
{pendingClose}
</PendingCloseRow>
)}
{!isOpen && math.roi != null ? (
<ClosedHero
{...part}

View File

@ -138,6 +138,13 @@ export type PredictionCardLabels = {
immutable: ReactNode;
/** The owner's «بستن زودهنگام». */
closePrediction?: ReactNode;
/** The owner's pending-close row title, in bold: «در انتظار تأیید بسته‌شدن» (J09-5). */
pendingClose?: ReactNode;
/**
* Why «بستن زودهنگام» is frozen while a close waits for ops: «این پیش‌بینی به‌زودی به‌صورت خودکار
* بسته می‌شود.» (J10-3f).
*/
closeFrozen?: ReactNode;
/**
* A closed card's reason row: «علت: رسیدن به هدف | منبع قیمت: TGJU». Without it the row never
* shows, even when the prediction has a reason or a source.
@ -199,6 +206,12 @@ type PredictionCardOwnProps = {
* in a preview.
*/
onClosePrediction?: () => void;
/**
* The owner's open card whose automatic close waits for ops (J09-5, J10-3f): the detail after
* `labels.pendingClose`, such as «هدف ۱ زده شد · ۲٬۶۰۰ · ۱۰ مهر، ۰۷:۴۲», in a warning row under
* the head; «بستن زودهنگام» is frozen with `labels.closeFrozen`. Never pass it to anyone else.
*/
pendingClose?: ReactNode;
/**
* The composer's confirm step (J09-3): the seal says «پیش‌نمایش | پس از انتشار، غیرقابل ویرایش و
* حذف» instead of the publish time. Pass the time it would publish (now) as `publishedAt`.
@ -360,8 +373,17 @@ export type LockedBodyProps = {
labels: PredictionCardLabels;
};
export type PendingCloseRowProps = {
/** «در انتظار تأیید بسته‌شدن». */
title: ReactNode;
/** What triggered it, at what price and when. */
children: ReactNode;
};
export type PredictionBodyProps = {
prediction: PredictionData;
/** The owner's pending close detail, on an open card only. */
pendingClose?: ReactNode;
href?: string;
expanded: boolean;
/** Already false when embedded. */

View File

@ -39,7 +39,8 @@ function displayDate(value: ReactNode): ReactNode {
* card, so a status always looks and acts the same. The status picks the badge and the action,
* the days left pick the time line. An active card with `href` opens the channel through its
* name, stretched over the card, while «تمدید» keeps its own tap. A suspended card dims all but
* support and terms, and does nothing on tap.
* support and terms, and does nothing on tap. In the history, only the latest expired row with each
* analyst offers «فعال‌سازی مجدد»; older rows link to the channel.
*/
export function SubscriptionCard({
status,
@ -52,6 +53,7 @@ export function SubscriptionCard({
daysLeft,
analystSuspended = false,
density = 'full',
latest = false,
href,
onRenew,
onReactivate,
@ -267,6 +269,13 @@ export function SubscriptionCard({
</Button>
</Element>
)}
{isCompact && latest && status === 'expired' && !analystSuspended && (
<Element className="mt-3">
<Button variant="secondary" size="sm" block onClick={onReactivate}>
{labels.reactivate}
</Button>
</Element>
)}
{/* The refund right has no deadline, so support outlives the subscription. */}
{status === 'expired' && analystSuspended && (

View File

@ -85,6 +85,12 @@ export type SubscriptionCardProps = {
analystSuspended?: boolean;
/** `compact`: the history and secondary row, header only, with the date range under the name. */
density?: 'full' | 'compact';
/**
* Compact and expired: the latest period with this analyst, so it offers «فعال‌سازی مجدد» (a
* small secondary button); older rows only link to the channel. Not while the analyst is
* suspended.
*/
latest?: boolean;
/** The analyst's channel: links the name, and makes an active card open it (not a suspended one). */
href?: string;
/** Active: «تمدید», which opens the renewal sheet. */

View File

@ -11,12 +11,14 @@ import { NetworkBoundary } from './components/NetworkBoundary';
import { usePwa } from './hooks/use-pwa';
import { useSession } from './hooks/use-session';
import { useSettleAbandonedPayment } from './hooks/use-settle-abandoned-payment';
import { useSuspendedHalt } from './hooks/use-suspended-halt';
import type { AppShellProps } from './types';
/**
* The provider shell shared by bull and bear: the query client, i18n, the connection bar (drawn
* under each page's top bar or header by `NetworkBar`), the one toast region, and the viewer's
* session (read once per load in the browser). The app's root client component renders it after
* session (read once per load in the browser), which halts on the suspended screen when the
* account is suspended mid-session (J01-3d). The app's root client component renders it after
* running the client bootstrap.
*
* The toasts sit above whatever the screen declares with island's `useToastPlacement`: the bottom
@ -25,6 +27,7 @@ import type { AppShellProps } from './types';
*/
export function AppShell({ queryClient, i18n, children }: AppShellProps) {
useSession(queryClient);
useSuspendedHalt();
useSettleAbandonedPayment(queryClient);
usePwa();
// Persisted stores wait for the first browser render, so it matches the server's.

View File

@ -14,8 +14,8 @@ import { usePostDraftStore } from '../../../stores/post-draft';
* skeleton until then. A read that failed offline or on a gateway error leaves the viewer unknown,
* so it runs again when the connection comes back. When the session ends (sign-out, or a refresh
* that failed), the store goes back to guest and every cached query is dropped: it belonged to the
* old account. A sign-out also drops what the account kept on the device (`session.` keys); a
* session that ran out keeps its drafts for the next sign-in.
* old account. A sign-out, or a suspension mid-session (J01-3d), also drops what the account kept
* on the device (`session.` keys); a session that ran out keeps its drafts for the next sign-in.
*/
export function useSession(queryClient: QueryClient): void {
useEffect(() => {
@ -33,7 +33,7 @@ export function useSession(queryClient: QueryClient): void {
queryClient.clear();
// A session that ran out keeps the drafts: the person signs in again and carries on (G-4f).
if (reason === 'session-ended') return;
// Signing out takes the account's own drafts and choices off the device. The stores go
// Signing out (or a suspension) takes the account's own drafts and choices off the device. The stores go
// first: a persisted store writes its key again on every change.
usePostDraftStore.getState().clearDraft();
useCheckoutDraftStore.getState().clearDraft();

View File

@ -0,0 +1,22 @@
import { eventEmitter } from '@lumina/libs/event-emitter';
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
import { AUTH_EVENTS } from '../../../features/auth';
import { ROUTES } from '../../navigation';
/**
* A session that ends because the account was suspended while in use (J01-3d) replaces the page
* with the halt: the suspended screen, with the brand bar and support only, no nav, no back and no
* bell. `useSession` has already cleared the session, the cached reads and the drafts.
*/
export function useSuspendedHalt(): void {
const router = useRouter();
useEffect(
() =>
eventEmitter.on(AUTH_EVENTS.logout, ({ reason }) => {
if (reason === 'suspended') router.replace(ROUTES.loginSuspended);
}),
[router],
);
}

View File

@ -34,6 +34,7 @@ export function ErrorFallback({
title,
description,
framed = false,
stateSize = 'section',
children,
}: ErrorFallbackProps) {
const { t } = useTranslation('errors');
@ -82,7 +83,7 @@ export function ErrorFallback({
return frame(
<ErrorState
kind={kind}
size={size === 'part' ? 'section' : 'page'}
size={size === 'part' ? stateSize : 'page'}
headingRef={headingRef}
title={own.title ?? t(`fallback.${kind}.title`)}
description={own.description ?? t(`fallback.${kind}.description`)}

View File

@ -27,6 +27,12 @@ export type ErrorFallbackProps = {
description?: string;
/** Sits in a Card, where the board draws the part's error as a card (S3-03, U8 ۴.۵). */
framed?: boolean;
/**
* A part whose board draws its error page-size, such as a dashboard tab's list (J07-1, J07-3):
* the ErrorState is `size="page"`, while the part still reports as a part and keeps focus where
* it is. `section` by default.
*/
stateSize?: 'section' | 'page';
/** The way out after retry: «بازگشت به خانه», or «تماس با پشتیبانی» after a second failure. */
children?: ReactNode;
};

View File

@ -8,7 +8,7 @@ import { ErrorFallback } from '../error-fallback';
import type { PartBoundaryProps } from './types';
function PartFallback(
{ name, title, description, framed }: PartBoundaryProps,
{ name, title, description, framed, size }: PartBoundaryProps,
{ error, retry, reset }: ErrorInfo,
) {
const queryErrors = useQueryErrorResetBoundary();
@ -24,6 +24,7 @@ function PartFallback(
title={title}
description={description}
framed={framed}
stateSize={size}
onRetry={() => {
queryErrors.reset();
if (isServerError) retry();

View File

@ -9,4 +9,9 @@ export type PartBoundaryProps = {
description?: string;
/** The fallback sits in a Card, where the board draws the part's error as a card (S3-03). */
framed?: boolean;
/**
* `page`: the board draws this part's error page-size, such as a dashboard tab's list (J07-1,
* J07-3). `section` by default.
*/
size?: 'section' | 'page';
};

View File

@ -4,6 +4,7 @@ import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
import { useCurrentAccount, useViewerStatus } from '../../../stores/auth';
import { useAuthFlowStore } from '../../../stores/auth-flow';
import { StatusEmptyState } from '../../error-boundaries';
import { loginRoute } from '../../navigation';
import { SessionEnded } from './components/SessionEnded';
@ -24,12 +25,16 @@ export function AuthGuard({ fallback, role, children }: AuthGuardProps) {
const router = useRouter();
const endedHere = useSessionEnded(status);
const showsEnded = status === 'guest' && endedHere !== null;
// A suspension mid-session goes to the halt screen (J01-3d), not to login.
const isHalted = useAuthFlowStore(
(state) => state.suspension?.midSession === true,
);
useEffect(() => {
if (status !== 'guest' || showsEnded) return;
if (status !== 'guest' || showsEnded || isHalted) return;
const { pathname, search } = window.location;
router.replace(loginRoute(`${pathname}${search}`));
}, [status, showsEnded, router]);
}, [status, showsEnded, isHalted, router]);
if (showsEnded) return <SessionEnded returnTo={endedHere} />;
if (status !== 'member' || !account) return fallback;

View File

@ -9,6 +9,7 @@ import type { ActionMenuItem } from '@lumina/island/molecules/action-menu';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { PAYOUT_ACCOUNT_ANCHOR } from '../../../../features/finance';
import { SignOutConfirm } from '../../../screens/organisms/sign-out-confirm';
import { useIsStandalone } from '../../hooks/use-is-standalone';
import { ROUTES } from '../../navigation';
@ -17,7 +18,7 @@ import type { AccountMenuProps } from './types';
/**
* The desktop header's avatar (J12-1c): it opens the account menu under it. Its header says whose
* account it is (the avatar, the member's own name and `@username`), then حساب کاربری, اطلاعات
* کاربری, تنظیمات اعلان‌ها and نصب اپلیکیشن (hidden in the installed app), and after a separator
* کاربری, a creator's «اطلاعات تسویه‌حساب» (J12-1e, the شبا on مالی), تنظیمات اعلان‌ها and نصب اپلیکیشن (hidden in the installed app), and after a separator
* «خروج از حساب» in red, which asks first (J12-1d). Mobile links the avatar to حساب کاربری instead.
*/
export function AccountMenu({ account }: AccountMenuProps) {
@ -40,6 +41,15 @@ export function AccountMenu({ account }: AccountMenuProps) {
icon: 'edit',
label: t('account-menu.profile'),
},
...(account.role === 'creator'
? [
{
href: `${ROUTES.dashboard.finance}#${PAYOUT_ACCOUNT_ANCHOR}`,
icon: 'wallet',
label: t('account-menu.payout'),
} as const,
]
: []),
{
href: ROUTES.account.notifications,
icon: 'bell',

View File

@ -1,3 +1,5 @@
import type { UserRole } from '../../../../features/auth';
export type AccountMenuProps = {
/** The signed-in member's account. */
account: {
@ -5,5 +7,7 @@ export type AccountMenuProps = {
firstName: string;
lastName: string;
avatarUrl: string | null;
/** A creator's menu adds «اطلاعات تسویه‌حساب» (J12-1e). */
role: UserRole;
};
};

View File

@ -4,11 +4,13 @@ import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { ActionMenu } from '@lumina/island/molecules/action-menu';
import { Element } from '@lumina/island/primitives/element';
import { useState } from 'react';
import { useRouter, useSearchParams } from 'next/navigation';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useCreatorStanding } from '../../../../features/profile';
import { useCurrentAccount } from '../../../../stores/auth';
import { LOCKED_PARAM } from '../../constants';
import { ROUTES } from '../../navigation';
import { BlockedPublishDialog } from './components/BlockedPublishDialog';
import type { BlockedStanding, PublishMenuProps } from './types';
@ -20,7 +22,9 @@ const isBlocked = (standing: string): standing is BlockedStanding =>
* «انتشار» (C4 ۱.۱, ۱.۲, ۷.۱): a verified creator gets the menu, «پست جدید» or «پیش‌بینی جدید». A
* creator who can't publish sees it frozen, and a press explains why instead of a tooltip. On
* mobile the open menu sits centred over the nav, on a light scrim that dims the page down to the
* nav; a press on the scrim closes it, and the FAB turns into an icon-only ✕ «بستن» (J08-1b).
* nav; a press on the scrim closes it, and the FAB turns into an icon-only ✕ «بستن» (J08-1b). A
* composer the creator may not use sends them to their channel with `?locked=`: the why opens at
* once there, and the parameter goes (0060).
*/
export function PublishMenu({ placement }: PublishMenuProps) {
const { t } = useTranslation();
@ -29,6 +33,26 @@ export function PublishMenu({ placement }: PublishMenuProps) {
const [isOpen, setIsOpen] = useState(false);
const [isExplaining, setIsExplaining] = useState(false);
const blocked = isBlocked(standing) ? standing : null;
const router = useRouter();
const lockedBy = useSearchParams().get(LOCKED_PARAM);
const [shownLock, setShownLock] = useState<string | null>(null);
// Opened once per arrival, while rendering: no extra pass through an effect.
if (lockedBy && blocked && shownLock !== lockedBy) {
setShownLock(lockedBy);
setIsExplaining(true);
}
if (!lockedBy && shownLock) setShownLock(null);
useEffect(() => {
if (!lockedBy || standing === 'unknown') return;
// Shown once: a reload or a shared link doesn't open it again.
const params = new URLSearchParams(window.location.search);
params.delete(LOCKED_PARAM);
const query = params.toString();
router.replace(`${window.location.pathname}${query ? `?${query}` : ''}`, {
scroll: false,
});
}, [lockedBy, standing, router]);
// J08-1b-M: the open FAB is just the ✕, named «بستن»; desktop keeps «انتشار» beside it.
const isClosingFab = placement === 'nav' && isOpen;

View File

@ -4,6 +4,12 @@ export const CHANNEL_PREFIX = '/@';
/** The App Router's own path for a channel, which `/@username` is rewritten onto. */
export const CHANNEL_ROUTE_PREFIX = '/channels/';
/**
* `?locked=post|prediction` on a creator's own channel: a composer they may not use sent them here,
* and «انتشار» explains why at once; the parameter is removed once shown (0060).
*/
export const LOCKED_PARAM = 'locked';
/** `?preview=visitor|subscriber`: the creator's preview of their own post as others see it (C5 §6). */
export const PREVIEW_PARAM = 'preview';

View File

@ -72,7 +72,11 @@ export const ROUTES = {
creatorProfileDone: '/onboarding/creator-profile/done',
investorProfile: '/onboarding/investor-profile',
},
terms: '/terms/subscription',
/** «قوانین لومینا» (G-2r): «قوانین عمومی» and «شرایط اشتراک», one tab each. */
rules: {
general: '/terms',
subscription: '/terms/subscription',
},
} as const;
/** `/auth/login?redirect=…`: auth returns to the page that asked for it. */

View File

@ -36,6 +36,7 @@ export function LoginStep({ size, supportPlacement }: LoginStepProps) {
} = useLoginPage({
codeHref: routes.loginVerify,
registerHref: routes.register.type,
resumeHref: routes.register.verify,
subscribeTo: routes.subscribeTo,
});

View File

@ -1,21 +1,25 @@
'use client';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { StateArt } from '@lumina/island/atoms/state-art';
import { Button } from '@lumina/island/atoms/button';
import { Typography } from '@lumina/island/atoms/typography';
import { PinnedFooter } from '@lumina/island/molecules/pinned-footer';
import { ResultPanel } from '@lumina/island/molecules/result-panel';
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { useLoginSuspendedPage } from '../../../../../../../../features/auth';
import { useAuthRoutes } from '../../../../../../../navigation';
import { ROUTES, useAuthRoutes } from '../../../../../../../navigation';
import { SupportEntry } from '../../../../../../organisms/support-entry';
import type { LoginSuspendedStepProps } from './types';
/**
* A valid code for a suspended account (S6 1.11, 2.1, 3.1): no session, nothing else reachable,
* one way out to support. Amber, because a suspension is a state, not an error. The admin's reason
* shows when there is one. Focus starts on the heading, as the page replaces the code step.
* A suspended account (J01-3, J01-3c), after a valid login code or mid-session (J01-3d): no
* session and nothing else reachable, only support and the landing. Amber, because a suspension is
* a state, not an error. A creator sees the admin's reason when there is one and that an SMS
* follows the lift; an investor sees neither, and mid-session learns they were signed out. Mobile
* pins both buttons to the bottom; desktop keeps them in the card. Focus starts on the heading,
* as the screen replaces the one before.
*/
export function LoginSuspendedStep({
size,
@ -33,42 +37,43 @@ export function LoginSuspendedStep({
// The page's own skeleton, while a reload goes back to login.
return <SkeletonPreset preset="state" label={t('loading')} />;
}
const isCreator = suspension.role === 'creator';
const body =
isCreator && suspension.reason
? t('suspended.reason', { reason: suspension.reason })
: !isCreator && suspension.midSession
? t('suspended.mid-session')
: t('suspended.description');
const actions = (
<>
<SupportEntry trigger="button" placement={supportPlacement} size={size} />
<Button variant="secondary" size={size} block href={ROUTES.landing}>
{t('suspended.home')}
</Button>
</>
);
return (
<FlexBox
direction="flex-col"
alignItems="items-center"
gap="gap-4"
className={
layout === 'mobile' ? 'flex-1 pt-6 text-center' : 'pt-6 text-center'
}
>
<StateArt icon="ban" tone="warning" />
<FlexBox direction="flex-col" alignItems="items-center" gap="gap-2">
<Typography
ref={headingRef}
tabIndex={-1}
tag="h1"
variant="heading-md"
className="outline-none"
>
{t('suspended.title')}
</Typography>
<Typography color="secondary">
{suspension.reason
? t('suspended.reason', { reason: suspension.reason })
: t('suspended.description')}
</Typography>
</FlexBox>
<FlexBox
direction="flex-col"
className={layout === 'mobile' ? 'mt-auto w-full' : 'mt-2 w-full'}
<>
<ResultPanel
tone="warning"
icon="ban"
title={t('suspended.title')}
titleRef={headingRef}
body={body}
actions={layout === 'desktop' ? actions : undefined}
className={layout === 'mobile' ? 'flex-1 justify-center' : undefined}
>
<SupportEntry
trigger="button"
placement={supportPlacement}
size={size}
/>
</FlexBox>
</FlexBox>
{isCreator && (
<Typography variant="caption" color="secondary">
{t('suspended.sms-note')}
</Typography>
)}
</ResultPanel>
{layout === 'mobile' && (
// Edge to edge under the auth column's 16px sides and bottom padding.
<PinnedFooter className="-mx-4 -mb-5">{actions}</PinnedFooter>
)}
</>
);
}

View File

@ -4,6 +4,6 @@ export type LoginSuspendedStepProps = {
/** `lg` on mobile, `md` on desktop. */
size: 'md' | 'lg';
supportPlacement: SupportEntryProps['placement'];
/** Mobile pins «تماس با پشتیبانی» to the bottom; desktop keeps it in the card. */
/** Mobile pins both buttons to the bottom; desktop keeps them in the card. */
layout: 'mobile' | 'desktop';
};

View File

@ -11,7 +11,8 @@ import type { RegisterDetailsStepProps } from './types';
/**
* Registration step 4, on the 15-minute token: account details for an investor, identity for a
* creator. There is no back: the code is used. Without a token (after a reload) it waits in its
* creator. Back never returns to the used code step: it asks whether to leave and resume later
* (J02-3f). Without a token (after a reload) it waits in its
* skeleton while the page sends the person back to the number.
*/
export function RegisterDetailsStep(props: RegisterDetailsStepProps) {

View File

@ -9,20 +9,17 @@ import { Controller } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { useCreatorIdentityPart } from '../../../../../../../../../features/auth';
import type { IdCardSide } from '../../../../../../../../../features/auth';
import { translateMessage } from '../../../../../../../../../shared/utils';
import { ID_CARD_IMAGE } from '../../../../../../../../../shared/validations';
import {
ID_CARD_IMAGE,
ID_CARD_SIDES,
} from '../../../../../../../../../shared/validations';
import type { DetailsFormProps } from '../types';
import { DetailsFrame } from './DetailsFrame';
import { NameFields } from './NameFields';
import { TermsLine } from './TermsLine';
import { UsernameField } from './UsernameField';
const ID_CARD_SIDES = [
{ side: 'idCardFront', label: 'id-card-front' },
{ side: 'idCardBack', label: 'id-card-back' },
] as const satisfies readonly { side: IdCardSide; label: string }[];
const BYTES_PER_MB = 1024 * 1024;
/**
@ -41,6 +38,7 @@ export function CreatorIdentityForm(props: DetailsFormProps) {
pickImage,
progress,
draft,
leave,
} = useCreatorIdentityPart(props.partOptions);
return (
@ -50,6 +48,7 @@ export function CreatorIdentityForm(props: DetailsFormProps) {
description={t('register.identity.description')}
formError={formError}
draft={draft}
leave={leave}
onSubmit={() => void submit()}
footer={
<>
@ -62,7 +61,11 @@ export function CreatorIdentityForm(props: DetailsFormProps) {
>
{t('register.identity.submit')}
</Button>
<TermsLine before={t('register.identity.terms-before')} />
<TermsLine
before={t('register.identity.terms-before')}
rules={props.rules}
placement={props.haltPlacement}
/>
</>
}
>

View File

@ -11,10 +11,12 @@ import { RegisterProgress } from '../../../../../../../organisms/register-progre
import type { DetailsFrameProps } from '../types';
import { ExpiryHalt } from './ExpiryHalt';
import { ExpiryWarning } from './ExpiryWarning';
import { LeaveRegistrationDialog } from './LeaveRegistrationDialog';
/**
* What both account types' step 4 share: the token's warning and halt, the server-failure banner,
* the step bar and heading, the form with its submit under the fields, and support.
* the step bar and heading, the form with its submit under the fields, support, and the dialog
* that back and links open (J02-3f).
*/
export function DetailsFrame({
page,
@ -23,6 +25,7 @@ export function DetailsFrame({
formError,
footer,
draft,
leave,
onSubmit,
supportPlacement,
haltPlacement,
@ -69,6 +72,12 @@ export function DetailsFrame({
<FlexBox justifyContent="justify-center" className="mt-auto">
<SupportEntry trigger="link" placement={supportPlacement} />
</FlexBox>
<LeaveRegistrationDialog
placement={haltPlacement}
open={leave.isLeaveOpen && page.phase !== 'expired'}
onStay={leave.stay}
onLeave={leave.leave}
/>
{page.phase === 'expired' && (
<ExpiryHalt
placement={haltPlacement}

View File

@ -13,7 +13,7 @@ import { UsernameField } from './UsernameField';
/** Step 4 for an investor: name, last name and username, then «ساخت حساب». */
export function InvestorDetailsForm(props: DetailsFormProps) {
const { t } = useTranslation('auth');
const { form, submit, isSubmitting, formError, username, draft } =
const { form, submit, isSubmitting, formError, username, draft, leave } =
useInvestorDetailsPart(props.partOptions);
return (
@ -23,6 +23,7 @@ export function InvestorDetailsForm(props: DetailsFormProps) {
description={t('register.details.description')}
formError={formError}
draft={draft}
leave={leave}
onSubmit={() => void submit()}
footer={
<>
@ -35,7 +36,11 @@ export function InvestorDetailsForm(props: DetailsFormProps) {
>
{t('register.details.submit')}
</Button>
<TermsLine before={t('register.details.terms-before')} />
<TermsLine
before={t('register.details.terms-before')}
rules={props.rules}
placement={props.haltPlacement}
/>
</>
}
>

View File

@ -0,0 +1,46 @@
'use client';
import { Button } from '@lumina/island/atoms/button';
import { Modal } from '@lumina/island/molecules/modal';
import { Sheet } from '@lumina/island/molecules/sheet';
import { useTranslation } from 'react-i18next';
import type { LeaveRegistrationDialogProps } from '../types';
/**
* Back (or any link) during step 4 (J02-3f): «ثبت‌نام را نیمه‌کاره رها می‌کنید؟». The number is
* proven and what was typed is kept, so a later login with it resumes here. «ادامه ثبت‌نام» stays,
* «بعداً ادامه می‌دهم» leaves; Escape and the scrim stay too. A bottom sheet on mobile, a modal on
* desktop.
*/
export function LeaveRegistrationDialog({
placement,
open,
onStay,
onLeave,
}: LeaveRegistrationDialogProps) {
const { t } = useTranslation('auth');
const title = t('register.leave.title');
const body = t('register.leave.body');
const size = placement === 'sheet' ? 'lg' : 'md';
const buttons = (
<>
<Button variant="primary" size={size} block onClick={onStay}>
{t('register.leave.stay')}
</Button>
<Button variant="secondary" size={size} block onClick={onLeave}>
{t('register.leave.later')}
</Button>
</>
);
return placement === 'sheet' ? (
<Sheet open={open} title={title} onClose={onStay} footer={buttons}>
{body}
</Sheet>
) : (
<Modal open={open} title={title} onClose={onStay} actions={buttons}>
{body}
</Modal>
);
}

View File

@ -0,0 +1,61 @@
'use client';
import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Modal } from '@lumina/island/molecules/modal';
import { Sheet } from '@lumina/island/molecules/sheet';
import { useTranslation } from 'react-i18next';
import type { RulesSheetProps } from '../types';
/**
* «قوانین لومینا» over the registration form (G-2s): the general rules, rendered on the server and
* passed in, with one «متوجه شدم» that closes it. A bottom sheet on mobile, the 640 modal on
* desktop; Escape and the scrim close it too.
*/
export function RulesSheet({
open,
placement,
onClose,
children,
}: RulesSheetProps) {
const { t } = useTranslation('auth');
const title = t('register.rules-title');
const close = (
<Button
variant="primary"
size={placement === 'sheet' ? 'lg' : 'md'}
block
onClick={onClose}
>
{t('register.rules-close')}
</Button>
);
if (placement === 'sheet') {
return (
<Sheet open={open} title={title} onClose={onClose} footer={close}>
{children}
</Sheet>
);
}
return (
<Modal open={open} size="wide" title={title} onClose={onClose}>
<FlexBox direction="flex-col" className="min-h-0 flex-1">
<FlexBox
direction="flex-col"
className="min-h-0 flex-1 overflow-auto p-6"
>
{children}
</FlexBox>
<FlexBox
tag="footer"
direction="flex-col"
className="flex-none border-t border-border-subtle px-6 py-4"
>
{close}
</FlexBox>
</FlexBox>
</Modal>
);
}

View File

@ -1,19 +1,37 @@
'use client';
import { LinkButton } from '@lumina/island/atoms/link-button';
import { Typography } from '@lumina/island/atoms/typography';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import type { TermsLineProps } from '../types';
import { RulesSheet } from './RulesSheet';
/**
* Accepting the rules by submitting, with no checkbox. The rules page isn't designed yet, so the
* line names it without a link.
* Accepting the rules by submitting, with no checkbox. «قوانین لومینا» opens the general rules in
* a sheet over the form (G-2s), so nothing typed is lost.
*/
export function TermsLine({ before }: TermsLineProps) {
export function TermsLine({ before, rules, placement }: TermsLineProps) {
const { t } = useTranslation('auth');
const [isOpen, setIsOpen] = useState(false);
return (
<Typography variant="body-sm" color="secondary" className="text-center">
{before}
{t('register.terms-link')}
</Typography>
<>
<Typography variant="body-sm" color="secondary" className="text-center">
{before}
<LinkButton aria-haspopup="dialog" onClick={() => setIsOpen(true)}>
{t('register.terms-link')}
</LinkButton>
{t('register.terms-after')}
</Typography>
<RulesSheet
open={isOpen}
placement={placement}
onClose={() => setIsOpen(false)}
>
{rules}
</RulesSheet>
</>
);
}

View File

@ -3,6 +3,7 @@ import type { Control, FieldValues, Path } from 'react-hook-form';
import type {
RegisterDetailsPageModel,
RegisterLeaveModel,
UseDetailsPartOptions,
UsernameAvailability,
} from '../../../../../../../../features/auth';
@ -12,8 +13,13 @@ export type RegisterDetailsStepProps = {
/** `lg` on mobile, `md` on desktop. */
size: 'md' | 'lg';
supportPlacement: SupportEntryProps['placement'];
/** The halt when the token runs out: a bottom sheet on mobile, a modal on desktop. */
/**
* The halt when the token runs out, the leave dialog and the rules: a bottom sheet on mobile, a
* modal on desktop.
*/
haltPlacement: 'sheet' | 'modal';
/** «قوانین عمومی», rendered on the server, for the terms line's rules sheet (G-2s). */
rules: ReactNode;
};
/** What each account type's form gets from the step. */
@ -31,6 +37,8 @@ export type DetailsFrameProps = DetailsFormProps & {
footer: ReactNode;
/** The values to keep for the halt's new code. */
draft: () => Parameters<RegisterDetailsPageModel['reverify']>[0];
/** Back and links ask first (J02-3f). */
leave: RegisterLeaveModel;
onSubmit: () => void;
children: ReactNode;
};
@ -42,6 +50,15 @@ export type ExpiryWarningProps = {
onRenew?: () => void;
};
export type LeaveRegistrationDialogProps = {
placement: RegisterDetailsStepProps['haltPlacement'];
open: boolean;
/** «ادامه ثبت‌نام», Escape or the scrim. */
onStay: () => void;
/** «بعداً ادامه می‌دهم». */
onLeave: () => void;
};
export type ExpiryHaltProps = {
placement: RegisterDetailsStepProps['haltPlacement'];
isSending: boolean;
@ -51,6 +68,17 @@ export type ExpiryHaltProps = {
export type TermsLineProps = {
/** «با ساخت حساب، » or «با ثبت اطلاعات، ». */
before: string;
/** The general rules the link opens. */
rules: ReactNode;
placement: RegisterDetailsStepProps['haltPlacement'];
};
export type RulesSheetProps = {
open: boolean;
placement: RegisterDetailsStepProps['haltPlacement'];
onClose: () => void;
/** The rules' text. */
children: ReactNode;
};
export type UsernameFieldProps<T extends FieldValues> = {

View File

@ -11,10 +11,10 @@ import {
useProfileBlock,
} from '../../../../../../../../features/profile';
import { useIdentityBlock } from '../../../../../../../../features/verification';
import { LeaveDialog } from '../../../../../../organisms/leave-dialog';
import { useLandOnIdentity } from '../hooks/use-land-on-identity';
import type { EditContentProps } from '../types';
import { IdentityBlock } from './IdentityBlock';
import { LeaveDialog } from './LeaveDialog';
import { ProfileBlock } from './ProfileBlock';
import { ProfileSummary } from './ProfileSummary';
@ -66,7 +66,11 @@ export function EditContent({
/>
);
const identityBlock = (
<IdentityBlock model={identity} headingRef={identityHeading} />
<IdentityBlock
model={identity}
headingRef={identityHeading}
layout={layout}
/>
);
const profileBlock = (
<ProfileBlock

View File

@ -14,7 +14,11 @@ import { useTranslation } from 'react-i18next';
import { IDENTITY_ANCHOR } from '../../../../../../../../features/verification';
import { translateMessage } from '../../../../../../../../shared/utils';
import { ID_CARD_IMAGE } from '../../../../../../../../shared/validations';
import {
ID_CARD_IMAGE,
ID_CARD_SIDES,
} from '../../../../../../../../shared/validations';
import { SupportEntry } from '../../../../../../organisms/support-entry';
import type { IdentityBlockProps } from '../types';
import { BlockHeading } from './BlockHeading';
@ -22,11 +26,16 @@ const BYTES_PER_MB = 1024 * 1024;
/**
* «اطلاعات هویتی» (J03-1): the username is never editable; the names and national ID (masked) are
* locked while the review is pending or approved. Rejected (J03-1c), the reason leads the block,
* the names and the full national ID can be corrected with a new card image, and «ارسال مجدد
* اطلاعات هویتی» stays frozen until all four are valid (a press shows what is missing).
* locked while the review is pending or approved. Rejected (J03-1c), the reason and a way to
* support lead the block, the names, the full national ID and both card sides can be corrected
* (the field the admin named starts in its error state), and «ارسال مجدد اطلاعات هویتی» stays
* frozen until all are valid (a press shows what is missing).
*/
export function IdentityBlock({ model, headingRef }: IdentityBlockProps) {
export function IdentityBlock({
model,
headingRef,
layout,
}: IdentityBlockProps) {
const { t } = useTranslation('auth');
const titleId = useId();
const { form } = model;
@ -46,9 +55,14 @@ export function IdentityBlock({ model, headingRef }: IdentityBlockProps) {
{model.isEditable && (
<Banner tone="danger" title={t('profile-edit.identity.rejected-title')}>
{model.rejectionReason &&
t('profile-edit.identity.rejected-reason', {
`${t('profile-edit.identity.rejected-reason', {
reason: model.rejectionReason,
})}
})} `}
{t('profile-edit.identity.rejected-guide')}{' '}
<SupportEntry
trigger="inline"
placement={layout === 'desktop' ? 'popover' : 'bottom'}
/>
</Banner>
)}
{model.formError && <Banner tone="danger">{model.formError}</Banner>}
@ -112,40 +126,43 @@ export function IdentityBlock({ model, headingRef }: IdentityBlockProps) {
/>
)}
/>
<Controller
name="idCardFront"
control={form.control}
render={({ field, fieldState }) => (
<FileField
// An empty required box takes focus on submit.
ref={field.ref}
name={field.name}
file={field.value}
onChange={model.pickImage}
onBlur={field.onBlur}
accept={ID_CARD_IMAGE.types.join(',')}
label={t('register.fields.id-card-front')}
hint={t('register.fields.id-card-front-hint')}
size={
field.value &&
t('register.fields.file-size', {
size: number(field.value.size / BYTES_PER_MB, 1),
})
}
error={translateMessage(t, fieldState.error?.message)}
progress={model.progress}
disabled={model.isSubmitting}
labels={{
pick: t('register.fields.id-card-pick'),
rules: t('register.fields.id-card-rules'),
remove: t('register.fields.id-card-remove'),
change: t('register.fields.id-card-change'),
uploading: (percent) =>
t('register.fields.id-card-uploading', { percent }),
}}
/>
)}
/>
{ID_CARD_SIDES.map(({ side, label }) => (
<Controller
key={side}
name={side}
control={form.control}
render={({ field, fieldState }) => (
<FileField
// An empty required box takes focus on submit.
ref={field.ref}
name={field.name}
file={field.value}
onChange={(file) => model.pickImage(side, file)}
onBlur={field.onBlur}
accept={ID_CARD_IMAGE.types.join(',')}
label={t(`register.fields.${label}`)}
hint={t(`register.fields.${label}-hint`)}
size={
field.value &&
t('register.fields.file-size', {
size: number(field.value.size / BYTES_PER_MB, 1),
})
}
error={translateMessage(t, fieldState.error?.message)}
progress={model.progress}
disabled={model.isSubmitting}
labels={{
pick: t('register.fields.id-card-pick'),
rules: t('register.fields.id-card-rules'),
remove: t('register.fields.id-card-remove'),
change: t('register.fields.id-card-change'),
uploading: (percent) =>
t('register.fields.id-card-uploading', { percent }),
}}
/>
)}
/>
))}
<FlexBox direction="flex-col" gap="gap-2">
<Button
type="submit"

View File

@ -6,7 +6,10 @@ import { useTranslation } from 'react-i18next';
import type { ProfileSummaryProps } from '../types';
/** Who this is: the 72px photo, the name, @username and where the identity review stands. */
/**
* Who this is: the 72px photo, the name, @username and where the identity review stands; while
* pending, how long the review takes (J03-1b).
*/
export function ProfileSummary({
name,
username,
@ -14,6 +17,7 @@ export function ProfileSummary({
status,
}: ProfileSummaryProps) {
const { t } = useTranslation('common');
const { t: tAuth } = useTranslation('auth');
return (
<FlexBox alignItems="items-center" gap="gap-4">
<Avatar name={username} src={avatarSrc} size="xl" />
@ -41,6 +45,11 @@ export function ProfileSummary({
<StatusBadge status={`verification.${status}`}>
{t(`status.verification.${status}`)}
</StatusBadge>
{status === 'pending' && (
<Typography variant="caption" color="secondary">
{tAuth('profile-edit.pending-note')}
</Typography>
)}
</FlexBox>
</FlexBox>
);

View File

@ -20,8 +20,9 @@ export type CreatorProfileEditSkeletonProps = {
label: string;
};
/** Where leaving goes once confirmed: a link that was followed, or back (no `href`). */
export type LeaveTarget = { href?: string };
import type { LeaveTarget } from '../../../../../organisms/leave-dialog';
export type { LeaveTarget };
export type EditContentProps = {
layout: CreatorProfileEditLayout;
@ -43,6 +44,8 @@ export type ProfileSummaryProps = {
export type IdentityBlockProps = {
model: IdentityBlockModel;
/** Where the banner's support link opens its sheet: bottom on mobile, a popover on desktop. */
layout: CreatorProfileEditLayout;
/** The block's heading, which the rejected deep link focuses. */
headingRef: RefObject<HTMLHeadingElement | null>;
};
@ -65,12 +68,3 @@ export type SubSectionProps = {
hint: string;
children: ReactNode;
};
export type LeaveDialogProps = {
open: boolean;
layout: CreatorProfileEditLayout;
isSaving: boolean;
onSave: () => void;
onDiscard: () => void;
onStay: () => void;
};

View File

@ -15,11 +15,16 @@ export function CheckoutSkeleton({
layout,
creator,
label,
delayed,
}: CheckoutSkeletonProps) {
const padding = layout === 'desktop' ? 'lg' : 'md';
return (
<SkeletonRegion label={label} className="flex flex-1 flex-col">
<SkeletonRegion
label={label}
delayed={delayed}
className="flex flex-1 flex-col"
>
<CheckoutFrame
layout={layout}
creator={creator}

View File

@ -3,15 +3,16 @@ import { Controller } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { translateMessage } from '../../../../../../../../shared/utils';
import type { CheckoutPartProps } from '../types';
import type { CheckoutCodeProps } from '../types';
/**
* «کد دعوت», left to right, with its own «ثبت» (J06-2j–2o): «ثبت» or Enter checks the code and
* never pays; leaving the field checks it quietly. Valid turns the field green and read-only with
* «تغییر»; invalid keeps the code in red; a check that couldn't run asks for «ثبت» again. A code
* from an invite link says so. The message only reassures or warns; «پرداخت» decides.
* from an invite link says so. The message only reassures or warns; «پرداخت» decides. «کد ندارم»
* ends the message row while the code can change (J06-2t).
*/
export function CheckoutCode({ model }: Pick<CheckoutPartProps, 'model'>) {
export function CheckoutCode({ model, onNoCode }: CheckoutCodeProps) {
const { t } = useTranslation(['payment', 'errors']);
return (
@ -33,6 +34,7 @@ export function CheckoutCode({ model }: Pick<CheckoutPartProps, 'model'>) {
}}
onCheck={model.checkCode}
onEdit={model.editCode}
onNoCode={onNoCode}
status={model.codeCheck}
source={model.codeSource}
label={t('checkout.code.label')}
@ -46,6 +48,7 @@ export function CheckoutCode({ model }: Pick<CheckoutPartProps, 'model'>) {
validFromLink: t('checkout.code.from-link'),
invalid: t('errors:checkout.code-invalid'),
error: t('checkout.code.check-failed'),
noCode: t('checkout.no-code.link'),
}}
/>
)}

View File

@ -57,7 +57,7 @@ export function CheckoutFooter({ model }: Pick<CheckoutPartProps, 'model'>) {
</FlexBox>
<Typography variant="caption" color="secondary" className="text-center">
{t('checkout.terms-before')}
<Link href={ROUTES.terms}>{t('checkout.terms-link')}</Link>
<Link href={ROUTES.rules.subscription}>{t('checkout.terms-link')}</Link>
{t('checkout.terms-after')}
</Typography>
{canPay ? (

View File

@ -1,5 +1,6 @@
import { Typography } from '@lumina/island/atoms/typography';
import { Banner } from '@lumina/island/molecules/banner';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useCheckoutPage } from '../../../../../../../../features/checkout';
@ -10,6 +11,7 @@ import { CheckoutFooter } from './CheckoutFooter';
import { CheckoutFrame } from './CheckoutFrame';
import { CheckoutHalts } from './CheckoutHalts';
import { CheckoutTiers } from './CheckoutTiers';
import { NoCodeSheet } from './NoCodeSheet';
const SKELETON_LABELS = {
pending: 'checkout.loading',
@ -21,16 +23,19 @@ const SKELETON_LABELS = {
* The signed-in investor's checkout: the screen loads in the browser behind the skeleton, which
* also covers settling a payment left at the gateway and the way to the channel for an investor
* who can't pay here. An ended subscription reactivates: the note that the period starts today in
* place of the invite note and code (U11 ۳.۱).
* place of the invite note and code (U11 ۳.۱). «کد ندارم» opens where to get a code (J06-2t).
*/
export function CheckoutForm({
creatorId,
channelHref,
layout,
creator,
creatorName,
creatorLinks,
}: CheckoutFormProps) {
const { t } = useTranslation('payment');
const model = useCheckoutPage({ creatorId, channelHref });
const [isNoCodeOpen, setIsNoCodeOpen] = useState(false);
if (model.status !== 'ready') {
return (
@ -70,13 +75,23 @@ export function CheckoutForm({
{t('checkout.invite-note')}
</Typography>
<CheckoutTiers model={model} layout={layout} />
<CheckoutCode model={model} />
<CheckoutCode
model={model}
onNoCode={() => setIsNoCodeOpen(true)}
/>
</>
)
}
footer={<CheckoutFooter model={model} />}
/>
<CheckoutHalts model={model} layout={layout} />
<NoCodeSheet
open={isNoCodeOpen}
onClose={() => setIsNoCodeOpen(false)}
layout={layout}
creatorName={creatorName}
creatorLinks={creatorLinks}
/>
</>
);
}

View File

@ -127,7 +127,7 @@ export function CheckoutHalts({ model, layout }: CheckoutPartProps) {
layout={layout}
open={halt?.kind === 'waitlisted'}
icon={<StateArt icon="clock" tone="brand" size="compact" />}
title={t('checkout.waitlist.title')}
title={t('checkout.waitlist.already-title')}
buttons={
<Button
variant="primary"

View File

@ -0,0 +1,134 @@
import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Typography } from '@lumina/island/atoms/typography';
import { List, ListRow } from '@lumina/island/molecules/list-row';
import { Modal } from '@lumina/island/molecules/modal';
import { Sheet } from '@lumina/island/molecules/sheet';
import { Element } from '@lumina/island/primitives/element';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import {
displaySocialUrl,
fromSocialUrl,
} from '../../../../../../../../shared/utils';
import { SupportDialog } from '../../../../../../organisms/support-entry';
import type { NoCodeSheetProps } from '../types';
/**
* «کد ندارم» (J06-2t): the code comes from the creator, so the sheet lists their channel links,
* each opening in a new tab, and says an invite link fills the code in by itself. A creator
* without links leaves «پشتیبانی», which opens the support sheet over this one. A bottom sheet on
* mobile, a centred modal on desktop; «بستن», ✕, Escape and the scrim return to checkout.
*/
export function NoCodeSheet({
open,
onClose,
layout,
creatorName,
creatorLinks,
}: NoCodeSheetProps) {
const { t } = useTranslation(['payment', 'channel']);
const [isSupportOpen, setIsSupportOpen] = useState(false);
const isMobile = layout === 'mobile';
const hasLinks = creatorLinks.length > 0;
const body = (
<FlexBox direction="flex-col" gap="gap-3">
<Typography>
{t(
hasLinks ? 'checkout.no-code.body' : 'checkout.no-code.body-no-links',
{
name: creatorName,
},
)}
</Typography>
{hasLinks ? (
<List tone="soft" aria-label={t('checkout.no-code.links')}>
{creatorLinks.map(({ label, url }) => {
const { platform } = fromSocialUrl(label, url);
const address = (
<Element tag="bdi" dir="ltr">
{displaySocialUrl(url)}
</Element>
);
return (
<ListRow
key={url}
href={url}
external
icon={platform === 'telegram' ? 'telegram' : 'link'}
title={
platform === 'website'
? address
: platform === 'telegram'
? t('checkout.no-code.platforms.telegram')
: t(`channel:header.platforms.${platform}`)
}
subtitle={
<>
{address}
<Typography tag="span" className="sr-only">
{t('checkout.no-code.opens-new-tab')}
</Typography>
</>
}
/>
);
})}
</List>
) : (
<List tone="soft">
<ListRow
icon="headset"
title={t('checkout.no-code.support')}
chevron
onClick={() => setIsSupportOpen(true)}
/>
</List>
)}
<Typography variant="caption" color="secondary">
{t('checkout.no-code.link-hint')}
</Typography>
</FlexBox>
);
const close = (
<Button
variant="secondary"
size={isMobile ? 'lg' : undefined}
block
onClick={onClose}
>
{t('checkout.no-code.close')}
</Button>
);
return (
<>
{isMobile ? (
<Sheet
open={open}
title={t('checkout.no-code.title')}
onClose={onClose}
footer={close}
>
{body}
</Sheet>
) : (
<Modal
open={open}
title={t('checkout.no-code.title')}
onClose={onClose}
actions={close}
>
{body}
</Modal>
)}
<SupportDialog
placement={isMobile ? 'bottom' : 'modal'}
open={open && isSupportOpen}
onClose={() => setIsSupportOpen(false)}
/>
</>
);
}

View File

@ -1,6 +1,7 @@
import type { FormEvent, ReactNode } from 'react';
import type { CheckoutPageModel } from '../../../../../../../features/checkout';
import type { SocialLinkPayload } from '../../../../../../../features/profile';
export type CheckoutLayout = 'mobile' | 'desktop';
@ -12,10 +13,27 @@ export type CheckoutPanelProps = {
layout: CheckoutLayout;
/** Who is being paid, rendered on the server: CheckoutCreator. */
creator: ReactNode;
/** The creator's display name, else their username, for «کد ندارم» (J06-2t). */
creatorName: string;
/** The creator's channel links, where «کد ندارم» sends the investor for a code. */
creatorLinks: SocialLinkPayload[];
};
export type CheckoutFormProps = CheckoutPanelProps;
export type NoCodeSheetProps = Pick<
CheckoutPanelProps,
'layout' | 'creatorName' | 'creatorLinks'
> & {
open: boolean;
onClose: () => void;
};
export type CheckoutCodeProps = Pick<CheckoutPartProps, 'model'> & {
/** «کد ندارم». */
onNoCode: () => void;
};
export type CheckoutFrameProps = {
layout: CheckoutLayout;
creator: ReactNode;
@ -37,6 +55,8 @@ export type CheckoutSkeletonProps = {
layout: CheckoutLayout;
creator: ReactNode;
label: string;
/** Fades in after 300 ms, so a fast route never flashes it (`loading.tsx` only, G-3d). */
delayed?: boolean;
};
export type HaltDialogProps = {

View File

@ -1,51 +0,0 @@
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Card } from '@lumina/island/molecules/card';
import { ResultPanel } from '@lumina/island/molecules/result-panel';
import { useTranslation } from 'react-i18next';
import { MobileTopBar } from '../../../../../navigation/components/mobile-top-bar';
import { LockedActions } from './components/LockedActions';
import { LOCKED_PANEL } from './constants';
import type { ComposerLockedProps } from './types';
/**
* A composer's address opened by a creator who may not publish (C4 ۲.۱–۲.۳, J08-1f…1j, J09-1e):
* what «انتشار» would explain in its sheet, as the page, with the one way forward and «بستن».
* Mobile: the pushed page's bar over the panel; desktop: the 640px card.
*/
export function ComposerLocked({
standing,
layout,
title,
onClose,
}: ComposerLockedProps) {
const { t } = useTranslation('common');
const { tone, icon } = LOCKED_PANEL[standing];
const panel = (
<ResultPanel
tone={tone}
icon={icon}
title={t(`publish.${standing}.title`)}
body={t(`publish.${standing}.reason`)}
actions={
<LockedActions standing={standing} layout={layout} onClose={onClose} />
}
/>
);
if (layout === 'mobile') {
return (
<FlexBox direction="flex-col" className="min-h-dvh bg-surface">
<MobileTopBar title={title} />
<FlexBox tag="main" direction="flex-col" className="flex-1 px-4 py-8">
{panel}
</FlexBox>
</FlexBox>
);
}
return (
<Card tag="section" padding="lg" className="w-full max-w-content">
{panel}
</Card>
);
}

View File

@ -1,41 +0,0 @@
import { Typography } from '@lumina/island/atoms/typography';
import { Modal } from '@lumina/island/molecules/modal';
import { useTranslation } from 'react-i18next';
import { useDialogRoute } from '../../../../../navigation/hooks/use-dialog-route';
import { ROUTES } from '../../../../../navigation/navigation';
import { LockedActions } from './components/LockedActions';
import type { ComposerLockedDialogProps } from './types';
/**
* A composer dialog's route opened by a creator who may not publish (J08-1f-D, J09-1e): the 420px
* question «انتشار» would have asked, title, reason and actions only, over the page. «بستن»,
* Escape and the scrim go back to that page.
*/
export function ComposerLockedDialog({
standing,
username,
}: ComposerLockedDialogProps) {
const { t } = useTranslation('common');
const route = useDialogRoute(ROUTES.channel(username));
return (
<Modal
open={route.open}
title={t(`publish.${standing}.title`)}
onClose={route.close}
onExited={route.onExited}
actions={
<LockedActions
standing={standing}
layout="desktop"
onClose={route.close}
/>
}
>
<Typography color="secondary">
{t(`publish.${standing}.reason`)}
</Typography>
</Modal>
);
}

View File

@ -0,0 +1,27 @@
'use client';
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
import { LOCKED_PARAM } from '../../../../../navigation/constants';
import { ROUTES } from '../../../../../navigation/navigation';
import type { ComposerLockedRedirectProps } from './types';
/**
* A composer opened by a creator who may not publish (pending, rejected, suspended; J09-1e, 0060):
* the address is replaced by their own channel, where «انتشار» opens why at once
* (`?locked=post|prediction`). The composer's skeleton stays until the channel arrives.
*/
export function ComposerLockedRedirect({
username,
kind,
children,
}: ComposerLockedRedirectProps) {
const router = useRouter();
useEffect(() => {
router.replace(`${ROUTES.channel(username)}?${LOCKED_PARAM}=${kind}`);
}, [router, username, kind]);
return <>{children}</>;
}

View File

@ -1,53 +0,0 @@
import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { useTranslation } from 'react-i18next';
import { ROUTES } from '../../../../../../navigation/navigation';
import { SupportEntry } from '../../../../../organisms/support-entry';
import type { LockedActionsProps } from '../types';
/**
* Why-not's actions (C4 ۲.۱–۲.۳, J09-1e, as «انتشار» explains it): the identity review's status for
* a pending creator, its form to correct and send again for a rejected one, support for a
* suspended one; «بستن» under it.
*/
export function LockedActions({
standing,
layout,
onClose,
}: LockedActionsProps) {
const { t } = useTranslation('common');
const isMobile = layout === 'mobile';
const size = isMobile ? 'lg' : undefined;
return (
<>
{standing === 'suspended' ? (
// A desktop popover hangs from a positioned parent that also holds its trigger.
<FlexBox direction="flex-col" className="relative">
<SupportEntry
trigger="button"
placement={isMobile ? 'bottom' : 'popover'}
size={isMobile ? 'lg' : 'md'}
/>
</FlexBox>
) : (
<Button
variant="primary"
size={size}
block
href={
standing === 'rejected'
? `${ROUTES.account.profile}#identity`
: ROUTES.account.profile
}
>
{t(`publish.${standing}.action`)}
</Button>
)}
<Button variant="secondary" size={size} block onClick={onClose}>
{t('publish.close')}
</Button>
</>
);
}

View File

@ -1,14 +0,0 @@
import type { IconName } from '@lumina/island/atoms/icon';
import type { ResultPanelTone } from '@lumina/island/molecules/result-panel';
import type { BlockedStanding } from '../../../../../../features/post';
/** The blocked composer page's panel for each standing: its tone and icon (J08-1f…1j, J09-1e). */
export const LOCKED_PANEL: Record<
BlockedStanding,
{ tone: ResultPanelTone; icon: IconName }
> = {
pending: { tone: 'info', icon: 'clock' },
rejected: { tone: 'danger', icon: 'alert' },
suspended: { tone: 'danger', icon: 'lock' },
};

View File

@ -1,7 +1,2 @@
export { ComposerLocked } from './ComposerLocked';
export { ComposerLockedDialog } from './ComposerLockedDialog';
export type {
ComposerLockedDialogProps,
ComposerLockedLayout,
ComposerLockedProps,
} from './types';
export { ComposerLockedRedirect } from './ComposerLockedRedirect';
export type { ComposerLockedKind, ComposerLockedRedirectProps } from './types';

Some files were not shown because too many files have changed in this diff Show More