diff --git a/platforms/market/src/app/app-shell/AppShell.tsx b/platforms/market/src/app/app-shell/AppShell.tsx index e32a060..8120d73 100644 --- a/platforms/market/src/app/app-shell/AppShell.tsx +++ b/platforms/market/src/app/app-shell/AppShell.tsx @@ -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. diff --git a/platforms/market/src/app/app-shell/hooks/use-session.ts b/platforms/market/src/app/app-shell/hooks/use-session.ts index 3778049..b1d7bef 100644 --- a/platforms/market/src/app/app-shell/hooks/use-session.ts +++ b/platforms/market/src/app/app-shell/hooks/use-session.ts @@ -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(); diff --git a/platforms/market/src/app/app-shell/hooks/use-suspended-halt.ts b/platforms/market/src/app/app-shell/hooks/use-suspended-halt.ts new file mode 100644 index 0000000..e037936 --- /dev/null +++ b/platforms/market/src/app/app-shell/hooks/use-suspended-halt.ts @@ -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], + ); +} diff --git a/platforms/market/src/app/error-boundaries/error-fallback/ErrorFallback.tsx b/platforms/market/src/app/error-boundaries/error-fallback/ErrorFallback.tsx index 6bad994..2302f13 100644 --- a/platforms/market/src/app/error-boundaries/error-fallback/ErrorFallback.tsx +++ b/platforms/market/src/app/error-boundaries/error-fallback/ErrorFallback.tsx @@ -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( { queryErrors.reset(); if (isServerError) retry(); diff --git a/platforms/market/src/app/error-boundaries/part-boundary/types.ts b/platforms/market/src/app/error-boundaries/part-boundary/types.ts index a3c4d12..9dadbce 100644 --- a/platforms/market/src/app/error-boundaries/part-boundary/types.ts +++ b/platforms/market/src/app/error-boundaries/part-boundary/types.ts @@ -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'; }; diff --git a/platforms/market/src/app/guards/auth-guard/AuthGuard.tsx b/platforms/market/src/app/guards/auth-guard/AuthGuard.tsx index 104d9b5..15a69cc 100644 --- a/platforms/market/src/app/guards/auth-guard/AuthGuard.tsx +++ b/platforms/market/src/app/guards/auth-guard/AuthGuard.tsx @@ -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 ; if (status !== 'member' || !account) return fallback; diff --git a/platforms/market/src/app/navigation/components/account-menu/AccountMenu.tsx b/platforms/market/src/app/navigation/components/account-menu/AccountMenu.tsx index ac9c56d..3dee72c 100644 --- a/platforms/market/src/app/navigation/components/account-menu/AccountMenu.tsx +++ b/platforms/market/src/app/navigation/components/account-menu/AccountMenu.tsx @@ -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', diff --git a/platforms/market/src/app/navigation/components/account-menu/types.ts b/platforms/market/src/app/navigation/components/account-menu/types.ts index 747d04f..9c346e4 100644 --- a/platforms/market/src/app/navigation/components/account-menu/types.ts +++ b/platforms/market/src/app/navigation/components/account-menu/types.ts @@ -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; }; }; diff --git a/platforms/market/src/app/navigation/components/publish-menu/PublishMenu.tsx b/platforms/market/src/app/navigation/components/publish-menu/PublishMenu.tsx index fa5aa8b..110a78d 100644 --- a/platforms/market/src/app/navigation/components/publish-menu/PublishMenu.tsx +++ b/platforms/market/src/app/navigation/components/publish-menu/PublishMenu.tsx @@ -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(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; diff --git a/platforms/market/src/app/navigation/constants.ts b/platforms/market/src/app/navigation/constants.ts index 4c7ed9a..ff8deda 100644 --- a/platforms/market/src/app/navigation/constants.ts +++ b/platforms/market/src/app/navigation/constants.ts @@ -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'; diff --git a/platforms/market/src/app/navigation/navigation.ts b/platforms/market/src/app/navigation/navigation.ts index 69bafd2..f34aa62 100644 --- a/platforms/market/src/app/navigation/navigation.ts +++ b/platforms/market/src/app/navigation/navigation.ts @@ -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. */ diff --git a/platforms/market/src/app/screens/(auth)/auth/login/organisms/login-step/LoginStep.tsx b/platforms/market/src/app/screens/(auth)/auth/login/organisms/login-step/LoginStep.tsx index 7b4a9ff..ec60d72 100644 --- a/platforms/market/src/app/screens/(auth)/auth/login/organisms/login-step/LoginStep.tsx +++ b/platforms/market/src/app/screens/(auth)/auth/login/organisms/login-step/LoginStep.tsx @@ -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, }); diff --git a/platforms/market/src/app/screens/(auth)/auth/login/suspended/organisms/login-suspended-step/LoginSuspendedStep.tsx b/platforms/market/src/app/screens/(auth)/auth/login/suspended/organisms/login-suspended-step/LoginSuspendedStep.tsx index f57725a..50cf514 100644 --- a/platforms/market/src/app/screens/(auth)/auth/login/suspended/organisms/login-suspended-step/LoginSuspendedStep.tsx +++ b/platforms/market/src/app/screens/(auth)/auth/login/suspended/organisms/login-suspended-step/LoginSuspendedStep.tsx @@ -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 ; } + 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 = ( + <> + + + + ); + return ( - - - - - {t('suspended.title')} - - - {suspension.reason - ? t('suspended.reason', { reason: suspension.reason }) - : t('suspended.description')} - - - + - - - + {isCreator && ( + + {t('suspended.sms-note')} + + )} + + {layout === 'mobile' && ( + // Edge to edge under the auth column's 16px sides and bottom padding. + {actions} + )} + ); } diff --git a/platforms/market/src/app/screens/(auth)/auth/login/suspended/organisms/login-suspended-step/types.ts b/platforms/market/src/app/screens/(auth)/auth/login/suspended/organisms/login-suspended-step/types.ts index 6b95520..82b341a 100644 --- a/platforms/market/src/app/screens/(auth)/auth/login/suspended/organisms/login-suspended-step/types.ts +++ b/platforms/market/src/app/screens/(auth)/auth/login/suspended/organisms/login-suspended-step/types.ts @@ -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'; }; diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/RegisterDetailsStep.tsx b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/RegisterDetailsStep.tsx index da26d15..9491acb 100644 --- a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/RegisterDetailsStep.tsx +++ b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/RegisterDetailsStep.tsx @@ -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) { diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/CreatorIdentityForm.tsx b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/CreatorIdentityForm.tsx index f6f5202..6936129 100644 --- a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/CreatorIdentityForm.tsx +++ b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/CreatorIdentityForm.tsx @@ -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')} - + } > diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/DetailsFrame.tsx b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/DetailsFrame.tsx index 90cffb3..eab0360 100644 --- a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/DetailsFrame.tsx +++ b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/DetailsFrame.tsx @@ -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({ + {page.phase === 'expired' && ( void submit()} footer={ <> @@ -35,7 +36,11 @@ export function InvestorDetailsForm(props: DetailsFormProps) { > {t('register.details.submit')} - + } > diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/LeaveRegistrationDialog.tsx b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/LeaveRegistrationDialog.tsx new file mode 100644 index 0000000..c5c0fa0 --- /dev/null +++ b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/LeaveRegistrationDialog.tsx @@ -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 = ( + <> + + + + ); + + return placement === 'sheet' ? ( + + {body} + + ) : ( + + {body} + + ); +} diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/RulesSheet.tsx b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/RulesSheet.tsx new file mode 100644 index 0000000..60faabf --- /dev/null +++ b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/RulesSheet.tsx @@ -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 = ( + + ); + + if (placement === 'sheet') { + return ( + + {children} + + ); + } + return ( + + + + {children} + + + {close} + + + + ); +} diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/TermsLine.tsx b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/TermsLine.tsx index 224919c..4daf212 100644 --- a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/TermsLine.tsx +++ b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/TermsLine.tsx @@ -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 ( - - {before} - {t('register.terms-link')} - + <> + + {before} + setIsOpen(true)}> + {t('register.terms-link')} + + {t('register.terms-after')} + + setIsOpen(false)} + > + {rules} + + ); } diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/types.ts b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/types.ts index 1a216d5..54ba16e 100644 --- a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/types.ts +++ b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/types.ts @@ -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[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 = { diff --git a/platforms/market/src/app/screens/(flow)/account/profile/organisms/creator-profile-edit/components/EditContent.tsx b/platforms/market/src/app/screens/(flow)/account/profile/organisms/creator-profile-edit/components/EditContent.tsx index a533c2a..a6d3f8d 100644 --- a/platforms/market/src/app/screens/(flow)/account/profile/organisms/creator-profile-edit/components/EditContent.tsx +++ b/platforms/market/src/app/screens/(flow)/account/profile/organisms/creator-profile-edit/components/EditContent.tsx @@ -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 = ( - + ); const profileBlock = ( {model.rejectionReason && - t('profile-edit.identity.rejected-reason', { + `${t('profile-edit.identity.rejected-reason', { reason: model.rejectionReason, - })} + })} `} + {t('profile-edit.identity.rejected-guide')}{' '} + )} {model.formError && {model.formError}} @@ -112,40 +126,43 @@ export function IdentityBlock({ model, headingRef }: IdentityBlockProps) { /> )} /> - ( - - t('register.fields.id-card-uploading', { percent }), - }} - /> - )} - /> + {ID_CARD_SIDES.map(({ side, label }) => ( + ( + 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 }), + }} + /> + )} + /> + ))} + ); + + return ( + <> + {isMobile ? ( + + {body} + + ) : ( + + {body} + + )} + setIsSupportOpen(false)} + /> + + ); +} diff --git a/platforms/market/src/app/screens/(flow)/checkout/[username]/organisms/checkout-panel/types.ts b/platforms/market/src/app/screens/(flow)/checkout/[username]/organisms/checkout-panel/types.ts index 0b71aa8..f590cb9 100644 --- a/platforms/market/src/app/screens/(flow)/checkout/[username]/organisms/checkout-panel/types.ts +++ b/platforms/market/src/app/screens/(flow)/checkout/[username]/organisms/checkout-panel/types.ts @@ -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 & { + /** «کد ندارم». */ + 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 = { diff --git a/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/ComposerLocked.tsx b/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/ComposerLocked.tsx deleted file mode 100644 index 5a0eb87..0000000 --- a/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/ComposerLocked.tsx +++ /dev/null @@ -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 = ( - - } - /> - ); - - if (layout === 'mobile') { - return ( - - - - {panel} - - - ); - } - return ( - - {panel} - - ); -} diff --git a/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/ComposerLockedDialog.tsx b/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/ComposerLockedDialog.tsx deleted file mode 100644 index 4b4b0b0..0000000 --- a/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/ComposerLockedDialog.tsx +++ /dev/null @@ -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 ( - - } - > - - {t(`publish.${standing}.reason`)} - - - ); -} diff --git a/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/ComposerLockedRedirect.tsx b/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/ComposerLockedRedirect.tsx new file mode 100644 index 0000000..5d8ae61 --- /dev/null +++ b/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/ComposerLockedRedirect.tsx @@ -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}; +} diff --git a/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/components/LockedActions.tsx b/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/components/LockedActions.tsx deleted file mode 100644 index afa265b..0000000 --- a/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/components/LockedActions.tsx +++ /dev/null @@ -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. - - - - ) : ( - - )} - - - ); -} diff --git a/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/constants.ts b/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/constants.ts deleted file mode 100644 index a3df771..0000000 --- a/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/constants.ts +++ /dev/null @@ -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' }, -}; diff --git a/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/index.ts b/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/index.ts index 8d3c805..21c0e86 100644 --- a/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/index.ts +++ b/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/index.ts @@ -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'; diff --git a/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/types.ts b/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/types.ts index 80d10e6..14abd90 100644 --- a/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/types.ts +++ b/platforms/market/src/app/screens/(flow)/compose/organisms/composer-locked/types.ts @@ -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; }; diff --git a/platforms/market/src/app/screens/(flow)/compose/post/organisms/post-composer/PostComposer.tsx b/platforms/market/src/app/screens/(flow)/compose/post/organisms/post-composer/PostComposer.tsx index 8ed1610..2a78a6e 100644 --- a/platforms/market/src/app/screens/(flow)/compose/post/organisms/post-composer/PostComposer.tsx +++ b/platforms/market/src/app/screens/(flow)/compose/post/organisms/post-composer/PostComposer.tsx @@ -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 ( - - ); - } + const skeleton = ( + + ); + if (access.status === 'pending') return skeleton; if (access.status === 'blocked') { return ( - { - if (window.history.length > 1) router.back(); - else router.push(ROUTES.channel(account.username)); - }} - /> + + {skeleton} + ); } return postId ? ( diff --git a/platforms/market/src/app/screens/(flow)/compose/post/organisms/post-composer/PostComposerDialog.tsx b/platforms/market/src/app/screens/(flow)/compose/post/organisms/post-composer/PostComposerDialog.tsx index 3723504..4c135d4 100644 --- a/platforms/market/src/app/screens/(flow)/compose/post/organisms/post-composer/PostComposerDialog.tsx +++ b/platforms/market/src/app/screens/(flow)/compose/post/organisms/post-composer/PostComposerDialog.tsx @@ -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) { ); } - if (access.status === 'pending') { - return ; - } + const skeleton = ; + if (access.status === 'pending') return skeleton; if (access.status === 'blocked') { return ( - + + {skeleton} + ); } return postId ? ( diff --git a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/PredictionComposer.tsx b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/PredictionComposer.tsx index a139c09..917a8ba 100644 --- a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/PredictionComposer.tsx +++ b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/PredictionComposer.tsx @@ -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 ( - - ); - } + const skeleton = ( + + ); + if (access.status === 'pending') return skeleton; if (access.status === 'blocked') { return ( - { - if (window.history.length > 1) router.back(); - else router.push(ROUTES.channel(account.username)); - }} - /> + + {skeleton} + ); } return ( diff --git a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/PredictionComposerDialog.tsx b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/PredictionComposerDialog.tsx index 475563a..4aa4803 100644 --- a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/PredictionComposerDialog.tsx +++ b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/PredictionComposerDialog.tsx @@ -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 ; if (access.status === 'blocked') { return ( - + + + ); } return ; diff --git a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor/PricingEditor.tsx b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor/PricingEditor.tsx new file mode 100644 index 0000000..8a51b47 --- /dev/null +++ b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor/PricingEditor.tsx @@ -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(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 = ; + + const content = ( + + + + setLeaveTo(null)} + onLeave={leave} + onDirtyChange={setIsDirty} + /> + + + + ); + + if (layout === 'desktop') { + return ( + + + {content} + + ); + } + return ( + <> + + + {content} + + + ); +} diff --git a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor/index.ts b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor/index.ts new file mode 100644 index 0000000..e412e2f --- /dev/null +++ b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor/index.ts @@ -0,0 +1,2 @@ +export { PricingEditor } from './PricingEditor'; +export type { PricingEditorProps } from './types'; diff --git a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor/types.ts b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor/types.ts new file mode 100644 index 0000000..20855bc --- /dev/null +++ b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor/types.ts @@ -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'; +}; diff --git a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/PricingForm.tsx b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/PricingForm.tsx index eec7fc2..9eb754b 100644 --- a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/PricingForm.tsx +++ b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/PricingForm.tsx @@ -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')} ); + const saveAndLeave = () => { + if (!leaveTo) return; + onStay(); + model.save({ onSaved: () => onLeave(leaveTo) }); + }; + return ( model.save()} {...offline} > {t('form.retry')} @@ -181,6 +200,14 @@ export function PricingForm({ layout }: PricingFormProps) { )} + leaveTo && onLeave(leaveTo)} + onStay={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 & { /** Hidden status text: «در حال بارگذاری قیمت‌گذاری…». */ label: string; /** Fades in after 300ms, so a fast route never flashes grey. loading.tsx only. */ diff --git a/platforms/market/src/app/screens/(flow)/payment/result/[paymentId]/organisms/payment-result/PaymentResultSkeleton.tsx b/platforms/market/src/app/screens/(flow)/payment/result/[paymentId]/organisms/payment-result/PaymentResultSkeleton.tsx index 529df87..54c0270 100644 --- a/platforms/market/src/app/screens/(flow)/payment/result/[paymentId]/organisms/payment-result/PaymentResultSkeleton.tsx +++ b/platforms/market/src/app/screens/(flow)/payment/result/[paymentId]/organisms/payment-result/PaymentResultSkeleton.tsx @@ -11,9 +11,14 @@ const RECEIPT_ROWS = ['period', 'amount', 'date', 'expiry', 'reference']; export function PaymentResultSkeleton({ layout, label, + delayed, }: PaymentResultSkeletonProps) { return ( - + + ); +} diff --git a/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/index.ts b/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/index.ts new file mode 100644 index 0000000..dde6429 --- /dev/null +++ b/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/index.ts @@ -0,0 +1,2 @@ +export { RulesTabs } from './RulesTabs'; +export type { RulesTabsLabels, RulesTabsProps } from './types'; diff --git a/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/types.ts b/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/types.ts new file mode 100644 index 0000000..843797a --- /dev/null +++ b/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/types.ts @@ -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; +}; diff --git a/platforms/market/src/app/screens/(landing)/templates/landing-template/LandingTemplate.tsx b/platforms/market/src/app/screens/(landing)/templates/landing-template/LandingTemplate.tsx index 4a2c077..ebceb73 100644 --- a/platforms/market/src/app/screens/(landing)/templates/landing-template/LandingTemplate.tsx +++ b/platforms/market/src/app/screens/(landing)/templates/landing-template/LandingTemplate.tsx @@ -173,7 +173,7 @@ export function LandingTemplate({ diff --git a/platforms/market/src/app/screens/(main)/account/organisms/account-overview/AccountOverview.tsx b/platforms/market/src/app/screens/(main)/account/organisms/account-overview/AccountOverview.tsx index 43f1c45..74cb173 100644 --- a/platforms/market/src/app/screens/(main)/account/organisms/account-overview/AccountOverview.tsx +++ b/platforms/market/src/app/screens/(main)/account/organisms/account-overview/AccountOverview.tsx @@ -92,7 +92,7 @@ export function AccountOverview({ layout }: AccountOverviewProps) { + + + ); + + if (isMobile) { + return ( + + + {intro} + {steps} + + + ); + } + return ( + + + + {intro} + {steps} + + + {buttons} + + + + ); +} diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/approved-welcome/index.ts b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/approved-welcome/index.ts new file mode 100644 index 0000000..2db180c --- /dev/null +++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/approved-welcome/index.ts @@ -0,0 +1,2 @@ +export { ApprovedWelcome } from './ApprovedWelcome'; +export type { ApprovedWelcomeProps } from './types'; diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/approved-welcome/types.ts b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/approved-welcome/types.ts new file mode 100644 index 0000000..b753bc7 --- /dev/null +++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/approved-welcome/types.ts @@ -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'; +}; diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/ChannelActions.tsx b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/ChannelActions.tsx index d83333f..a94d8f4 100644 --- a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/ChannelActions.tsx +++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/ChannelActions.tsx @@ -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: diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/GuestActions.tsx b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/GuestActions.tsx index bee8639..c782d1b 100644 --- a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/GuestActions.tsx +++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/GuestActions.tsx @@ -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 ( <> - - {hasInviteCode ? ( + {saleOpen ? ( + + ) : ( + + )} + {followsToSubscribe ? ( @@ -54,7 +68,11 @@ export function GuestActions({ )} - {hasInviteCode && } + {!saleOpen && } + {saleOpen && inviteNoteName !== undefined && ( + + )} + {followsToSubscribe && } + ) : standing.subscribed ? ( - {hasInviteCode && !standing.subscribed && !standing.paymentPending && ( - + {saleClosed && ( + )} + {subscribeLive && + !standing.waitlisted && + inviteNoteName !== undefined && ( + + )} + {hasInviteCode && subscribeLive && } {standing.paymentPending && ( )} diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/InviteOnlyNote.tsx b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/InviteOnlyNote.tsx new file mode 100644 index 0000000..4b433bd --- /dev/null +++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/InviteOnlyNote.tsx @@ -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 ( + + + + {t('actions.invite-only', { + name: name ?? t('actions.invite-only-someone'), + })} + + + ); +} diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/SaleClosedNote.tsx b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/SaleClosedNote.tsx new file mode 100644 index 0000000..cf9aa86 --- /dev/null +++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/SaleClosedNote.tsx @@ -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 ( + + + {onCancel ? ( + + + {t('sale.notified-note')} + + {t('sale.cancel')} + + ) : ( + + {t('sale.closed-note')} + + )} + + ); +} diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/SaleNoticeAction.tsx b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/SaleNoticeAction.tsx new file mode 100644 index 0000000..f144d0d --- /dev/null +++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/SaleNoticeAction.tsx @@ -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 ( + + + + {t('sale.notified')} + + + ); + } + + return href ? ( + + ) : ( + + ); +} diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/types.ts b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/types.ts index 5ddaecd..5c62e40 100644 --- a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/types.ts +++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/types.ts @@ -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 & { + 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; +}; diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-not-found/PendingChannelGate.tsx b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-not-found/PendingChannelGate.tsx new file mode 100644 index 0000000..2e80b2f --- /dev/null +++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-not-found/PendingChannelGate.tsx @@ -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 ( + + ); + } + if (own.kind === 'own') { + return ; + } + return children; +} diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-not-found/index.ts b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-not-found/index.ts index fdfd20e..b39f3a5 100644 --- a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-not-found/index.ts +++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-not-found/index.ts @@ -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'; diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-not-found/types.ts b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-not-found/types.ts index 90aa1d8..0064c5f 100644 --- a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-not-found/types.ts +++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-not-found/types.ts @@ -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; +}; diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-unavailable/ChannelUnavailable.tsx b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-unavailable/ChannelUnavailable.tsx index bd0f1d3..d28ae28 100644 --- a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-unavailable/ChannelUnavailable.tsx +++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-unavailable/ChannelUnavailable.tsx @@ -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({ > + ) : context === 'post' ? ( + + + ) : ( - {context === 'post' && ( - - )} - + 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 diff --git a/platforms/market/src/app/screens/(main)/dashboard/finance/organisms/ledger/components/LedgerDetail.tsx b/platforms/market/src/app/screens/(main)/dashboard/finance/organisms/ledger/components/LedgerDetail.tsx index 5ac8301..2bb6af0 100644 --- a/platforms/market/src/app/screens/(main)/dashboard/finance/organisms/ledger/components/LedgerDetail.tsx +++ b/platforms/market/src/app/screens/(main)/dashboard/finance/organisms/ledger/components/LedgerDetail.tsx @@ -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) { {item.status === 'cancelled' && ( - {t('ledger.detail.returned')} + {t('ledger.detail.returned', { + day: t(`weekdays.${PAYOUT_WEEKDAY}`), + })} )} {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 ? ( + <> + + + + + + + ) : receipt ? ( <> @@ -67,7 +83,7 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) { icon="link" block={isMobile} onClick={model.copyLink} - {...frozen} + {...shareFrozen} > {t('invite.copy-link')} @@ -115,6 +131,16 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) { {t('invite.full')} )} + {approved && ( + + {t('invite.active')} + + )} + {isDisabled && ( + + {t('invite.disabled.badge')} + + )} 0 && !card.nearFull) + ? 'brand' + : 'warning' + } caption={ model.view === 'near-full' ? ( @@ -160,7 +191,7 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) { } /> )} - {isFull && ( + {(isFull || (isDisabled && card.remaining === 0)) && ( @@ -168,6 +199,16 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) { )} + {approved && approved.notifiedCount > 0 && ( + + + + {t('invite.approved.notified', { + n: number(approved.notifiedCount), + })} + + + )} {isMobile ? ( <> {linkField} @@ -189,6 +230,32 @@ export function InviteCodePanel({ layout, siteUrl }: InviteCodeCardProps) { {copyLinkButton} )} + {(approved || rejected || isDisabled) && ( + + )} + {approved && ( + + {approved.from === null + ? t('invite.approved.body-plain', { to: number(approved.to) }) + : t('invite.approved.body', { + from: number(approved.from), + to: number(approved.to), + })} + + )} + {rejected && ( + + {rejected.reason && + t('invite.rejected.reason', { reason: rejected.reason })} + + )} {isFull && (model.isRequestPending ? ( @@ -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')} ))} - - {t(isFull ? 'invite.sms-note' : 'invite.team-note')} - + {isDisabled && ( + <> + + {card.inactiveNote + ? t('invite.disabled.body', { reason: card.inactiveNote }) + : t('invite.disabled.body-plain')} + + + + + + )} + {rejected ? ( + + + {retryDate + ? t('invite.rejected.note', { date: retryDate }) + : t('invite.rejected.note-plain')} + + + + ) : ( + !approved && + !isDisabled && ( + + {t(isFull ? 'invite.sms-note' : 'invite.team-note')} + + ) + )} {isMobile && } diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/pricing-card/PricingCard.tsx b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/pricing-card/PricingCard.tsx index 7ab1188..e07d052 100644 --- a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/pricing-card/PricingCard.tsx +++ b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/pricing-card/PricingCard.tsx @@ -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) { {model.verification !== 'approved' && ( - - {t(`common:status.verification.${model.verification}`)} - + + + + {t(`common:status.verification.${model.verification}`)} + + {model.verification === 'pending' && ( + + {t('card.review-time')} + + )} + + )} /** * 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 && ( diff --git a/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/subscription-list/SubscriptionList.tsx b/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/subscription-list/SubscriptionList.tsx index 6af5623..7ba4cd0 100644 --- a/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/subscription-list/SubscriptionList.tsx +++ b/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/subscription-list/SubscriptionList.tsx @@ -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) => ( - 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 => ( + 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 ( + + {group.subscriptions.map((subscription, rank) => + card(subscription, { + density: full && rank === 0 ? 'full' : 'compact', + latest: rank === 0 && subscription.status === 'expired', + }), + )} + {group.periods.map((period) => ( + + ))} + + ); + }; return ( <> @@ -68,12 +95,12 @@ export function SubscriptionList({ layout }: SubscriptionListProps) { {active.length > 0 ? ( - {cards(active)} + {active.map((subscription) => card(subscription))} ) : ( )} - {(expired.length > 0 || pastPeriods.length > 0) && ( + {endedGroups.length > 0 && ( <> - {cards(expired)} - {pastPeriods.map((period) => ( - - ))} + {endedGroups.map(ended)} )} diff --git a/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/subscription-list/components/SubscriptionItem.tsx b/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/subscription-list/components/SubscriptionItem.tsx index 7d8740e..8b6516b 100644 --- a/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/subscription-list/components/SubscriptionItem.tsx +++ b/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/subscription-list/components/SubscriptionItem.tsx @@ -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 && ( diff --git a/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/subscription-list/types.ts b/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/subscription-list/types.ts index ea0ffc7..4864fe1 100644 --- a/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/subscription-list/types.ts +++ b/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/subscription-list/types.ts @@ -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; diff --git a/platforms/market/src/app/screens/(main)/notifications/organisms/notification-centre/NotificationCentre.tsx b/platforms/market/src/app/screens/(main)/notifications/organisms/notification-centre/NotificationCentre.tsx index f835a0f..3d304ad 100644 --- a/platforms/market/src/app/screens/(main)/notifications/organisms/notification-centre/NotificationCentre.tsx +++ b/platforms/market/src/app/screens/(main)/notifications/organisms/notification-centre/NotificationCentre.tsx @@ -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 ? ( + ) : model.visibleItems.length === 0 ? ( + + + + ) : ( + + {model.visibleItems.map((item) => ( + model.open(item)} + onRead={() => model.markRead(item)} + canDispute={model.canDispute(item)} + isOpening={model.openingId === item.id} + supportPlacement={supportPlacement} + /> + ))} + ); - } + + if (!model.showsCategories) return content; return ( - - {model.items.map((item) => ( - model.open(item)} - isOpening={model.openingId === item.id} - supportPlacement={supportPlacement} - /> - ))} - + + ({ + value, + label: t(`categories.${value}`), + }))} + value={model.category} + onChange={model.setCategory} + /> + {content} + ); } diff --git a/platforms/market/src/app/screens/(main)/notifications/organisms/notification-centre/components/NotificationItem.tsx b/platforms/market/src/app/screens/(main)/notifications/organisms/notification-centre/components/NotificationItem.tsx index ebe7e69..059fed9 100644 --- a/platforms/market/src/app/screens/(main)/notifications/organisms/notification-centre/components/NotificationItem.tsx +++ b/platforms/market/src/app/screens/(main)/notifications/organisms/notification-centre/components/NotificationItem.tsx @@ -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 = new Set(NOTIFICATION_SUPPORT_TYPES); +const BODY_AS_TITLE_TYPES: ReadonlySet = 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 ? ( + + ) : 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} ) : target.kind === 'creator' ? ( { + onRead(); + onOpen(); + }} aria-busy={isOpening} className={STRETCHED} > - {item.serverTitle} + {titleText} + + ) : !message ? ( + // Nothing more to show: a tap only marks it read. + + {titleText} ) : ( - item.serverTitle + titleText ); const body = - item.serverMessage && + message && (leads ? ( - {item.serverMessage} + {message} ) : ( setIsExpanded((expanded) => !expanded)} + onClick={() => { + onRead(); + setIsExpanded((expanded) => !expanded); + }} className={STRETCHED} > - {item.serverMessage} + {message} )); + const toggleSupport = () => { + onRead(); + setIsSupportOpen((open) => !open); + }; return ( - + {t(`cta.${cta}`)} )} {cta && target.kind === 'creator' && ( - + { + onRead(); + onOpen(); + }} + > {t(`cta.${cta}`)} )} - {opensSupport && ( + {(opensSupport || canDispute) && ( // A popover hangs from a positioned parent that also holds its trigger. - setIsSupportOpen((open) => !open)} - > - {t('support')} - + {canDispute ? ( + + ) : ( + + {t('support')} + + )} = { subscription_subscribe: { icon: 'check', tone: 'success' }, subscription_renew: { icon: 'check', tone: 'success' }, @@ -18,20 +22,27 @@ export const NOTIFICATION_ART: Record = { 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', diff --git a/platforms/market/src/app/screens/(main)/notifications/organisms/notification-centre/types.ts b/platforms/market/src/app/screens/(main)/notifications/organisms/notification-centre/types.ts index 87ff37e..67a06b7 100644 --- a/platforms/market/src/app/screens/(main)/notifications/organisms/notification-centre/types.ts +++ b/platforms/market/src/app/screens/(main)/notifications/organisms/notification-centre/types.ts @@ -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'; }; diff --git a/platforms/market/src/app/screens/(main)/organisms/analyst-list/AnalystList.tsx b/platforms/market/src/app/screens/(main)/organisms/analyst-list/AnalystList.tsx index 70b6347..c632a14 100644 --- a/platforms/market/src/app/screens/(main)/organisms/analyst-list/AnalystList.tsx +++ b/platforms/market/src/app/screens/(main)/organisms/analyst-list/AnalystList.tsx @@ -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. diff --git a/platforms/market/src/app/screens/(main)/organisms/analyst-list/types.ts b/platforms/market/src/app/screens/(main)/organisms/analyst-list/types.ts index 09d8363..47b2b2e 100644 --- a/platforms/market/src/app/screens/(main)/organisms/analyst-list/types.ts +++ b/platforms/market/src/app/screens/(main)/organisms/analyst-list/types.ts @@ -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 = { diff --git a/platforms/market/src/app/screens/(main)/organisms/channel-post-card/ChannelPostCard.tsx b/platforms/market/src/app/screens/(main)/organisms/channel-post-card/ChannelPostCard.tsx index 51b246b..a25c4a4 100644 --- a/platforms/market/src/app/screens/(main)/organisms/channel-post-card/ChannelPostCard.tsx +++ b/platforms/market/src/app/screens/(main)/organisms/channel-post-card/ChannelPostCard.tsx @@ -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 }; diff --git a/platforms/market/src/app/screens/(main)/organisms/close-prediction-sheet/ClosePredictionSheet.tsx b/platforms/market/src/app/screens/(main)/organisms/close-prediction-sheet/ClosePredictionSheet.tsx index 3b0e2bb..1063f49 100644 --- a/platforms/market/src/app/screens/(main)/organisms/close-prediction-sheet/ClosePredictionSheet.tsx +++ b/platforms/market/src/app/screens/(main)/organisms/close-prediction-sheet/ClosePredictionSheet.tsx @@ -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({ {t('close.description')} - {!unavailable && } + {!blockedReason && } - {unavailable ? ( - + {blockedReason ? ( + ) : ( diff --git a/platforms/market/src/app/screens/(main)/organisms/home-feed/HomeFeed.tsx b/platforms/market/src/app/screens/(main)/organisms/home-feed/HomeFeed.tsx index c1c16e2..4107189 100644 --- a/platforms/market/src/app/screens/(main)/organisms/home-feed/HomeFeed.tsx +++ b/platforms/market/src/app/screens/(main)/organisms/home-feed/HomeFeed.tsx @@ -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(null); @@ -55,13 +61,20 @@ export function HomeFeed({ layout }: HomeFeedProps) { const isDesktop = layout === 'desktop'; if (isEmpty) { - return ; + return ( + + ); } return ( <> - + {!firstFollow.addedFrom && } + {firstFollow.addedFrom && ( + + )} {viewed && viewedPost && diff --git a/platforms/market/src/app/screens/(main)/organisms/home-feed/components/FeaturedHome.tsx b/platforms/market/src/app/screens/(main)/organisms/home-feed/components/FeaturedHome.tsx index 2fbad14..74b1267 100644 --- a/platforms/market/src/app/screens/(main)/organisms/home-feed/components/FeaturedHome.tsx +++ b/platforms/market/src/app/screens/(main)/organisms/home-feed/components/FeaturedHome.tsx @@ -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} /> ) : ( EMPTY_HOME_ANALYSTS; + const allLabel = t('featured.all'); + + return ( + + + {featured.error ? ( + + ) : creators ? ( + + ) : ( + + )} + {!isDesktop && hasMore && ( + + {allLabel} + + )} + + ); +} diff --git a/platforms/market/src/app/screens/(main)/organisms/home-feed/components/HomeFeedEmpty.tsx b/platforms/market/src/app/screens/(main)/organisms/home-feed/components/HomeFeedEmpty.tsx index 34d3e04..452a40e 100644 --- a/platforms/market/src/app/screens/(main)/organisms/home-feed/components/HomeFeedEmpty.tsx +++ b/platforms/market/src/app/screens/(main)/organisms/home-feed/components/HomeFeedEmpty.tsx @@ -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 ; + if (!followsAnyone || keepsFeatured) { + return ; + } const state = ( 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. */ diff --git a/platforms/market/src/app/screens/(onboarding)/onboarding/creator-profile/done/organisms/creator-profile-done-step/CreatorProfileDoneStep.tsx b/platforms/market/src/app/screens/(onboarding)/onboarding/creator-profile/done/organisms/creator-profile-done-step/CreatorProfileDoneStep.tsx index b2cd852..1efa029 100644 --- a/platforms/market/src/app/screens/(onboarding)/onboarding/creator-profile/done/organisms/creator-profile-done-step/CreatorProfileDoneStep.tsx +++ b/platforms/market/src/app/screens/(onboarding)/onboarding/creator-profile/done/organisms/creator-profile-done-step/CreatorProfileDoneStep.tsx @@ -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 ( - - - - {t('register.profile.done.title')} - {tCommon('status.verification.pending')} - - - - {NEXT_STEPS.map(({ icon, text, tone }) => ( - - - - {t(`register.profile.done.${text}`)} - - - ))} - - - + + + {NEXT_STEPS.map(({ icon, text, tone }) => ( + + ))} + + ); diff --git a/platforms/market/src/app/screens/organisms/leave-dialog/index.ts b/platforms/market/src/app/screens/organisms/leave-dialog/index.ts new file mode 100644 index 0000000..0d0505f --- /dev/null +++ b/platforms/market/src/app/screens/organisms/leave-dialog/index.ts @@ -0,0 +1,2 @@ +export { LeaveDialog } from './LeaveDialog'; +export type { LeaveDialogProps, LeaveTarget } from './types'; diff --git a/platforms/market/src/app/screens/organisms/leave-dialog/types.ts b/platforms/market/src/app/screens/organisms/leave-dialog/types.ts new file mode 100644 index 0000000..db10409 --- /dev/null +++ b/platforms/market/src/app/screens/organisms/leave-dialog/types.ts @@ -0,0 +1,16 @@ +/** Where leaving goes once confirmed: a link that was followed, or back (no `href`). */ +export type LeaveTarget = { href?: string }; + +export type LeaveDialogProps = { + open: boolean; + /** mobile: a bottom sheet. desktop: an alert modal. */ + layout: 'mobile' | 'desktop'; + /** «ذخیره و خروج» is saving: it spins and the other two wait. */ + isSaving: boolean; + /** «ذخیره و خروج»: save first, leave once it went through. */ + onSave: () => void; + /** «خروج بدون ذخیره»: drop the changes and leave. */ + onDiscard: () => void; + /** «ادامه ویرایش», Escape or the scrim: stay on the page. */ + onStay: () => void; +}; diff --git a/platforms/market/src/app/screens/organisms/support-entry/SupportDialog.tsx b/platforms/market/src/app/screens/organisms/support-entry/SupportDialog.tsx index e3ffa4b..93690d2 100644 --- a/platforms/market/src/app/screens/organisms/support-entry/SupportDialog.tsx +++ b/platforms/market/src/app/screens/organisms/support-entry/SupportDialog.tsx @@ -29,7 +29,7 @@ export function SupportDialog({ onClose={onClose} baleHref={chats.bale} telegramHref={chats.telegram} - termsHref={ROUTES.terms} + termsHref={ROUTES.rules.subscription} labels={{ title: t('support.title'), bale: t('support.bale'), diff --git a/platforms/market/src/app/screens/organisms/support-entry/SupportEntry.tsx b/platforms/market/src/app/screens/organisms/support-entry/SupportEntry.tsx index 75cb7ef..2c5b759 100644 --- a/platforms/market/src/app/screens/organisms/support-entry/SupportEntry.tsx +++ b/platforms/market/src/app/screens/organisms/support-entry/SupportEntry.tsx @@ -35,6 +35,8 @@ export function SupportEntry({ trigger, placement, size }: SupportEntryProps) { {t('support.link')} + ) : trigger === 'inline' ? ( + {t('support.link')} ) : trigger === 'ghost' ? (