feat(apps): rules pages under /terms, pricing editor with leave guard, page-size errors on subscriptions and transactions, pending channel gate, welcome sheet and invite notes on channels, registration back on step 4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Amiram_se 2026-10-10 13:29:48 +04:00
parent 6791282b38
commit c593e09554
38 changed files with 487 additions and 296 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.