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 { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { ROUTES } from '@lumina/market/app/navigation';
import { i18n } from '../../../../../i18n'; import { i18n } from '../../../../../i18n';
import { AuthTemplate } from '../../../../templates/auth-template'; 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. */ /** 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() { export default function Loading() {
return ( return (
<AuthTemplate> <AuthTemplate back={ROUTES.landing}>
<SkeletonPreset <SkeletonPreset
preset="form" preset="form"
count={3} 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 { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { GuestGuard } from '@lumina/market/app/guards/guest-guard'; 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 { RegisterDetailsStep } from '@lumina/market/app/screens/(auth)/auth/register/details/organisms/register-details-step';
import type { Metadata } from 'next'; 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). */ /** Registration step 4, account details or identity. The frame renders on the server; the step only in the browser (0013). */
export default function RegisterDetailsPage() { export default function RegisterDetailsPage() {
return ( return (
<AuthTemplate> <AuthTemplate back={ROUTES.landing}>
<GuestGuard <GuestGuard
fallback={ fallback={
<SkeletonPreset <SkeletonPreset
@ -28,6 +37,12 @@ export default function RegisterDetailsPage() {
size="md" size="md"
supportPlacement="popover" supportPlacement="popover"
haltPlacement="modal" haltPlacement="modal"
rules={
<GeneralRules
layout="sheet"
labels={generalRulesLabels(i18n.getFixedT(null, 'rules'))}
/>
}
/> />
</GuestGuard> </GuestGuard>
</AuthTemplate> </AuthTemplate>

View File

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

View File

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

View File

@ -1,17 +1,7 @@
import { FlexBox } from '@lumina/island/atoms/flex-box'; import { FlexBox } from '@lumina/island/atoms/flex-box';
import { PartBoundary } from '@lumina/market/app/error-boundaries'; import { DesktopHeader } from '@lumina/market/app/navigation';
import { AuthGuard } from '@lumina/market/app/guards/auth-guard'; import { PricingEditor } from '@lumina/market/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor';
import {
DesktopHeader,
DesktopPageTitle,
ROUTES,
} from '@lumina/market/app/navigation';
import {
PricingForm,
PricingFormSkeleton,
} from '@lumina/market/app/screens/(flow)/dashboard/pricing/organisms/pricing-form';
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { Suspense } from 'react';
import { i18n } from '../../../../i18n'; import { i18n } from '../../../../i18n';
@ -22,14 +12,11 @@ export const metadata: Metadata = {
/** /**
* C7, «ویرایش قیمت‌ها» on desktop (C7 ۸.۱): the creator header with داشبورد on, «بازگشت» above * 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 * the title (to طرح‌های اشتراک when opened on its own, R14), and the form in the 560 column; with
* browser behind cards of the same size. * 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() { export default function PricingPage() {
const skeleton = (
<PricingFormSkeleton layout="desktop" label={i18n.t('pricing:loading')} />
);
return ( return (
<FlexBox direction="flex-col" className="min-h-dvh bg-bg-page"> <FlexBox direction="flex-col" className="min-h-dvh bg-bg-page">
<DesktopHeader /> <DesktopHeader />
@ -38,22 +25,8 @@ export default function PricingPage() {
justifyContent="justify-center" justifyContent="justify-center"
className="px-8 py-10" className="px-8 py-10"
> >
<FlexBox direction="flex-col" gap="gap-4" className="w-full max-w-form"> <FlexBox direction="flex-col" className="w-full max-w-form">
<DesktopPageTitle <PricingEditor layout="desktop" />
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> </FlexBox>
</FlexBox> </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. */} {/* To the channel paid for once the payment loads (R14), never to the bank. */}
<DeskBack href={ROUTES.dashboard.subscriptions} /> <DeskBack href={ROUTES.dashboard.subscriptions} />
<PaymentResultSkeleton <PaymentResultSkeleton
delayed
layout="desktop" layout="desktop"
label={i18n.t('payment:result.loading')} 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'; // First: the static `metadata` below reads a server-only namespace, which the server bootstrap
import { redirect } from 'next/navigation'; // adds to i18n when this module loads, whichever module Next loads first (0055).
import '../../../bootstrap/bootstrap.server';
/** import { Card } from '@lumina/island/molecules/card';
* `/terms`, the address the boards give «شرایط اشتراک» (G-2), sends on to the page at its own import {
* address. Temporary, so `/terms` can become a page of its own later. GeneralRules,
*/ generalRulesLabels,
export default function TermsPage(): never { } from '@lumina/market/app/screens/organisms/general-rules';
redirect(ROUTES.terms); 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 { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
import { Card } from '@lumina/island/molecules/card';
import { i18n } from '../../../../i18n'; 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() { export default function Loading() {
return ( return (
<SkeletonRegion <SkeletonRegion delayed label={i18n.t('terms:meta-title')}>
delayed <Card padding="lg">
label={i18n.t('terms:meta-title')} <Skeleton width="40%" height="1.25rem" className="mb-3" />
className="mx-auto w-full max-w-content p-4" <Skeleton lines={4} />
> <Skeleton width="35%" height="1.25rem" className="mt-6 mb-3" />
<Skeleton width="40%" height="1.25rem" className="mb-3" /> <Skeleton lines={5} />
<Skeleton lines={4} /> </Card>
<Skeleton width="35%" height="1.25rem" className="mt-6 mb-3" />
<Skeleton lines={5} />
</SkeletonRegion> </SkeletonRegion>
); );
} }

View File

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

View File

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

View File

@ -1,6 +1,7 @@
import { FlexBox } from '@lumina/island/atoms/flex-box'; import { FlexBox } from '@lumina/island/atoms/flex-box';
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset'; import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { PartBoundary } from '@lumina/market/app/error-boundaries'; 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 { 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 { 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'; import { ChannelFeed } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-feed/server';
@ -8,6 +9,7 @@ import {
ChannelHeader, ChannelHeader,
channelHeaderLabels, channelHeaderLabels,
} from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-header'; } 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 { 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 { 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'; 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 ( return (
<FlexBox tag="main" justifyContent="justify-center" className="px-8 py-10"> <FlexBox tag="main" justifyContent="justify-center" className="px-8 py-10">
<FlexBox <FlexBox
@ -64,64 +129,13 @@ export function ChannelTemplate({
className="w-full max-w-content" className="w-full max-w-content"
> >
<ChannelDeskBack creatorId={channel.creatorId} /> <ChannelDeskBack creatorId={channel.creatorId} />
<ChannelHeader {channel.verificationPending ? (
channel={channel} <PendingChannelGate layout="desktop" channelUrl={channelUrl}>
layout="desktop" {publicChannel}
share={ </PendingChannelGate>
<ChannelShare ) : (
creatorId={channel.creatorId} publicChannel
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>
</FlexBox> </FlexBox>
</FlexBox> </FlexBox>
); );

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,13 @@ import { http } from '@lumina/libs/http';
import { captureInstallPrompt, configureServiceWorker } from '@lumina/libs/pwa'; import { captureInstallPrompt, configureServiceWorker } from '@lumina/libs/pwa';
import { mapApiErrorBody } from '@lumina/market/app/http'; import { mapApiErrorBody } from '@lumina/market/app/http';
import { setEnv as setMarketEnv } from '@lumina/market/env'; 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 { API_PROXY_PATH, API_VERSION_PATH } from '../constants';
import { clientEnv } from '../env'; 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 // 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; // 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({ http.configure({
baseUrl: `${API_PROXY_PATH}${API_VERSION_PATH}`, baseUrl: `${API_PROXY_PATH}${API_VERSION_PATH}`,
refresh: { refresh: {
endpoint: AUTH_ENDPOINTS.refresh, endpoint: AUTH_ENDPOINTS.refresh,
onFailure: () => shouldRefresh: (error) =>
eventEmitter.emit(AUTH_EVENTS.logout, { reason: 'session-ended' }), error.status === 401 && suspendedSessionOf(error) === null,
onFailure: () => {
if (isSessionSuspended()) return;
eventEmitter.emit(AUTH_EVENTS.logout, { reason: 'session-ended' });
},
}, },
mapErrorBody: mapApiErrorBody, mapErrorBody: mapApiErrorBody,
}); });
http.interceptors.response.use(undefined, (error) => {
const suspension = suspendedSessionOf(error);
if (suspension) endSuspendedSession(suspension);
return error;
});
configureErrorHandler(ERROR_HANDLER_CONFIG); configureErrorHandler(ERROR_HANDLER_CONFIG);
// The service worker stores only JS, CSS, fonts and the icon sprite (pwa lib); the AppShell // 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. // 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 { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { ROUTES } from '@lumina/market/app/navigation';
import { i18n } from '../../../../../i18n'; import { i18n } from '../../../../../i18n';
import { AuthTopBar } from '../../../../organisms/auth-top-bar'; import { AuthTopBar } from '../../../../organisms/auth-top-bar';
@ -8,7 +9,12 @@ import { AuthTemplate } from '../../../../templates/auth-template';
export default function Loading() { export default function Loading() {
return ( return (
<AuthTemplate <AuthTemplate
header={<AuthTopBar title={i18n.t('auth:register.header')} />} header={
<AuthTopBar
title={i18n.t('auth:register.header')}
back={ROUTES.landing}
/>
}
> >
<SkeletonPreset <SkeletonPreset
preset="form" 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 { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { GuestGuard } from '@lumina/market/app/guards/guest-guard'; 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 { RegisterDetailsStep } from '@lumina/market/app/screens/(auth)/auth/register/details/organisms/register-details-step';
import type { Metadata } from 'next'; import type { Metadata } from 'next';
@ -16,7 +25,12 @@ export const metadata: Metadata = {
export default function RegisterDetailsPage() { export default function RegisterDetailsPage() {
return ( return (
<AuthTemplate <AuthTemplate
header={<AuthTopBar title={i18n.t('auth:register.header')} />} header={
<AuthTopBar
title={i18n.t('auth:register.header')}
back={ROUTES.landing}
/>
}
> >
<GuestGuard <GuestGuard
fallback={ fallback={
@ -31,6 +45,12 @@ export default function RegisterDetailsPage() {
size="lg" size="lg"
supportPlacement="bottom" supportPlacement="bottom"
haltPlacement="sheet" haltPlacement="sheet"
rules={
<GeneralRules
layout="sheet"
labels={generalRulesLabels(i18n.getFixedT(null, 'rules'))}
/>
}
/> />
</GuestGuard> </GuestGuard>
</AuthTemplate> </AuthTemplate>

View File

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

View File

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

View File

@ -1,13 +1,6 @@
import { FlexBox } from '@lumina/island/atoms/flex-box'; import { FlexBox } from '@lumina/island/atoms/flex-box';
import { PartBoundary } from '@lumina/market/app/error-boundaries'; import { PricingEditor } from '@lumina/market/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor';
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 type { Metadata } from 'next'; import type { Metadata } from 'next';
import { Suspense } from 'react';
import { i18n } from '../../../../i18n'; import { i18n } from '../../../../i18n';
@ -19,33 +12,14 @@ export const metadata: Metadata = {
/** /**
* C7, «ویرایش قیمت‌ها» on mobile: a task page pushed from the «قیمت طرح‌ها» card, back · title · * 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, * 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 * back goes to طرح‌های اشتراک (R14), and with unsaved changes it asks first (J10-4n). The form
* the creator's own, so it renders in the browser behind cards of the same size. * 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() { export default function PricingPage() {
const skeleton = (
<PricingFormSkeleton layout="mobile" label={i18n.t('pricing:loading')} />
);
return ( return (
<FlexBox direction="flex-col" className="min-h-dvh bg-bg-page"> <FlexBox direction="flex-col" className="min-h-dvh bg-bg-page">
<MobileTopBar <PricingEditor layout="mobile" />
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>
</FlexBox> </FlexBox>
); );
} }

View File

@ -15,6 +15,7 @@ export default function Loading() {
/> />
<FlexBox tag="main" direction="flex-col" className="flex-1"> <FlexBox tag="main" direction="flex-col" className="flex-1">
<PaymentResultSkeleton <PaymentResultSkeleton
delayed
layout="mobile" layout="mobile"
label={i18n.t('payment:result.loading')} 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'; // First: the static `metadata` below reads a server-only namespace, which the server bootstrap
import { redirect } from 'next/navigation'; // adds to i18n when this module loads, whichever module Next loads first (0055).
import '../../../bootstrap/bootstrap.server';
/** import {
* `/terms`, the address the boards give «شرایط اشتراک» (G-2), sends on to the page at its own GeneralRules,
* address. Temporary, so `/terms` can become a page of its own later. generalRulesLabels,
*/ } from '@lumina/market/app/screens/organisms/general-rules';
export default function TermsPage(): never { import type { Metadata } from 'next';
redirect(ROUTES.terms);
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'; 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() { export default function Loading() {
return ( return (
<SkeletonRegion <SkeletonRegion delayed label={i18n.t('terms:meta-title')}>
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 width="40%" height="1.25rem" className="mb-3" />
<Skeleton lines={4} /> <Skeleton lines={4} />
<Skeleton width="35%" height="1.25rem" className="mt-6 mb-3" /> <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). // adds to i18n when this module loads, whichever module Next loads first (0055).
import '../../../../bootstrap/bootstrap.server'; import '../../../../bootstrap/bootstrap.server';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { MobileTopBar } from '@lumina/market/app/navigation';
import { import {
SubscriptionTerms, SubscriptionTerms,
subscriptionTermsLabels, subscriptionTermsLabels,
@ -20,8 +18,9 @@ export const metadata: Metadata = {
}; };
/** /**
* «شرایط اشتراک» on mobile (S5 ۱.۱): a task page pushed from checkout, a suspended card or the * «شرایط اشتراک», the second tab of «قوانین لومینا» on mobile (S5 ۱.۱, G-2): the section's bar and
* support sheet, back · title · support and no bottom nav; back returns to where it was opened. * tabs come from its layout; back returns to where the rules were opened (checkout, a suspended
* card, the support sheet).
*/ */
export default function SubscriptionTermsPage() { export default function SubscriptionTermsPage() {
const labels = subscriptionTermsLabels( const labels = subscriptionTermsLabels(
@ -31,19 +30,10 @@ export default function SubscriptionTermsPage() {
); );
return ( return (
<FlexBox direction="flex-col" className="min-h-dvh bg-surface"> <SubscriptionTerms
<MobileTopBar title={labels.title} /> layout="mobile"
<FlexBox chats={supportChatUrls()}
tag="main" labels={labels}
direction="flex-col" />
className="flex-1 px-4 pt-4 pb-8"
>
<SubscriptionTerms
layout="mobile"
chats={supportChatUrls()}
labels={labels}
/>
</FlexBox>
</FlexBox>
); );
} }

View File

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

View File

@ -2,12 +2,14 @@ import { FlexBox } from '@lumina/island/atoms/flex-box';
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset'; import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { PartBoundary } from '@lumina/market/app/error-boundaries'; import { PartBoundary } from '@lumina/market/app/error-boundaries';
import { MobileTopBar } from '@lumina/market/app/navigation'; 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 { 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 { ChannelFeed } from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-feed/server';
import { import {
ChannelHeader, ChannelHeader,
channelHeaderLabels, channelHeaderLabels,
} from '@lumina/market/app/screens/(main)/channels/[username]/organisms/channel-header'; } 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 { 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 { 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'; 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 ( return (
<> <>
<MobileTopBar <MobileTopBar
@ -59,66 +130,13 @@ export function ChannelTemplate({
tabOwnerId={channel.creatorId} tabOwnerId={channel.creatorId}
/> />
<FlexBox tag="main" direction="flex-col" className="flex-1"> <FlexBox tag="main" direction="flex-col" className="flex-1">
<ChannelHeader {channel.verificationPending ? (
channel={channel} <PendingChannelGate layout="mobile" channelUrl={channelUrl}>
layout="mobile" {publicChannel}
share={ </PendingChannelGate>
<ChannelShare ) : (
creatorId={channel.creatorId} publicChannel
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>
</FlexBox> </FlexBox>
</> </>
); );

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,13 @@ import { http } from '@lumina/libs/http';
import { captureInstallPrompt, configureServiceWorker } from '@lumina/libs/pwa'; import { captureInstallPrompt, configureServiceWorker } from '@lumina/libs/pwa';
import { mapApiErrorBody } from '@lumina/market/app/http'; import { mapApiErrorBody } from '@lumina/market/app/http';
import { setEnv as setMarketEnv } from '@lumina/market/env'; 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 { API_PROXY_PATH, API_VERSION_PATH } from '../constants';
import { clientEnv } from '../env'; 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 // 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; // 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({ http.configure({
baseUrl: `${API_PROXY_PATH}${API_VERSION_PATH}`, baseUrl: `${API_PROXY_PATH}${API_VERSION_PATH}`,
refresh: { refresh: {
endpoint: AUTH_ENDPOINTS.refresh, endpoint: AUTH_ENDPOINTS.refresh,
onFailure: () => shouldRefresh: (error) =>
eventEmitter.emit(AUTH_EVENTS.logout, { reason: 'session-ended' }), error.status === 401 && suspendedSessionOf(error) === null,
onFailure: () => {
if (isSessionSuspended()) return;
eventEmitter.emit(AUTH_EVENTS.logout, { reason: 'session-ended' });
},
}, },
mapErrorBody: mapApiErrorBody, mapErrorBody: mapApiErrorBody,
}); });
http.interceptors.response.use(undefined, (error) => {
const suspension = suspendedSessionOf(error);
if (suspension) endSuspendedSession(suspension);
return error;
});
configureErrorHandler(ERROR_HANDLER_CONFIG); configureErrorHandler(ERROR_HANDLER_CONFIG);
// The service worker stores only JS, CSS, fonts and the icon sprite (pwa lib); the AppShell // 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. // registers it when this flag is on, and turning the flag off unregisters it for every visitor.