feat(market): canvas 86fc — not-for-sale channel and sale notice, first follow in place, no-code sheet, checkout ?code=, notification seen/read with analyst filters, approved welcome, compose lock redirect, pending close, invite request outcomes, pricing leave sheet, payout retry, mid-session suspension halt, registration leave and resume, both ID sides, rules page and sheet

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 4924257ae1
commit 6791282b38
263 changed files with 4251 additions and 945 deletions

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';

View File

@ -1,25 +1,12 @@
import type { BlockedStanding } from '../../../../../../features/post';
import type { ReactNode } from 'react';
export type ComposerLockedLayout = 'mobile' | 'desktop';
/** Which composer sent the creator away: `?locked=post|prediction` on their channel. */
export type ComposerLockedKind = 'post' | 'prediction';
export type ComposerLockedProps = {
standing: BlockedStanding;
layout: ComposerLockedLayout;
/** The composer's own title for the mobile bar: «پست جدید», «ویرایش پست», «پیش‌بینی جدید». */
title: string;
/** «بستن»: back to where the composer was opened, or the creator's channel. */
onClose: () => void;
};
export type ComposerLockedDialogProps = {
standing: BlockedStanding;
/** The creator's own: their channel is where «بستن» goes with no history. */
export type ComposerLockedRedirectProps = {
/** The creator's own: their channel is where «انتشار» explains why. */
username: string;
};
/** The blocked composer's way forward over «بستن», in a page or a dialog. */
export type LockedActionsProps = {
standing: BlockedStanding;
layout: ComposerLockedLayout;
onClose: () => void;
kind: ComposerLockedKind;
/** What stays on screen until the channel replaces it: the composer's skeleton. */
children: ReactNode;
};

View File

@ -1,51 +1,41 @@
'use client';
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { useRouter } from 'next/navigation';
import { useTranslation } from 'react-i18next';
import { usePublishAccess } from '../../../../../../../features/post';
import { useCurrentAccount } from '../../../../../../../stores/auth';
import { ROUTES } from '../../../../../../navigation/navigation';
import { ComposerForm } from './components/ComposerForm';
import { ComposerLocked } from '../../../organisms/composer-locked';
import { ComposerLockedRedirect } from '../../../organisms/composer-locked';
import { EditComposer } from './components/EditComposer';
import type { PostComposerProps } from './types';
/**
* The creator's post composer, new or editing, in the browser only: the page wraps it in the
* creator-only guard, which shows the skeleton until the session is known. A creator who may not
* publish (pending, rejected, suspended) gets why instead, however they reached the address
* (C4 ۲.۱–۲.۳); the skeleton stays until their standing is known.
* publish (pending, rejected, suspended) is sent to their own channel, which says why, however
* they reached the address (C4 ۲.۱–۲.۳, 0060); the skeleton stays until then.
*/
export function PostComposer({ layout, postId }: PostComposerProps) {
const { t } = useTranslation('content');
const router = useRouter();
const account = useCurrentAccount();
const access = usePublishAccess(account?.role === 'creator');
if (!account) return null;
if (access.status === 'pending') {
return (
<SkeletonPreset
preset="form"
count={2}
label={t('composer.loading')}
className={layout === 'mobile' ? 'p-4' : 'w-full max-w-content'}
/>
);
}
const skeleton = (
<SkeletonPreset
preset="form"
count={2}
label={t('composer.loading')}
className={layout === 'mobile' ? 'p-4' : 'w-full max-w-content'}
/>
);
if (access.status === 'pending') return skeleton;
if (access.status === 'blocked') {
return (
<ComposerLocked
standing={access.standing}
layout={layout}
title={t(postId ? 'composer.edit-title' : 'composer.new-title')}
onClose={() => {
if (window.history.length > 1) router.back();
else router.push(ROUTES.channel(account.username));
}}
/>
<ComposerLockedRedirect username={account.username} kind="post">
{skeleton}
</ComposerLockedRedirect>
);
}
return postId ? (

View File

@ -8,7 +8,7 @@ import { StatusEmptyState } from '../../../../../../error-boundaries';
import { ROUTES } from '../../../../../../navigation/navigation';
import { ComposerDialog } from './components/ComposerDialog';
import { ComposerDialogPlaceholder } from './components/ComposerDialogPlaceholder';
import { ComposerLockedDialog } from '../../../organisms/composer-locked';
import { ComposerLockedRedirect } from '../../../organisms/composer-locked';
import { EditComposerDialog } from './components/EditComposerDialog';
import { PostComposerDialogSkeleton } from './PostComposerDialogSkeleton';
import type { PostComposerDialogProps } from './types';
@ -17,8 +17,9 @@ import type { PostComposerDialogProps } from './types';
* «پست جدید» or «ویرایش پست» over the current page on desktop (C4 ۷.۳, J08-4-D), for the routes
* that intercept /compose/post and /compose/post/:id. The app wraps it in AuthGuard with
* `PostComposerDialogSkeleton`, so it renders once the browser knows a signed-in viewer. Only a
* creator who may publish gets the composer; another creator gets why not (J08-1f-D), and anyone
* else the no-access state inside the same dialog, not AuthGuard's page-size one under the page.
* creator who may publish gets the composer; another creator goes to their own channel, which says
* why not (J08-1f-D, 0060), and anyone else gets the no-access state inside the same dialog, not
* AuthGuard's page-size one under the page.
*/
export function PostComposerDialog({ postId }: PostComposerDialogProps) {
const { t } = useTranslation('content');
@ -37,15 +38,13 @@ export function PostComposerDialog({ postId }: PostComposerDialogProps) {
</ComposerDialogPlaceholder>
);
}
if (access.status === 'pending') {
return <PostComposerDialogSkeleton edit={postId != null} />;
}
const skeleton = <PostComposerDialogSkeleton edit={postId != null} />;
if (access.status === 'pending') return skeleton;
if (access.status === 'blocked') {
return (
<ComposerLockedDialog
standing={access.standing}
username={account.username}
/>
<ComposerLockedRedirect username={account.username} kind="post">
{skeleton}
</ComposerLockedRedirect>
);
}
return postId ? (

View File

@ -1,50 +1,40 @@
'use client';
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { useRouter } from 'next/navigation';
import { useTranslation } from 'react-i18next';
import { usePublishAccess } from '../../../../../../../features/post';
import { useCurrentAccount } from '../../../../../../../stores/auth';
import { ROUTES } from '../../../../../../navigation/navigation';
import { ComposerLocked } from '../../../organisms/composer-locked';
import { ComposerLockedRedirect } from '../../../organisms/composer-locked';
import { ComposerPage } from './components/ComposerPage';
import type { PredictionComposerProps } from './types';
/**
* The creator's prediction composer at /compose/prediction, in the browser only: the page wraps it
* in the creator-only guard, which shows the skeleton until the session is known. A creator who
* may not publish (pending, rejected, suspended) gets why instead, however they reached the
* address (J09-1e); the skeleton stays until their standing is known.
* may not publish (pending, rejected, suspended) is sent to their own channel, which says why,
* however they reached the address (J09-1e, 0060); the skeleton stays until then.
*/
export function PredictionComposer({ layout }: PredictionComposerProps) {
const { t } = useTranslation('predictions');
const router = useRouter();
const account = useCurrentAccount();
const access = usePublishAccess(account?.role === 'creator');
if (!account) return null;
if (access.status === 'pending') {
return (
<SkeletonPreset
preset="form"
count={3}
label={t('composer.loading')}
className={layout === 'mobile' ? 'p-4' : 'w-full max-w-240'}
/>
);
}
const skeleton = (
<SkeletonPreset
preset="form"
count={3}
label={t('composer.loading')}
className={layout === 'mobile' ? 'p-4' : 'w-full max-w-240'}
/>
);
if (access.status === 'pending') return skeleton;
if (access.status === 'blocked') {
return (
<ComposerLocked
standing={access.standing}
layout={layout}
title={t('composer.title')}
onClose={() => {
if (window.history.length > 1) router.back();
else router.push(ROUTES.channel(account.username));
}}
/>
<ComposerLockedRedirect username={account.username} kind="prediction">
{skeleton}
</ComposerLockedRedirect>
);
}
return (

View File

@ -6,15 +6,15 @@ import { StatusEmptyState } from '../../../../../../error-boundaries';
import { ROUTES } from '../../../../../../navigation/navigation';
import { ComposerDialog } from './components/ComposerDialog';
import { ComposerDialogPlaceholder } from './components/ComposerDialogPlaceholder';
import { ComposerLockedDialog } from '../../../organisms/composer-locked';
import { ComposerLockedRedirect } from '../../../organisms/composer-locked';
import { PredictionComposerDialogSkeleton } from './PredictionComposerDialogSkeleton';
/**
* «پیش‌بینی جدید» over the current page on desktop (J09-1-D, 0023), for the route that intercepts
* /compose/prediction. The app wraps it in AuthGuard with `PredictionComposerDialogSkeleton`, so
* it renders once the browser knows a signed-in viewer. Only a creator who may publish gets the
* composer; another creator gets why not (J09-1e), and anyone else the no-access state inside
* the same dialog.
* composer; another creator goes to their own channel, which says why not (J09-1e, 0060), and
* anyone else gets the no-access state inside the same dialog.
*/
export function PredictionComposerDialog() {
const account = useCurrentAccount();
@ -32,10 +32,9 @@ export function PredictionComposerDialog() {
if (access.status === 'pending') return <PredictionComposerDialogSkeleton />;
if (access.status === 'blocked') {
return (
<ComposerLockedDialog
standing={access.standing}
username={account.username}
/>
<ComposerLockedRedirect username={account.username} kind="prediction">
<PredictionComposerDialogSkeleton />
</ComposerLockedRedirect>
);
}
return <ComposerDialog creatorId={account.id} username={account.username} />;

View File

@ -0,0 +1,84 @@
'use client';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { useRouter } from 'next/navigation';
import { Suspense, useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { PartBoundary } from '../../../../../../error-boundaries';
import { AuthGuard } from '../../../../../../guards/auth-guard';
import {
DesktopPageTitle,
MobileTopBar,
ROUTES,
useGoBack,
useLeaveGuard,
} from '../../../../../../navigation';
import type { LeaveTarget } from '../../../../../organisms/leave-dialog';
import { PricingForm, PricingFormSkeleton } from '../pricing-form';
import type { PricingEditorProps } from './types';
/**
* C7, «ویرایش قیمت‌ها», with its bar or title: back goes to طرح‌های اشتراک (R14). The bar is this
* organism's, so back can ask first: with unsaved changes, back and any link inside the app open
* the three-action sheet (J10-4n, as J03-1g), and closing the tab gets the browser's prompt. The
* form is the creator's own, so it renders in the browser behind cards of the same size, in its
* own boundary.
*/
export function PricingEditor({ layout }: PricingEditorProps) {
const { t } = useTranslation('pricing');
const router = useRouter();
const [isDirty, setIsDirty] = useState(false);
const [leaveTo, setLeaveTo] = useState<LeaveTarget | null>(null);
const parentHref = ROUTES.dashboard.plans;
const goBack = useGoBack({ parentHref });
const requestLeave = useCallback((href: string) => setLeaveTo({ href }), []);
useLeaveGuard(isDirty, requestLeave);
const leave = (target: LeaveTarget) => {
setLeaveTo(null);
if (target.href) router.push(target.href);
else goBack();
};
const onBack = isDirty ? () => setLeaveTo({}) : undefined;
const title = t('title');
const skeleton = <PricingFormSkeleton layout={layout} label={t('loading')} />;
const content = (
<PartBoundary name="pricing-form" description={t('error')} framed>
<AuthGuard role="creator" fallback={skeleton}>
<Suspense fallback={skeleton}>
<PricingForm
layout={layout}
leaveTo={leaveTo}
onStay={() => setLeaveTo(null)}
onLeave={leave}
onDirtyChange={setIsDirty}
/>
</Suspense>
</AuthGuard>
</PartBoundary>
);
if (layout === 'desktop') {
return (
<FlexBox direction="flex-col" gap="gap-4">
<DesktopPageTitle
title={title}
parentHref={parentHref}
onBack={onBack}
/>
{content}
</FlexBox>
);
}
return (
<>
<MobileTopBar title={title} parentHref={parentHref} onBack={onBack} />
<FlexBox tag="main" direction="flex-col" className="flex-1">
{content}
</FlexBox>
</>
);
}

View File

@ -0,0 +1,2 @@
export { PricingEditor } from './PricingEditor';
export type { PricingEditorProps } from './types';

View File

@ -0,0 +1,4 @@
export type PricingEditorProps = {
/** mobile: the task bar over the page (C7 ۴.۱). desktop: «بازگشت» and the title over the form (۸.۱). */
layout: 'mobile' | 'desktop';
};

View File

@ -14,6 +14,7 @@ import { useEffect, useId, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { usePricingPage } from '../../../../../../../features/pricing';
import { LeaveDialog } from '../../../../../organisms/leave-dialog';
import { ConfirmDialog } from './components/ConfirmDialog';
import { DateTimeDialog } from './components/DateTimeDialog';
import { PromotionBlock } from './components/PromotionBlock';
@ -27,10 +28,19 @@ import type { DatePick, PricingFormProps } from './types';
* During the lock each offered period's promotion follows as its own live card. Under the cards,
* once something is saved, the note on existing subscribers. Save is pinned to the bottom on
* mobile and sits under the form on desktop; while a broken rule shows it freezes with the line
* above it (۳), and offline it freezes and says why. The confirmation and the date picker are
* sheets on mobile and modals on desktop.
* above it (۳), and offline it freezes and says why. During the lock it reads «ذخیره تخفیف» (J10-4m,
* 0036). The confirmation and the date picker are sheets on mobile and modals on desktop. It
* reports unsaved changes to the frame and answers its leave sheet (J10-4n): «ذخیره و خروج» closes
* it and saves as the save button does, leaving once «تأیید و ذخیره» went through; a broken rule
* or «انصراف» keeps the page.
*/
export function PricingForm({ layout }: PricingFormProps) {
export function PricingForm({
layout,
leaveTo,
onStay,
onLeave,
onDirtyChange,
}: PricingFormProps) {
const { t } = useTranslation(['pricing', 'common']);
const model = usePricingPage();
const headingId = useId();
@ -44,6 +54,9 @@ export function PricingForm({ layout }: PricingFormProps) {
const showsHeading =
model.firstTimeSetup || model.verification !== 'approved';
useEffect(() => onDirtyChange(model.isDirty), [model.isDirty, onDirtyChange]);
useEffect(() => () => onDirtyChange(false), [onDirtyChange]);
// The banner replaces the error toast (۵.۴), so bring it into view wherever the save was tapped.
useEffect(() => {
if (model.saveFailed)
@ -65,10 +78,16 @@ export function PricingForm({ layout }: PricingFormProps) {
? { frozen: true, pressableWhenFrozen: true }
: offline)}
>
{t('form.save')}
{t(locked ? 'form.save-promotion' : 'form.save')}
</Button>
);
const saveAndLeave = () => {
if (!leaveTo) return;
onStay();
model.save({ onSaved: () => onLeave(leaveTo) });
};
return (
<FlexBox
tag="form"
@ -101,7 +120,7 @@ export function PricingForm({ layout }: PricingFormProps) {
variant="secondary"
size="sm"
icon="refresh"
onClick={model.save}
onClick={() => model.save()}
{...offline}
>
{t('form.retry')}
@ -181,6 +200,14 @@ export function PricingForm({ layout }: PricingFormProps) {
</PinnedFooter>
)}
<ConfirmDialog model={model} layout={layout} />
<LeaveDialog
open={leaveTo !== null}
layout={layout}
isSaving={false}
onSave={saveAndLeave}
onDiscard={() => leaveTo && onLeave(leaveTo)}
onStay={onStay}
/>
<DateTimeDialog
layout={layout}
pick={pick}

View File

@ -1,4 +1,5 @@
import type { BillingPeriod } from '../../../../../../../shared/constants';
import type { LeaveTarget } from '../../../../../organisms/leave-dialog';
import type {
PricingPageModel,
PricingTierView,
@ -7,9 +8,16 @@ import type {
export type PricingFormProps = {
/** mobile: bottom sheets. desktop: centred modals, cards padded lg (۸). */
layout: 'mobile' | 'desktop';
/** Set while the unsaved-changes sheet asks (J10-4n). */
leaveTo: LeaveTarget | null;
/** «ادامه ویرایش», or «ذخیره و خروج» on its way to the confirmation: the sheet closes. */
onStay: () => void;
onLeave: (target: LeaveTarget) => void;
/** The form holds something not saved. Keep it stable. */
onDirtyChange: (isDirty: boolean) => void;
};
export type PricingFormSkeletonProps = PricingFormProps & {
export type PricingFormSkeletonProps = Pick<PricingFormProps, 'layout'> & {
/** Hidden status text: «در حال بارگذاری قیمت‌گذاری…». */
label: string;
/** Fades in after 300ms, so a fast route never flashes grey. loading.tsx only. */

View File

@ -11,9 +11,14 @@ const RECEIPT_ROWS = ['period', 'amount', 'date', 'expiry', 'reference'];
export function PaymentResultSkeleton({
layout,
label,
delayed,
}: PaymentResultSkeletonProps) {
return (
<SkeletonRegion label={label} className="flex flex-1 flex-col">
<SkeletonRegion
label={label}
delayed={delayed}
className="flex flex-1 flex-col"
>
<ResultFrame
layout={layout}
body={

View File

@ -29,6 +29,8 @@ export type ResultActionsProps = {
export type PaymentResultSkeletonProps = {
layout: PaymentResultLayout;
label: string;
/** Fades in after 300 ms, so a fast route never flashes it (`loading.tsx` only, G-3d). */
delayed?: boolean;
};
export type ResultFrameProps = {

View File

@ -0,0 +1,38 @@
'use client';
import { TabLinks } from '@lumina/island/molecules/tab-links';
import { usePathname } from 'next/navigation';
import { ROUTES } from '../../../../../navigation';
import type { RulesTabsProps } from './types';
/**
* «قوانین لومینا»'s two tabs (G-2r): «قوانین عمومی» · «شرایط اشتراک», the current one from the URL,
* which the server render already knows. The section's layout renders it once, so it stays put
* while a tab loads. A tab replaces the history entry, so back still returns to the page that
* opened the rules.
*/
export function RulesTabs({ layout, labels }: RulesTabsProps) {
const pathname = usePathname();
return (
<TabLinks
items={[
{
href: ROUTES.rules.general,
label: labels.general,
isActive: pathname === ROUTES.rules.general,
},
{
href: ROUTES.rules.subscription,
label: labels.subscription,
isActive: pathname === ROUTES.rules.subscription,
},
]}
label={labels.label}
fill
replace
band={layout === 'mobile'}
/>
);
}

View File

@ -0,0 +1,2 @@
export { RulesTabs } from './RulesTabs';
export type { RulesTabsLabels, RulesTabsProps } from './types';

View File

@ -0,0 +1,15 @@
export type RulesTabsLabels = {
/** The nav's name: «قوانین لومینا». */
label: string;
/** «قوانین عمومی». */
general: string;
/** «شرایط اشتراک». */
subscription: string;
};
export type RulesTabsProps = {
/** mobile: the band under the top bar; desktop: in the column under the title. */
layout: 'mobile' | 'desktop';
/** From the server's translations (0020): the rules are a server namespace. */
labels: RulesTabsLabels;
};

View File

@ -173,7 +173,7 @@ export function LandingTemplate({
<LandingFooter
topId={IDS.top}
sections={footerSections}
termsHref={ROUTES.terms}
termsHref={ROUTES.rules.subscription}
siteHost={siteHost}
labels={labels.footer}
/>

View File

@ -92,7 +92,7 @@ export function AccountOverview({ layout }: AccountOverviewProps) {
<ListRow
icon="file"
title={t('overview.rows.terms')}
href={ROUTES.terms}
href={ROUTES.rules.general}
/>
</List>
<Button

View File

@ -0,0 +1,126 @@
'use client';
import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Typography } from '@lumina/island/atoms/typography';
import { List, ListRow } from '@lumina/island/molecules/list-row';
import { Modal } from '@lumina/island/molecules/modal';
import { Sheet } from '@lumina/island/molecules/sheet';
import { useTranslation } from 'react-i18next';
import { useApprovedWelcome } from '../../../../../../../features/profile';
import { useCurrentAccount } from '../../../../../../../stores/auth';
import { ROUTES } from '../../../../../../navigation/navigation';
import type { ApprovedWelcomeProps } from './types';
/**
* «حساب شما تأیید شد» (J08-1k), once, on the creator's first open of their own channel after
* approval: three steps to start, each a link (prices, the invite code, a first prediction), then
* «تعیین قیمت‌ها» and «بعداً». A bottom sheet on mobile, the 640px dialog on desktop. Nothing for
* anyone else, and nothing on the server render.
*/
export function ApprovedWelcome({ creatorId, layout }: ApprovedWelcomeProps) {
const { t } = useTranslation('channel');
const account = useCurrentAccount();
const model = useApprovedWelcome({
enabled: account?.role === 'creator' && account.id === creatorId,
});
const isMobile = layout === 'mobile';
const size = isMobile ? 'lg' : undefined;
const steps = (
<List aria-label={t('welcome.steps')}>
<ListRow
href={ROUTES.dashboard.pricing}
onClick={model.close}
icon="tag"
iconTone="brand"
title={t('welcome.prices.title')}
subtitle={t('welcome.prices.subtitle')}
chevron
/>
<ListRow
href={ROUTES.dashboard.plans}
onClick={model.close}
icon="share"
iconTone="brand"
title={t('welcome.code.title')}
subtitle={
model.code
? t('welcome.code.subtitle', { code: model.code })
: undefined
}
chevron
/>
<ListRow
href={ROUTES.composePrediction}
onClick={model.close}
icon="trend-up"
iconTone="brand"
title={t('welcome.prediction.title')}
subtitle={t('welcome.prediction.subtitle')}
chevron
/>
</List>
);
const intro = <Typography color="secondary">{t('welcome.intro')}</Typography>;
const buttons = (
<>
<Button
variant="primary"
size={size}
block
href={ROUTES.dashboard.pricing}
onClick={model.close}
>
{t('welcome.cta')}
</Button>
<Button variant="secondary" size={size} block onClick={model.close}>
{t('welcome.later')}
</Button>
</>
);
if (isMobile) {
return (
<Sheet
open={model.isOpen}
title={t('welcome.title')}
onClose={model.close}
footer={buttons}
>
<FlexBox direction="flex-col" gap="gap-3">
{intro}
{steps}
</FlexBox>
</Sheet>
);
}
return (
<Modal
open={model.isOpen}
size="wide"
title={t('welcome.title')}
onClose={model.close}
>
<FlexBox direction="flex-col" className="min-h-0 flex-1">
<FlexBox
direction="flex-col"
gap="gap-3"
className="min-h-0 flex-1 overflow-auto p-6"
>
{intro}
{steps}
</FlexBox>
<FlexBox
tag="footer"
direction="flex-col"
gap="gap-3"
className="flex-none border-t border-border-subtle px-6 py-4"
>
{buttons}
</FlexBox>
</FlexBox>
</Modal>
);
}

View File

@ -0,0 +1,2 @@
export { ApprovedWelcome } from './ApprovedWelcome';
export type { ApprovedWelcomeProps } from './types';

View File

@ -0,0 +1,6 @@
export type ApprovedWelcomeProps = {
/** The channel's creator: the welcome is for them alone. */
creatorId: string;
/** mobile: a bottom sheet over the channel. desktop: the 640px dialog (J08-1k-D). */
layout: 'mobile' | 'desktop';
};

View File

@ -14,12 +14,16 @@ import type { ChannelActionsProps } from './types';
* only in the browser: a same-size skeleton until the viewer is known. Guests and investors get
* subscribe and follow; the creator on their own channel, and other creators, get none. A channel
* opened from an invite link keeps its code for checkout and says so under the actions (J06-1b/1c).
* A channel that sells nothing yet offers the sale notice instead of «اشتراک» (J05-1g/1h): the
* server says so for a guest, an investor's own standing for them.
*/
export function ChannelActions({
creatorId,
username,
channelUrl,
layout,
saleOpen = true,
inviteNoteName,
}: ChannelActionsProps) {
const { t } = useTranslation('channel');
const { viewer, ...model } = useChannelActionsPart({ creatorId, username });
@ -34,7 +38,9 @@ export function ChannelActions({
username={username}
channelUrl={channelUrl}
layout={layout}
saleOpen={saleOpen}
hasInviteCode={hasInviteCode}
inviteNoteName={inviteNoteName}
isGuestPromptOpen={model.isGuestPromptOpen}
openGuestPrompt={model.openGuestPrompt}
closeGuestPrompt={model.closeGuestPrompt}
@ -46,6 +52,7 @@ export function ChannelActions({
username={username}
layout={layout}
hasInviteCode={hasInviteCode}
inviteNoteName={inviteNoteName}
standing={viewer.standing}
follow={model.follow}
askUnfollow={model.askUnfollow}
@ -54,6 +61,8 @@ export function ChannelActions({
cancelUnfollow={model.cancelUnfollow}
leaveWaitlist={model.leaveWaitlist}
isLeavingWaitlist={model.isLeavingWaitlist}
requestSaleNotice={model.requestSaleNotice}
cancelSaleNotice={model.cancelSaleNotice}
/>
);
default:

View File

@ -10,37 +10,51 @@ import {
import type { GuestActionsProps } from '../types';
import { GuestPrompt } from './GuestPrompt';
import { InviteLinkNote } from './InviteLinkNote';
import { InviteOnlyNote } from './InviteOnlyNote';
import { SaleClosedNote } from './SaleClosedNote';
import { SaleNoticeAction } from './SaleNoticeAction';
/**
* A guest sees both actions. «اشتراک» goes straight to login, which says why and comes back to
* checkout; «دنبال کردن» opens the login prompt. A guest who came with an invite link is on their
* way to subscribe, so both go to that login (J06-1c), and the note says the code came along.
* way to subscribe, so both go to that login (J06-1c), and the note says the code came along;
* otherwise the channel says it is invite-only (J06-1). A channel that sells nothing yet offers
* «وقتی اشتراک باز شد خبرم کن» instead, through login and back here, where it is tapped again
* (J05-1g); its note replaces the invite notes.
*/
export function GuestActions({
username,
channelUrl,
layout,
saleOpen,
hasInviteCode,
inviteNoteName,
isGuestPromptOpen,
openGuestPrompt,
closeGuestPrompt,
}: GuestActionsProps) {
const { t } = useTranslation('channel');
const isMobile = layout === 'mobile';
const fill = isMobile ? 'flex-1' : undefined;
const toSubscribe = subscribeLoginRoute(username);
const followsToSubscribe = saleOpen && hasInviteCode;
return (
<>
<FlexBox direction="flex-col" gap="gap-3">
<FlexBox gap="gap-2">
<Button
variant="primary"
href={toSubscribe}
className={isMobile ? 'flex-1' : undefined}
>
{t('actions.subscribe')}
</Button>
{hasInviteCode ? (
{saleOpen ? (
<Button variant="primary" href={toSubscribe} className={fill}>
{t('actions.subscribe')}
</Button>
) : (
<SaleNoticeAction
notified={false}
href={loginRoute(ROUTES.channel(username))}
className={fill}
/>
)}
{followsToSubscribe ? (
<Button variant="secondary" href={toSubscribe}>
{t('actions.follow')}
</Button>
@ -54,7 +68,11 @@ export function GuestActions({
</Button>
)}
</FlexBox>
{hasInviteCode && <InviteLinkNote />}
{!saleOpen && <SaleClosedNote />}
{saleOpen && inviteNoteName !== undefined && (
<InviteOnlyNote name={inviteNoteName} />
)}
{followsToSubscribe && <InviteLinkNote />}
</FlexBox>
<GuestPrompt
open={isGuestPromptOpen}

View File

@ -11,9 +11,12 @@ import { ROUTES } from '../../../../../../../navigation/navigation';
import { UnfollowConfirm } from '../../../../../organisms/unfollow-confirm';
import type { InvestorActionsProps } from '../types';
import { InviteLinkNote } from './InviteLinkNote';
import { InviteOnlyNote } from './InviteOnlyNote';
import { PaymentFailedNote } from './PaymentFailedNote';
import { PaymentPendingNote } from './PaymentPendingNote';
import { PendingIndicator } from './PendingIndicator';
import { SaleClosedNote } from './SaleClosedNote';
import { SaleNoticeAction } from './SaleNoticeAction';
import { WaitlistNote } from './WaitlistNote';
/**
@ -21,13 +24,17 @@ import { WaitlistNote } from './WaitlistNote';
* هستید» once subscribed, or frozen while a payment waits for the bank; live again once the bank
* turns it down, with why under the row (U10 ۵.۴). Follow sits beside it; while the subscription
* is active unfollow is frozen and says why. Come with an invite link, a note under the row says
* the code came along while «اشتراک» is live (J06-1b). Offline, subscribe, follow and unfollow
* freeze and say they need the internet.
* the code came along while «اشتراک» is live (J06-1b); while it is live and nothing else is said
* under the row, the channel says it is invite-only (J06-1). A channel that sells nothing yet offers
* «وقتی اشتراک باز شد خبرم کن» in the subscribe slot, then «به شما خبر می‌دهیم» with «لغو
* اطلاع‌رسانی» under the row (J05-1g/1h); follow stays beside it, unchanged. Offline, subscribe,
* follow, unfollow and the sale notice freeze and say they need the internet.
*/
export function InvestorActions({
username,
layout,
hasInviteCode,
inviteNoteName,
standing,
follow,
askUnfollow,
@ -36,14 +43,28 @@ export function InvestorActions({
cancelUnfollow,
leaveWaitlist,
isLeavingWaitlist,
requestSaleNotice,
cancelSaleNotice,
}: InvestorActionsProps) {
const { t } = useTranslation(['channel', 'common']);
const offline = useOfflineFreeze(t('common:network.frozen'));
const pendingNoteId = useId();
const isMobile = layout === 'mobile';
const fill = isMobile ? 'flex-1' : undefined;
// A subscriber or a payment in review outranks a sale that closed since.
const saleClosed =
standing.saleClosed && !standing.subscribed && !standing.paymentPending;
const subscribeLive =
!saleClosed && !standing.subscribed && !standing.paymentPending;
const subscribe = standing.subscribed ? (
const subscribe = saleClosed ? (
<SaleNoticeAction
notified={standing.saleNotice}
onRequest={requestSaleNotice}
frozenProps={offline}
className={fill}
/>
) : standing.subscribed ? (
<FlexBox
alignItems="items-center"
justifyContent="justify-center"
@ -105,9 +126,17 @@ export function InvestorActions({
{subscribe}
{followControl}
</FlexBox>
{hasInviteCode && !standing.subscribed && !standing.paymentPending && (
<InviteLinkNote />
{saleClosed && (
<SaleClosedNote
onCancel={standing.saleNotice ? cancelSaleNotice : undefined}
/>
)}
{subscribeLive &&
!standing.waitlisted &&
inviteNoteName !== undefined && (
<InviteOnlyNote name={inviteNoteName} />
)}
{hasInviteCode && subscribeLive && <InviteLinkNote />}
{standing.paymentPending && (
<PaymentPendingNote id={pendingNoteId} layout={layout} />
)}

View File

@ -0,0 +1,25 @@
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Icon } from '@lumina/island/atoms/icon';
import { Typography } from '@lumina/island/atoms/typography';
import { useTranslation } from 'react-i18next';
import type { InviteOnlyNoteProps } from '../types';
/**
* Under the actions of a channel whose subscription is open (J06-1, J06-2j): subscribing needs an
* invite code, and it comes from the creator, named by their display name or «تحلیلگر».
*/
export function InviteOnlyNote({ name }: InviteOnlyNoteProps) {
const { t } = useTranslation('channel');
return (
<FlexBox alignItems="items-start" className="gap-1.5 text-text-secondary">
<Icon name="lock" size={16} className="mt-0.75 flex-none" />
<Typography variant="caption" color="inherit">
{t('actions.invite-only', {
name: name ?? t('actions.invite-only-someone'),
})}
</Typography>
</FlexBox>
);
}

View File

@ -0,0 +1,33 @@
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Icon } from '@lumina/island/atoms/icon';
import { LinkButton } from '@lumina/island/atoms/link-button';
import { Typography } from '@lumina/island/atoms/typography';
import { useTranslation } from 'react-i18next';
import type { SaleClosedNoteProps } from '../types';
/**
* Under the actions of a channel that sells nothing yet (J05-1g): why there is no «اشتراک». Once
* the investor asked to hear (J05-1h), how they will hear, and the way to take it back.
*/
export function SaleClosedNote({ onCancel }: SaleClosedNoteProps) {
const { t } = useTranslation('channel');
return (
<FlexBox alignItems="items-start" className="gap-1.5 text-text-secondary">
<Icon name="clock" size={16} className="mt-0.75 flex-none" />
{onCancel ? (
<FlexBox alignItems="items-center" wrap="flex-wrap" xGap="gap-x-2">
<Typography variant="caption" color="inherit">
{t('sale.notified-note')}
</Typography>
<LinkButton onClick={onCancel}>{t('sale.cancel')}</LinkButton>
</FlexBox>
) : (
<Typography variant="caption" color="inherit">
{t('sale.closed-note')}
</Typography>
)}
</FlexBox>
);
}

View File

@ -0,0 +1,54 @@
import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Icon } from '@lumina/island/atoms/icon';
import { Typography } from '@lumina/island/atoms/typography';
import { cn } from '@lumina/island/tools/cn';
import { useTranslation } from 'react-i18next';
import type { SaleNoticeActionProps } from '../types';
/**
* The subscribe slot of a channel that sells nothing yet (J05-1g/1h): «وقتی اشتراک باز شد خبرم کن»,
* a link to login for a guest, then «به شما خبر می‌دهیم» once asked, drawn as «مشترک هستید» is.
*/
export function SaleNoticeAction({
notified,
onRequest,
href,
frozenProps,
className,
}: SaleNoticeActionProps) {
const { t } = useTranslation('channel');
if (notified) {
return (
<FlexBox
alignItems="items-center"
justifyContent="justify-center"
gap="gap-1"
className={cn('min-h-control-md px-2 text-success-text', className)}
>
<Icon name="check" size={20} className="flex-none" />
<Typography tag="span" color="inherit" className="font-semibold">
{t('sale.notified')}
</Typography>
</FlexBox>
);
}
return href ? (
<Button variant="primary" icon="bell" href={href} className={className}>
{t('sale.notify')}
</Button>
) : (
<Button
variant="primary"
icon="bell"
onClick={onRequest}
className={className}
{...frozenProps}
>
{t('sale.notify')}
</Button>
);
}

View File

@ -1,3 +1,5 @@
import type { OfflineFreeze } from '@lumina/island/hooks/use-online';
import type {
ChannelActionsPartModel,
ChannelStanding,
@ -13,18 +15,33 @@ export type ChannelActionsProps = {
channelUrl: string;
/** mobile: «اشتراک» fills the row; dialogs are bottom sheets. desktop: content width, modals. */
layout: ChannelActionsLayout;
/**
* Anything can be bought (`PublicCreatorPayload.saleOpen`, from the server). `false`: «اشتراک»
* gives way to «وقتی اشتراک باز شد خبرم کن» for a guest (J05-1g); an investor's own checkout
* screen decides for them. `true` by default.
*/
saleOpen?: boolean;
/**
* Shows the invite-only note under the actions (J06-1), naming the creator: their display name,
* or `null` for «تحلیلگر». Left out where the actions have no note, such as the post's bar.
*/
inviteNoteName?: string | null;
};
export type ActionsSkeletonProps = { label: string };
/** The viewer came with this creator's invite link: the note under the actions (J06-1b/1c). */
type InviteLinkProps = { hasInviteCode: boolean };
/**
* The viewer came with this creator's invite link: the note under the actions (J06-1b/1c). And
* the invite-only note's name, when that note shows (`ChannelActionsProps.inviteNoteName`).
*/
type InviteLinkProps = Pick<ChannelActionsProps, 'inviteNoteName'> & {
hasInviteCode: boolean;
};
export type GuestActionsProps = Pick<
ChannelActionsProps,
'username' | 'channelUrl' | 'layout'
> &
Pick<
> & { saleOpen: boolean } & Pick<
ChannelActionsPartModel,
'isGuestPromptOpen' | 'openGuestPrompt' | 'closeGuestPrompt'
> &
@ -68,3 +85,24 @@ export type PendingIndicatorProps = {
layout: ChannelActionsLayout;
className?: string;
};
export type InviteOnlyNoteProps = {
/** The creator's display name; `null` says «تحلیلگر». */
name: string | null;
};
export type SaleClosedNoteProps = {
/** Once the notice is asked for: «لغو اطلاع‌رسانی». */
onCancel?: () => void;
};
export type SaleNoticeActionProps = {
/** Asked already: «به شما خبر می‌دهیم». */
notified: boolean;
onRequest?: () => void;
/** A guest's way: login, back to the channel. */
href?: string;
/** Frozen offline, with why. */
frozenProps?: OfflineFreeze;
className?: string;
};

View File

@ -0,0 +1,33 @@
'use client';
import { useTranslation } from 'react-i18next';
import { ChannelHeaderSkeleton } from '../channel-header';
import { OwnPendingChannel } from './components/OwnPendingChannel';
import { useOwnAddress } from './hooks/use-own-address';
import type { PendingChannelGateProps } from './types';
/**
* A channel whose creator is still under review is public (J05-1g, not for sale), but its creator
* sees their own page under review instead (J08-1g). Which of the two depends on the viewer, so
* until the browser knows it every visitor gets the header's skeleton; the server render stays the
* same for everyone.
*/
export function PendingChannelGate({
layout,
channelUrl,
children,
}: PendingChannelGateProps) {
const { t } = useTranslation('channel');
const own = useOwnAddress();
if (own.kind === 'unknown') {
return (
<ChannelHeaderSkeleton layout={layout} delayed label={t('loading')} />
);
}
if (own.kind === 'own') {
return <OwnPendingChannel layout={layout} channelUrl={channelUrl} />;
}
return children;
}

View File

@ -1,3 +1,8 @@
export { ChannelNotFound } from './ChannelNotFound';
export { ChannelNotFoundTopBar } from './ChannelNotFoundTopBar';
export type { ChannelNotFoundProps, ChannelNotFoundTopBarProps } from './types';
export { PendingChannelGate } from './PendingChannelGate';
export type {
ChannelNotFoundProps,
ChannelNotFoundTopBarProps,
PendingChannelGateProps,
} from './types';

View File

@ -1,3 +1,5 @@
import type { ReactNode } from 'react';
import type { AccountPayload } from '../../../../../../../features/auth';
import type { PublicCreatorPayload } from '../../../../../../../features/channel';
@ -32,3 +34,10 @@ export type OwnAddress =
| { kind: 'unknown' }
| { kind: 'own'; account: AccountPayload }
| { kind: 'other' };
export type PendingChannelGateProps = ChannelLayoutProps & {
/** The channel's address as people read it, for the own page's share. */
channelUrl: string;
/** The public channel every other visitor sees. */
children: ReactNode;
};

View File

@ -3,6 +3,7 @@
import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { EmptyState } from '@lumina/island/molecules/empty-state';
import { ErrorState } from '@lumina/island/molecules/error-state';
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { useTranslation } from 'react-i18next';
@ -19,7 +20,8 @@ import type { ChannelUnavailableProps } from './types';
* «این کانال در حال حاضر در دسترس نیست.», which says that every post, free and premium, stays hidden
* until the suspension is lifted (J05-1f). Suspension outranks everything else, including the paywall. On the channel page
* the creator themself sees their suspended tab instead, so there it waits for the viewer in the
* message's skeleton; a post link shows the message at once.
* message's skeleton; a post link shows the message at once, as a not-found error state with the
* way home (J05-4k).
*/
export function ChannelUnavailable({
context,
@ -52,28 +54,26 @@ export function ChannelUnavailable({
>
<SkeletonPreset preset="state" delayed label={t('loading')} />
</FlexBox>
) : context === 'post' ? (
<ErrorState
kind="not-found"
size="page"
icon="ban"
title={t('unavailable.post-title')}
description={t('unavailable.post-description')}
>
<Button variant="primary" href={ROUTES.home}>
{t('unavailable.home')}
</Button>
</ErrorState>
) : (
<EmptyState
tone="neutral"
icon="ban"
size="page"
title={t(
context === 'post'
? 'unavailable.post-title'
: 'unavailable.channel-title',
)}
description={t(
context === 'post'
? 'unavailable.post-description'
: 'unavailable.channel-description',
)}
>
{context === 'post' && (
<Button variant="primary" href={ROUTES.home}>
{t('unavailable.home')}
</Button>
)}
</EmptyState>
title={t('unavailable.channel-title')}
description={t('unavailable.channel-description')}
/>
);
// The mobile channel page is flush, for the own tab's header; the message keeps the page's inset

View File

@ -3,6 +3,7 @@ import { Button } from '@lumina/island/atoms/button';
import { FieldError } from '@lumina/island/atoms/field-error';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { StatusBadge } from '@lumina/island/atoms/status-badge';
import { useOfflineFreeze } from '@lumina/island/hooks/use-online';
import { Typography } from '@lumina/island/atoms/typography';
import { DetailRow } from '@lumina/island/molecules/detail-row';
import { KeyValue } from '@lumina/island/molecules/key-value';
@ -12,19 +13,25 @@ import type { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import type { LedgerItemPayload } from '../../../../../../../../features/finance';
import { PAYOUT_WEEKDAY } from '../../../../../../../../shared/constants';
import { maskIban } from '../../../../../../../../shared/utils';
import { SupportEntry } from '../../../../../../organisms/support-entry';
import type { LedgerDetailProps } from '../types';
/**
* A row's details (C20 §۳): a bottom sheet on mobile, a side panel on desktop (۶.۲), closed with
* ✕, Escape or the scrim. The values sit in a KeyValue with hairlines, regular unless the board
* makes them strong (your share, the amount). Every figure is the one stored with the entry, never
* today's. A payout always carries its receipt buttons, «مشاهده رسید» first; a receipt that won't
* show says so under them, and they stay as the retry (۳.۸).
* today's. A payout with a receipt carries its buttons, «مشاهده رسید» first; a receipt that won't
* show says so under them, and they stay as the retry (۳.۸). A cancelled payout says the money came
* back and offers «ویرایش شماره شبا», then «درخواست واریز دوباره», frozen until the number was
* fixed, and support (J10-7h).
*/
export function LedgerDetail({ model, layout }: LedgerDetailProps) {
const { t } = useTranslation(['finance', 'common']);
const offline = useOfflineFreeze(t('common:network.frozen'));
const row = model.detail;
const size = layout === 'mobile' ? 'lg' : undefined;
const currency = t('common:currency');
// A missing username reads «مشترک», not a handle.
const subscriber = (name: string | null) =>
@ -178,7 +185,9 @@ export function LedgerDetail({ model, layout }: LedgerDetailProps) {
</KeyValue>
{item.status === 'cancelled' && (
<Typography variant="body-md">
{t('ledger.detail.returned')}
{t('ledger.detail.returned', {
day: t(`weekdays.${PAYOUT_WEEKDAY}`),
})}
</Typography>
)}
{item.status === 'in_progress' && (
@ -192,11 +201,51 @@ export function LedgerDetail({ model, layout }: LedgerDetailProps) {
};
const receipt = row?.kind === 'payout' ? row.receipt : null;
const footer = receipt ? (
const cancelled =
row?.kind === 'payout' && row.status === 'cancelled' ? row : null;
const retryFrozen = cancelled && !cancelled.retry.available;
const footer = cancelled ? (
<>
<Button
variant="primary"
size={size}
block
icon="edit"
onClick={model.editSheba}
>
{t('ledger.detail.edit-sheba')}
</Button>
<Button
variant="secondary"
size={size}
block
isLoading={model.isRetrying}
onClick={model.retryPayout}
{...(retryFrozen
? {
frozen: true,
frozenReason: t(
cancelled.retry.requestedAt
? 'ledger.detail.retry-requested'
: 'ledger.detail.retry-frozen',
),
}
: offline)}
>
{t('ledger.detail.retry')}
</Button>
<FlexBox>
<SupportEntry
trigger="link"
placement={layout === 'mobile' ? 'bottom' : 'popover'}
/>
</FlexBox>
</>
) : receipt ? (
<>
<Button
variant="secondary"
size={layout === 'mobile' ? 'lg' : undefined}
size={size}
block
icon="receipt"
isLoading={model.isReceiptLoading}
@ -206,7 +255,7 @@ export function LedgerDetail({ model, layout }: LedgerDetailProps) {
</Button>
<Button
variant="secondary"
size={layout === 'mobile' ? 'lg' : undefined}
size={size}
block
icon="download"
onClick={() => window.location.assign(receipt.downloadUrl)}

View File

@ -9,11 +9,12 @@ import { Card } from '@lumina/island/molecules/card';
import { Meter } from '@lumina/island/molecules/meter';
import { Element } from '@lumina/island/primitives/element';
import { cn } from '@lumina/island/tools/cn';
import { number } from '@lumina/tools/format';
import { date, number } from '@lumina/tools/format';
import { useId } from 'react';
import { useTranslation } from 'react-i18next';
import { useInviteCodePart } from '../../../../../../../../features/referral';
import { SupportEntry } from '../../../../../../organisms/support-entry';
import type { InviteCodeCardProps } from '../types';
import { CapacityRequestDialog } from './CapacityRequestDialog';
import { InviteShareSheet } from './InviteShareSheet';
@ -24,8 +25,11 @@ const SOFT_ROW = 'min-w-0 rounded-md bg-surface-sunken px-4 py-3';
* The «کد دعوت» card (J10-2): the code with «کپی کد», its capacity, the channel link that carries
* it with «اشتراک‌گذاری» and «کپی لینک», and who sets the capacity. Near full the meter turns amber
* with the seats left (2c); full, a badge, the waitlist and «درخواست افزایش ظرفیت» (2d), or the
* pending request's banner (2f); share and copy stay live. With no priced plan the card is dimmed
* and its actions frozen with the reason (J10-1d).
* pending request's banner (2f); share and copy stay live. The team's answer follows: approved
* shows «فعال», who was told by SMS and the new capacity (2g); rejected shows the reason and
* «درخواست دوباره», frozen until the week is over (2h). With no priced plan the card is dimmed and
* its actions frozen with the reason (J10-1d). Switched off by an admin, the card stays readable:
* «کپی کد» stays live, sharing freezes, and a banner gives the reason (2i).
*/
export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) {
const { t } = useTranslation('dashboard');
@ -36,13 +40,25 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) {
if (!card) return null;
const isInactive = model.view === 'inactive';
const isDisabled = model.view === 'disabled';
const isFull = model.view === 'full';
// Only missing prices have words of their own (J10-1d); a suspended or disabled code just freezes.
const outcome = model.outcome;
const approved = outcome?.kind === 'approved' ? outcome : null;
const rejected = outcome?.kind === 'rejected' ? outcome : null;
const placement = isMobile ? 'bottom' : 'popover';
// Only missing prices have words of their own (J10-1d); a suspended code just freezes.
const inactiveReason =
isInactive && card.inactiveReason === 'no_prices'
? t('invite.inactive')
: undefined;
const frozen = { frozen: isInactive, frozenReason: inactiveReason };
// A switched-off code can still be copied, but its links no longer work (2i).
const shareFrozen = isDisabled
? { frozen: true, frozenReason: t('invite.disabled.frozen') }
: frozen;
const retryDate = rejected?.retryAt
? date(rejected.retryAt, { time: false })
: '';
const capacity = t('invite.capacity', {
used: number(card.used),
max: number(card.maxUses),
@ -56,7 +72,7 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) {
aria-haspopup="dialog"
aria-expanded={model.share.isOpen}
onClick={model.share.share}
{...frozen}
{...shareFrozen}
>
{t('invite.share-open')}
</Button>
@ -67,7 +83,7 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) {
icon="link"
block={isMobile}
onClick={model.copyLink}
{...frozen}
{...shareFrozen}
>
{t('invite.copy-link')}
</Button>
@ -115,6 +131,16 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) {
{t('invite.full')}
</StatusBadge>
)}
{approved && (
<StatusBadge tone="success" icon="check">
{t('invite.active')}
</StatusBadge>
)}
{isDisabled && (
<StatusBadge tone="danger" icon="ban">
{t('invite.disabled.badge')}
</StatusBadge>
)}
</FlexBox>
<FlexBox
alignItems="items-center"
@ -150,7 +176,12 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) {
value={card.used}
max={card.maxUses}
label={capacity}
tone={model.view === 'active' ? 'brand' : 'warning'}
tone={
model.view === 'active' ||
(isDisabled && card.remaining > 0 && !card.nearFull)
? 'brand'
: 'warning'
}
caption={
model.view === 'near-full' ? (
<StatusBadge tone="warning" icon="alert" plain>
@ -160,7 +191,7 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) {
}
/>
)}
{isFull && (
{(isFull || (isDisabled && card.remaining === 0)) && (
<FlexBox alignItems="items-center" gap="gap-2">
<Icon name="users" size={16} className="flex-none" />
<Typography variant="body-sm">
@ -168,6 +199,16 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) {
</Typography>
</FlexBox>
)}
{approved && approved.notifiedCount > 0 && (
<FlexBox alignItems="items-center" gap="gap-2">
<Icon name="users" size={16} className="flex-none" />
<Typography variant="body-sm">
{t('invite.approved.notified', {
n: number(approved.notifiedCount),
})}
</Typography>
</FlexBox>
)}
{isMobile ? (
<>
{linkField}
@ -189,6 +230,32 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) {
{copyLinkButton}
</FlexBox>
)}
{(approved || rejected || isDisabled) && (
<Element
tag="hr"
className="my-0 border-0 border-t border-border-subtle"
/>
)}
{approved && (
<Banner tone="info" icon="check" title={t('invite.approved.title')}>
{approved.from === null
? t('invite.approved.body-plain', { to: number(approved.to) })
: t('invite.approved.body', {
from: number(approved.from),
to: number(approved.to),
})}
</Banner>
)}
{rejected && (
<Banner
tone="warning"
icon="alert"
title={t('invite.rejected.title')}
>
{rejected.reason &&
t('invite.rejected.reason', { reason: rejected.reason })}
</Banner>
)}
{isFull &&
(model.isRequestPending ? (
<Banner tone="neutral" icon="clock">
@ -201,14 +268,51 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) {
block={isMobile}
aria-haspopup="dialog"
onClick={model.request.open}
frozen={rejected ? !rejected.canRetry : false}
frozenReason={
rejected && retryDate
? t('invite.rejected.frozen', { date: retryDate })
: undefined
}
>
{t('invite.request.open')}
{t(rejected ? 'invite.rejected.retry' : 'invite.request.open')}
</Button>
</FlexBox>
))}
<Typography data-keep variant="caption" color="secondary">
{t(isFull ? 'invite.sms-note' : 'invite.team-note')}
</Typography>
{isDisabled && (
<>
<Banner tone="danger" icon="ban" title={t('invite.disabled.title')}>
{card.inactiveNote
? t('invite.disabled.body', { reason: card.inactiveNote })
: t('invite.disabled.body-plain')}
</Banner>
<FlexBox data-keep>
<SupportEntry trigger="link" placement={placement} />
</FlexBox>
</>
)}
{rejected ? (
<FlexBox
data-keep
alignItems="items-center"
wrap="flex-wrap"
xGap="gap-x-1"
>
<Typography variant="caption" color="secondary">
{retryDate
? t('invite.rejected.note', { date: retryDate })
: t('invite.rejected.note-plain')}
</Typography>
<SupportEntry trigger="link" placement={placement} />
</FlexBox>
) : (
!approved &&
!isDisabled && (
<Typography data-keep variant="caption" color="secondary">
{t(isFull ? 'invite.sms-note' : 'invite.team-note')}
</Typography>
)
)}
</Card>
{isMobile && <InviteShareSheet model={model.share} layout={layout} />}
<CapacityRequestDialog model={model.request} layout={layout} />

View File

@ -2,6 +2,7 @@
import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Link } from '@lumina/island/atoms/link';
import { StatusBadge } from '@lumina/island/atoms/status-badge';
import { Typography } from '@lumina/island/atoms/typography';
import { Banner } from '@lumina/island/molecules/banner';
@ -11,6 +12,7 @@ import { useId } from 'react';
import { useTranslation } from 'react-i18next';
import { usePricingCardPart } from '../../../../../../../features/pricing';
import { IDENTITY_ANCHOR } from '../../../../../../../features/verification/constants';
import { ROUTES } from '../../../../../../navigation/navigation';
import { PlanRow } from './components/PlanRow';
import type { PricingCardProps } from './types';
@ -21,7 +23,8 @@ import type { PricingCardProps } from './types';
* desktop). With nothing priced it is one line and «تعیین قیمت‌ها» (1d); during the 7-day lock the
* notice «قیمت‌ها را هر ۷ روز یک‌بار می‌توانید تغییر دهید.» sits under the plans and the button
* stays live, since promotions stay editable (1c). A creator not yet verified, or rejected, sees
* that status above the card (1e); prices stay editable.
* that status above the card as a link to the identity block (1e), pending with «بررسی معمولاً تا
* ۲۴ ساعت طول می‌کشد.» beside it; prices stay editable.
*/
export function PricingCard({ layout }: PricingCardProps) {
const { t } = useTranslation(['pricing', 'common']);
@ -33,14 +36,28 @@ export function PricingCard({ layout }: PricingCardProps) {
<FlexBox direction="flex-col" gap="gap-3">
{model.verification !== 'approved' && (
<FlexBox>
<StatusBadge
status={`verification.${model.verification}`}
aria-label={t('card.verification', {
status: t(`common:status.verification.${model.verification}`),
})}
>
{t(`common:status.verification.${model.verification}`)}
</StatusBadge>
<Link href={`${ROUTES.account.profile}#${IDENTITY_ANCHOR}`}>
<FlexBox
tag="span"
alignItems="items-center"
gap="gap-2"
wrap="flex-wrap"
>
<StatusBadge
status={`verification.${model.verification}`}
aria-label={t('card.verification', {
status: t(`common:status.verification.${model.verification}`),
})}
>
{t(`common:status.verification.${model.verification}`)}
</StatusBadge>
{model.verification === 'pending' && (
<Typography tag="span" variant="caption" color="secondary">
{t('card.review-time')}
</Typography>
)}
</FlexBox>
</Link>
</FlexBox>
)}
<Card

View File

@ -7,7 +7,10 @@ import { useTranslation } from 'react-i18next';
import { MARKETS } from '../../../../../../../shared/constants';
import type { Market } from '../../../../../../../shared/constants';
import { predictionCardLabels } from '../../../../../../../shared/labels';
import {
pendingCloseDetail,
predictionCardLabels,
} from '../../../../../../../shared/labels';
import { useCurrentAccount } from '../../../../../../../stores/auth';
import { ROUTES } from '../../../../../../navigation/navigation';
import type { OwnPredictionCardProps } from './types';
@ -24,8 +27,9 @@ const isMarket = (market: string): market is Market =>
/**
* One of the creator's own predictions on its own (J10-3, J10-3f, J10-3g): پریمیوم when it is, an
* open one with «بستن زودهنگام», a closed one with why and at whose price it closed. A tap on the
* card opens its post, as the DS card links to it. Closing it here updates it in place.
* open one with «بستن زودهنگام», a closed one with why and at whose price it closed. An automatic
* close waiting for ops shows «در انتظار تأیید بسته‌شدن» and freezes «بستن زودهنگام» (J10-3f). A tap
* on the card opens its post, as the DS card links to it. Closing it here updates it in place.
*/
export function OwnPredictionCard({ post, layout }: OwnPredictionCardProps) {
const { t } = useTranslation('content');
@ -51,6 +55,7 @@ export function OwnPredictionCard({ post, layout }: OwnPredictionCardProps) {
onClosePrediction={
prediction.status === 'open' ? () => setIsClosing(true) : undefined
}
pendingClose={pendingCloseDetail(t, prediction)}
labels={labels}
/>
{isClosing && (

View File

@ -5,11 +5,14 @@ import { Typography } from '@lumina/island/atoms/typography';
import { SectionTitle } from '@lumina/island/molecules/section-title';
import { number } from '@lumina/tools/format';
import type { ReactNode } from 'react';
import { useId } from 'react';
import { Fragment, useId } from 'react';
import { useTranslation } from 'react-i18next';
import { useSubscriptionsPart } from '../../../../../../../features/subscription';
import type { SubscriptionPayload } from '../../../../../../../features/subscription';
import type {
EndedGroup,
SubscriptionPayload,
} from '../../../../../../../features/subscription';
import { SupportDialog } from '../../../../../organisms/support-entry';
import { RenewalSheet } from '../renewal-sheet';
import { PeriodItem } from './components/PeriodItem';
@ -19,8 +22,11 @@ import type { SubscriptionListProps } from './types';
/**
* داشبورد › اشتراک‌ها (U2, U11, J07-1): how many are active, then the active cards by nearest
* expiry, a suspended creator's among them, then «اشتراک‌های منقضی‌شده»: the expired cards, then
* every earlier period as its own compact row (J07-1h). No active one: the empty state, with the
* expiry, a suspended creator's among them, then «اشتراک‌های منقضی‌شده», grouped by creator, the
* one that ended last first: their expired card, then every earlier period as its own compact row
* (J07-1h). Only the first group's card is full, when it has no earlier rows; every other row is
* compact, the latest expired one with each creator keeping a small «فعال‌سازی مجدد» and older
* ones linking to the channel (J07-1g, 1h). No active one: the empty state, with the
* expired ones still under it (۳.۲). «تمدید» and «فعال‌سازی مجدد» open the renewal sheet; support
* opens a bottom sheet on mobile and, on desktop, a 320 popover under the card's link with no
* scrim (J07-1b).
@ -29,28 +35,49 @@ export function SubscriptionList({ layout }: SubscriptionListProps) {
const { t } = useTranslation('dashboard');
const model = useSubscriptionsPart();
const expiredTitleId = useId();
const { active, expired, activeCount } = model.dashboard;
const { pastPeriods } = model;
const { active, activeCount } = model.dashboard;
const { endedGroups } = model;
const isDesktop = layout === 'desktop';
const gap = isDesktop ? 'gap-4' : 'gap-3';
const cards = (items: SubscriptionPayload[]): ReactNode =>
items.map((subscription) => (
<SubscriptionItem
key={subscription.id}
subscription={subscription}
onRenew={() => model.openRenewal(subscription)}
onSupport={() => model.toggleSupport(subscription.id)}
supportPopover={
isDesktop
? {
isOpen: model.supportFor === subscription.id,
onClose: model.closeSupport,
}
: undefined
}
/>
));
const card = (
subscription: SubscriptionPayload,
ended?: { density: 'full' | 'compact'; latest: boolean },
): ReactNode => (
<SubscriptionItem
key={subscription.id}
subscription={subscription}
density={ended?.density}
latest={ended?.latest}
onRenew={() => model.openRenewal(subscription)}
onSupport={() => model.toggleSupport(subscription.id)}
supportPopover={
isDesktop
? {
isOpen: model.supportFor === subscription.id,
onClose: model.closeSupport,
}
: undefined
}
/>
);
const ended = (group: EndedGroup, index: number): ReactNode => {
const full = index === 0 && group.periods.length === 0;
return (
<Fragment key={group.creatorId}>
{group.subscriptions.map((subscription, rank) =>
card(subscription, {
density: full && rank === 0 ? 'full' : 'compact',
latest: rank === 0 && subscription.status === 'expired',
}),
)}
{group.periods.map((period) => (
<PeriodItem key={period.id} period={period} />
))}
</Fragment>
);
};
return (
<>
@ -68,12 +95,12 @@ export function SubscriptionList({ layout }: SubscriptionListProps) {
</Typography>
{active.length > 0 ? (
<FlexBox tag="ul" direction="flex-col" gap={gap}>
{cards(active)}
{active.map((subscription) => card(subscription))}
</FlexBox>
) : (
<SubscriptionsEmpty layout={layout} />
)}
{(expired.length > 0 || pastPeriods.length > 0) && (
{endedGroups.length > 0 && (
<>
<SectionTitle
title={t('subscriptions.expired')}
@ -86,10 +113,7 @@ export function SubscriptionList({ layout }: SubscriptionListProps) {
direction="flex-col"
gap={gap}
>
{cards(expired)}
{pastPeriods.map((period) => (
<PeriodItem key={period.id} period={period} />
))}
{endedGroups.map(ended)}
</FlexBox>
</>
)}

View File

@ -12,14 +12,17 @@ import type { SubscriptionItemProps } from '../types';
/**
* One subscription as its card (U2, J07-1): an active one opens its channel and offers «تمدید»;
* a suspended creator's is dimmed with support and the terms, and opens nothing (۱.۳); an expired
* one offers «فعال‌سازی مجدد» and ends at its minute (J07-1g), or, while its creator is still
* suspended, is a compact row with support (J07-1e); a refunded one reads «پایان یافته · بازگشت
* one offers «فعال‌سازی مجدد» and ends at its minute (J07-1g); as a compact row it keeps a small
* «فعال‌سازی مجدد» only when it is the latest with its creator (J07-1h), and while its creator is
* still suspended it is a compact row with support (J07-1e); a refunded one reads «پایان یافته · بازگشت
* وجه» with its end date. Each shows what its latest purchase paid (J07-1f). The creator's display
* name heads the card, their handle under it; without a display name the handle stands for both.
* On desktop support opens as a popover under the card, by its link (J07-1b).
*/
export function SubscriptionItem({
subscription,
density = 'full',
latest = false,
onRenew,
onSupport,
supportPopover,
@ -49,14 +52,15 @@ export function SubscriptionItem({
amount={subscription.amountPaidToman ?? undefined}
daysLeft={subscription.daysLeft ?? undefined}
analystSuspended={isExpiredSuspended}
density={isExpiredSuspended ? 'compact' : 'full'}
density={isExpiredSuspended ? 'compact' : density}
latest={latest}
href={
username && !creator.suspended ? ROUTES.channel(username) : undefined
}
onRenew={onRenew}
onReactivate={onRenew}
onSupport={onSupport}
termsHref={ROUTES.terms}
termsHref={ROUTES.rules.subscription}
labels={subscriptionCardLabels(t, tCommon)}
/>
{supportPopover && (

View File

@ -11,6 +11,14 @@ export type SubscriptionsEmptyProps = { layout: DashboardLayout };
export type SubscriptionItemProps = {
subscription: SubscriptionPayload;
/**
* Under «اشتراک‌های منقضی‌شده» (J07-1g, 1h): `full` only for the group that ended last when it
* has no earlier rows, else `compact`; an active card is always full. Expired while its creator is
* suspended is always compact (J07-1e).
*/
density?: 'full' | 'compact';
/** The latest expired row with its creator: a compact one keeps «فعال‌سازی مجدد». */
latest?: boolean;
onRenew: () => void;
/** «تماس با پشتیبانی» on the card: opens or closes support for it. */
onSupport: () => void;

View File

@ -1,49 +1,98 @@
'use client';
import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { EmptyState } from '@lumina/island/molecules/empty-state';
import { FilterChips } from '@lumina/island/molecules/filter-chips';
import { List } from '@lumina/island/molecules/list-row';
import { useTranslation } from 'react-i18next';
import { useNotificationCentre } from '../../../../../../features/notification';
import {
NOTIFICATION_CATEGORIES,
useNotificationCentre,
} from '../../../../../../features/notification';
import type { NotificationFilter } from '../../../../../../features/notification';
import { NotificationItem } from './components/NotificationItem';
import type { NotificationCentreProps } from './types';
const FILTERS: readonly NotificationFilter[] = [
'all',
...NOTIFICATION_CATEGORIES,
];
/**
* اعلان‌ها (U5 §۲, J07-5): every notification of the last 30 days, newest first, in one list of
* rows whatever its type. Opening it clears the bell. Nothing there: one calm line under a muted
* bell, with no action (۲.۳, J07-5e).
* اعلان‌ها (U5 §۲, J07-5, J07-5h): every notification of the last 30 days, newest first, in one
* list of rows whatever its type. Opening it clears the bell. A creator filters it with chips
* «همه · پیش‌بینی‌ها · مالی · حساب» in place (0058), which stay in both empty states: nothing at
* all says what will arrive here (J07-5k), and an empty chip offers «نمایش همه». An investor's
* empty list is one calm line under a muted bell, with no action (۲.۳, J07-5e).
*/
export function NotificationCentre({
layout,
supportPlacement,
}: NotificationCentreProps) {
const { t } = useTranslation('notifications');
const { t } = useTranslation(['notifications', 'common']);
const model = useNotificationCentre();
const isPage = layout === 'page';
if (model.items.length === 0) {
return (
const content =
model.items.length === 0 ? (
<EmptyState
title={t('empty')}
description={model.showsCategories ? t('empty-analyst') : undefined}
icon="bell-off"
tone="neutral"
size={layout === 'page' ? 'page' : 'section'}
className={layout === 'page' ? 'flex-1' : undefined}
size={isPage ? 'page' : 'section'}
className={isPage ? 'flex-1' : undefined}
/>
) : model.visibleItems.length === 0 ? (
<EmptyState
title={t('empty-category')}
icon="bell-off"
tone="neutral"
size="section"
>
<Button variant="secondary" onClick={() => model.setCategory('all')}>
{t('common:show-all')}
</Button>
</EmptyState>
) : (
<List aria-label={t('label')}>
{model.visibleItems.map((item) => (
<NotificationItem
key={item.id}
item={item}
target={model.targetOf(item)}
onOpen={() => model.open(item)}
onRead={() => model.markRead(item)}
canDispute={model.canDispute(item)}
isOpening={model.openingId === item.id}
supportPlacement={supportPlacement}
/>
))}
</List>
);
}
if (!model.showsCategories) return content;
return (
<List aria-label={t('label')}>
{model.items.map((item) => (
<NotificationItem
key={item.id}
item={item}
target={model.targetOf(item)}
onOpen={() => model.open(item)}
isOpening={model.openingId === item.id}
supportPlacement={supportPlacement}
/>
))}
</List>
<FlexBox
direction="flex-col"
gap="gap-3"
className={isPage ? 'flex-1' : undefined}
>
<FilterChips
label={t('categories.label')}
size="sm"
scroll
options={FILTERS.map((value) => ({
value,
label: t(`categories.${value}`),
}))}
value={model.category}
onChange={model.setCategory}
/>
{content}
</FlexBox>
);
}

View File

@ -1,3 +1,5 @@
import { Avatar } from '@lumina/island/atoms/avatar';
import { Button } from '@lumina/island/atoms/button';
import { Link } from '@lumina/island/atoms/link';
import { LinkButton } from '@lumina/island/atoms/link-button';
import { SupportLink } from '@lumina/island/atoms/support-link';
@ -10,12 +12,15 @@ import { useTranslation } from 'react-i18next';
import { SupportDialog } from '../../../../../organisms/support-entry';
import {
CAPACITY_RESULT_ART,
NOTIFICATION_ART,
NOTIFICATION_BODY_AS_TITLE_TYPES,
NOTIFICATION_CTA_TYPES,
NOTIFICATION_FALLBACK_ART,
NOTIFICATION_SUPPORT_TYPES,
PREDICTION_CLOSE_ART,
} from '../constants';
import type { NotificationArt } from '../constants';
import type { NotificationItemProps } from '../types';
import { useNoticeTime } from './use-notice-time';
@ -27,6 +32,10 @@ const isCtaType = (type: string): type is CtaType => CTA_TYPES.has(type);
const SUPPORT_TYPES: ReadonlySet<string> = new Set(NOTIFICATION_SUPPORT_TYPES);
const BODY_AS_TITLE_TYPES: ReadonlySet<string> = new Set(
NOTIFICATION_BODY_AS_TITLE_TYPES,
);
/** Stretched over the row, so a tap anywhere opens what the title opens. */
const STRETCHED =
'cursor-pointer text-start text-inherit no-underline outline-none after:absolute after:inset-0';
@ -35,20 +44,38 @@ const STRETCHED =
const RING =
'has-[[data-notification-open]:focus-visible]:outline-2 has-[[data-notification-open]:focus-visible]:-outline-offset-2 has-[[data-notification-open]:focus-visible]:outline-action-primary';
function artOf(item: NotificationItemProps['item']): NotificationArt {
if (item.type === 'prediction_closed' && item.closeReason) {
const art = PREDICTION_CLOSE_ART[item.closeReason];
if (art) return art;
}
if (item.type === 'capacity_request_result' && item.outcome) {
return CAPACITY_RESULT_ART[item.outcome];
}
// The type comes from the server, which may send one added after this build.
return Object.hasOwn(NOTIFICATION_ART, item.type)
? NOTIFICATION_ART[item.type]
: NOTIFICATION_FALLBACK_ART;
}
/**
* One notification as a list row (U5 ۱.۱, ۲.۱, J07-5): its icon tile, the title, the body clamped
* to two lines, when it came, and its call to action where one applies. The server writes the
* title and body with the names and amounts in them. An unread one is tinted with a dot. An item
* that leads somewhere opens it from anywhere on the row; one that leads nowhere (a receipt)
* opens its full body on tap instead. An app path (a section, a channel, a post) is a real link; a
* creator's channel is looked up first, so it is a button. A closed prediction's tile follows why
* it closed (J09-6). The expiry notice of a suspended creator's channel offers «تماس با پشتیبانی»
* in place (U5 ۳.۱, ۳.۲).
* One notification as a list row (U5 ۱.۱, ۲.۱, J07-5, J07-5h): its icon tile, the title, the body
* clamped to two lines, when it came, and its call to action where one applies. The server writes
* the title and body with the names and amounts in them; a money notice shows its one long
* sentence as the title (J10-9), and a new subscriber leads with their avatar. An unread one is
* tinted with a dot until it is tapped (0058). An item that leads somewhere opens it from anywhere
* on the row; one that leads nowhere opens its full body on tap instead. An app path (a section, a
* channel, a post, مالی's entry) is a real link; a creator's channel is looked up first, so it is a
* button. A closed prediction's tile follows why it closed (J09-6), and an admin's correction of
* the creator's own offers «اعتراض به اصلاح», which opens support in place, as the expiry notice
* of a suspended creator's channel offers «تماس با پشتیبانی» (U5 ۳.۱, ۳.۲).
*/
export function NotificationItem({
item,
target,
onOpen,
onRead,
canDispute,
isOpening,
supportPlacement,
}: NotificationItemProps) {
@ -57,16 +84,17 @@ export function NotificationItem({
const [isExpanded, setIsExpanded] = useState(false);
const [isSupportOpen, setIsSupportOpen] = useState(false);
const opensSupport = SUPPORT_TYPES.has(item.type);
// The type comes from the server, which may send one added after this build.
const art =
(item.type === 'prediction_closed' && item.closeReason
? PREDICTION_CLOSE_ART[item.closeReason]
: undefined) ??
(Object.hasOwn(NOTIFICATION_ART, item.type)
? NOTIFICATION_ART[item.type]
: NOTIFICATION_FALLBACK_ART);
const art = artOf(item);
const leads = target.kind !== 'none';
const cta = leads && isCtaType(item.type) ? item.type : null;
const bodyAsTitle =
BODY_AS_TITLE_TYPES.has(item.type) && !!item.serverMessage;
const titleText = bodyAsTitle ? item.serverMessage : item.serverTitle;
const message = bodyAsTitle ? '' : item.serverMessage;
const avatar =
item.type === 'new_subscriber' && item.subjectUsername ? (
<Avatar name={item.subjectUsername} size="md" />
) : undefined;
const title =
target.kind === 'path' ? (
@ -74,29 +102,44 @@ export function NotificationItem({
tag={NextLink}
href={target.href}
data-notification-open
onClick={onRead}
className={STRETCHED}
>
{item.serverTitle}
{titleText}
</Element>
) : target.kind === 'creator' ? (
<Element
tag="button"
type="button"
data-notification-open
onClick={onOpen}
onClick={() => {
onRead();
onOpen();
}}
aria-busy={isOpening}
className={STRETCHED}
>
{item.serverTitle}
{titleText}
</Element>
) : !message ? (
// Nothing more to show: a tap only marks it read.
<Element
tag="button"
type="button"
data-notification-open
onClick={onRead}
className={STRETCHED}
>
{titleText}
</Element>
) : (
item.serverTitle
titleText
);
const body =
item.serverMessage &&
message &&
(leads ? (
<Element tag="span" className="line-clamp-2">
{item.serverMessage}
{message}
</Element>
) : (
<Element
@ -105,17 +148,25 @@ export function NotificationItem({
data-notification-open
aria-expanded={isExpanded}
aria-label={t('show-more')}
onClick={() => setIsExpanded((expanded) => !expanded)}
onClick={() => {
onRead();
setIsExpanded((expanded) => !expanded);
}}
className={STRETCHED}
>
<Element tag="span" className={isExpanded ? undefined : 'line-clamp-2'}>
{item.serverMessage}
{message}
</Element>
</Element>
));
const toggleSupport = () => {
onRead();
setIsSupportOpen((open) => !open);
};
return (
<ListRow
leading={avatar}
icon={art.icon}
iconTone={art.tone}
title={title}
@ -128,29 +179,48 @@ export function NotificationItem({
{/* Above the stretched control, so each keeps its own tap and focus. */}
{cta && target.kind === 'path' && (
<Element tag="span" className="relative self-start">
<Link href={target.href} standalone>
<Link href={target.href} standalone onClick={onRead}>
{t(`cta.${cta}`)}
</Link>
</Element>
)}
{cta && target.kind === 'creator' && (
<Element tag="span" className="relative self-start">
<LinkButton standalone onClick={onOpen}>
<LinkButton
standalone
onClick={() => {
onRead();
onOpen();
}}
>
{t(`cta.${cta}`)}
</LinkButton>
</Element>
)}
{opensSupport && (
{(opensSupport || canDispute) && (
// A popover hangs from a positioned parent that also holds its trigger.
<FlexBox tag="span" className="relative self-start">
<SupportLink
standalone
aria-haspopup="dialog"
aria-expanded={isSupportOpen}
onClick={() => setIsSupportOpen((open) => !open)}
>
{t('support')}
</SupportLink>
{canDispute ? (
<Button
variant="secondary"
size="sm"
icon="message"
aria-haspopup="dialog"
aria-expanded={isSupportOpen}
onClick={toggleSupport}
>
{t('cta.dispute')}
</Button>
) : (
<SupportLink
standalone
aria-haspopup="dialog"
aria-expanded={isSupportOpen}
onClick={toggleSupport}
>
{t('support')}
</SupportLink>
)}
<SupportDialog
placement={supportPlacement}
open={isSupportOpen}

View File

@ -2,6 +2,7 @@ import type { IconName } from '@lumina/island/atoms/icon';
import type { ListRowIconTone } from '@lumina/island/molecules/list-row';
import type {
CapacityResultOutcome,
NotificationType,
PredictionCloseReason,
} from '../../../../../../features/notification';
@ -9,7 +10,10 @@ import type {
/** A row's lead tile: its icon on its tone's subtle ground. */
export type NotificationArt = { icon: IconName; tone: ListRowIconTone };
/** Each notification type's icon tile (U5 ۲.۱, J07-5): a payment confirmed is a check on success, etc. */
/**
* Each notification type's icon tile (U5 ۲.۱, J07-5, J07-5h, J10-9): a payment confirmed is a
* check on success, a payout sent a receipt on brand, a refund a minus on danger, etc.
*/
export const NOTIFICATION_ART: Record<NotificationType, NotificationArt> = {
subscription_subscribe: { icon: 'check', tone: 'success' },
subscription_renew: { icon: 'check', tone: 'success' },
@ -18,20 +22,27 @@ export const NOTIFICATION_ART: Record<NotificationType, NotificationArt> = {
subscription_expiry_warning: { icon: 'clock', tone: 'warning' },
subscription_expired: { icon: 'clock', tone: 'neutral' },
payment_pending_review: { icon: 'clock', tone: 'neutral' },
payment_not_confirmed: { icon: 'x-circle', tone: 'danger' },
subscription_expired_suspended: { icon: 'ban', tone: 'warning' },
waitlist_capacity: { icon: 'users', tone: 'brand' },
// Capacity opened, with the investor's code ready (J06-7e).
waitlist_capacity: { icon: 'tag', tone: 'brand' },
sale_opened: { icon: 'bell', tone: 'brand' },
new_subscriber: { icon: 'users', tone: 'brand' },
creator_suspended: { icon: 'ban', tone: 'warning' },
access_restored: { icon: 'check', tone: 'brand' },
account_suspended: { icon: 'ban', tone: 'warning' },
account_reinstated: { icon: 'check', tone: 'brand' },
payout_account_changed: { icon: 'shield-check', tone: 'warning' },
payout_created: { icon: 'receipt', tone: 'neutral' },
payout_cancelled: { icon: 'x-circle', tone: 'warning' },
refund_deducted: { icon: 'receipt', tone: 'neutral' },
verification_approved: { icon: 'shield-check', tone: 'success' },
verification_rejected: { icon: 'x-circle', tone: 'danger' },
payout_account_changed: { icon: 'bell', tone: 'brand' },
payout_created: { icon: 'receipt', tone: 'brand' },
payout_cancelled: { icon: 'alert', tone: 'danger' },
refund_deducted: { icon: 'minus-circle', tone: 'danger' },
ledger_correction: { icon: 'edit', tone: 'neutral' },
capacity_request_result: { icon: 'tag', tone: 'brand' },
capacity_request_result: { icon: 'check', tone: 'success' },
invite_code_deactivated: { icon: 'alert', tone: 'warning' },
prediction_closed: { icon: 'target', tone: 'neutral' },
prediction_corrected: { icon: 'shield-check', tone: 'warning' },
};
/** A closed prediction's tile by why it closed (J09-6): target, stop, horizon or an admin. */
@ -41,9 +52,30 @@ export const PREDICTION_CLOSE_ART: Partial<
target: { icon: 'target', tone: 'success' },
stop: { icon: 'alert', tone: 'danger' },
horizon: { icon: 'clock', tone: 'neutral' },
admin: { icon: 'shield-check', tone: 'neutral' },
admin: { icon: 'shield-check', tone: 'warning' },
};
/** A capacity request's tile by how it ended (J10-2g, J10-2h): approved, or declined. */
export const CAPACITY_RESULT_ART: Record<
CapacityResultOutcome,
NotificationArt
> = {
approved: { icon: 'check', tone: 'success' },
rejected: { icon: 'alert', tone: 'warning' },
};
/**
* Money notices whose one long sentence is the row's title, with no subtitle (J10-9): the server
* keeps a short title for SMS and older clients, the board shows the body alone.
*/
export const NOTIFICATION_BODY_AS_TITLE_TYPES = [
'payout_created',
'payout_cancelled',
'refund_deducted',
'ledger_correction',
'payout_account_changed',
] as const satisfies readonly NotificationType[];
/** A type this front end doesn't know yet (a newer service, an old row): a plain bell. */
export const NOTIFICATION_FALLBACK_ART: NotificationArt = {
icon: 'bell',

View File

@ -16,6 +16,10 @@ export type NotificationItemProps = {
item: NotificationPayload;
target: NotificationTarget;
onOpen: () => void;
/** Any tap on the row: it is read from now on (0058). */
onRead: () => void;
/** The creator's own corrected prediction: «اعتراض به اصلاح» opens support (J09-6). */
canDispute: boolean;
isOpening: boolean;
supportPlacement: 'bottom' | 'popover';
};

View File

@ -29,11 +29,12 @@ export function AnalystList({
columns = 3,
label,
onOpen,
onFollowed,
}: AnalystListProps) {
const { t } = useTranslation('home');
const { t: tCommon } = useTranslation('common');
const labels = useMemo(() => analystCardLabels(t), [t]);
const follow = useAnalystFollowPart();
const follow = useAnalystFollowPart({ onFollowed });
const isDesktop = layout === 'desktop';
// The card's own link is the channel; the follow button above it isn't.

View File

@ -15,6 +15,8 @@ export type AnalystListProps = {
label?: string;
/** A card's channel link was followed: search remembers the analyst. */
onOpen?: (analyst: CreatorSummaryPayload) => void;
/** A follow from a card succeeded: the empty خانه reads its feed again in place (J04-2b). */
onFollowed?: (analyst: CreatorSummaryPayload) => void;
};
export type AnalystListSkeletonProps = {

View File

@ -11,6 +11,7 @@ import { useOwnerPostPart } from '../../../../../features/post';
import { MARKETS } from '../../../../../shared/constants';
import type { Market } from '../../../../../shared/constants';
import {
pendingCloseDetail,
postCardLabels,
predictionCardLabels,
} from '../../../../../shared/labels';
@ -108,6 +109,11 @@ export function ChannelPostCard({
onClosePrediction: canClosePrediction
? owner.openClosePrediction
: undefined,
// An automatic close waiting for ops freezes it (J09-5).
pendingClose:
canClosePrediction && !post.locked && post.prediction
? pendingCloseDetail(t, post.prediction)
: undefined,
},
}
: { onShare, onCopyLink };

View File

@ -25,7 +25,8 @@ import type { ClosePredictionSheetProps } from './types';
* never types. The sheet shows the levels, the price with its source and time (read again every
* 15 seconds), the outcome and return it would record, and that it is final. Without a price now
* the CTA waits frozen behind the warning (J09-4e); if the system closed it meanwhile, the sheet
* shows the closed card instead (J09-4f). A bottom sheet on mobile, a modal on desktop; «انصراف»
* shows the closed card instead (J09-4f); an automatic close waiting for ops (409
* `PREDICTION_CLOSE_PENDING`) freezes it with why (J09-5). A bottom sheet on mobile, a modal on desktop; «انصراف»
* cancels, so there is no ✕. Nothing dismisses it while closing.
*/
export function ClosePredictionSheet({
@ -42,6 +43,13 @@ export function ClosePredictionSheet({
const size = layout === 'mobile' ? 'lg' : undefined;
const closed = model.view === 'closed' ? model.closedPost : null;
const unavailable = model.view === 'unavailable';
// An automatic close waits for ops (J09-5): nothing to close by hand.
const pending = model.view === 'pending';
const blockedReason = pending
? tContent('prediction.pending-close.frozen')
: unavailable
? t('close.unavailable')
: undefined;
const marketName = (market: string) =>
(MARKETS as readonly string[]).includes(market)
@ -63,10 +71,10 @@ export function ClosePredictionSheet({
<FlexBox direction="flex-col" gap="gap-4">
<Typography>{t('close.description')}</Typography>
<PredictionSummary post={post}>
{!unavailable && <QuoteRows quote={model.quote} />}
{!blockedReason && <QuoteRows quote={model.quote} />}
</PredictionSummary>
{unavailable ? (
<Banner tone="warning" title={t('close.unavailable')} />
{blockedReason ? (
<Banner tone="warning" title={blockedReason} />
) : (
<FlexBox
alignItems="items-start"
@ -95,7 +103,7 @@ export function ClosePredictionSheet({
size={size}
block
frozen={model.view !== 'quote'}
frozenReason={unavailable ? t('close.unavailable') : undefined}
frozenReason={blockedReason}
isLoading={model.isClosing}
onClick={model.close}
>

View File

@ -8,9 +8,10 @@ import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { usePrefetchFeaturedCreators } from '../../../../../features/discovery';
import { useHomeFeedPart } from '../../../../../features/feed';
import { useFirstFollow, useHomeFeedPart } from '../../../../../features/feed';
import { ROUTES } from '../../../../navigation/navigation';
import { ChannelPostCard } from '../channel-post-card';
import { FeaturedMore } from './components/FeaturedMore';
import { FeaturedRow } from './components/FeaturedRow';
import { HomeFeedEmpty } from './components/HomeFeedEmpty';
import type { HomeFeedProps, ViewedImage } from './types';
@ -32,6 +33,10 @@ const PostLightbox = dynamic(() =>
* subscription at checkout without leaving the feed (U7 ۲.۶). A tap on an open post's image opens
* the viewer over the feed at that image (C4 ۴.۳), with a back arrow on mobile and ✕ on desktop.
* Share is the device's sheet on mobile and the «کپی لینک» menu on desktop (C4b ۳.۴).
*
* A follow from the empty خانه reads the feed again in place (J04-2b): on this visit the posts
* show without the entry row, with more analysts to follow under them; the next visit is the usual
* خانه.
*/
export function HomeFeed({ layout }: HomeFeedProps) {
const { t } = useTranslation(['home', 'errors']);
@ -47,6 +52,7 @@ export function HomeFeed({ layout }: HomeFeedProps) {
followsAnyone,
now,
} = useHomeFeedPart();
const firstFollow = useFirstFollow();
// The last image tapped stays after the viewer closes, so it closes in place: it fades out and
// focus goes back to the image.
const [viewed, setViewed] = useState<ViewedImage | null>(null);
@ -55,13 +61,20 @@ export function HomeFeed({ layout }: HomeFeedProps) {
const isDesktop = layout === 'desktop';
if (isEmpty) {
return <HomeFeedEmpty followsAnyone={followsAnyone} layout={layout} />;
return (
<HomeFeedEmpty
followsAnyone={followsAnyone}
keepsFeatured={firstFollow.addedFrom !== null}
onFollowed={firstFollow.followed}
layout={layout}
/>
);
}
return (
<>
<FlexBox direction="flex-col" gap={isDesktop ? 'gap-4' : 'gap-3'}>
<FeaturedRow />
{!firstFollow.addedFrom && <FeaturedRow />}
<FlexBox
tag="section"
aria-label={t('feed.label')}
@ -119,6 +132,9 @@ export function HomeFeed({ layout }: HomeFeedProps) {
)
)}
</FlexBox>
{firstFollow.addedFrom && (
<FeaturedMore layout={layout} onFollowed={firstFollow.followed} />
)}
</FlexBox>
{viewed &&
viewedPost &&

View File

@ -20,11 +20,12 @@ import type { FeaturedHomeProps } from '../types';
* خانه for an investor who follows nobody yet (J04-2): what to do, then the first three featured
* analysts to follow from here, and «همه تحلیلگران منتخب» when there are more. The heading is
* static; only the list waits, behind cards of the same size, and a failed read shows in a card
* with a retry under it. Following never refreshes خانه in place: its feed is read again on the
* next visit. With nobody featured, the first-use message alone, centred. On desktop the page
* with a retry under it. A follow here reads خانه's feed again in place (J04-2b): the analyst's
* posts take over, or, with none yet, this layout stays and the card says «دنبال می‌کنید». With
* nobody featured, the first-use message alone, centred. On desktop the page
* widens to the wide column (`data-home-wide`) for a three-card grid, the heading kept to 640px.
*/
export function FeaturedHome({ layout }: FeaturedHomeProps) {
export function FeaturedHome({ layout, onFollowed }: FeaturedHomeProps) {
const { t } = useTranslation('home');
const titleId = useId();
const featured = useFeaturedCreatorsPart();
@ -93,6 +94,7 @@ export function FeaturedHome({ layout }: FeaturedHomeProps) {
analysts={creators.slice(0, EMPTY_HOME_ANALYSTS)}
layout={layout}
columns={3}
onFollowed={onFollowed}
/>
) : (
<AnalystListSkeleton

View File

@ -0,0 +1,84 @@
'use client';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Link } from '@lumina/island/atoms/link';
import { SectionTitle } from '@lumina/island/molecules/section-title';
import { useId } from 'react';
import { useTranslation } from 'react-i18next';
import { useFeaturedCreatorsPart } from '../../../../../../features/discovery';
import { ErrorFallback } from '../../../../../error-boundaries';
import { ROUTES } from '../../../../../navigation/navigation';
import { AnalystList, AnalystListSkeleton } from '../../analyst-list';
import { EMPTY_HOME_ANALYSTS } from '../constants';
import type { FeaturedMoreProps } from '../types';
/**
* Under the posts after the first follow from the empty خانه (J04-2b): «تحلیلگران بیشتر برای دنبال
* کردن» with the first three featured analysts, the one just followed among them saying «دنبال
* می‌کنید», then «همه تحلیلگران منتخب» when there are more: a link on mobile, the title's action on
* desktop, as on the empty خانه, but one card per row in the feed's 640px column. Another follow
* here reads the feed again too.
*/
export function FeaturedMore({ layout, onFollowed }: FeaturedMoreProps) {
const { t } = useTranslation('home');
const titleId = useId();
const featured = useFeaturedCreatorsPart();
const isDesktop = layout === 'desktop';
const creators = featured.creators;
if (creators?.length === 0) return null;
const hasMore = (creators?.length ?? 0) > EMPTY_HOME_ANALYSTS;
const allLabel = t('featured.all');
return (
<FlexBox
tag="section"
aria-labelledby={titleId}
direction="flex-col"
gap={isDesktop ? 'gap-4' : 'gap-3'}
className={isDesktop ? 'pt-4' : 'pt-2'}
>
<SectionTitle
title={t('featured.more-title')}
titleId={titleId}
actionLabel={isDesktop && hasMore ? allLabel : undefined}
actionHref={isDesktop && hasMore ? ROUTES.analysts : undefined}
/>
{featured.error ? (
<ErrorFallback
error={featured.error}
size="part"
name="featured-more"
onRetry={featured.retry}
framed
/>
) : creators ? (
<AnalystList
analysts={creators.slice(0, EMPTY_HOME_ANALYSTS)}
layout={layout}
columns={1}
onFollowed={onFollowed}
/>
) : (
<AnalystListSkeleton
layout={layout}
columns={1}
count={EMPTY_HOME_ANALYSTS}
label={t('featured.loading')}
/>
)}
{!isDesktop && hasMore && (
<Link
href={ROUTES.analysts}
standalone
icon="chevron-left"
className="self-start"
>
{allLabel}
</Link>
)}
</FlexBox>
);
}

View File

@ -10,14 +10,22 @@ import { FeaturedHome } from './FeaturedHome';
/**
* خانه with no posts. Following nobody yet is the first use: the featured analysts to follow
* (J04-2). Following creators who have nothing to show yet says so, with the way to follow more;
* centred in the page on mobile, a card in the column on desktop (S2-Desktop ۰۱).
* (J04-2), which stays after a follow from it while that analyst has nothing to show (J04-2b).
* Following creators who have nothing to show yet says so, with the way to follow more; centred in
* the page on mobile, a card in the column on desktop (S2-Desktop ۰۱).
*/
export function HomeFeedEmpty({ followsAnyone, layout }: HomeFeedEmptyProps) {
export function HomeFeedEmpty({
followsAnyone,
keepsFeatured,
onFollowed,
layout,
}: HomeFeedEmptyProps) {
const { t } = useTranslation('home');
const isDesktop = layout === 'desktop';
if (!followsAnyone) return <FeaturedHome layout={layout} />;
if (!followsAnyone || keepsFeatured) {
return <FeaturedHome layout={layout} onFollowed={onFollowed} />;
}
const state = (
<EmptyState

View File

@ -1,5 +1,7 @@
import type { ReactNode } from 'react';
import type { CreatorSummaryPayload } from '../../../../../features/discovery';
/** mobile: the device's share sheet and bottom sheets. desktop: the 640 column, copy, modals. */
export type HomeFeedLayout = 'mobile' | 'desktop';
@ -21,14 +23,29 @@ export type HomeGuardProps = {
children: ReactNode;
};
/** A follow from the empty خانه succeeded: the feed is read again in place (J04-2b). */
type FollowedHandler = (analyst: CreatorSummaryPayload) => void;
export type HomeFeedEmptyProps = {
/** Follows creators who have nothing to show yet, rather than nobody (S2-01). */
followsAnyone: boolean;
/**
* Followed someone from the empty خانه on this visit, who has nothing to show yet: the featured
* layout stays (J04-2), not the no-posts message.
*/
keepsFeatured: boolean;
onFollowed: FollowedHandler;
layout: HomeFeedLayout;
};
export type FeaturedHomeProps = {
layout: HomeFeedLayout;
onFollowed: FollowedHandler;
};
export type FeaturedMoreProps = {
layout: HomeFeedLayout;
onFollowed: FollowedHandler;
};
/** The image last opened in the viewer: which post, and its place among the post's images. */

View File

@ -2,12 +2,11 @@
import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Icon } from '@lumina/island/atoms/icon';
import type { IconName } from '@lumina/island/atoms/icon';
import { StateArt } from '@lumina/island/atoms/state-art';
import { StatusBadge } from '@lumina/island/atoms/status-badge';
import { Typography } from '@lumina/island/atoms/typography';
import { Card } from '@lumina/island/molecules/card';
import { List, ListRow } from '@lumina/island/molecules/list-row';
import type { ListRowIconTone } from '@lumina/island/molecules/list-row';
import { ResultPanel } from '@lumina/island/molecules/result-panel';
import { useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
@ -18,17 +17,22 @@ import { CreatorProfileDoneStepSkeleton } from './CreatorProfileDoneStepSkeleton
import type { CreatorProfileDoneStepProps } from './types';
const NEXT_STEPS = [
{ icon: 'check-circle', text: 'account', tone: 'text-success-text' },
{ icon: 'clock', text: 'review', tone: 'text-text-secondary' },
{ icon: 'tag', text: 'pricing', tone: 'text-text-secondary' },
{ icon: 'lock', text: 'posting', tone: 'text-text-secondary' },
] as const satisfies readonly { icon: IconName; text: string; tone: string }[];
{ icon: 'check-circle', text: 'account', tone: 'success' },
{ icon: 'clock', text: 'review', tone: 'neutral' },
{ icon: 'tag', text: 'pricing', tone: 'neutral' },
{ icon: 'lock', text: 'posting', tone: 'neutral' },
] as const satisfies readonly {
icon: IconName;
text: string;
tone: ListRowIconTone;
}[];
/**
* The end of registration for a creator (R2-CompleteProfile 1.8, 3.3): identity under review (the
* dashboard's badge), news by SMS and notification, prices can be set now, posting opens after
* approval. «رفتن به کانال» goes to the page that asked for login, else the channel. Focus moves
* to the heading so screen readers hear it.
* The end of registration for a creator (J02-6): the result (registration done, the review takes
* up to 24 hours and its outcome comes by SMS) with the dashboard's pending badge, then what
* happens next as plain rows: the account is made, news by SMS and notification, prices can be set
* now, posting opens after approval. «رفتن به کانال» goes to the page that asked for login, else
* the channel. Focus moves to the heading so screen readers hear it.
*/
export function CreatorProfileDoneStep({
size,
@ -49,48 +53,26 @@ export function CreatorProfileDoneStep({
}
return (
<FlexBox direction="flex-col" gap="gap-6" className="flex-1">
<FlexBox
direction="flex-col"
alignItems="items-center"
gap="gap-3"
className="text-center"
<ResultPanel
title={t('register.profile.done.title')}
titleRef={headingRef}
body={t('register.profile.done.body')}
>
<StateArt icon="check" tone="success" size="compact" />
<Typography
ref={headingRef}
tabIndex={-1}
tag="h1"
variant="heading-md"
className="outline-none"
>
{t('register.profile.done.title')}
</Typography>
<StatusBadge status="verification.pending">
{tCommon('status.verification.pending')}
</StatusBadge>
</FlexBox>
<Card>
<FlexBox
tag="ul"
aria-label={t('register.profile.done.steps-label')}
direction="flex-col"
gap="gap-3"
>
{NEXT_STEPS.map(({ icon, text, tone }) => (
<FlexBox key={text} tag="li" alignItems="items-start" gap="gap-3">
<Icon
name={icon}
size={20}
className={`mt-0.5 flex-none ${tone}`}
/>
<Typography tag="span" variant="body-sm">
{t(`register.profile.done.${text}`)}
</Typography>
</FlexBox>
))}
</FlexBox>
</Card>
<FlexBox direction="flex-col" gap="gap-3">
</ResultPanel>
<List aria-label={t('register.profile.done.steps-label')}>
{NEXT_STEPS.map(({ icon, text, tone }) => (
<ListRow
key={text}
icon={icon}
iconTone={tone}
title={t(`register.profile.done.${text}`)}
/>
))}
</List>
<FlexBox direction="flex-col" gap="gap-2">
<Button
href={routes.landing({
role: 'creator',

View File

@ -1,33 +1,49 @@
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
import { Card } from '@lumina/island/molecules/card';
import { List } from '@lumina/island/molecules/list-row';
import { Element } from '@lumina/island/primitives/element';
import type { CreatorProfileDoneStepSkeletonProps } from './types';
/**
* The end of registration's shape before the viewer and the profile are known: the art, heading
* and badge, the four next steps in their card, and the two buttons. Server-safe, for the page's
* guard and Suspense.
* The end of registration's shape before the viewer and the profile are known: the result's disc,
* heading, body and badge, the four next steps as rows, and the two buttons. Server-safe, for the
* page's guard and Suspense; `delayed` only in the route's `loading.tsx`.
*/
export function CreatorProfileDoneStepSkeleton({
label,
delayed,
}: CreatorProfileDoneStepSkeletonProps) {
return (
<SkeletonRegion label={label}>
<SkeletonRegion label={label} delayed={delayed}>
<FlexBox direction="flex-col" gap="gap-6" aria-hidden>
<FlexBox direction="flex-col" alignItems="items-center" gap="gap-3">
<Skeleton shape="circle" className="size-19" />
<Skeleton className="h-6 w-[55%]" />
<FlexBox
direction="flex-col"
alignItems="items-center"
gap="gap-2"
className="pt-2"
>
<Skeleton shape="circle" className="size-18" />
<Skeleton className="mt-1 h-7 w-[55%]" />
<Skeleton className="h-5 w-[85%]" />
<Skeleton className="h-5 w-[60%]" />
<Skeleton shape="pill" className="h-6 w-32" />
</FlexBox>
<Card>
<FlexBox direction="flex-col" gap="gap-3">
{['account', 'review', 'pricing', 'posting'].map((line) => (
<Skeleton key={line} className="h-5 w-[85%]" />
))}
</FlexBox>
</Card>
<FlexBox direction="flex-col" gap="gap-3">
<List>
{['account', 'review', 'pricing', 'posting'].map((line) => (
<Element key={line} tag="li">
<FlexBox
alignItems="items-center"
gap="gap-3"
className="min-h-16 px-4 py-3"
>
<Skeleton className="size-10 flex-none rounded-lg" />
<Skeleton className="h-5 w-[75%]" />
</FlexBox>
</Element>
))}
</List>
<FlexBox direction="flex-col" gap="gap-2">
<Skeleton shape="pill" className="h-control-lg w-full" />
<Skeleton shape="pill" className="h-control-lg w-full" />
</FlexBox>

View File

@ -9,4 +9,6 @@ export type CreatorProfileDoneStepProps = {
export type CreatorProfileDoneStepSkeletonProps = {
/** Hidden status text: «در حال بارگذاری…». */
label: string;
/** Fades in after 300 ms, so a fast route never flashes it (`loading.tsx` only, G-3d). */
delayed?: boolean;
};

View File

@ -11,6 +11,7 @@ import type { CreatorProfileStepSkeletonProps } from './types';
export function CreatorProfileStepSkeleton({
layout,
label,
delayed,
}: CreatorProfileStepSkeletonProps) {
return (
<StepLayout
@ -18,12 +19,12 @@ export function CreatorProfileStepSkeleton({
aside={
layout === 'desktop' && (
<Card padding="lg">
<SkeletonPreset preset="header" label={label} />
<SkeletonPreset preset="header" label={label} delayed={delayed} />
</Card>
)
}
>
<SkeletonPreset preset="form" count={4} label={label} />
<SkeletonPreset preset="form" count={4} label={label} delayed={delayed} />
</StepLayout>
);
}

View File

@ -22,6 +22,8 @@ export type CreatorProfileStepSkeletonProps = {
layout: CreatorProfileLayout;
/** Hidden status text: «در حال بارگذاری…». */
label: string;
/** Fades in after 300 ms, so a fast route never flashes it (`loading.tsx` only, G-3d). */
delayed?: boolean;
};
export type StepLayoutProps = {

View File

@ -22,9 +22,10 @@ const CHIP_WIDTHS = [
*/
export function InvestorProfileStepSkeleton({
label,
delayed,
}: InvestorProfileStepSkeletonProps) {
return (
<SkeletonRegion label={label}>
<SkeletonRegion label={label} delayed={delayed}>
<FlexBox direction="flex-col" gap="gap-6" aria-hidden>
<FlexBox direction="flex-col" gap="gap-2">
<Skeleton className="h-1 w-full" />

View File

@ -9,4 +9,6 @@ export type InvestorProfileStepProps = {
export type InvestorProfileStepSkeletonProps = {
/** Hidden status text: «در حال بارگذاری…». */
label: string;
/** Fades in after 300 ms, so a fast route never flashes it (`loading.tsx` only, G-3d). */
delayed?: boolean;
};

View File

@ -0,0 +1,48 @@
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Typography } from '@lumina/island/atoms/typography';
import type { GeneralRulesProps } from './types';
/**
* «قوانین عمومی» of «قوانین لومینا» (G-2r): seven numbered sections, verbatim, then when they last
* changed. The same for every visitor, so it renders on the server: on its tab, and inside the
* registration form's rules sheet (G-2s), which gets it rendered.
*/
export function GeneralRules({ layout, labels }: GeneralRulesProps) {
return (
<FlexBox
tag="article"
direction="flex-col"
gap={layout === 'desktop' ? 'gap-6' : 'gap-4'}
>
{/* Desktop's column title is the h1; the mobile bar's name is not a heading. */}
{layout === 'mobile' && (
<Typography tag="h1" className="sr-only">
{labels.title}
</Typography>
)}
{labels.sections.map((section) => {
const titleId = `rules-${layout}-${section.id}`;
return (
<FlexBox
key={section.id}
tag="section"
aria-labelledby={titleId}
direction="flex-col"
className="gap-1.5"
>
<Typography tag="h2" id={titleId} variant="heading-sm">
{section.title}
</Typography>
{section.paragraphs.map((paragraph) => (
<Typography key={paragraph}>{paragraph}</Typography>
))}
</FlexBox>
);
})}
<Typography variant="caption" color="secondary">
{labels.updated}
</Typography>
</FlexBox>
);
}

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