Compare commits
No commits in common. "e5c7ec54d7a0ad34727e1b69e012f980a1a0ca13" and "381e01e030ccba5339b7d0aeba6716acb364f7f7" have entirely different histories.
e5c7ec54d7
...
381e01e030
|
|
@ -1,28 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { DesktopHeader, DesktopPageTitle } from '@lumina/market/app/navigation';
|
|
||||||
import { PricingFormSkeleton } from '@lumina/market/app/screens/(flow)/dashboard/pricing/organisms/pricing-form';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../i18n';
|
|
||||||
|
|
||||||
/** C7 before the page arrives, card for card, under the header and its title. */
|
|
||||||
export default function Loading() {
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" className="min-h-dvh bg-bg-page">
|
|
||||||
<DesktopHeader />
|
|
||||||
<FlexBox
|
|
||||||
tag="main"
|
|
||||||
justifyContent="justify-center"
|
|
||||||
className="px-8 py-10"
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-4" className="w-full max-w-form">
|
|
||||||
<DesktopPageTitle title={i18n.t('pricing:title')} />
|
|
||||||
<PricingFormSkeleton
|
|
||||||
layout="desktop"
|
|
||||||
label={i18n.t('pricing:loading')}
|
|
||||||
delayed
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
</FlexBox>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
|
||||||
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
|
|
||||||
import { DesktopHeader, DesktopPageTitle } from '@lumina/market/app/navigation';
|
|
||||||
import {
|
|
||||||
PricingForm,
|
|
||||||
PricingFormSkeleton,
|
|
||||||
} from '@lumina/market/app/screens/(flow)/dashboard/pricing/organisms/pricing-form';
|
|
||||||
import type { Metadata } from 'next';
|
|
||||||
import { Suspense } from 'react';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../i18n';
|
|
||||||
|
|
||||||
export function generateMetadata(): Metadata {
|
|
||||||
return {
|
|
||||||
title: i18n.t('pricing:meta-title'),
|
|
||||||
robots: { index: false },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* C7, «ویرایش قیمتها» on desktop (C7 ۸.۱): the creator header with داشبورد on, back beside the
|
|
||||||
* title, and the form in the 560 column. The form is the creator's own, so it renders in the
|
|
||||||
* browser behind cards of the same size.
|
|
||||||
*/
|
|
||||||
export default function PricingPage() {
|
|
||||||
const skeleton = (
|
|
||||||
<PricingFormSkeleton layout="desktop" label={i18n.t('pricing:loading')} />
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" className="min-h-dvh bg-bg-page">
|
|
||||||
<DesktopHeader />
|
|
||||||
<FlexBox
|
|
||||||
tag="main"
|
|
||||||
justifyContent="justify-center"
|
|
||||||
className="px-8 py-10"
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-4" className="w-full max-w-form">
|
|
||||||
<DesktopPageTitle title={i18n.t('pricing:title')} />
|
|
||||||
<PartBoundary
|
|
||||||
name="pricing-form"
|
|
||||||
description={i18n.t('pricing:error')}
|
|
||||||
framed
|
|
||||||
>
|
|
||||||
<AuthGuard role="creator" fallback={skeleton}>
|
|
||||||
<Suspense fallback={skeleton}>
|
|
||||||
<PricingForm layout="desktop" />
|
|
||||||
</Suspense>
|
|
||||||
</AuthGuard>
|
|
||||||
</PartBoundary>
|
|
||||||
</FlexBox>
|
|
||||||
</FlexBox>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { BalanceSummarySkeleton } from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/balance-summary';
|
|
||||||
import { LedgerSkeleton } from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/ledger';
|
|
||||||
import { PayoutAccountSkeleton } from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/payout-account';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../../i18n';
|
|
||||||
|
|
||||||
/** مالی before it arrives, block for block; the layout keeps the bar and the tabs. */
|
|
||||||
export default function Loading() {
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<BalanceSummarySkeleton
|
|
||||||
layout="desktop"
|
|
||||||
label={i18n.t('finance:balance.loading')}
|
|
||||||
delayed
|
|
||||||
/>
|
|
||||||
<PayoutAccountSkeleton
|
|
||||||
layout="desktop"
|
|
||||||
label={i18n.t('finance:account.loading')}
|
|
||||||
delayed
|
|
||||||
/>
|
|
||||||
<LedgerSkeleton
|
|
||||||
layout="desktop"
|
|
||||||
label={i18n.t('finance:ledger.loading')}
|
|
||||||
delayed
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,103 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
|
||||||
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
|
|
||||||
import {
|
|
||||||
BalanceSummary,
|
|
||||||
BalanceSummarySkeleton,
|
|
||||||
} from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/balance-summary';
|
|
||||||
import {
|
|
||||||
Ledger,
|
|
||||||
LedgerSkeleton,
|
|
||||||
} from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/ledger';
|
|
||||||
import {
|
|
||||||
PayoutAccount,
|
|
||||||
PayoutAccountSkeleton,
|
|
||||||
} from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/payout-account';
|
|
||||||
import { PayoutScheduleNotice } from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/payout-schedule-notice';
|
|
||||||
import { PAYOUT_WEEKDAY } from '@lumina/market/shared/constants';
|
|
||||||
import type { Metadata } from 'next';
|
|
||||||
import { Suspense } from 'react';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../../i18n';
|
|
||||||
|
|
||||||
export function generateMetadata(): Metadata {
|
|
||||||
return {
|
|
||||||
title: i18n.t('dashboard:finance.meta-title'),
|
|
||||||
robots: { index: false },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* داشبورد › مالی (brief §4; C19, C20), in this order: when payouts are made (the same for every
|
|
||||||
* creator, so from the server), then the creator's own balance, شبا and گردش حساب, each loading
|
|
||||||
* and failing on its own, so a failed balance never hides the ledger (C20 ۲.۴).
|
|
||||||
*/
|
|
||||||
export default function FinancePage() {
|
|
||||||
const balanceSkeleton = (
|
|
||||||
<BalanceSummarySkeleton
|
|
||||||
layout="desktop"
|
|
||||||
label={i18n.t('finance:balance.loading')}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
const accountSkeleton = (
|
|
||||||
<PayoutAccountSkeleton
|
|
||||||
layout="desktop"
|
|
||||||
label={i18n.t('finance:account.loading')}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
const ledgerSkeleton = (
|
|
||||||
<LedgerSkeleton layout="desktop" label={i18n.t('finance:ledger.loading')} />
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<PayoutScheduleNotice
|
|
||||||
labels={{
|
|
||||||
before: i18n.t('finance:notice.before'),
|
|
||||||
day: i18n.t(`finance:weekdays.${PAYOUT_WEEKDAY}`),
|
|
||||||
after: i18n.t('finance:notice.after'),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<AuthGuard
|
|
||||||
role="creator"
|
|
||||||
fallback={
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
{balanceSkeleton}
|
|
||||||
{accountSkeleton}
|
|
||||||
{ledgerSkeleton}
|
|
||||||
</FlexBox>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<PartBoundary
|
|
||||||
name="balance-summary"
|
|
||||||
description={i18n.t('finance:balance.error')}
|
|
||||||
framed
|
|
||||||
>
|
|
||||||
<Suspense fallback={balanceSkeleton}>
|
|
||||||
<BalanceSummary layout="desktop" />
|
|
||||||
</Suspense>
|
|
||||||
</PartBoundary>
|
|
||||||
<PartBoundary
|
|
||||||
name="payout-account"
|
|
||||||
description={i18n.t('finance:account.error')}
|
|
||||||
framed
|
|
||||||
>
|
|
||||||
<Suspense fallback={accountSkeleton}>
|
|
||||||
<PayoutAccount layout="desktop" />
|
|
||||||
</Suspense>
|
|
||||||
</PartBoundary>
|
|
||||||
<PartBoundary
|
|
||||||
name="ledger"
|
|
||||||
description={i18n.t('finance:ledger.error')}
|
|
||||||
framed
|
|
||||||
>
|
|
||||||
<Suspense fallback={ledgerSkeleton}>
|
|
||||||
<Ledger layout="desktop" />
|
|
||||||
</Suspense>
|
|
||||||
</PartBoundary>
|
|
||||||
</FlexBox>
|
|
||||||
</AuthGuard>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { OnboardingGuard } from '@lumina/market/app/guards/onboarding-guard';
|
|
||||||
import { DashboardTabs } from '@lumina/market/app/screens/(main)/dashboard/organisms/dashboard-tabs';
|
|
||||||
import type { ReactNode } from 'react';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../i18n';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The creator's داشبورد on desktop (Creator Dashboard ۵.۱): the 640 column under the header, with
|
|
||||||
* the «داشبورد» heading, the two tabs «طرحهای اشتراک» · «مالی», then the tab. Each tab is its own
|
|
||||||
* route with its own loading, so the heading and the tabs stay while one loads. Locked until
|
|
||||||
* registration step 5 is done (0016).
|
|
||||||
*/
|
|
||||||
export default function CreatorDashboardLayout({
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: ReactNode;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<OnboardingGuard>
|
|
||||||
<FlexBox
|
|
||||||
tag="main"
|
|
||||||
justifyContent="justify-center"
|
|
||||||
className="px-8 py-10"
|
|
||||||
>
|
|
||||||
<FlexBox
|
|
||||||
direction="flex-col"
|
|
||||||
gap="gap-4"
|
|
||||||
className="w-full max-w-content"
|
|
||||||
>
|
|
||||||
<Typography tag="h1" variant="heading-lg">
|
|
||||||
{i18n.t('common:nav.dashboard')}
|
|
||||||
</Typography>
|
|
||||||
<DashboardTabs layout="desktop" role="creator" />
|
|
||||||
{children}
|
|
||||||
</FlexBox>
|
|
||||||
</FlexBox>
|
|
||||||
</OnboardingGuard>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { PricingCardSkeleton } from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/pricing-card';
|
|
||||||
import { SubscriberListSkeleton } from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/subscriber-list';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../../i18n';
|
|
||||||
|
|
||||||
/** طرحهای اشتراک before it arrives, card for card; the layout keeps the bar and the tabs. */
|
|
||||||
export default function Loading() {
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-4">
|
|
||||||
<PricingCardSkeleton
|
|
||||||
layout="desktop"
|
|
||||||
label={i18n.t('pricing:card.loading')}
|
|
||||||
delayed
|
|
||||||
/>
|
|
||||||
<SubscriberListSkeleton
|
|
||||||
layout="desktop"
|
|
||||||
label={i18n.t('dashboard:subscribers.loading')}
|
|
||||||
delayed
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
|
||||||
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
|
|
||||||
import {
|
|
||||||
PricingCard,
|
|
||||||
PricingCardSkeleton,
|
|
||||||
} from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/pricing-card';
|
|
||||||
import {
|
|
||||||
SubscriberList,
|
|
||||||
SubscriberListSkeleton,
|
|
||||||
} from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/subscriber-list';
|
|
||||||
import type { Metadata } from 'next';
|
|
||||||
import { Suspense } from 'react';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../../i18n';
|
|
||||||
|
|
||||||
export function generateMetadata(): Metadata {
|
|
||||||
return {
|
|
||||||
title: i18n.t('dashboard:plans.meta-title'),
|
|
||||||
robots: { index: false },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* داشبورد › طرحهای اشتراک (Creator Dashboard §۲): «قیمت طرحها» over مشترکان, the creator's own,
|
|
||||||
* in the browser only. Each card loads and fails on its own (۲.۶); the tabs stay.
|
|
||||||
*/
|
|
||||||
export default function PlansPage() {
|
|
||||||
const pricingSkeleton = (
|
|
||||||
<PricingCardSkeleton
|
|
||||||
layout="desktop"
|
|
||||||
label={i18n.t('pricing:card.loading')}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
const subscribersSkeleton = (
|
|
||||||
<SubscriberListSkeleton
|
|
||||||
layout="desktop"
|
|
||||||
label={i18n.t('dashboard:subscribers.loading')}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<AuthGuard
|
|
||||||
role="creator"
|
|
||||||
fallback={
|
|
||||||
<FlexBox direction="flex-col" gap="gap-4">
|
|
||||||
{pricingSkeleton}
|
|
||||||
{subscribersSkeleton}
|
|
||||||
</FlexBox>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-4">
|
|
||||||
<PartBoundary
|
|
||||||
name="pricing-card"
|
|
||||||
description={i18n.t('pricing:card.error')}
|
|
||||||
framed
|
|
||||||
>
|
|
||||||
<Suspense fallback={pricingSkeleton}>
|
|
||||||
<PricingCard layout="desktop" />
|
|
||||||
</Suspense>
|
|
||||||
</PartBoundary>
|
|
||||||
<PartBoundary
|
|
||||||
name="subscriber-list"
|
|
||||||
description={i18n.t('dashboard:subscribers.error')}
|
|
||||||
framed
|
|
||||||
>
|
|
||||||
<Suspense fallback={subscribersSkeleton}>
|
|
||||||
<SubscriberList layout="desktop" />
|
|
||||||
</Suspense>
|
|
||||||
</PartBoundary>
|
|
||||||
</FlexBox>
|
|
||||||
</AuthGuard>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { MobileTopBar } from '@lumina/market/app/navigation';
|
|
||||||
import { PricingFormSkeleton } from '@lumina/market/app/screens/(flow)/dashboard/pricing/organisms/pricing-form';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../i18n';
|
|
||||||
|
|
||||||
/** C7 before the page arrives, card for card, under its bar. */
|
|
||||||
export default function Loading() {
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" className="min-h-dvh bg-bg-page">
|
|
||||||
<MobileTopBar title={i18n.t('pricing:title')} />
|
|
||||||
<FlexBox tag="main" direction="flex-col" className="flex-1 p-4">
|
|
||||||
<PricingFormSkeleton
|
|
||||||
layout="mobile"
|
|
||||||
label={i18n.t('pricing:loading')}
|
|
||||||
delayed
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
|
||||||
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
|
|
||||||
import { MobileTopBar } from '@lumina/market/app/navigation';
|
|
||||||
import {
|
|
||||||
PricingForm,
|
|
||||||
PricingFormSkeleton,
|
|
||||||
} from '@lumina/market/app/screens/(flow)/dashboard/pricing/organisms/pricing-form';
|
|
||||||
import type { Metadata } from 'next';
|
|
||||||
import { Suspense } from 'react';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../i18n';
|
|
||||||
|
|
||||||
export function generateMetadata(): Metadata {
|
|
||||||
return {
|
|
||||||
title: i18n.t('pricing:meta-title'),
|
|
||||||
robots: { index: false },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* C7, «ویرایش قیمتها» on mobile: a task page pushed from the «قیمت طرحها» card, back · title ·
|
|
||||||
* support and no bottom nav (Creator Dashboard ۴.۱; consistency rules R7, R8). The form is the
|
|
||||||
* creator's own, so it renders in the browser behind cards of the same size.
|
|
||||||
*/
|
|
||||||
export default function PricingPage() {
|
|
||||||
const skeleton = (
|
|
||||||
<PricingFormSkeleton layout="mobile" label={i18n.t('pricing:loading')} />
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" className="min-h-dvh bg-bg-page">
|
|
||||||
<MobileTopBar title={i18n.t('pricing:title')} />
|
|
||||||
<FlexBox tag="main" direction="flex-col" className="flex-1 p-4">
|
|
||||||
<PartBoundary
|
|
||||||
name="pricing-form"
|
|
||||||
description={i18n.t('pricing:error')}
|
|
||||||
framed
|
|
||||||
>
|
|
||||||
<AuthGuard role="creator" fallback={skeleton}>
|
|
||||||
<Suspense fallback={skeleton}>
|
|
||||||
<PricingForm layout="mobile" />
|
|
||||||
</Suspense>
|
|
||||||
</AuthGuard>
|
|
||||||
</PartBoundary>
|
|
||||||
</FlexBox>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { BalanceSummarySkeleton } from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/balance-summary';
|
|
||||||
import { LedgerSkeleton } from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/ledger';
|
|
||||||
import { PayoutAccountSkeleton } from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/payout-account';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../../i18n';
|
|
||||||
|
|
||||||
/** مالی before it arrives, block for block; the layout keeps the bar and the tabs. */
|
|
||||||
export default function Loading() {
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<BalanceSummarySkeleton
|
|
||||||
layout="mobile"
|
|
||||||
label={i18n.t('finance:balance.loading')}
|
|
||||||
delayed
|
|
||||||
/>
|
|
||||||
<PayoutAccountSkeleton
|
|
||||||
layout="mobile"
|
|
||||||
label={i18n.t('finance:account.loading')}
|
|
||||||
delayed
|
|
||||||
/>
|
|
||||||
<LedgerSkeleton
|
|
||||||
layout="mobile"
|
|
||||||
label={i18n.t('finance:ledger.loading')}
|
|
||||||
delayed
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,103 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
|
||||||
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
|
|
||||||
import {
|
|
||||||
BalanceSummary,
|
|
||||||
BalanceSummarySkeleton,
|
|
||||||
} from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/balance-summary';
|
|
||||||
import {
|
|
||||||
Ledger,
|
|
||||||
LedgerSkeleton,
|
|
||||||
} from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/ledger';
|
|
||||||
import {
|
|
||||||
PayoutAccount,
|
|
||||||
PayoutAccountSkeleton,
|
|
||||||
} from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/payout-account';
|
|
||||||
import { PayoutScheduleNotice } from '@lumina/market/app/screens/(main)/dashboard/finance/organisms/payout-schedule-notice';
|
|
||||||
import { PAYOUT_WEEKDAY } from '@lumina/market/shared/constants';
|
|
||||||
import type { Metadata } from 'next';
|
|
||||||
import { Suspense } from 'react';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../../i18n';
|
|
||||||
|
|
||||||
export function generateMetadata(): Metadata {
|
|
||||||
return {
|
|
||||||
title: i18n.t('dashboard:finance.meta-title'),
|
|
||||||
robots: { index: false },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* داشبورد › مالی (brief §4; C19, C20), in this order: when payouts are made (the same for every
|
|
||||||
* creator, so from the server), then the creator's own balance, شبا and گردش حساب, each loading
|
|
||||||
* and failing on its own, so a failed balance never hides the ledger (C20 ۲.۴).
|
|
||||||
*/
|
|
||||||
export default function FinancePage() {
|
|
||||||
const balanceSkeleton = (
|
|
||||||
<BalanceSummarySkeleton
|
|
||||||
layout="mobile"
|
|
||||||
label={i18n.t('finance:balance.loading')}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
const accountSkeleton = (
|
|
||||||
<PayoutAccountSkeleton
|
|
||||||
layout="mobile"
|
|
||||||
label={i18n.t('finance:account.loading')}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
const ledgerSkeleton = (
|
|
||||||
<LedgerSkeleton layout="mobile" label={i18n.t('finance:ledger.loading')} />
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<PayoutScheduleNotice
|
|
||||||
labels={{
|
|
||||||
before: i18n.t('finance:notice.before'),
|
|
||||||
day: i18n.t(`finance:weekdays.${PAYOUT_WEEKDAY}`),
|
|
||||||
after: i18n.t('finance:notice.after'),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<AuthGuard
|
|
||||||
role="creator"
|
|
||||||
fallback={
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
{balanceSkeleton}
|
|
||||||
{accountSkeleton}
|
|
||||||
{ledgerSkeleton}
|
|
||||||
</FlexBox>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<PartBoundary
|
|
||||||
name="balance-summary"
|
|
||||||
description={i18n.t('finance:balance.error')}
|
|
||||||
framed
|
|
||||||
>
|
|
||||||
<Suspense fallback={balanceSkeleton}>
|
|
||||||
<BalanceSummary layout="mobile" />
|
|
||||||
</Suspense>
|
|
||||||
</PartBoundary>
|
|
||||||
<PartBoundary
|
|
||||||
name="payout-account"
|
|
||||||
description={i18n.t('finance:account.error')}
|
|
||||||
framed
|
|
||||||
>
|
|
||||||
<Suspense fallback={accountSkeleton}>
|
|
||||||
<PayoutAccount layout="mobile" />
|
|
||||||
</Suspense>
|
|
||||||
</PartBoundary>
|
|
||||||
<PartBoundary
|
|
||||||
name="ledger"
|
|
||||||
description={i18n.t('finance:ledger.error')}
|
|
||||||
framed
|
|
||||||
>
|
|
||||||
<Suspense fallback={ledgerSkeleton}>
|
|
||||||
<Ledger layout="mobile" />
|
|
||||||
</Suspense>
|
|
||||||
</PartBoundary>
|
|
||||||
</FlexBox>
|
|
||||||
</AuthGuard>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { OnboardingGuard } from '@lumina/market/app/guards/onboarding-guard';
|
|
||||||
import { MobileTopBar } from '@lumina/market/app/navigation';
|
|
||||||
import { DashboardTabs } from '@lumina/market/app/screens/(main)/dashboard/organisms/dashboard-tabs';
|
|
||||||
import type { ReactNode } from 'react';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../i18n';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The creator's داشبورد on mobile (Creator Dashboard ۱.۱): the tab bar «داشبورد», the two tabs
|
|
||||||
* «طرحهای اشتراک» · «مالی», then the tab. Each tab is its own route with its own loading, so the
|
|
||||||
* bar and the tabs stay while one loads. Locked until registration step 5 is done (0016).
|
|
||||||
*/
|
|
||||||
export default function CreatorDashboardLayout({
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: ReactNode;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<OnboardingGuard>
|
|
||||||
<MobileTopBar isTab title={i18n.t('common:nav.dashboard')} />
|
|
||||||
<DashboardTabs layout="mobile" role="creator" />
|
|
||||||
<FlexBox tag="main" direction="flex-col" className="flex-1 p-4">
|
|
||||||
{children}
|
|
||||||
</FlexBox>
|
|
||||||
</OnboardingGuard>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { PricingCardSkeleton } from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/pricing-card';
|
|
||||||
import { SubscriberListSkeleton } from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/subscriber-list';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../../i18n';
|
|
||||||
|
|
||||||
/** طرحهای اشتراک before it arrives, card for card; the layout keeps the bar and the tabs. */
|
|
||||||
export default function Loading() {
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-4">
|
|
||||||
<PricingCardSkeleton
|
|
||||||
layout="mobile"
|
|
||||||
label={i18n.t('pricing:card.loading')}
|
|
||||||
delayed
|
|
||||||
/>
|
|
||||||
<SubscriberListSkeleton
|
|
||||||
layout="mobile"
|
|
||||||
label={i18n.t('dashboard:subscribers.loading')}
|
|
||||||
delayed
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { PartBoundary } from '@lumina/market/app/error-boundaries';
|
|
||||||
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
|
|
||||||
import {
|
|
||||||
PricingCard,
|
|
||||||
PricingCardSkeleton,
|
|
||||||
} from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/pricing-card';
|
|
||||||
import {
|
|
||||||
SubscriberList,
|
|
||||||
SubscriberListSkeleton,
|
|
||||||
} from '@lumina/market/app/screens/(main)/dashboard/plans/organisms/subscriber-list';
|
|
||||||
import type { Metadata } from 'next';
|
|
||||||
import { Suspense } from 'react';
|
|
||||||
|
|
||||||
import { i18n } from '../../../../../i18n';
|
|
||||||
|
|
||||||
export function generateMetadata(): Metadata {
|
|
||||||
return {
|
|
||||||
title: i18n.t('dashboard:plans.meta-title'),
|
|
||||||
robots: { index: false },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* داشبورد › طرحهای اشتراک (Creator Dashboard §۲): «قیمت طرحها» over مشترکان, the creator's own,
|
|
||||||
* in the browser only. Each card loads and fails on its own (۲.۶); the tabs stay.
|
|
||||||
*/
|
|
||||||
export default function PlansPage() {
|
|
||||||
const pricingSkeleton = (
|
|
||||||
<PricingCardSkeleton
|
|
||||||
layout="mobile"
|
|
||||||
label={i18n.t('pricing:card.loading')}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
const subscribersSkeleton = (
|
|
||||||
<SubscriberListSkeleton
|
|
||||||
layout="mobile"
|
|
||||||
label={i18n.t('dashboard:subscribers.loading')}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<AuthGuard
|
|
||||||
role="creator"
|
|
||||||
fallback={
|
|
||||||
<FlexBox direction="flex-col" gap="gap-4">
|
|
||||||
{pricingSkeleton}
|
|
||||||
{subscribersSkeleton}
|
|
||||||
</FlexBox>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-4">
|
|
||||||
<PartBoundary
|
|
||||||
name="pricing-card"
|
|
||||||
description={i18n.t('pricing:card.error')}
|
|
||||||
framed
|
|
||||||
>
|
|
||||||
<Suspense fallback={pricingSkeleton}>
|
|
||||||
<PricingCard layout="mobile" />
|
|
||||||
</Suspense>
|
|
||||||
</PartBoundary>
|
|
||||||
<PartBoundary
|
|
||||||
name="subscriber-list"
|
|
||||||
description={i18n.t('dashboard:subscribers.error')}
|
|
||||||
framed
|
|
||||||
>
|
|
||||||
<Suspense fallback={subscribersSkeleton}>
|
|
||||||
<SubscriberList layout="mobile" />
|
|
||||||
</Suspense>
|
|
||||||
</PartBoundary>
|
|
||||||
</FlexBox>
|
|
||||||
</AuthGuard>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
# 0034 The creator's داشبورد is two tab routes, C7 a pushed page
|
|
||||||
|
|
||||||
Status: Proposed · Area: architecture · Date: 2026-10-08 · Decided by: agent
|
|
||||||
|
|
||||||
## Context
|
|
||||||
|
|
||||||
Board 04 gives the creator two dashboard tabs, «طرحهای اشتراک» (pricing card and مشترکان) and «مالی» (C19 + C20), and opens C7 as a full page behind «ویرایش قیمتها» with no tab row and no bottom nav. The repo had placeholder routes `/dashboard/pricing` (under `(main)`), `/dashboard/finance/ledger` and `/dashboard/finance/sheba`.
|
|
||||||
|
|
||||||
## Decision
|
|
||||||
|
|
||||||
- The creator's tabs live in `dashboard/(creator)`, mirroring 0025: `/dashboard/plans` (the default; the nav's داشبورد links here) and `/dashboard/finance`, each with its own `loading.tsx`, under a layout with the bar or heading, `DashboardTabs role="creator"` and `OnboardingGuard`.
|
|
||||||
- C7 is `/dashboard/pricing` in `(flow)`: back · title · support on mobile, the header with back beside the title on desktop.
|
|
||||||
- The شبا form expands in place inside مالی and the ledger's details open in a bottom sheet (mobile) or side panel (desktop); `ledger` and `sheba` sub-routes are removed. Only the ledger tab is in the URL (`?ledger=payouts`).
|
|
||||||
- Each card (pricing, مشترکان, balance, شبا, ledger) is its own browser part with a same-size skeleton and `PartBoundary`; the payout-day notice is server-rendered, the same for every creator.
|
|
||||||
|
|
||||||
## Alternatives
|
|
||||||
|
|
||||||
- One `/dashboard` page with in-page tabs: one boundary for both tabs, and the URL couldn't open مالی (the SMS links to `/dashboard/finance`).
|
|
||||||
- Keep C7 under `(main)`: the bottom nav would show on a task page (R8).
|
|
||||||
|
|
||||||
## Consequences
|
|
||||||
|
|
||||||
The new_subscriber notice now links to `/dashboard/plans` (API). `ROUTES.dashboard.ledger` and `.sheba` are gone.
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
# 0035 A promotion's date and time are picked with native selects
|
|
||||||
|
|
||||||
Status: Proposed · Area: design · Date: 2026-10-08 · Decided by: agent
|
|
||||||
|
|
||||||
## Context
|
|
||||||
|
|
||||||
C7 ۴.۳ draws a Shamsi wheel picker (day, month, year columns and a time row) in a bottom sheet. Island has no date picker, and a drawn wheel needs its own scroll physics, snapping and keyboard model.
|
|
||||||
|
|
||||||
## Decision
|
|
||||||
|
|
||||||
Pick a promotion's start and end with island `Select`s (day, month, year, hour, minute; minutes in steps of 5 plus 59) in a `Sheet` on mobile and a `Modal` on desktop, with «بدون تاریخ پایان» for an end. Phones draw native selects as wheels. Shamsi ↔ instant conversion is `@lumina/tools/jalali`, in Tehran time.
|
|
||||||
|
|
||||||
## Alternatives
|
|
||||||
|
|
||||||
- A drawn wheel: closer to the board, but a new interaction component to build and test for one field.
|
|
||||||
- `<input type="datetime-local">`: Gregorian only.
|
|
||||||
|
|
||||||
## Consequences
|
|
||||||
|
|
||||||
The desktop picker is a row of selects rather than columns. A real wheel can replace the body later without changing the form.
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
# 0036 Save stays live during the 7-day lock, for promotions
|
|
||||||
|
|
||||||
Status: Proposed · Area: architecture · Date: 2026-10-08 · Decided by: agent
|
|
||||||
|
|
||||||
## Context
|
|
||||||
|
|
||||||
C7 ۶.۲ removes «ذخیره قیمتگذاری» during the lock while promotion controls stay live; the board leaves open how a promotion change is then committed. The API saves a promotion change during the lock and refuses only a standing-price or period change (409).
|
|
||||||
|
|
||||||
## Decision
|
|
||||||
|
|
||||||
During the lock, standing prices and period switches are read-only (50%), promotions stay editable, and the save button stays, so promotion changes go through the same check and confirmation as any save.
|
|
||||||
|
|
||||||
## Alternatives
|
|
||||||
|
|
||||||
- No save button (as drawn): a promotion set during the lock could never be stored.
|
|
||||||
- Save each promotion on toggle: a second commit path, unlike every other C7 change.
|
|
||||||
|
|
||||||
## Consequences
|
|
||||||
|
|
||||||
The locked form looks like the free one apart from the frozen fields and the notice.
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
# 0037 Payout receipts open through the creator's session, not signed URLs
|
|
||||||
|
|
||||||
Status: Proposed · Area: architecture · Date: 2026-10-08 · Decided by: agent
|
|
||||||
|
|
||||||
## Context
|
|
||||||
|
|
||||||
C20 ۳.۷ opens a payout's receipt (an image in the lightbox, a PDF in a new tab) and downloads it "through a signed expiring URL". The API has no signed URLs; an admin uploads the receipt, so file-service's owner check would refuse the creator.
|
|
||||||
|
|
||||||
## Decision
|
|
||||||
|
|
||||||
The API streams a receipt from `GET /v1/payouts/me/payouts/:id/receipt` after checking the payout is the creator's (`?download=1` for an attachment). The browser loads it on its own origin through `/api` (0018), so the session cookie authorizes it; the repository maps each payout to `receipt { url, downloadUrl, isImage }`.
|
|
||||||
|
|
||||||
## Alternatives
|
|
||||||
|
|
||||||
- Signed expiring URLs: a signing secret and expiry handling in the gateway, for files that only their creator ever opens.
|
|
||||||
|
|
||||||
## Consequences
|
|
||||||
|
|
||||||
A receipt link only works in a signed-in browser of that creator; nothing expires to regenerate (C20 ۳.۸'s "expired link" case cannot happen).
|
|
||||||
|
|
@ -35,7 +35,3 @@
|
||||||
- 0031 design: List renew and reactivate periods as island `TierOption` cards, as checkout does, instead of R3's chip grid.
|
- 0031 design: List renew and reactivate periods as island `TierOption` cards, as checkout does, instead of R3's chip grid.
|
||||||
- 0032 architecture: Serve the notification centre at `/notifications` on mobile and as a lazily loaded side panel from bear's header bell; opening it marks all read.
|
- 0032 architecture: Serve the notification centre at `/notifications` on mobile and as a lazily loaded side panel from bear's header bell; opening it marks all read.
|
||||||
- 0033 architecture: Keep the payment sent to the bank in the checkout draft and settle it through `POST /subscriptions/payments/:id/abandon` only on the page that came back from the bank (bfcache or a history load), triggered by the app shell and awaited by checkout's screen read.
|
- 0033 architecture: Keep the payment sent to the bank in the checkout draft and settle it through `POST /subscriptions/payments/:id/abandon` only on the page that came back from the bank (bfcache or a history load), triggered by the app shell and awaited by checkout's screen read.
|
||||||
- 0034 architecture: Serve the creator's داشبورد from `dashboard/(creator)` as `/dashboard/plans` (default) and `/dashboard/finance`, and C7 at `/dashboard/pricing` in `(flow)`; the شبا form and ledger details open in place.
|
|
||||||
- 0035 design: Pick a promotion's Shamsi date and time with island `Select`s in a sheet or modal, not a drawn wheel.
|
|
||||||
- 0036 architecture: Keep «ذخیره قیمتگذاری» live during the 7-day lock so promotion changes save; standing prices and period switches stay read-only.
|
|
||||||
- 0037 architecture: Open payout receipts from the API's session-authorized `/payouts/me/payouts/:id/receipt` through `/api`, not signed expiring URLs.
|
|
||||||
|
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
import { useId } from 'react';
|
|
||||||
|
|
||||||
import { Element } from '../../primitives/element';
|
|
||||||
import { cn } from '../../tools/cn';
|
|
||||||
import { FlexBox } from '../flex-box';
|
|
||||||
import { Icon } from '../icon';
|
|
||||||
import { Typography } from '../typography';
|
|
||||||
import type { SelectProps } from './types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A labelled native select, 44px high. On phones the system draws its own wheel or list, so a
|
|
||||||
* date or time picker built from these needs no script of its own.
|
|
||||||
*/
|
|
||||||
export function Select({
|
|
||||||
label,
|
|
||||||
options,
|
|
||||||
className,
|
|
||||||
id,
|
|
||||||
...props
|
|
||||||
}: SelectProps) {
|
|
||||||
const fallbackId = useId();
|
|
||||||
const selectId = id ?? fallbackId;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox
|
|
||||||
direction="flex-col"
|
|
||||||
gap="gap-1"
|
|
||||||
className={cn('min-w-0', className)}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
tag="label"
|
|
||||||
htmlFor={selectId}
|
|
||||||
variant="caption"
|
|
||||||
color="secondary"
|
|
||||||
>
|
|
||||||
{label}
|
|
||||||
</Typography>
|
|
||||||
<FlexBox tag="span" alignItems="items-center" className="relative">
|
|
||||||
<Element
|
|
||||||
tag="select"
|
|
||||||
id={selectId}
|
|
||||||
className="h-touch-target w-full cursor-pointer appearance-none rounded-md border border-border-default bg-surface ps-3 pe-8 text-body-md text-text-primary outline-none transition-colors duration-120 ease-standard hover:border-border-strong focus-visible:focus-ring disabled:cursor-not-allowed disabled:opacity-(--opacity-dimmed)"
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
{options.map((option) => (
|
|
||||||
<Element tag="option" key={option.value} value={option.value}>
|
|
||||||
{option.label}
|
|
||||||
</Element>
|
|
||||||
))}
|
|
||||||
</Element>
|
|
||||||
<Icon
|
|
||||||
name="chevron-down"
|
|
||||||
size={16}
|
|
||||||
className="pointer-events-none absolute end-3 text-text-secondary"
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
export { Select } from './Select';
|
|
||||||
export type { SelectOption, SelectProps } from './types';
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
import type { ComponentPropsWithRef, ReactNode } from 'react';
|
|
||||||
|
|
||||||
export type SelectOption = { value: string; label: ReactNode };
|
|
||||||
|
|
||||||
export type SelectProps = Omit<ComponentPropsWithRef<'select'>, 'children'> & {
|
|
||||||
/** The visible label above the control, such as «روز». */
|
|
||||||
label: ReactNode;
|
|
||||||
options: readonly SelectOption[];
|
|
||||||
};
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
'use client';
|
|
||||||
|
|
||||||
import { Element } from '../../primitives/element';
|
|
||||||
import { cn } from '../../tools/cn';
|
|
||||||
import { Typography } from '../typography';
|
|
||||||
import type { SwitchProps } from './types';
|
|
||||||
import { switchKnobVariants, switchTrackVariants } from './variants';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An on/off control that applies to a form, such as offering a period or running a promotion. It
|
|
||||||
* is a `role="switch"` button in a 44px hit area; with `children` the label is part of it. A locked
|
|
||||||
* switch stays focusable and says why elsewhere; a disabled one is never used.
|
|
||||||
*/
|
|
||||||
export function Switch({
|
|
||||||
checked,
|
|
||||||
onCheckedChange,
|
|
||||||
locked = false,
|
|
||||||
children,
|
|
||||||
className,
|
|
||||||
onClick,
|
|
||||||
...props
|
|
||||||
}: SwitchProps) {
|
|
||||||
return (
|
|
||||||
<Element
|
|
||||||
tag="button"
|
|
||||||
type="button"
|
|
||||||
role="switch"
|
|
||||||
aria-checked={checked}
|
|
||||||
aria-disabled={locked || undefined}
|
|
||||||
onClick={(event) => {
|
|
||||||
onClick?.(event);
|
|
||||||
if (!locked && !event.defaultPrevented) onCheckedChange?.(!checked);
|
|
||||||
}}
|
|
||||||
className={cn(
|
|
||||||
'inline-flex min-h-touch-target min-w-touch-target items-center justify-center gap-3 rounded-md outline-none focus-visible:focus-ring',
|
|
||||||
locked
|
|
||||||
? 'cursor-not-allowed opacity-(--opacity-dimmed)'
|
|
||||||
: 'cursor-pointer',
|
|
||||||
children && 'justify-between text-start',
|
|
||||||
className,
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
{children && (
|
|
||||||
<Typography tag="span" variant="body-sm" className="font-semibold">
|
|
||||||
{children}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
<Element
|
|
||||||
tag="span"
|
|
||||||
aria-hidden
|
|
||||||
className={switchTrackVariants({ checked })}
|
|
||||||
>
|
|
||||||
<Element tag="span" className={switchKnobVariants({ checked })} />
|
|
||||||
</Element>
|
|
||||||
</Element>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export { Switch } from './Switch';
|
|
||||||
export type { SwitchProps } from './types';
|
|
||||||
export { switchKnobVariants, switchTrackVariants } from './variants';
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
import type { ComponentPropsWithRef, ReactNode } from 'react';
|
|
||||||
|
|
||||||
export type SwitchProps = Omit<
|
|
||||||
ComponentPropsWithRef<'button'>,
|
|
||||||
'type' | 'role' | 'onChange' | 'children'
|
|
||||||
> & {
|
|
||||||
checked: boolean;
|
|
||||||
onCheckedChange?: (checked: boolean) => void;
|
|
||||||
/**
|
|
||||||
* Visible text beside the switch, such as «تخفیف دورهای»; the whole row is then the hit area.
|
|
||||||
* Without it, give the switch an `aria-label`.
|
|
||||||
*/
|
|
||||||
children?: ReactNode;
|
|
||||||
/** Can't change now, such as a period during the 7-day lock: 50%, `aria-disabled`, still focusable. */
|
|
||||||
locked?: boolean;
|
|
||||||
};
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
import { cva } from 'class-variance-authority';
|
|
||||||
|
|
||||||
/** The 44×24 track; the knob slides to the end when on, mirrored in RTL. */
|
|
||||||
export const switchTrackVariants = cva(
|
|
||||||
'relative inline-flex h-6 w-11 flex-none items-center rounded-full border-[1.5px] p-0.5 transition-colors duration-120 ease-standard',
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
checked: {
|
|
||||||
true: 'border-action-primary bg-action-primary',
|
|
||||||
false: 'border-border-default bg-surface-sunken',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: { checked: false },
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
export const switchKnobVariants = cva(
|
|
||||||
'size-4.5 rounded-full shadow-1 transition-transform duration-120 ease-standard motion-reduce:transition-none',
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
checked: {
|
|
||||||
true: 'translate-x-[-1.25rem] bg-text-on-action ltr:translate-x-5',
|
|
||||||
false: 'translate-x-0 bg-surface',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: { checked: false },
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
@ -92,14 +92,6 @@ export type {
|
||||||
} from './atoms/status-badge';
|
} from './atoms/status-badge';
|
||||||
export { SupportLink } from './atoms/support-link';
|
export { SupportLink } from './atoms/support-link';
|
||||||
export type { SupportLinkProps } from './atoms/support-link';
|
export type { SupportLinkProps } from './atoms/support-link';
|
||||||
export { Select } from './atoms/select';
|
|
||||||
export type { SelectOption, SelectProps } from './atoms/select';
|
|
||||||
export {
|
|
||||||
Switch,
|
|
||||||
switchKnobVariants,
|
|
||||||
switchTrackVariants,
|
|
||||||
} from './atoms/switch';
|
|
||||||
export type { SwitchProps } from './atoms/switch';
|
|
||||||
export { Tag, tagVariants } from './atoms/tag';
|
export { Tag, tagVariants } from './atoms/tag';
|
||||||
export type { TagProps, TagVariant } from './atoms/tag';
|
export type { TagProps, TagVariant } from './atoms/tag';
|
||||||
export { Typography, typographyVariants } from './atoms/typography';
|
export { Typography, typographyVariants } from './atoms/typography';
|
||||||
|
|
@ -140,8 +132,6 @@ export type {
|
||||||
} from './molecules/filter-chips';
|
} from './molecules/filter-chips';
|
||||||
export { FormSection } from './molecules/form-section';
|
export { FormSection } from './molecules/form-section';
|
||||||
export type { FormSectionProps } from './molecules/form-section';
|
export type { FormSectionProps } from './molecules/form-section';
|
||||||
export { InfoTip, infoTipVariants } from './molecules/info-tip';
|
|
||||||
export type { InfoTipProps } from './molecules/info-tip';
|
|
||||||
export { LockedTeaser } from './molecules/locked-teaser';
|
export { LockedTeaser } from './molecules/locked-teaser';
|
||||||
export type { LockedTeaserProps } from './molecules/locked-teaser';
|
export type { LockedTeaserProps } from './molecules/locked-teaser';
|
||||||
export { MediaCarousel } from './molecules/media-carousel';
|
export { MediaCarousel } from './molecules/media-carousel';
|
||||||
|
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
'use client';
|
|
||||||
|
|
||||||
import { useEffect, useId, useRef, useState } from 'react';
|
|
||||||
|
|
||||||
import { Icon } from '../../atoms/icon';
|
|
||||||
import { Typography } from '../../atoms/typography';
|
|
||||||
import { Element } from '../../primitives/element';
|
|
||||||
import { cn } from '../../tools/cn';
|
|
||||||
import type { InfoTipProps } from './types';
|
|
||||||
import { infoTipVariants } from './variants';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An ⓘ that explains the figure beside it. Hover and keyboard focus show the text; a tap toggles
|
|
||||||
* it, and a tap anywhere else or Escape closes it, because touch has no hover. The button is 44px;
|
|
||||||
* the icon 16.
|
|
||||||
*/
|
|
||||||
export function InfoTip({ label, children, className }: InfoTipProps) {
|
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
|
||||||
const tipId = useId();
|
|
||||||
const rootRef = useRef<HTMLSpanElement>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!isOpen) return;
|
|
||||||
const close = (event: Event) => {
|
|
||||||
if (event instanceof KeyboardEvent && event.key !== 'Escape') return;
|
|
||||||
if (
|
|
||||||
event instanceof PointerEvent &&
|
|
||||||
rootRef.current?.contains(event.target as Node)
|
|
||||||
)
|
|
||||||
return;
|
|
||||||
setIsOpen(false);
|
|
||||||
};
|
|
||||||
document.addEventListener('pointerdown', close);
|
|
||||||
document.addEventListener('keydown', close);
|
|
||||||
return () => {
|
|
||||||
document.removeEventListener('pointerdown', close);
|
|
||||||
document.removeEventListener('keydown', close);
|
|
||||||
};
|
|
||||||
}, [isOpen]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Element
|
|
||||||
tag="span"
|
|
||||||
ref={rootRef}
|
|
||||||
className={cn('group relative -my-3 inline-flex', className)}
|
|
||||||
onMouseLeave={() => setIsOpen(false)}
|
|
||||||
>
|
|
||||||
<Element
|
|
||||||
tag="button"
|
|
||||||
type="button"
|
|
||||||
aria-label={label}
|
|
||||||
aria-describedby={tipId}
|
|
||||||
aria-expanded={isOpen}
|
|
||||||
onClick={() => setIsOpen((open) => !open)}
|
|
||||||
className="inline-flex size-touch-target cursor-pointer items-center justify-center rounded-full text-text-secondary outline-none hover:text-text-primary focus-visible:focus-ring"
|
|
||||||
>
|
|
||||||
<Icon name="info" size={16} />
|
|
||||||
</Element>
|
|
||||||
<Typography
|
|
||||||
tag="span"
|
|
||||||
id={tipId}
|
|
||||||
role="tooltip"
|
|
||||||
variant="caption"
|
|
||||||
color="inverse"
|
|
||||||
className={infoTipVariants({ open: isOpen })}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</Typography>
|
|
||||||
</Element>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export { InfoTip } from './InfoTip';
|
|
||||||
export type { InfoTipProps } from './types';
|
|
||||||
export { infoTipVariants } from './variants';
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
import type { ReactNode } from 'react';
|
|
||||||
|
|
||||||
export type InfoTipProps = {
|
|
||||||
/** The button's accessible name, such as «توضیح قابل واریز». */
|
|
||||||
label: string;
|
|
||||||
/** What the figure means, one or two sentences. */
|
|
||||||
children: ReactNode;
|
|
||||||
className?: string;
|
|
||||||
};
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
import { cva } from 'class-variance-authority';
|
|
||||||
|
|
||||||
/** Under the ⓘ, its start on the icon's, on the inverse surface. */
|
|
||||||
export const infoTipVariants = cva(
|
|
||||||
'pointer-events-none absolute start-0 top-[calc(100%+0.25rem)] z-menu hidden w-max max-w-[16.25rem] rounded-sm bg-surface-inverse px-3 py-1.5 text-start whitespace-normal shadow-2 group-hover:block group-has-[:focus-visible]:block',
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
open: { true: 'block', false: '' },
|
|
||||||
},
|
|
||||||
defaultVariants: { open: false },
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
@ -21,10 +21,3 @@ export type {
|
||||||
DateInput,
|
DateInput,
|
||||||
ShebaFormatOptions,
|
ShebaFormatOptions,
|
||||||
} from './format';
|
} from './format';
|
||||||
export {
|
|
||||||
fromJalali,
|
|
||||||
isJalaliLeapYear,
|
|
||||||
jalaliMonthLength,
|
|
||||||
toJalali,
|
|
||||||
} from './jalali';
|
|
||||||
export type { JalaliDateTime } from './jalali';
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
/** Tehran's offset from UTC. Iran dropped daylight saving in 2022, so it is fixed. */
|
|
||||||
export const TEHRAN_OFFSET_MINUTES = 210;
|
|
||||||
|
|
||||||
/** The years the calendar arithmetic covers (`BREAKS`' first and last). */
|
|
||||||
export const MIN_JALALI_YEAR = -61;
|
|
||||||
export const MAX_JALALI_YEAR = 3177;
|
|
||||||
|
|
||||||
/** The Jalali leap-cycle break years (Borkowski), the table the arithmetic below needs. */
|
|
||||||
export const BREAKS = [
|
|
||||||
-61, 9, 38, 199, 426, 686, 756, 818, 1111, 1181, 1210, 1635, 2060, 2097, 2192,
|
|
||||||
2262, 2324, 2394, 2456, 3178,
|
|
||||||
] as const;
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
export {
|
|
||||||
fromJalali,
|
|
||||||
isJalaliLeapYear,
|
|
||||||
jalaliMonthLength,
|
|
||||||
toJalali,
|
|
||||||
} from './jalali';
|
|
||||||
export type { JalaliDateTime } from './types';
|
|
||||||
|
|
@ -1,129 +0,0 @@
|
||||||
import type { DateInput } from '../format';
|
|
||||||
import {
|
|
||||||
BREAKS,
|
|
||||||
MAX_JALALI_YEAR,
|
|
||||||
MIN_JALALI_YEAR,
|
|
||||||
TEHRAN_OFFSET_MINUTES,
|
|
||||||
} from './constants';
|
|
||||||
import type { JalaliDateTime } from './types';
|
|
||||||
|
|
||||||
// Jalali ↔ Gregorian through Julian day numbers (Borkowski's algorithm, as in jalaali-js).
|
|
||||||
|
|
||||||
const MINUTE_MS = 60_000;
|
|
||||||
|
|
||||||
function div(a: number, b: number): number {
|
|
||||||
return Math.trunc(a / b);
|
|
||||||
}
|
|
||||||
|
|
||||||
function mod(a: number, b: number): number {
|
|
||||||
return a - Math.trunc(a / b) * b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The Gregorian year that starts in a Jalali year, the March day of its Nowruz, and its leap state. */
|
|
||||||
function jalCal(jy: number): { leap: number; gy: number; march: number } {
|
|
||||||
if (jy < MIN_JALALI_YEAR || jy > MAX_JALALI_YEAR) {
|
|
||||||
throw new RangeError(`Jalali year ${jy} is out of range`);
|
|
||||||
}
|
|
||||||
const gy = jy + 621;
|
|
||||||
let leapJ = -14;
|
|
||||||
let jp: number = BREAKS[0];
|
|
||||||
let jump = 0;
|
|
||||||
for (let i = 1; i < BREAKS.length; i += 1) {
|
|
||||||
const jm = BREAKS[i];
|
|
||||||
jump = jm - jp;
|
|
||||||
if (jy < jm) break;
|
|
||||||
leapJ += div(jump, 33) * 8 + div(mod(jump, 33), 4);
|
|
||||||
jp = jm;
|
|
||||||
}
|
|
||||||
let n = jy - jp;
|
|
||||||
leapJ += div(n, 33) * 8 + div(mod(n, 33) + 3, 4);
|
|
||||||
if (mod(jump, 33) === 4 && jump - n === 4) leapJ += 1;
|
|
||||||
const leapG = div(gy, 4) - div((div(gy, 100) + 1) * 3, 4) - 150;
|
|
||||||
const march = 20 + leapJ - leapG;
|
|
||||||
if (jump - n < 6) n = n - jump + div(jump + 4, 33) * 33;
|
|
||||||
let leap = mod(mod(n + 1, 33) - 1, 4);
|
|
||||||
if (leap === -1) leap = 4;
|
|
||||||
return { leap, gy, march };
|
|
||||||
}
|
|
||||||
|
|
||||||
function g2d(gy: number, gm: number, gd: number): number {
|
|
||||||
const d =
|
|
||||||
div((gy + div(gm - 8, 6) + 100100) * 1461, 4) +
|
|
||||||
div(153 * mod(gm + 9, 12) + 2, 5) +
|
|
||||||
gd -
|
|
||||||
34840408;
|
|
||||||
return d - div(div(gy + 100100 + div(gm - 8, 6), 100) * 3, 4) + 752;
|
|
||||||
}
|
|
||||||
|
|
||||||
function d2g(jdn: number): { gy: number; gm: number; gd: number } {
|
|
||||||
let j = 4 * jdn + 139361631;
|
|
||||||
j += div(div(4 * jdn + 183187720, 146097) * 3, 4) * 4 - 3908;
|
|
||||||
const i = div(mod(j, 1461), 4) * 5 + 308;
|
|
||||||
const gd = div(mod(i, 153), 5) + 1;
|
|
||||||
const gm = mod(div(i, 153), 12) + 1;
|
|
||||||
const gy = div(j, 1461) - 100100 + div(8 - gm, 6);
|
|
||||||
return { gy, gm, gd };
|
|
||||||
}
|
|
||||||
|
|
||||||
function j2d(jy: number, jm: number, jd: number): number {
|
|
||||||
const { gy, march } = jalCal(jy);
|
|
||||||
return g2d(gy, 3, march) + (jm - 1) * 31 - div(jm, 7) * (jm - 7) + jd - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function d2j(jdn: number): { jy: number; jm: number; jd: number } {
|
|
||||||
const { gy } = d2g(jdn);
|
|
||||||
let jy = gy - 621;
|
|
||||||
const { leap, march } = jalCal(jy);
|
|
||||||
let k = jdn - g2d(gy, 3, march);
|
|
||||||
if (k >= 0) {
|
|
||||||
if (k <= 185) return { jy, jm: 1 + div(k, 31), jd: mod(k, 31) + 1 };
|
|
||||||
k -= 186;
|
|
||||||
} else {
|
|
||||||
jy -= 1;
|
|
||||||
k += 179;
|
|
||||||
if (leap === 1) k += 1;
|
|
||||||
}
|
|
||||||
return { jy, jm: 7 + div(k, 30), jd: mod(k, 30) + 1 };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Whether a Shamsi year has 30 days in اسفند. */
|
|
||||||
export function isJalaliLeapYear(year: number): boolean {
|
|
||||||
return jalCal(year).leap === 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Days in a Shamsi month: 31 for the first six, 30 for the next five, 29 or 30 for اسفند. */
|
|
||||||
export function jalaliMonthLength(year: number, month: number): number {
|
|
||||||
if (month <= 6) return 31;
|
|
||||||
if (month <= 11) return 30;
|
|
||||||
return isJalaliLeapYear(year) ? 30 : 29;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A moment as Tehran's Shamsi wall clock: `2026-10-02T19:00:00Z` → 1405/7/10 22:30. */
|
|
||||||
export function toJalali(value: DateInput): JalaliDateTime {
|
|
||||||
const at = value instanceof Date ? value : new Date(value);
|
|
||||||
const local = new Date(at.getTime() + TEHRAN_OFFSET_MINUTES * MINUTE_MS);
|
|
||||||
const { jy, jm, jd } = d2j(
|
|
||||||
g2d(local.getUTCFullYear(), local.getUTCMonth() + 1, local.getUTCDate()),
|
|
||||||
);
|
|
||||||
return {
|
|
||||||
year: jy,
|
|
||||||
month: jm,
|
|
||||||
day: jd,
|
|
||||||
hour: local.getUTCHours(),
|
|
||||||
minute: local.getUTCMinutes(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Tehran's Shamsi wall clock as an ISO instant: 1405/7/10 22:30 → `2026-10-02T19:00:00.000Z`. */
|
|
||||||
export function fromJalali({
|
|
||||||
year,
|
|
||||||
month,
|
|
||||||
day,
|
|
||||||
hour,
|
|
||||||
minute,
|
|
||||||
}: JalaliDateTime): string {
|
|
||||||
const { gy, gm, gd } = d2g(j2d(year, month, day));
|
|
||||||
return new Date(
|
|
||||||
Date.UTC(gy, gm - 1, gd, hour, minute) - TEHRAN_OFFSET_MINUTES * MINUTE_MS,
|
|
||||||
).toISOString();
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
/** A wall-clock moment in Tehran on the Shamsi calendar. Months and days start at 1. */
|
|
||||||
export type JalaliDateTime = {
|
|
||||||
year: number;
|
|
||||||
month: number;
|
|
||||||
day: number;
|
|
||||||
hour: number;
|
|
||||||
minute: number;
|
|
||||||
};
|
|
||||||
|
|
@ -12,8 +12,7 @@ import type { OnboardingGuardProps } from './types';
|
||||||
* then: publishing and prices (R2-CompleteProfile 4.2). It changes nothing in the render, so the
|
* then: publishing and prices (R2-CompleteProfile 4.2). It changes nothing in the render, so the
|
||||||
* server HTML stays the same for every visitor; once the browser knows the viewer, such a creator
|
* server HTML stays the same for every visitor; once the browser knows the viewer, such a creator
|
||||||
* goes to step 5, which returns here when done. The layouts of those routes render it
|
* goes to step 5, which returns here when done. The layouts of those routes render it
|
||||||
* (`compose`, `dashboard/pricing`, the creator's داشبورد); everything else, such as the terms, stays
|
* (`compose`, `dashboard/pricing`); everything else, such as the terms, stays open.
|
||||||
* open.
|
|
||||||
*/
|
*/
|
||||||
export function OnboardingGuard({ children }: OnboardingGuardProps) {
|
export function OnboardingGuard({ children }: OnboardingGuardProps) {
|
||||||
const status = useViewerStatus();
|
const status = useViewerStatus();
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,9 @@ export function BottomNav() {
|
||||||
)}
|
)}
|
||||||
<NavTab
|
<NavTab
|
||||||
href={
|
href={
|
||||||
isCreator ? ROUTES.dashboard.plans : ROUTES.dashboard.subscriptions
|
isCreator
|
||||||
|
? ROUTES.dashboard.pricing
|
||||||
|
: ROUTES.dashboard.subscriptions
|
||||||
}
|
}
|
||||||
icon="dashboard"
|
icon="dashboard"
|
||||||
label={t('nav.dashboard')}
|
label={t('nav.dashboard')}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ export function DesktopHeader() {
|
||||||
<HeaderNavLink
|
<HeaderNavLink
|
||||||
href={
|
href={
|
||||||
isCreator
|
isCreator
|
||||||
? ROUTES.dashboard.plans
|
? ROUTES.dashboard.pricing
|
||||||
: ROUTES.dashboard.subscriptions
|
: ROUTES.dashboard.subscriptions
|
||||||
}
|
}
|
||||||
label={t('nav.dashboard')}
|
label={t('nav.dashboard')}
|
||||||
|
|
|
||||||
|
|
@ -41,11 +41,9 @@ export const ROUTES = {
|
||||||
subscriptions: '/dashboard/subscriptions',
|
subscriptions: '/dashboard/subscriptions',
|
||||||
transactions: '/dashboard/transactions',
|
transactions: '/dashboard/transactions',
|
||||||
following: '/dashboard/following',
|
following: '/dashboard/following',
|
||||||
/** The creator's داشبورد: «طرحهای اشتراک» (the default tab) and «مالی». */
|
|
||||||
plans: '/dashboard/plans',
|
|
||||||
finance: '/dashboard/finance',
|
|
||||||
/** C7, pushed from the «قیمت طرحها» card. */
|
|
||||||
pricing: '/dashboard/pricing',
|
pricing: '/dashboard/pricing',
|
||||||
|
ledger: '/dashboard/finance/ledger',
|
||||||
|
sheba: '/dashboard/finance/sheba',
|
||||||
},
|
},
|
||||||
onboarding: {
|
onboarding: {
|
||||||
creatorProfile: '/onboarding/creator-profile',
|
creatorProfile: '/onboarding/creator-profile',
|
||||||
|
|
|
||||||
|
|
@ -1,140 +0,0 @@
|
||||||
'use client';
|
|
||||||
|
|
||||||
import { Button } from '@lumina/island/atoms/button';
|
|
||||||
import { FieldError } from '@lumina/island/atoms/field-error';
|
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Icon } from '@lumina/island/atoms/icon';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { Banner } from '@lumina/island/molecules/banner';
|
|
||||||
import { date } from '@lumina/tools/format';
|
|
||||||
import { useState } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import { usePricingPage } from '../../../../../../../features/pricing';
|
|
||||||
import { ConfirmDialog } from './components/ConfirmDialog';
|
|
||||||
import { DateTimeDialog } from './components/DateTimeDialog';
|
|
||||||
import { TierCard } from './components/TierCard';
|
|
||||||
import type { DatePick, PricingFormProps } from './types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* C7, ویرایش قیمتها: the four period cards and «ذخیره قیمتگذاری» under them. Above the cards,
|
|
||||||
* in order: a failed save with «تلاش دوباره» (۵.۴), the pending-verification note (۱.۳), the lock
|
|
||||||
* notice (۶.۲) or the free-to-edit note (۶.۱). With broken rules a tap on save says so above it
|
|
||||||
* (۳). The confirmation and the date picker are sheets on mobile and modals on desktop.
|
|
||||||
*/
|
|
||||||
export function PricingForm({ layout }: PricingFormProps) {
|
|
||||||
const { t } = useTranslation('pricing');
|
|
||||||
const model = usePricingPage();
|
|
||||||
const [pick, setPick] = useState<DatePick | null>(null);
|
|
||||||
const picked = pick
|
|
||||||
? model.tiers.find((tier) => tier.billingPeriod === pick.period)?.promotion
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox
|
|
||||||
tag="form"
|
|
||||||
noValidate
|
|
||||||
aria-label={t('form.label')}
|
|
||||||
direction="flex-col"
|
|
||||||
gap="gap-4"
|
|
||||||
onSubmit={(event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
model.save();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{model.saveFailed && (
|
|
||||||
<Banner
|
|
||||||
tone="danger"
|
|
||||||
action={
|
|
||||||
<Button
|
|
||||||
variant="secondary"
|
|
||||||
size="sm"
|
|
||||||
icon="refresh"
|
|
||||||
onClick={model.save}
|
|
||||||
>
|
|
||||||
{t('form.retry')}
|
|
||||||
</Button>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{t('form.network')}
|
|
||||||
</Banner>
|
|
||||||
)}
|
|
||||||
{model.verification !== 'approved' && (
|
|
||||||
<Banner tone="warning" icon="alert">
|
|
||||||
{t('form.pending-note')}
|
|
||||||
</Banner>
|
|
||||||
)}
|
|
||||||
{model.lockedUntil ? (
|
|
||||||
<Banner tone="info" icon="lock">
|
|
||||||
{t('form.locked-note', {
|
|
||||||
date: date(model.lockedUntil, { time: false }),
|
|
||||||
})}
|
|
||||||
</Banner>
|
|
||||||
) : (
|
|
||||||
model.prePurchase && (
|
|
||||||
<FlexBox
|
|
||||||
alignItems="items-start"
|
|
||||||
gap="gap-2"
|
|
||||||
className="rounded-md bg-success-subtle px-3 py-2.5 text-success-text"
|
|
||||||
>
|
|
||||||
<Icon name="check-circle" size={18} className="mt-0.5 flex-none" />
|
|
||||||
<Typography variant="body-sm" color="success">
|
|
||||||
{t('form.pre-purchase-note')}
|
|
||||||
</Typography>
|
|
||||||
</FlexBox>
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
{model.tiers.map((tier) => (
|
|
||||||
<TierCard
|
|
||||||
key={tier.billingPeriod}
|
|
||||||
tier={tier}
|
|
||||||
model={model}
|
|
||||||
layout={layout}
|
|
||||||
onPickDate={(period, edge) => setPick({ period, edge })}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
{model.lockedUntil && (
|
|
||||||
<Typography variant="caption" color="secondary">
|
|
||||||
{t('promotion.locked-live')}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
<Typography variant="body-sm" color="secondary">
|
|
||||||
{t('form.existing-note')}
|
|
||||||
</Typography>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-2">
|
|
||||||
{model.isBlocked && <FieldError>{t('form.blocked')}</FieldError>}
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
variant="primary"
|
|
||||||
size="lg"
|
|
||||||
block={layout === 'mobile'}
|
|
||||||
isLoading={model.phase === 'checking'}
|
|
||||||
frozen={model.isBlocked}
|
|
||||||
pressableWhenFrozen
|
|
||||||
>
|
|
||||||
{t('form.save')}
|
|
||||||
</Button>
|
|
||||||
</FlexBox>
|
|
||||||
<ConfirmDialog model={model} layout={layout} />
|
|
||||||
<DateTimeDialog
|
|
||||||
layout={layout}
|
|
||||||
pick={pick}
|
|
||||||
value={
|
|
||||||
pick?.edge === 'end'
|
|
||||||
? (picked?.endsAt ?? null)
|
|
||||||
: (picked?.startsAt ?? null)
|
|
||||||
}
|
|
||||||
indefinite={pick?.edge === 'end' ? Boolean(picked?.indefinite) : false}
|
|
||||||
onClose={() => setPick(null)}
|
|
||||||
onConfirm={(iso, indefinite) => {
|
|
||||||
if (!pick) return;
|
|
||||||
if (pick.edge === 'start' && iso)
|
|
||||||
model.setPromotionStart(pick.period, iso);
|
|
||||||
if (pick.edge === 'end')
|
|
||||||
model.setPromotionEnd(pick.period, iso, indefinite);
|
|
||||||
setPick(null);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
|
|
||||||
import { Card } from '@lumina/island/molecules/card';
|
|
||||||
|
|
||||||
import type { PricingFormSkeletonProps } from './types';
|
|
||||||
|
|
||||||
/** C7 before it arrives: four period cards, each a title row, the total field and the promotion row. */
|
|
||||||
export function PricingFormSkeleton({
|
|
||||||
layout,
|
|
||||||
label,
|
|
||||||
delayed,
|
|
||||||
}: PricingFormSkeletonProps) {
|
|
||||||
return (
|
|
||||||
<SkeletonRegion label={label} delayed={delayed}>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-4">
|
|
||||||
{[0, 1, 2, 3].map((card) => (
|
|
||||||
<Card key={card} padding={layout === 'desktop' ? 'lg' : 'md'}>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<FlexBox
|
|
||||||
justifyContent="justify-between"
|
|
||||||
alignItems="items-center"
|
|
||||||
>
|
|
||||||
<Skeleton width="28%" height={18} />
|
|
||||||
<Skeleton shape="pill" width={44} height={24} />
|
|
||||||
</FlexBox>
|
|
||||||
<Skeleton shape="rect" height={48} />
|
|
||||||
<Skeleton width="45%" />
|
|
||||||
<Skeleton shape="rect" height={44} />
|
|
||||||
</FlexBox>
|
|
||||||
</Card>
|
|
||||||
))}
|
|
||||||
<Skeleton shape="pill" height={52} />
|
|
||||||
</FlexBox>
|
|
||||||
</SkeletonRegion>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,155 +0,0 @@
|
||||||
import { Button } from '@lumina/island/atoms/button';
|
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Tag } from '@lumina/island/atoms/tag';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { Modal } from '@lumina/island/molecules/modal';
|
|
||||||
import { Sheet } from '@lumina/island/molecules/sheet';
|
|
||||||
import { cn } from '@lumina/island/tools/cn';
|
|
||||||
import { date, percent, price } from '@lumina/tools/format';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import { BILLING_PERIOD_MONTHS } from '../../../../../../../../shared/constants';
|
|
||||||
import type { ConfirmDialogProps } from '../types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The confirmation on every save (C7 §۵): each offered period, total and per month, in the order
|
|
||||||
* investors see them; a promoted one adds its discount, end and promotional price (۵.۲). Then the
|
|
||||||
* lock warning and the safety valve. «تأیید و ذخیره» saves; «انصراف» or the scrim go back with
|
|
||||||
* everything kept. A bottom sheet on mobile, a modal of 420 on desktop (۸.۲); no ✕.
|
|
||||||
*/
|
|
||||||
export function ConfirmDialog({ model, layout }: ConfirmDialogProps) {
|
|
||||||
const { t } = useTranslation(['pricing', 'common']);
|
|
||||||
const confirmation = model.confirmation;
|
|
||||||
const open = confirmation !== null;
|
|
||||||
const saving = model.phase === 'saving';
|
|
||||||
|
|
||||||
const buttons = (
|
|
||||||
<>
|
|
||||||
<Button
|
|
||||||
variant="primary"
|
|
||||||
size={layout === 'mobile' ? 'lg' : undefined}
|
|
||||||
block
|
|
||||||
isLoading={saving}
|
|
||||||
onClick={model.confirm}
|
|
||||||
>
|
|
||||||
{t('confirm.submit')}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="secondary"
|
|
||||||
size={layout === 'mobile' ? 'lg' : undefined}
|
|
||||||
block
|
|
||||||
disabled={saving}
|
|
||||||
onClick={model.closeConfirmation}
|
|
||||||
>
|
|
||||||
{t('confirm.cancel')}
|
|
||||||
</Button>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
const body = confirmation && (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<FlexBox
|
|
||||||
tag="ul"
|
|
||||||
direction="flex-col"
|
|
||||||
className="rounded-md bg-surface-sunken px-3"
|
|
||||||
>
|
|
||||||
{confirmation.tiers.map((tier, index) => {
|
|
||||||
const months = BILLING_PERIOD_MONTHS[tier.billingPeriod];
|
|
||||||
const view = model.tiers.find(
|
|
||||||
(item) => item.billingPeriod === tier.billingPeriod,
|
|
||||||
);
|
|
||||||
const promo =
|
|
||||||
tier.promotion && view?.promotion.enabled ? view.promotion : null;
|
|
||||||
return (
|
|
||||||
<FlexBox
|
|
||||||
key={tier.billingPeriod}
|
|
||||||
tag="li"
|
|
||||||
direction="flex-col"
|
|
||||||
className={cn(
|
|
||||||
'gap-0.5 py-2.5',
|
|
||||||
index > 0 && 'border-t border-border-subtle',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<FlexBox
|
|
||||||
alignItems="items-baseline"
|
|
||||||
justifyContent="justify-between"
|
|
||||||
gap="gap-3"
|
|
||||||
>
|
|
||||||
<Typography tag="span" className="font-semibold">
|
|
||||||
{t(`common:billing-periods.${tier.billingPeriod}`)}
|
|
||||||
</Typography>
|
|
||||||
<Typography tag="span" variant="body-sm">
|
|
||||||
{t('confirm.row', {
|
|
||||||
total: price(tier.priceToman),
|
|
||||||
perMonth: price(Math.round(tier.priceToman / months)),
|
|
||||||
})}
|
|
||||||
</Typography>
|
|
||||||
</FlexBox>
|
|
||||||
{promo && promo.percentValue !== null && (
|
|
||||||
<FlexBox
|
|
||||||
direction="flex-col"
|
|
||||||
alignItems="items-end"
|
|
||||||
className="gap-0.5"
|
|
||||||
>
|
|
||||||
<FlexBox alignItems="items-center" gap="gap-2">
|
|
||||||
<Tag variant="discount" icon={null}>
|
|
||||||
{promo.indefinite || !promo.endsAt
|
|
||||||
? t('confirm.promotion-open', {
|
|
||||||
percent: percent(promo.percentValue, 0),
|
|
||||||
})
|
|
||||||
: t('confirm.promotion', {
|
|
||||||
percent: percent(promo.percentValue, 0),
|
|
||||||
date: date(promo.endsAt, { time: false }),
|
|
||||||
})}
|
|
||||||
</Tag>
|
|
||||||
</FlexBox>
|
|
||||||
{promo.priceToman !== null &&
|
|
||||||
promo.perMonthToman !== null && (
|
|
||||||
<Typography
|
|
||||||
tag="span"
|
|
||||||
variant="body-sm"
|
|
||||||
className="font-semibold"
|
|
||||||
>
|
|
||||||
{t('confirm.promotion-price', {
|
|
||||||
total: price(promo.priceToman),
|
|
||||||
perMonth: price(promo.perMonthToman),
|
|
||||||
})}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</FlexBox>
|
|
||||||
<Typography variant="body-sm" className="font-semibold">
|
|
||||||
{t('confirm.cooldown')}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="body-sm" color="secondary">
|
|
||||||
{t('confirm.safety')}
|
|
||||||
</Typography>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
|
|
||||||
const onClose = saving ? undefined : model.closeConfirmation;
|
|
||||||
|
|
||||||
return layout === 'mobile' ? (
|
|
||||||
<Sheet
|
|
||||||
open={open}
|
|
||||||
title={t('confirm.title')}
|
|
||||||
footer={buttons}
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
{body}
|
|
||||||
</Sheet>
|
|
||||||
) : (
|
|
||||||
<Modal
|
|
||||||
open={open}
|
|
||||||
title={t('confirm.title')}
|
|
||||||
actions={buttons}
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
{body}
|
|
||||||
</Modal>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
import { DateTime } from '@lumina/island/atoms/date-time';
|
|
||||||
import { FieldError } from '@lumina/island/atoms/field-error';
|
|
||||||
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 { useId } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import type { DateFieldProps } from './types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A promotion's start or end (C7 ۴.۲): a button that shows the Shamsi date and time and opens the
|
|
||||||
* picker. Its error sits under it, as a text field's does.
|
|
||||||
*/
|
|
||||||
export function DateField({ id, label, value, error, onOpen }: DateFieldProps) {
|
|
||||||
const { t } = useTranslation('pricing');
|
|
||||||
const errorId = useId();
|
|
||||||
const labelId = useId();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-1" className="min-w-0 flex-1">
|
|
||||||
<Typography tag="span" id={labelId} variant="caption" color="secondary">
|
|
||||||
{label}
|
|
||||||
</Typography>
|
|
||||||
<FlexBox
|
|
||||||
tag="button"
|
|
||||||
type="button"
|
|
||||||
id={id}
|
|
||||||
alignItems="items-center"
|
|
||||||
justifyContent="justify-between"
|
|
||||||
gap="gap-2"
|
|
||||||
aria-haspopup="dialog"
|
|
||||||
aria-invalid={error ? true : undefined}
|
|
||||||
aria-describedby={error ? errorId : undefined}
|
|
||||||
aria-labelledby={`${labelId} ${id}`}
|
|
||||||
onClick={onOpen}
|
|
||||||
className={cn(
|
|
||||||
'h-input-height w-full cursor-pointer rounded-md border bg-surface px-3 text-start text-body-md outline-none transition-colors duration-120 ease-standard hover:border-border-strong focus-visible:focus-ring',
|
|
||||||
error ? 'border-danger' : 'border-border-default',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<Typography
|
|
||||||
tag="span"
|
|
||||||
color={value ? 'primary' : 'tertiary'}
|
|
||||||
className="truncate"
|
|
||||||
>
|
|
||||||
{value ? <DateTime value={value} /> : t('promotion.not-set')}
|
|
||||||
</Typography>
|
|
||||||
<Icon
|
|
||||||
name="calendar"
|
|
||||||
size={18}
|
|
||||||
className="flex-none text-text-secondary"
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
{error && <FieldError id={errorId}>{error}</FieldError>}
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,202 +0,0 @@
|
||||||
import { Button } from '@lumina/island/atoms/button';
|
|
||||||
import { Checkbox } from '@lumina/island/atoms/checkbox';
|
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { GridBox } from '@lumina/island/atoms/grid-box';
|
|
||||||
import { Select } from '@lumina/island/atoms/select';
|
|
||||||
import { Modal } from '@lumina/island/molecules/modal';
|
|
||||||
import { Sheet } from '@lumina/island/molecules/sheet';
|
|
||||||
import { number } from '@lumina/tools/format';
|
|
||||||
import { fromJalali, jalaliMonthLength, toJalali } from '@lumina/tools/jalali';
|
|
||||||
import type { JalaliDateTime } from '@lumina/tools/jalali';
|
|
||||||
import { useState } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import type { DateTimeDialogProps } from '../types';
|
|
||||||
|
|
||||||
const MONTHS = Array.from({ length: 12 }, (_, index) => index + 1);
|
|
||||||
const HOURS = Array.from({ length: 24 }, (_, index) => index);
|
|
||||||
const MINUTES = Array.from({ length: 12 }, (_, index) => index * 5).concat(59);
|
|
||||||
/** This year and the next two: a promotion is never set further out. */
|
|
||||||
const YEARS_AHEAD = 2;
|
|
||||||
|
|
||||||
const pad = (value: number) => number(value).padStart(2, '0');
|
|
||||||
|
|
||||||
function nearestMinute(minute: number): number {
|
|
||||||
return MINUTES.reduce((best, option) =>
|
|
||||||
Math.abs(option - minute) < Math.abs(best - minute) ? option : best,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Shamsi date and time picker (C7 ۴.۳): day, month, year, hour and minute, each a native select
|
|
||||||
* (a wheel on phones), and for an end «بدون تاریخ پایان», so ending is one decision in one place.
|
|
||||||
* A bottom sheet on mobile, a centred modal on desktop (۸.۱). «تأیید» sets the field.
|
|
||||||
*/
|
|
||||||
export function DateTimeDialog({
|
|
||||||
layout,
|
|
||||||
pick,
|
|
||||||
value,
|
|
||||||
indefinite,
|
|
||||||
onConfirm,
|
|
||||||
onClose,
|
|
||||||
}: DateTimeDialogProps) {
|
|
||||||
const { t } = useTranslation('pricing');
|
|
||||||
const title =
|
|
||||||
pick?.edge === 'end' ? t('promotion.end') : t('promotion.start');
|
|
||||||
|
|
||||||
return layout === 'mobile' ? (
|
|
||||||
<Sheet
|
|
||||||
open={pick !== null}
|
|
||||||
title={title}
|
|
||||||
closeLabel={t('picker.close')}
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
{pick && (
|
|
||||||
<PickerBody
|
|
||||||
key={`${pick.period}-${pick.edge}`}
|
|
||||||
isEnd={pick.edge === 'end'}
|
|
||||||
value={value}
|
|
||||||
indefinite={indefinite}
|
|
||||||
onConfirm={onConfirm}
|
|
||||||
size="lg"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Sheet>
|
|
||||||
) : (
|
|
||||||
<Modal
|
|
||||||
open={pick !== null}
|
|
||||||
title={title}
|
|
||||||
closeLabel={t('picker.close')}
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
{pick && (
|
|
||||||
<PickerBody
|
|
||||||
key={`${pick.period}-${pick.edge}`}
|
|
||||||
isEnd={pick.edge === 'end'}
|
|
||||||
value={value}
|
|
||||||
indefinite={indefinite}
|
|
||||||
onConfirm={onConfirm}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Modal>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
type PickerBodyProps = {
|
|
||||||
isEnd: boolean;
|
|
||||||
value: string | null;
|
|
||||||
indefinite: boolean;
|
|
||||||
onConfirm: (iso: string | null, indefinite: boolean) => void;
|
|
||||||
size?: 'lg';
|
|
||||||
};
|
|
||||||
|
|
||||||
function PickerBody({
|
|
||||||
isEnd,
|
|
||||||
value,
|
|
||||||
indefinite,
|
|
||||||
onConfirm,
|
|
||||||
size,
|
|
||||||
}: PickerBodyProps) {
|
|
||||||
const { t } = useTranslation('pricing');
|
|
||||||
const [parts, setParts] = useState<JalaliDateTime>(() => {
|
|
||||||
const start = toJalali(value ?? new Date());
|
|
||||||
return { ...start, minute: nearestMinute(start.minute) };
|
|
||||||
});
|
|
||||||
const [open, setOpen] = useState(indefinite);
|
|
||||||
const [thisYear] = useState(() => toJalali(new Date()).year);
|
|
||||||
const years = Array.from(
|
|
||||||
{ length: YEARS_AHEAD + 1 },
|
|
||||||
(_, index) => thisYear + index,
|
|
||||||
);
|
|
||||||
if (!years.includes(parts.year)) years.unshift(parts.year);
|
|
||||||
const days = Array.from(
|
|
||||||
{ length: jalaliMonthLength(parts.year, parts.month) },
|
|
||||||
(_, index) => index + 1,
|
|
||||||
);
|
|
||||||
|
|
||||||
const set = (key: keyof JalaliDateTime, next: number) =>
|
|
||||||
setParts((current) => {
|
|
||||||
const updated = { ...current, [key]: next };
|
|
||||||
// 31 اردیبهشت → مهر has 30 days: keep the last one.
|
|
||||||
updated.day = Math.min(
|
|
||||||
updated.day,
|
|
||||||
jalaliMonthLength(updated.year, updated.month),
|
|
||||||
);
|
|
||||||
return updated;
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-4">
|
|
||||||
<GridBox cols="grid-cols-3" gap="gap-2">
|
|
||||||
<Select
|
|
||||||
label={t('picker.day')}
|
|
||||||
value={String(parts.day)}
|
|
||||||
disabled={open}
|
|
||||||
onChange={(event) => set('day', Number(event.target.value))}
|
|
||||||
options={days.map((day) => ({
|
|
||||||
value: String(day),
|
|
||||||
label: number(day),
|
|
||||||
}))}
|
|
||||||
/>
|
|
||||||
<Select
|
|
||||||
label={t('picker.month')}
|
|
||||||
value={String(parts.month)}
|
|
||||||
disabled={open}
|
|
||||||
onChange={(event) => set('month', Number(event.target.value))}
|
|
||||||
options={MONTHS.map((month) => ({
|
|
||||||
value: String(month),
|
|
||||||
label: t(`picker.months.${month}` as 'picker.months.1'),
|
|
||||||
}))}
|
|
||||||
/>
|
|
||||||
<Select
|
|
||||||
label={t('picker.year')}
|
|
||||||
value={String(parts.year)}
|
|
||||||
disabled={open}
|
|
||||||
onChange={(event) => set('year', Number(event.target.value))}
|
|
||||||
options={years.map((year) => ({
|
|
||||||
value: String(year),
|
|
||||||
label: String(year),
|
|
||||||
}))}
|
|
||||||
/>
|
|
||||||
</GridBox>
|
|
||||||
<GridBox cols="grid-cols-2" gap="gap-2">
|
|
||||||
<Select
|
|
||||||
label={t('picker.hour')}
|
|
||||||
value={String(parts.hour)}
|
|
||||||
disabled={open}
|
|
||||||
onChange={(event) => set('hour', Number(event.target.value))}
|
|
||||||
options={HOURS.map((hour) => ({
|
|
||||||
value: String(hour),
|
|
||||||
label: pad(hour),
|
|
||||||
}))}
|
|
||||||
/>
|
|
||||||
<Select
|
|
||||||
label={t('picker.minute')}
|
|
||||||
value={String(parts.minute)}
|
|
||||||
disabled={open}
|
|
||||||
onChange={(event) => set('minute', Number(event.target.value))}
|
|
||||||
options={MINUTES.map((minute) => ({
|
|
||||||
value: String(minute),
|
|
||||||
label: pad(minute),
|
|
||||||
}))}
|
|
||||||
/>
|
|
||||||
</GridBox>
|
|
||||||
{isEnd && (
|
|
||||||
<Checkbox
|
|
||||||
checked={open}
|
|
||||||
onChange={(event) => setOpen(event.target.checked)}
|
|
||||||
>
|
|
||||||
{t('picker.indefinite')}
|
|
||||||
</Checkbox>
|
|
||||||
)}
|
|
||||||
<Button
|
|
||||||
variant="primary"
|
|
||||||
size={size}
|
|
||||||
block
|
|
||||||
onClick={() => onConfirm(open ? null : fromJalali(parts), open)}
|
|
||||||
>
|
|
||||||
{t('picker.confirm')}
|
|
||||||
</Button>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,106 +0,0 @@
|
||||||
import { Checkbox } from '@lumina/island/atoms/checkbox';
|
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Switch } from '@lumina/island/atoms/switch';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { TextInput } from '@lumina/island/molecules/text-input';
|
|
||||||
import { price } from '@lumina/tools/format';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import type { PromotionBlockProps } from '../types';
|
|
||||||
import { DateField } from './DateField';
|
|
||||||
import { useFieldMessage } from './use-field-message';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A period's تخفیف دورهای (C7 §۴), on the sunken ground inside its card, so it reads as a
|
|
||||||
* different mechanic. Off, it is one switch and a line on what it does (۴.۱). On: the percent,
|
|
||||||
* start and end side by side, «بدون تاریخ پایان», the promotional price and who it applies to
|
|
||||||
* (۴.۲, ۴.۷). The same switch ends it, from the next save (۴.۴, ۴.۵). It stays live during the
|
|
||||||
* 7-day lock (۶.۲).
|
|
||||||
*/
|
|
||||||
export function PromotionBlock({
|
|
||||||
tier,
|
|
||||||
model,
|
|
||||||
onPickDate,
|
|
||||||
}: PromotionBlockProps) {
|
|
||||||
const { t } = useTranslation(['pricing', 'common']);
|
|
||||||
const message = useFieldMessage();
|
|
||||||
const promo = tier.promotion;
|
|
||||||
const period = tier.billingPeriod;
|
|
||||||
const periodLabel = t(`common:billing-periods.${period}`);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox
|
|
||||||
direction="flex-col"
|
|
||||||
gap="gap-3"
|
|
||||||
className="rounded-md bg-surface-sunken p-3"
|
|
||||||
>
|
|
||||||
<Switch
|
|
||||||
checked={promo.enabled}
|
|
||||||
onCheckedChange={(enabled) =>
|
|
||||||
model.setPromotionEnabled(period, enabled)
|
|
||||||
}
|
|
||||||
aria-label={t('promotion.switch', { period: periodLabel })}
|
|
||||||
className="-my-2 w-full"
|
|
||||||
>
|
|
||||||
{t('promotion.title')}
|
|
||||||
</Switch>
|
|
||||||
{!promo.enabled ? (
|
|
||||||
<Typography variant="caption" color="secondary">
|
|
||||||
{t('promotion.intro')}
|
|
||||||
</Typography>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<TextInput
|
|
||||||
id={promo.percentId}
|
|
||||||
label={t('promotion.percent')}
|
|
||||||
inputMode="numeric"
|
|
||||||
dir="ltr"
|
|
||||||
suffix={t('promotion.percent-sign')}
|
|
||||||
value={promo.percent}
|
|
||||||
onChange={(event) =>
|
|
||||||
model.setPromotionPercent(period, event.target.value)
|
|
||||||
}
|
|
||||||
error={message(promo.percentMessage)}
|
|
||||||
className="max-w-40"
|
|
||||||
/>
|
|
||||||
<FlexBox gap="gap-3" wrap="flex-wrap">
|
|
||||||
<DateField
|
|
||||||
id={`${promo.endsAtId}-start`}
|
|
||||||
label={t('promotion.start')}
|
|
||||||
value={promo.startsAt}
|
|
||||||
onOpen={() => onPickDate(period, 'start')}
|
|
||||||
/>
|
|
||||||
{!promo.indefinite && (
|
|
||||||
<DateField
|
|
||||||
id={promo.endsAtId}
|
|
||||||
label={t('promotion.end')}
|
|
||||||
value={promo.endsAt}
|
|
||||||
error={message(promo.endsAtMessage)}
|
|
||||||
onOpen={() => onPickDate(period, 'end')}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
<Checkbox
|
|
||||||
checked={promo.indefinite}
|
|
||||||
onChange={(event) =>
|
|
||||||
model.setPromotionEnd(period, promo.endsAt, event.target.checked)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{t('promotion.indefinite')}
|
|
||||||
</Checkbox>
|
|
||||||
{promo.priceToman !== null && promo.perMonthToman !== null && (
|
|
||||||
<Typography variant="body-sm" className="font-semibold">
|
|
||||||
{t('promotion.price', {
|
|
||||||
total: price(promo.priceToman),
|
|
||||||
perMonth: price(promo.perMonthToman),
|
|
||||||
})}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
<Typography variant="caption" color="secondary">
|
|
||||||
{t('promotion.scope-note')}
|
|
||||||
</Typography>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,127 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Switch } from '@lumina/island/atoms/switch';
|
|
||||||
import { Tag } from '@lumina/island/atoms/tag';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { Card } from '@lumina/island/molecules/card';
|
|
||||||
import { TextInput } from '@lumina/island/molecules/text-input';
|
|
||||||
import { date, number, percent, price } from '@lumina/tools/format';
|
|
||||||
import { useId } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import type { TierCardProps } from '../types';
|
|
||||||
import { PromotionBlock } from './PromotionBlock';
|
|
||||||
import { WarnNote } from './WarnNote';
|
|
||||||
import { useFieldMessage } from './use-field-message';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* One period (C7 §۲): its name and switch (monthly has «الزامی» and no switch, ۱.۱), the period
|
|
||||||
* total with its floor before typing and its per-month equivalent after (۲.۱), the rule it
|
|
||||||
* breaks in place of either (۳). Switched off, it collapses to its switch row, with a note when
|
|
||||||
* subscribers run on it (۲.۲). During the lock the total and the switch are read-only at 50%; the
|
|
||||||
* promotion stays live (۶.۲).
|
|
||||||
*/
|
|
||||||
export function TierCard({ tier, model, layout, onPickDate }: TierCardProps) {
|
|
||||||
const { t } = useTranslation(['pricing', 'common']);
|
|
||||||
const message = useFieldMessage();
|
|
||||||
const headingId = useId();
|
|
||||||
const period = tier.billingPeriod;
|
|
||||||
const periodLabel = t(`common:billing-periods.${period}`);
|
|
||||||
const locked = model.lockedUntil !== null;
|
|
||||||
const priceError = message(tier.priceMessage);
|
|
||||||
const promoPercent = tier.promotion.enabled
|
|
||||||
? tier.promotion.percentValue
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
tag="section"
|
|
||||||
aria-labelledby={headingId}
|
|
||||||
padding={layout === 'desktop' ? 'lg' : 'md'}
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<FlexBox
|
|
||||||
alignItems="items-center"
|
|
||||||
justifyContent="justify-between"
|
|
||||||
gap="gap-3"
|
|
||||||
>
|
|
||||||
<FlexBox alignItems="items-center" gap="gap-2">
|
|
||||||
<Typography tag="h3" id={headingId} variant="heading-sm">
|
|
||||||
{periodLabel}
|
|
||||||
</Typography>
|
|
||||||
{tier.mandatory && (
|
|
||||||
<Tag variant="soft" icon={null}>
|
|
||||||
{t('form.required-tag')}
|
|
||||||
</Tag>
|
|
||||||
)}
|
|
||||||
{promoPercent !== null && tier.enabled && (
|
|
||||||
<Tag variant="discount" icon={null}>
|
|
||||||
{t('card.discount', { percent: percent(promoPercent, 0) })}
|
|
||||||
</Tag>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
{!tier.mandatory && (
|
|
||||||
<Switch
|
|
||||||
checked={tier.enabled}
|
|
||||||
locked={locked}
|
|
||||||
onCheckedChange={(enabled) => model.setEnabled(period, enabled)}
|
|
||||||
aria-label={t('form.offer', { period: periodLabel })}
|
|
||||||
className="-my-2"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
{tier.mandatory && (
|
|
||||||
<Typography variant="caption" color="secondary" className="-mt-2">
|
|
||||||
{t('form.monthly-note')}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
{tier.disableNoteCount !== null && (
|
|
||||||
<WarnNote>
|
|
||||||
{t('form.disable-note', { count: number(tier.disableNoteCount) })}
|
|
||||||
</WarnNote>
|
|
||||||
)}
|
|
||||||
{tier.enabled && (
|
|
||||||
<>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-1">
|
|
||||||
<TextInput
|
|
||||||
id={tier.priceId}
|
|
||||||
label={t('form.price-label')}
|
|
||||||
aria-label={t('form.price-label-of', { period: periodLabel })}
|
|
||||||
inputMode="numeric"
|
|
||||||
suffix={t('form.currency')}
|
|
||||||
value={tier.priceText}
|
|
||||||
onChange={(event) => model.setPrice(period, event.target.value)}
|
|
||||||
onBlur={() => model.blurPrice(period)}
|
|
||||||
error={priceError}
|
|
||||||
hint={
|
|
||||||
tier.perMonthToman === null
|
|
||||||
? t('form.floor', { floor: price(tier.floorTomanPerMonth) })
|
|
||||||
: t('form.per-month', { amount: price(tier.perMonthToman) })
|
|
||||||
}
|
|
||||||
locked={locked}
|
|
||||||
lockedNote={
|
|
||||||
locked && model.lockedUntil
|
|
||||||
? t('form.locked-field', {
|
|
||||||
date: date(model.lockedUntil, { time: false }),
|
|
||||||
})
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
className={locked ? 'opacity-(--opacity-dimmed)' : undefined}
|
|
||||||
/>
|
|
||||||
{priceError && tier.perMonthToman !== null && (
|
|
||||||
<Typography variant="caption" color="secondary">
|
|
||||||
{t('form.per-month', { amount: price(tier.perMonthToman) })}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
<PromotionBlock
|
|
||||||
tier={tier}
|
|
||||||
model={model}
|
|
||||||
layout={layout}
|
|
||||||
onPickDate={onPickDate}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Icon } from '@lumina/island/atoms/icon';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import type { ReactNode } from 'react';
|
|
||||||
|
|
||||||
/** An amber note on the amber tint, readable on white: a period switched off with subscribers. */
|
|
||||||
export function WarnNote({ children }: { children: ReactNode }) {
|
|
||||||
return (
|
|
||||||
<FlexBox
|
|
||||||
alignItems="items-start"
|
|
||||||
gap="gap-2"
|
|
||||||
className="rounded-md bg-warning-subtle px-3 py-2 text-warning-text"
|
|
||||||
>
|
|
||||||
<Icon name="alert" size={16} className="mt-1 flex-none" />
|
|
||||||
<Typography variant="caption" color="warning">
|
|
||||||
{children}
|
|
||||||
</Typography>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
export type DateFieldProps = {
|
|
||||||
id: string;
|
|
||||||
label: string;
|
|
||||||
value: string | null;
|
|
||||||
error?: string;
|
|
||||||
onOpen: () => void;
|
|
||||||
};
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
import { price } from '@lumina/tools/format';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import type { PricingFieldMessage } from '../../../../../../../../features/pricing';
|
|
||||||
|
|
||||||
/** A field's message as shown: a broken rule worded with its figures, or the API's own text. */
|
|
||||||
export function useFieldMessage() {
|
|
||||||
const { t } = useTranslation(['pricing', 'common']);
|
|
||||||
|
|
||||||
return (message: PricingFieldMessage | null): string | undefined => {
|
|
||||||
if (!message) return undefined;
|
|
||||||
if (message.kind === 'server') return message.message;
|
|
||||||
const { issue } = message;
|
|
||||||
switch (issue.code) {
|
|
||||||
case 'required':
|
|
||||||
return t('form.errors.required');
|
|
||||||
case 'below-floor':
|
|
||||||
return t('form.errors.below-floor', { floor: price(issue.floor) });
|
|
||||||
case 'per-month-increase':
|
|
||||||
return t('form.errors.per-month-increase', {
|
|
||||||
amount: price(issue.amount),
|
|
||||||
period: t(`common:billing-periods.${issue.shorter}`),
|
|
||||||
shorter: price(issue.shorterAmount),
|
|
||||||
});
|
|
||||||
case 'promo-percent':
|
|
||||||
return t('form.errors.promo-percent');
|
|
||||||
case 'promo-floor':
|
|
||||||
return t('form.errors.promo-floor', {
|
|
||||||
amount: price(issue.amount),
|
|
||||||
floor: price(issue.floor),
|
|
||||||
});
|
|
||||||
case 'promo-end-required':
|
|
||||||
return t('form.errors.promo-end-required');
|
|
||||||
case 'promo-range':
|
|
||||||
return t('form.errors.promo-range');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export { PricingForm } from './PricingForm';
|
|
||||||
export { PricingFormSkeleton } from './PricingFormSkeleton';
|
|
||||||
export type { PricingFormProps, PricingFormSkeletonProps } from './types';
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
import type { BillingPeriod } from '../../../../../../../shared/constants';
|
|
||||||
import type {
|
|
||||||
PricingPageModel,
|
|
||||||
PricingTierView,
|
|
||||||
} from '../../../../../../../features/pricing';
|
|
||||||
|
|
||||||
export type PricingFormProps = {
|
|
||||||
/** mobile: bottom sheets. desktop: centred modals, cards padded lg (۸). */
|
|
||||||
layout: 'mobile' | 'desktop';
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PricingFormSkeletonProps = PricingFormProps & {
|
|
||||||
/** Hidden status text: «در حال بارگذاری قیمتگذاری…». */
|
|
||||||
label: string;
|
|
||||||
/** Fades in after 300ms, so a fast route never flashes grey. loading.tsx only. */
|
|
||||||
delayed?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type TierCardProps = {
|
|
||||||
tier: PricingTierView;
|
|
||||||
model: PricingPageModel;
|
|
||||||
layout: 'mobile' | 'desktop';
|
|
||||||
/** Opens the date picker for this period's promotion. */
|
|
||||||
onPickDate: (period: BillingPeriod, edge: 'start' | 'end') => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PromotionBlockProps = TierCardProps;
|
|
||||||
|
|
||||||
/** Which date the picker is choosing, and for which period. */
|
|
||||||
export type DatePick = { period: BillingPeriod; edge: 'start' | 'end' };
|
|
||||||
|
|
||||||
export type DateTimeDialogProps = {
|
|
||||||
layout: 'mobile' | 'desktop';
|
|
||||||
pick: DatePick | null;
|
|
||||||
/** The value it opens at: the field's, else now. */
|
|
||||||
value: string | null;
|
|
||||||
/** End only: «بدون تاریخ پایان» ticked. */
|
|
||||||
indefinite: boolean;
|
|
||||||
onConfirm: (iso: string | null, indefinite: boolean) => void;
|
|
||||||
onClose: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type ConfirmDialogProps = {
|
|
||||||
model: PricingPageModel;
|
|
||||||
layout: 'mobile' | 'desktop';
|
|
||||||
};
|
|
||||||
|
|
@ -1,134 +0,0 @@
|
||||||
'use client';
|
|
||||||
|
|
||||||
import { Amount } from '@lumina/island/atoms/amount';
|
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Icon } from '@lumina/island/atoms/icon';
|
|
||||||
import { Link } from '@lumina/island/atoms/link';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { Card } from '@lumina/island/molecules/card';
|
|
||||||
import { InfoTip } from '@lumina/island/molecules/info-tip';
|
|
||||||
import { Element } from '@lumina/island/primitives/element';
|
|
||||||
import { date } from '@lumina/tools/format';
|
|
||||||
import { useId } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import {
|
|
||||||
PAYOUT_ACCOUNT_ANCHOR,
|
|
||||||
useBalancePart,
|
|
||||||
} from '../../../../../../../features/finance';
|
|
||||||
import { PAYOUT_WEEKDAY } from '../../../../../../../shared/constants';
|
|
||||||
import type { BalanceSummaryProps } from './types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* مالی › the balance (C20 §۱): قابل واریز, the one large figure on the page, red with its minus and
|
|
||||||
* the reason when a refund took it below zero (۱.۲); در حال واریز under it only while a payout is
|
|
||||||
* in progress; مجموع واریزشده under a hairline. Each has its ⓘ. Under the card, the next-payout
|
|
||||||
* line (Appendix B §۳): the day, a link to register a شبا, nothing to pay, or the suspension.
|
|
||||||
*/
|
|
||||||
export function BalanceSummary({ layout }: BalanceSummaryProps) {
|
|
||||||
const { t } = useTranslation(['finance', 'common']);
|
|
||||||
const { balance } = useBalancePart();
|
|
||||||
const headingId = useId();
|
|
||||||
const negative = balance.availableToman < 0;
|
|
||||||
const next = balance.nextPayout;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<Card
|
|
||||||
tag="section"
|
|
||||||
aria-labelledby={headingId}
|
|
||||||
padding={layout === 'desktop' ? 'lg' : 'md'}
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col" className="gap-0.5">
|
|
||||||
<FlexBox alignItems="items-center">
|
|
||||||
<Typography
|
|
||||||
tag="h2"
|
|
||||||
id={headingId}
|
|
||||||
variant="caption"
|
|
||||||
color="secondary"
|
|
||||||
>
|
|
||||||
{t('balance.available')}
|
|
||||||
</Typography>
|
|
||||||
<InfoTip label={t('balance.available-info')}>
|
|
||||||
{t('balance.available-tip')}
|
|
||||||
</InfoTip>
|
|
||||||
</FlexBox>
|
|
||||||
<Amount
|
|
||||||
value={balance.availableToman}
|
|
||||||
size="figure"
|
|
||||||
tone={negative ? 'negative' : 'figure'}
|
|
||||||
signed={negative}
|
|
||||||
currency={t('common:currency')}
|
|
||||||
/>
|
|
||||||
{negative ? (
|
|
||||||
<Typography variant="caption" color="secondary">
|
|
||||||
{t('balance.negative-note')}
|
|
||||||
</Typography>
|
|
||||||
) : (
|
|
||||||
balance.inTransitToman > 0 && (
|
|
||||||
<Typography variant="caption" color="secondary">
|
|
||||||
{t('balance.in-transit')}{' '}
|
|
||||||
<Amount
|
|
||||||
value={balance.inTransitToman}
|
|
||||||
size="caption"
|
|
||||||
tone="mute"
|
|
||||||
currency={t('common:currency')}
|
|
||||||
/>
|
|
||||||
</Typography>
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
<Element
|
|
||||||
tag="hr"
|
|
||||||
className="mt-3 mb-2 border-0 border-t border-border-subtle"
|
|
||||||
/>
|
|
||||||
<FlexBox
|
|
||||||
alignItems="items-center"
|
|
||||||
justifyContent="justify-between"
|
|
||||||
gap="gap-3"
|
|
||||||
>
|
|
||||||
<FlexBox alignItems="items-center">
|
|
||||||
<Typography tag="span" variant="caption" color="secondary">
|
|
||||||
{t('balance.paid-total')}
|
|
||||||
</Typography>
|
|
||||||
<InfoTip label={t('balance.paid-total-info')}>
|
|
||||||
{t('balance.paid-total-tip')}
|
|
||||||
</InfoTip>
|
|
||||||
</FlexBox>
|
|
||||||
<Amount
|
|
||||||
value={balance.paidTotalToman}
|
|
||||||
currency={t('common:currency')}
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
</Card>
|
|
||||||
{next.state !== 'hidden' && (
|
|
||||||
<FlexBox alignItems="items-center" gap="gap-2" className="px-1">
|
|
||||||
<Icon
|
|
||||||
name="clock"
|
|
||||||
size={16}
|
|
||||||
className="flex-none text-text-secondary"
|
|
||||||
/>
|
|
||||||
{next.state === 'no_account' ? (
|
|
||||||
<Link href={`#${PAYOUT_ACCOUNT_ANCHOR}`} className="text-caption">
|
|
||||||
{t('balance.next.no_account')}
|
|
||||||
</Link>
|
|
||||||
) : (
|
|
||||||
<Typography
|
|
||||||
variant="caption"
|
|
||||||
color={next.state === 'scheduled' ? 'primary' : 'secondary'}
|
|
||||||
>
|
|
||||||
{next.state === 'scheduled' && next.date
|
|
||||||
? t('balance.next.scheduled', {
|
|
||||||
day: t(`weekdays.${PAYOUT_WEEKDAY}`),
|
|
||||||
date: date(next.date, { time: false }),
|
|
||||||
})
|
|
||||||
: t(
|
|
||||||
`balance.next.${next.state === 'scheduled' ? 'nothing' : next.state}`,
|
|
||||||
)}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
|
|
||||||
import { Card } from '@lumina/island/molecules/card';
|
|
||||||
|
|
||||||
import type { BalanceSummarySkeletonProps } from './types';
|
|
||||||
|
|
||||||
/** The balance before it arrives: the label, the figure, a line, the total row and the next-payout line. */
|
|
||||||
export function BalanceSummarySkeleton({
|
|
||||||
layout,
|
|
||||||
label,
|
|
||||||
delayed,
|
|
||||||
}: BalanceSummarySkeletonProps) {
|
|
||||||
return (
|
|
||||||
<SkeletonRegion label={label} delayed={delayed}>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<Card padding={layout === 'desktop' ? 'lg' : 'md'}>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-2">
|
|
||||||
<Skeleton width="22%" />
|
|
||||||
<Skeleton width="55%" height={36} />
|
|
||||||
<Skeleton width="40%" />
|
|
||||||
</FlexBox>
|
|
||||||
<FlexBox justifyContent="justify-between" className="mt-5">
|
|
||||||
<Skeleton width="30%" />
|
|
||||||
<Skeleton width="25%" />
|
|
||||||
</FlexBox>
|
|
||||||
</Card>
|
|
||||||
<Skeleton width="45%" className="mx-1" />
|
|
||||||
</FlexBox>
|
|
||||||
</SkeletonRegion>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export { BalanceSummary } from './BalanceSummary';
|
|
||||||
export { BalanceSummarySkeleton } from './BalanceSummarySkeleton';
|
|
||||||
export type { BalanceSummaryProps, BalanceSummarySkeletonProps } from './types';
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
export type BalanceSummaryProps = {
|
|
||||||
layout: 'mobile' | 'desktop';
|
|
||||||
};
|
|
||||||
|
|
||||||
export type BalanceSummarySkeletonProps = BalanceSummaryProps & {
|
|
||||||
/** Hidden status text: «در حال بارگذاری موجودی…». */
|
|
||||||
label: string;
|
|
||||||
/** Fades in after 300ms, so a fast route never flashes grey. loading.tsx only. */
|
|
||||||
delayed?: boolean;
|
|
||||||
};
|
|
||||||
|
|
@ -1,141 +0,0 @@
|
||||||
'use client';
|
|
||||||
|
|
||||||
import { Button } from '@lumina/island/atoms/button';
|
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { Card } from '@lumina/island/molecules/card';
|
|
||||||
import { EmptyState } from '@lumina/island/molecules/empty-state';
|
|
||||||
import { ErrorState } from '@lumina/island/molecules/error-state';
|
|
||||||
import { FilterChips } from '@lumina/island/molecules/filter-chips';
|
|
||||||
import { Lightbox } from '@lumina/island/organisms/lightbox';
|
|
||||||
import { price } from '@lumina/tools/format';
|
|
||||||
import { useId } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import {
|
|
||||||
LEDGER_FILTERS,
|
|
||||||
useLedgerPart,
|
|
||||||
} from '../../../../../../../features/finance';
|
|
||||||
import { LedgerDetail } from './components/LedgerDetail';
|
|
||||||
import { LedgerRow } from './components/LedgerRow';
|
|
||||||
import type { LedgerProps } from './types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* مالی › گردش حساب (C20 §۲): «همه» or «واریزها», newest first, 20 at a time; the rows stay while a
|
|
||||||
* tab or the next page loads, and a failed page says so in place of «نمایش بیشتر» (۲.۵). Each tab
|
|
||||||
* has its own empty line (۱.۳, ۲.۳). A row opens its details; an image receipt opens in the
|
|
||||||
* lightbox (۳.۷).
|
|
||||||
*/
|
|
||||||
export function Ledger({ layout }: LedgerProps) {
|
|
||||||
const { t } = useTranslation(['finance', 'errors']);
|
|
||||||
const model = useLedgerPart();
|
|
||||||
const headingId = useId();
|
|
||||||
const receipt = model.lightboxReceipt;
|
|
||||||
const receiptRow = model.detail?.kind === 'payout' ? model.detail : null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
tag="section"
|
|
||||||
aria-labelledby={headingId}
|
|
||||||
aria-busy={model.isFiltering}
|
|
||||||
padding="none"
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-2" className="px-4 pt-3.5 pb-2">
|
|
||||||
<Typography tag="h2" id={headingId} variant="heading-sm">
|
|
||||||
{t('ledger.title')}
|
|
||||||
</Typography>
|
|
||||||
<FilterChips
|
|
||||||
label={t('ledger.filter')}
|
|
||||||
size="sm"
|
|
||||||
options={LEDGER_FILTERS.map((value) => ({
|
|
||||||
value,
|
|
||||||
label: t(`ledger.filters.${value}`),
|
|
||||||
}))}
|
|
||||||
value={model.filter}
|
|
||||||
onChange={model.setFilter}
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
{model.isEmpty ? (
|
|
||||||
<EmptyState
|
|
||||||
title={t(`ledger.empty.${model.filter}`)}
|
|
||||||
icon={model.filter === 'payouts' ? 'wallet' : 'receipt'}
|
|
||||||
size="compact"
|
|
||||||
className="px-4 pb-6"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<FlexBox
|
|
||||||
tag="ul"
|
|
||||||
direction="flex-col"
|
|
||||||
className="border-t border-border-subtle"
|
|
||||||
>
|
|
||||||
{model.rows.map((row) => (
|
|
||||||
<LedgerRow
|
|
||||||
key={row.id}
|
|
||||||
row={row}
|
|
||||||
isOpen={
|
|
||||||
layout === 'desktop' &&
|
|
||||||
model.isDetailOpen &&
|
|
||||||
model.detail?.id === row.id
|
|
||||||
}
|
|
||||||
onOpen={() => model.openDetail(row)}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</FlexBox>
|
|
||||||
)}
|
|
||||||
{model.loadMoreError ? (
|
|
||||||
<FlexBox className="border-t border-border-subtle p-3">
|
|
||||||
<ErrorState
|
|
||||||
kind={model.loadMoreError}
|
|
||||||
size="inline"
|
|
||||||
title={t(`errors:fallback.${model.loadMoreError}.title`)}
|
|
||||||
description={t('ledger.more-failed')}
|
|
||||||
onRetry={model.loadMore}
|
|
||||||
retryLabel={t('errors:fallback.retry')}
|
|
||||||
retryingLabel={t('errors:fallback.retrying')}
|
|
||||||
retrying={model.isLoadingMore}
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
) : (
|
|
||||||
model.hasMore && (
|
|
||||||
<FlexBox className="border-t border-border-subtle p-3">
|
|
||||||
<Button
|
|
||||||
variant="secondary"
|
|
||||||
block
|
|
||||||
onClick={model.loadMore}
|
|
||||||
isLoading={model.isLoadingMore}
|
|
||||||
>
|
|
||||||
{t('ledger.more')}
|
|
||||||
</Button>
|
|
||||||
</FlexBox>
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
<LedgerDetail model={model} layout={layout} />
|
|
||||||
{receipt && (
|
|
||||||
<Lightbox
|
|
||||||
open
|
|
||||||
images={[
|
|
||||||
{
|
|
||||||
src: receipt.url,
|
|
||||||
alt: t('ledger.lightbox.alt', {
|
|
||||||
amount: price(Math.abs(receiptRow?.amountToman ?? 0)),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
onClose={model.closeLightbox}
|
|
||||||
zoomable
|
|
||||||
onDownload={() => window.location.assign(receipt.downloadUrl)}
|
|
||||||
labels={{
|
|
||||||
dialog: t('ledger.lightbox.dialog'),
|
|
||||||
close: t('ledger.lightbox.close'),
|
|
||||||
back: t('ledger.lightbox.back'),
|
|
||||||
previous: t('ledger.lightbox.previous'),
|
|
||||||
next: t('ledger.lightbox.next'),
|
|
||||||
zoomIn: t('ledger.lightbox.zoom-in'),
|
|
||||||
zoomOut: t('ledger.lightbox.zoom-out'),
|
|
||||||
download: t('ledger.lightbox.download'),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
|
|
||||||
import { Card } from '@lumina/island/molecules/card';
|
|
||||||
|
|
||||||
import type { LedgerSkeletonProps } from './types';
|
|
||||||
|
|
||||||
/** گردش حساب before it arrives: its title, the two tabs and four 60px rows. */
|
|
||||||
export function LedgerSkeleton({ label, delayed }: LedgerSkeletonProps) {
|
|
||||||
return (
|
|
||||||
<SkeletonRegion label={label} delayed={delayed}>
|
|
||||||
<Card padding="none">
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3" className="px-4 pt-4 pb-3">
|
|
||||||
<Skeleton width="30%" height={16} />
|
|
||||||
<FlexBox gap="gap-2">
|
|
||||||
<Skeleton shape="pill" width={56} height={36} />
|
|
||||||
<Skeleton shape="pill" width={72} height={36} />
|
|
||||||
</FlexBox>
|
|
||||||
</FlexBox>
|
|
||||||
{[0, 1, 2, 3].map((row) => (
|
|
||||||
<FlexBox
|
|
||||||
key={row}
|
|
||||||
direction="flex-col"
|
|
||||||
justifyContent="justify-center"
|
|
||||||
gap="gap-2"
|
|
||||||
className="min-h-15 border-t border-border-subtle px-4 py-2"
|
|
||||||
>
|
|
||||||
<FlexBox justifyContent="justify-between">
|
|
||||||
<Skeleton width="30%" />
|
|
||||||
<Skeleton width="22%" />
|
|
||||||
</FlexBox>
|
|
||||||
<Skeleton width="55%" />
|
|
||||||
</FlexBox>
|
|
||||||
))}
|
|
||||||
</Card>
|
|
||||||
</SkeletonRegion>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,263 +0,0 @@
|
||||||
import { Amount } from '@lumina/island/atoms/amount';
|
|
||||||
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 { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { DetailRow } from '@lumina/island/molecules/detail-row';
|
|
||||||
import { Sheet } from '@lumina/island/molecules/sheet';
|
|
||||||
import { Element } from '@lumina/island/primitives/element';
|
|
||||||
import { date, percent } from '@lumina/tools/format';
|
|
||||||
import type { ReactNode } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import type { LedgerItemPayload } from '../../../../../../../../features/finance';
|
|
||||||
import { maskIban } from '../../../../../../../../shared/utils';
|
|
||||||
import type { LedgerDetailProps } from '../types';
|
|
||||||
|
|
||||||
function Divider() {
|
|
||||||
return (
|
|
||||||
<Element
|
|
||||||
tag="div"
|
|
||||||
aria-hidden
|
|
||||||
className="my-2 border-t border-border-subtle"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A row's details (C20 §۳): a bottom sheet on mobile, a side panel on desktop (۶.۲), closed with
|
|
||||||
* ✕, Escape or the scrim. 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 (۳.۸).
|
|
||||||
*/
|
|
||||||
export function LedgerDetail({ model, layout }: LedgerDetailProps) {
|
|
||||||
const { t } = useTranslation(['finance', 'common']);
|
|
||||||
const row = model.detail;
|
|
||||||
const currency = t('common:currency');
|
|
||||||
const username = (name: string | null) => (
|
|
||||||
<Element tag="bdi" dir="ltr">
|
|
||||||
@{name ?? t('ledger.unknown-subscriber')}
|
|
||||||
</Element>
|
|
||||||
);
|
|
||||||
const period = (value: string | null) =>
|
|
||||||
value ? t(`common:billing-periods.${value as 'monthly'}`) : '—';
|
|
||||||
|
|
||||||
const body = (item: LedgerItemPayload): ReactNode => {
|
|
||||||
switch (item.kind) {
|
|
||||||
case 'income':
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<DetailRow label={t('ledger.detail.plan-price')}>
|
|
||||||
<Amount value={item.planPriceToman} currency={currency} />
|
|
||||||
</DetailRow>
|
|
||||||
{item.discountPercent !== null && (
|
|
||||||
<DetailRow label={t('ledger.detail.discount')}>
|
|
||||||
{percent(item.discountPercent, 0)}
|
|
||||||
</DetailRow>
|
|
||||||
)}
|
|
||||||
<DetailRow label={t('ledger.detail.paid')}>
|
|
||||||
<Amount value={item.paidToman} currency={currency} />
|
|
||||||
</DetailRow>
|
|
||||||
<DetailRow
|
|
||||||
label={t('ledger.detail.commission', {
|
|
||||||
percent: percent(item.commissionPercent, 0),
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
<Amount
|
|
||||||
value={-item.commissionToman}
|
|
||||||
signed
|
|
||||||
currency={currency}
|
|
||||||
/>
|
|
||||||
</DetailRow>
|
|
||||||
<Divider />
|
|
||||||
<FlexBox
|
|
||||||
alignItems="items-center"
|
|
||||||
justifyContent="justify-between"
|
|
||||||
gap="gap-3"
|
|
||||||
>
|
|
||||||
<Typography tag="dt" variant="body-md" className="font-semibold">
|
|
||||||
{t('ledger.detail.share')}
|
|
||||||
</Typography>
|
|
||||||
<Element tag="dd" className="m-0">
|
|
||||||
<Amount
|
|
||||||
value={item.shareToman}
|
|
||||||
size="title"
|
|
||||||
currency={currency}
|
|
||||||
/>
|
|
||||||
</Element>
|
|
||||||
</FlexBox>
|
|
||||||
<Divider />
|
|
||||||
<DetailRow label={t('ledger.detail.subscriber')}>
|
|
||||||
{username(item.subscriberUsername)}
|
|
||||||
</DetailRow>
|
|
||||||
<DetailRow label={t('ledger.detail.plan')}>
|
|
||||||
{period(item.billingPeriod)}
|
|
||||||
</DetailRow>
|
|
||||||
<DetailRow label={t('ledger.detail.paid-at')}>
|
|
||||||
{date(item.occurredAt)}
|
|
||||||
</DetailRow>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
case 'refund_deduction':
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<DetailRow label={t('ledger.detail.subscriber')}>
|
|
||||||
{username(item.subscriberUsername)}
|
|
||||||
</DetailRow>
|
|
||||||
<DetailRow label={t('ledger.detail.plan')}>
|
|
||||||
{period(item.billingPeriod)}
|
|
||||||
</DetailRow>
|
|
||||||
{item.originalPaidAt && (
|
|
||||||
<DetailRow label={t('ledger.detail.original-paid-at')}>
|
|
||||||
{date(item.originalPaidAt, { time: false })}
|
|
||||||
</DetailRow>
|
|
||||||
)}
|
|
||||||
<DetailRow label={t('ledger.detail.refunded')}>
|
|
||||||
<Amount value={item.refundedToman} currency={currency} />
|
|
||||||
</DetailRow>
|
|
||||||
<DetailRow label={t('ledger.detail.deducted')}>
|
|
||||||
<Amount value={-item.deductedToman} signed currency={currency} />
|
|
||||||
</DetailRow>
|
|
||||||
<DetailRow label={t('ledger.detail.date')}>
|
|
||||||
{date(item.occurredAt, { time: false })}
|
|
||||||
</DetailRow>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
case 'correction':
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<DetailRow label={t('ledger.detail.amount')}>
|
|
||||||
<Amount value={item.amountToman} signed currency={currency} />
|
|
||||||
</DetailRow>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-1" className="py-2">
|
|
||||||
<Typography tag="dt" variant="body-sm" color="secondary">
|
|
||||||
{t('ledger.detail.reason')}
|
|
||||||
</Typography>
|
|
||||||
<Typography tag="dd" variant="body-md" className="m-0">
|
|
||||||
{item.reason}
|
|
||||||
</Typography>
|
|
||||||
</FlexBox>
|
|
||||||
<DetailRow label={t('ledger.detail.date')}>
|
|
||||||
{date(item.occurredAt, { time: false })}
|
|
||||||
</DetailRow>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
case 'payout':
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<DetailRow label={t('ledger.detail.amount')}>
|
|
||||||
<Amount
|
|
||||||
value={Math.abs(item.amountToman)}
|
|
||||||
currency={currency}
|
|
||||||
struck={item.status === 'cancelled'}
|
|
||||||
/>
|
|
||||||
</DetailRow>
|
|
||||||
<DetailRow label={t('ledger.detail.status')}>
|
|
||||||
{item.status === 'completed' ? (
|
|
||||||
t('ledger.status.completed')
|
|
||||||
) : (
|
|
||||||
<StatusBadge status={`payout.${item.status}`}>
|
|
||||||
{t(`ledger.status.${item.status}`)}
|
|
||||||
</StatusBadge>
|
|
||||||
)}
|
|
||||||
</DetailRow>
|
|
||||||
<DetailRow label={t('ledger.detail.created')}>
|
|
||||||
{date(item.occurredAt)}
|
|
||||||
</DetailRow>
|
|
||||||
{item.status === 'completed' && item.completedAt && (
|
|
||||||
<DetailRow label={t('ledger.detail.completed')}>
|
|
||||||
{date(item.completedAt, { time: false })}
|
|
||||||
</DetailRow>
|
|
||||||
)}
|
|
||||||
<DetailRow label={t('ledger.detail.destination')}>
|
|
||||||
<Element
|
|
||||||
tag="bdi"
|
|
||||||
dir="ltr"
|
|
||||||
className="font-latin whitespace-nowrap tabular-nums"
|
|
||||||
>
|
|
||||||
{maskIban(item.ibanCheckDigits, item.ibanTail)}
|
|
||||||
</Element>
|
|
||||||
</DetailRow>
|
|
||||||
{item.status === 'cancelled' && (
|
|
||||||
<>
|
|
||||||
{item.cancelledAt && (
|
|
||||||
<DetailRow label={t('ledger.detail.cancelled')}>
|
|
||||||
{date(item.cancelledAt, { time: false })}
|
|
||||||
</DetailRow>
|
|
||||||
)}
|
|
||||||
{item.cancelReason && (
|
|
||||||
<DetailRow label={t('ledger.detail.reason')}>
|
|
||||||
{item.cancelReason}
|
|
||||||
</DetailRow>
|
|
||||||
)}
|
|
||||||
<Typography
|
|
||||||
tag="div"
|
|
||||||
variant="body-sm"
|
|
||||||
color="secondary"
|
|
||||||
className="pt-2"
|
|
||||||
>
|
|
||||||
{t('ledger.detail.returned')}
|
|
||||||
</Typography>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{item.status === 'in_progress' && (
|
|
||||||
<Typography
|
|
||||||
tag="div"
|
|
||||||
variant="body-sm"
|
|
||||||
color="secondary"
|
|
||||||
className="pt-2"
|
|
||||||
>
|
|
||||||
{t('ledger.detail.timing')}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const receipt = row?.kind === 'payout' ? row.receipt : null;
|
|
||||||
const footer = receipt ? (
|
|
||||||
<>
|
|
||||||
<Button
|
|
||||||
variant="secondary"
|
|
||||||
size={layout === 'mobile' ? 'lg' : undefined}
|
|
||||||
block
|
|
||||||
icon="eye"
|
|
||||||
isLoading={model.isReceiptLoading}
|
|
||||||
onClick={() => model.viewReceipt(receipt)}
|
|
||||||
>
|
|
||||||
{t('ledger.detail.view-receipt')}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="secondary"
|
|
||||||
size={layout === 'mobile' ? 'lg' : undefined}
|
|
||||||
block
|
|
||||||
icon="download"
|
|
||||||
onClick={() => window.location.assign(receipt.downloadUrl)}
|
|
||||||
>
|
|
||||||
{t('ledger.detail.download-receipt')}
|
|
||||||
</Button>
|
|
||||||
{model.receiptFailed && (
|
|
||||||
<FieldError>{t('ledger.detail.receipt-failed')}</FieldError>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : undefined;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Sheet
|
|
||||||
placement={layout === 'mobile' ? 'bottom' : 'side'}
|
|
||||||
open={model.isDetailOpen}
|
|
||||||
title={row ? t(`ledger.detail.titles.${row.kind}`) : ''}
|
|
||||||
closeLabel={t('ledger.detail.close')}
|
|
||||||
onClose={model.closeDetail}
|
|
||||||
footer={footer}
|
|
||||||
>
|
|
||||||
{row && (
|
|
||||||
<Element tag="dl" className="m-0">
|
|
||||||
{body(row)}
|
|
||||||
</Element>
|
|
||||||
)}
|
|
||||||
</Sheet>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
import { Amount } from '@lumina/island/atoms/amount';
|
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Separator } from '@lumina/island/atoms/separator';
|
|
||||||
import { StatusBadge } from '@lumina/island/atoms/status-badge';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { Element } from '@lumina/island/primitives/element';
|
|
||||||
import { cn } from '@lumina/island/tools/cn';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import type { LedgerRowProps } from '../types';
|
|
||||||
import { useLedgerRowText } from './use-ledger-row-text';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* One line of گردش حساب (C20 ۲.۱): what it is and its signed amount, then who or where, what, and
|
|
||||||
* the date. The whole row is one button (at least 60px) that opens its details. Only an in-progress
|
|
||||||
* or cancelled payout has a pill; a cancelled one's amount is struck, since it never left.
|
|
||||||
*/
|
|
||||||
export function LedgerRow({ row, isOpen, onOpen }: LedgerRowProps) {
|
|
||||||
const { t } = useTranslation('finance');
|
|
||||||
const text = useLedgerRowText()(row);
|
|
||||||
const cancelled = row.kind === 'payout' && row.status === 'cancelled';
|
|
||||||
const pill =
|
|
||||||
row.kind === 'payout' && row.status !== 'completed' ? row.status : null;
|
|
||||||
const meta = [
|
|
||||||
text.who && (
|
|
||||||
<Element key="who" tag="bdi" dir="ltr">
|
|
||||||
@{text.who}
|
|
||||||
</Element>
|
|
||||||
),
|
|
||||||
text.what && (
|
|
||||||
<Typography
|
|
||||||
key="what"
|
|
||||||
tag="span"
|
|
||||||
variant="inherit"
|
|
||||||
color="inherit"
|
|
||||||
className="truncate"
|
|
||||||
>
|
|
||||||
{text.what}
|
|
||||||
</Typography>
|
|
||||||
),
|
|
||||||
<Typography
|
|
||||||
key="when"
|
|
||||||
tag="span"
|
|
||||||
variant="inherit"
|
|
||||||
color="inherit"
|
|
||||||
className="flex-none"
|
|
||||||
>
|
|
||||||
{text.when}
|
|
||||||
</Typography>,
|
|
||||||
].filter(Boolean);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Element
|
|
||||||
tag="li"
|
|
||||||
className="border-t border-border-subtle first:border-t-0"
|
|
||||||
>
|
|
||||||
<FlexBox
|
|
||||||
tag="button"
|
|
||||||
type="button"
|
|
||||||
direction="flex-col"
|
|
||||||
justifyContent="justify-center"
|
|
||||||
aria-haspopup="dialog"
|
|
||||||
aria-label={t('ledger.open', { title: text.title, date: text.when })}
|
|
||||||
onClick={onOpen}
|
|
||||||
className={cn(
|
|
||||||
'min-h-15 w-full cursor-pointer gap-0.5 px-4 py-2 text-start outline-none transition-colors duration-120 ease-standard hover:bg-surface-hover focus-visible:focus-ring',
|
|
||||||
isOpen && 'bg-action-primary-subtle hover:bg-action-primary-subtle',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<FlexBox
|
|
||||||
alignItems="items-center"
|
|
||||||
justifyContent="justify-between"
|
|
||||||
gap="gap-3"
|
|
||||||
>
|
|
||||||
<FlexBox alignItems="items-center" gap="gap-2" className="min-w-0">
|
|
||||||
<Typography
|
|
||||||
tag="span"
|
|
||||||
variant="label"
|
|
||||||
className="whitespace-nowrap"
|
|
||||||
>
|
|
||||||
{text.title}
|
|
||||||
</Typography>
|
|
||||||
{pill && (
|
|
||||||
<StatusBadge status={`payout.${pill}`}>
|
|
||||||
{t(`ledger.status.${pill}`)}
|
|
||||||
</StatusBadge>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
<Amount
|
|
||||||
value={row.amountToman}
|
|
||||||
size="caption"
|
|
||||||
signed
|
|
||||||
struck={cancelled}
|
|
||||||
srLabel={cancelled ? t('ledger.cancelled') : undefined}
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
<FlexBox
|
|
||||||
tag="span"
|
|
||||||
alignItems="items-center"
|
|
||||||
className="min-w-0 text-caption text-text-secondary"
|
|
||||||
>
|
|
||||||
{meta.flatMap((part, index) =>
|
|
||||||
index === 0 ? [part] : [<Separator key={`sep-${index}`} />, part],
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
</FlexBox>
|
|
||||||
</Element>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
import { date } from '@lumina/tools/format';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import type { LedgerItemPayload } from '../../../../../../../../features/finance';
|
|
||||||
|
|
||||||
/** A row's title and the parts of its second line: who or where, what, then the Shamsi date. */
|
|
||||||
export function useLedgerRowText() {
|
|
||||||
const { t } = useTranslation(['finance', 'common']);
|
|
||||||
|
|
||||||
return (row: LedgerItemPayload) => {
|
|
||||||
const title = t(`ledger.rows.${row.kind}`);
|
|
||||||
const when = date(row.occurredAt, { time: false });
|
|
||||||
switch (row.kind) {
|
|
||||||
case 'income':
|
|
||||||
return {
|
|
||||||
title,
|
|
||||||
who: row.subscriberUsername,
|
|
||||||
what: row.billingPeriod
|
|
||||||
? t('ledger.plan', {
|
|
||||||
period: t(`common:billing-periods.${row.billingPeriod}`),
|
|
||||||
})
|
|
||||||
: null,
|
|
||||||
when,
|
|
||||||
};
|
|
||||||
case 'refund_deduction':
|
|
||||||
return {
|
|
||||||
title,
|
|
||||||
who: row.subscriberUsername,
|
|
||||||
what: row.billingPeriod
|
|
||||||
? t('ledger.refund-plan', {
|
|
||||||
period: t(`common:billing-periods.${row.billingPeriod}`),
|
|
||||||
})
|
|
||||||
: null,
|
|
||||||
when,
|
|
||||||
};
|
|
||||||
case 'correction':
|
|
||||||
return { title, who: null, what: row.reason, when };
|
|
||||||
case 'payout':
|
|
||||||
return {
|
|
||||||
title,
|
|
||||||
who: null,
|
|
||||||
what: t('ledger.payout-line', { tail: `…${row.ibanTail}` }),
|
|
||||||
when,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export { Ledger } from './Ledger';
|
|
||||||
export { LedgerSkeleton } from './LedgerSkeleton';
|
|
||||||
export type { LedgerProps, LedgerSkeletonProps } from './types';
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
import type {
|
|
||||||
LedgerItemPayload,
|
|
||||||
LedgerPartModel,
|
|
||||||
} from '../../../../../../../features/finance';
|
|
||||||
|
|
||||||
export type LedgerProps = {
|
|
||||||
/** mobile: details in a bottom sheet. desktop: in a side panel, the row highlighted (۶.۲). */
|
|
||||||
layout: 'mobile' | 'desktop';
|
|
||||||
};
|
|
||||||
|
|
||||||
export type LedgerSkeletonProps = LedgerProps & {
|
|
||||||
/** Hidden status text: «در حال بارگذاری گردش حساب…». */
|
|
||||||
label: string;
|
|
||||||
/** Fades in after 300ms, so a fast route never flashes grey. loading.tsx only. */
|
|
||||||
delayed?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type LedgerRowProps = {
|
|
||||||
row: LedgerItemPayload;
|
|
||||||
/** Its details are open in the side panel. */
|
|
||||||
isOpen: boolean;
|
|
||||||
onOpen: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type LedgerDetailProps = {
|
|
||||||
model: LedgerPartModel;
|
|
||||||
layout: 'mobile' | 'desktop';
|
|
||||||
};
|
|
||||||
|
|
@ -1,138 +0,0 @@
|
||||||
'use client';
|
|
||||||
|
|
||||||
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 { Card } from '@lumina/island/molecules/card';
|
|
||||||
import { useId } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import {
|
|
||||||
PAYOUT_ACCOUNT_ANCHOR,
|
|
||||||
usePayoutAccountPart,
|
|
||||||
} from '../../../../../../../features/finance';
|
|
||||||
import { AccountForm } from './components/AccountForm';
|
|
||||||
import { ReadBackDialog } from './components/ReadBackDialog';
|
|
||||||
import { SavedAccount } from './components/SavedAccount';
|
|
||||||
import { WarnLine } from './components/WarnLine';
|
|
||||||
import type { PayoutAccountProps } from './types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* مالی › اطلاعات تسویهحساب (C19). Saved: the number, its bank and date, «ویرایش» in the header
|
|
||||||
* (۴.۳). None: the empty line, the amber reassurance when money is waiting (۱.۲) and «ثبت شماره
|
|
||||||
* شبا». Unverified or rejected: a lock and one line, no button (۱.۳). Suspended: the saved card
|
|
||||||
* read-only, a lock where «ویرایش» was and the amber reason (۵.۳). The form expands in place, with
|
|
||||||
* «انصراف» in the header when a number is already saved (۵.۱).
|
|
||||||
*/
|
|
||||||
export function PayoutAccount({ layout }: PayoutAccountProps) {
|
|
||||||
const { t } = useTranslation('finance');
|
|
||||||
const model = usePayoutAccountPart();
|
|
||||||
const headingId = useId();
|
|
||||||
const { state, account } = model;
|
|
||||||
const canEdit = state === 'open';
|
|
||||||
|
|
||||||
let headerAction = null;
|
|
||||||
if (model.isEditing && account) {
|
|
||||||
headerAction = (
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
aria-label={t('account.cancel-label')}
|
|
||||||
onClick={model.cancelEditing}
|
|
||||||
disabled={model.isSaving}
|
|
||||||
>
|
|
||||||
{t('account.cancel')}
|
|
||||||
</Button>
|
|
||||||
);
|
|
||||||
} else if (!model.isEditing && account && canEdit) {
|
|
||||||
headerAction = (
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
icon="edit"
|
|
||||||
aria-label={t('account.edit-label')}
|
|
||||||
onClick={model.startEditing}
|
|
||||||
>
|
|
||||||
{t('account.edit')}
|
|
||||||
</Button>
|
|
||||||
);
|
|
||||||
} else if (account && state === 'suspended') {
|
|
||||||
headerAction = (
|
|
||||||
<FlexBox
|
|
||||||
alignItems="items-center"
|
|
||||||
justifyContent="justify-center"
|
|
||||||
className="size-touch-target text-text-secondary"
|
|
||||||
>
|
|
||||||
<Icon name="lock" size={20} label={t('account.read-only')} />
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
tag="section"
|
|
||||||
id={PAYOUT_ACCOUNT_ANCHOR}
|
|
||||||
aria-labelledby={headingId}
|
|
||||||
padding={layout === 'desktop' ? 'lg' : 'md'}
|
|
||||||
className="scroll-mt-20"
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<FlexBox
|
|
||||||
alignItems="items-center"
|
|
||||||
justifyContent="justify-between"
|
|
||||||
gap="gap-3"
|
|
||||||
className="-my-2"
|
|
||||||
>
|
|
||||||
<Typography tag="h2" id={headingId} variant="heading-sm">
|
|
||||||
{t('account.title')}
|
|
||||||
</Typography>
|
|
||||||
{headerAction}
|
|
||||||
</FlexBox>
|
|
||||||
{model.isEditing ? (
|
|
||||||
<AccountForm model={model} layout={layout} />
|
|
||||||
) : account ? (
|
|
||||||
<>
|
|
||||||
<SavedAccount
|
|
||||||
iban={account.iban}
|
|
||||||
bankCode={account.bankCode}
|
|
||||||
savedAt={account.savedAt}
|
|
||||||
/>
|
|
||||||
{state === 'suspended' && (
|
|
||||||
<WarnLine>{t('account.suspended')}</WarnLine>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : state === 'open' ? (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<Typography variant="body-sm" color="secondary">
|
|
||||||
{t('account.empty')}
|
|
||||||
</Typography>
|
|
||||||
{model.showHeldNote && (
|
|
||||||
<WarnLine>{t('account.held-note')}</WarnLine>
|
|
||||||
)}
|
|
||||||
<Button
|
|
||||||
variant="primary"
|
|
||||||
size="lg"
|
|
||||||
block={layout === 'mobile'}
|
|
||||||
onClick={model.startEditing}
|
|
||||||
>
|
|
||||||
{t('account.register')}
|
|
||||||
</Button>
|
|
||||||
</FlexBox>
|
|
||||||
) : (
|
|
||||||
<FlexBox alignItems="items-start" gap="gap-2">
|
|
||||||
<Icon
|
|
||||||
name="lock"
|
|
||||||
size={20}
|
|
||||||
className="mt-0.5 flex-none text-text-secondary"
|
|
||||||
/>
|
|
||||||
<Typography variant="body-sm" color="secondary">
|
|
||||||
{state === 'suspended'
|
|
||||||
? t('account.suspended')
|
|
||||||
: t('account.locked')}
|
|
||||||
</Typography>
|
|
||||||
</FlexBox>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
<ReadBackDialog model={model} layout={layout} />
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
|
|
||||||
import { Card } from '@lumina/island/molecules/card';
|
|
||||||
|
|
||||||
import type { PayoutAccountSkeletonProps } from './types';
|
|
||||||
|
|
||||||
/** اطلاعات تسویهحساب before it arrives: the header, the number panel and its meta line. */
|
|
||||||
export function PayoutAccountSkeleton({
|
|
||||||
layout,
|
|
||||||
label,
|
|
||||||
delayed,
|
|
||||||
}: PayoutAccountSkeletonProps) {
|
|
||||||
return (
|
|
||||||
<SkeletonRegion label={label} delayed={delayed}>
|
|
||||||
<Card padding={layout === 'desktop' ? 'lg' : 'md'}>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<Skeleton width="40%" height={16} />
|
|
||||||
<Skeleton shape="rect" height={56} />
|
|
||||||
<FlexBox justifyContent="justify-between">
|
|
||||||
<Skeleton width="30%" />
|
|
||||||
<Skeleton width="35%" />
|
|
||||||
</FlexBox>
|
|
||||||
</FlexBox>
|
|
||||||
</Card>
|
|
||||||
</SkeletonRegion>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,118 +0,0 @@
|
||||||
import { Button } from '@lumina/island/atoms/button';
|
|
||||||
import { Checkbox } from '@lumina/island/atoms/checkbox';
|
|
||||||
import { FieldError } from '@lumina/island/atoms/field-error';
|
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { Banner } from '@lumina/island/molecules/banner';
|
|
||||||
import { TextInput } from '@lumina/island/molecules/text-input';
|
|
||||||
import { useId } from 'react';
|
|
||||||
import { Controller } from 'react-hook-form';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import { translateMessage } from '../../../../../../../../shared/utils';
|
|
||||||
import type { PayoutAccountPartProps } from '../types';
|
|
||||||
import { WarnLine } from './WarnLine';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The شبا form, in place of the card's body (C19 §۲–۳). The field is the page's only LTR one: `IR`
|
|
||||||
* fixed before it, digits grouped as typed. Under it, in order: the error, the bank, the duplicate
|
|
||||||
* warning, the helper. The box is ticked on every save. «ثبت شماره شبا» is pressable at any time,
|
|
||||||
* so a tap shows what is missing (۳.۴); the save's failure shows at the top (۵.۲).
|
|
||||||
*/
|
|
||||||
export function AccountForm({ model, layout }: PayoutAccountPartProps) {
|
|
||||||
const { t } = useTranslation('finance');
|
|
||||||
const hintId = useId();
|
|
||||||
const { form } = model;
|
|
||||||
const rootError = form.formState.errors.root?.server?.message;
|
|
||||||
const bank = model.bankCode
|
|
||||||
? t(`banks.${model.bankCode}`, { defaultValue: '' })
|
|
||||||
: '';
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox
|
|
||||||
tag="form"
|
|
||||||
noValidate
|
|
||||||
direction="flex-col"
|
|
||||||
gap="gap-3"
|
|
||||||
onSubmit={(event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
model.submit();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{rootError && (
|
|
||||||
<Banner tone="danger" role="alert">
|
|
||||||
{translateMessage(t, rootError)}
|
|
||||||
</Banner>
|
|
||||||
)}
|
|
||||||
<FlexBox direction="flex-col" gap="gap-1">
|
|
||||||
<Controller
|
|
||||||
name="iban"
|
|
||||||
control={form.control}
|
|
||||||
render={({ field, fieldState }) => (
|
|
||||||
<TextInput
|
|
||||||
ref={field.ref}
|
|
||||||
name={field.name}
|
|
||||||
label={t('account.iban')}
|
|
||||||
dir="ltr"
|
|
||||||
prefix="IR"
|
|
||||||
inputMode="numeric"
|
|
||||||
autoComplete="off"
|
|
||||||
spellCheck={false}
|
|
||||||
placeholder="00 0000 0000 0000 0000 0000 00"
|
|
||||||
value={model.ibanText}
|
|
||||||
onChange={(event) => model.changeIban(event.target.value)}
|
|
||||||
onBlur={() => {
|
|
||||||
field.onBlur();
|
|
||||||
model.checkDuplicate();
|
|
||||||
}}
|
|
||||||
error={translateMessage(t, fieldState.error?.message)}
|
|
||||||
aria-describedby={hintId}
|
|
||||||
inputClassName="font-latin tabular-nums"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
{bank && (
|
|
||||||
<Typography variant="caption" color="secondary">
|
|
||||||
{t('account.bank', { name: bank })}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
{model.duplicate && <WarnLine>{t('account.duplicate')}</WarnLine>}
|
|
||||||
<Typography id={hintId} variant="caption" color="secondary">
|
|
||||||
{t('account.hint')}
|
|
||||||
</Typography>
|
|
||||||
</FlexBox>
|
|
||||||
<Controller
|
|
||||||
name="confirmed"
|
|
||||||
control={form.control}
|
|
||||||
render={({ field, fieldState }) => (
|
|
||||||
<FlexBox direction="flex-col">
|
|
||||||
<Checkbox
|
|
||||||
ref={field.ref}
|
|
||||||
name={field.name}
|
|
||||||
checked={field.value}
|
|
||||||
onChange={(event) => field.onChange(event.target.checked)}
|
|
||||||
onBlur={field.onBlur}
|
|
||||||
invalid={fieldState.error != null}
|
|
||||||
>
|
|
||||||
{t('account.confirm')}
|
|
||||||
</Checkbox>
|
|
||||||
{fieldState.error?.message && (
|
|
||||||
<FieldError className="ps-8.5">
|
|
||||||
{translateMessage(t, fieldState.error.message)}
|
|
||||||
</FieldError>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
variant="primary"
|
|
||||||
size="lg"
|
|
||||||
block={layout === 'mobile'}
|
|
||||||
isLoading={model.isSaving}
|
|
||||||
>
|
|
||||||
{t('account.register')}
|
|
||||||
</Button>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,112 +0,0 @@
|
||||||
import { Button } from '@lumina/island/atoms/button';
|
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { Modal } from '@lumina/island/molecules/modal';
|
|
||||||
import { Sheet } from '@lumina/island/molecules/sheet';
|
|
||||||
import { Element } from '@lumina/island/primitives/element';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import {
|
|
||||||
groupIbanDigits,
|
|
||||||
ibanBankCode,
|
|
||||||
} from '../../../../../../../../shared/utils';
|
|
||||||
import type { PayoutAccountPartProps } from '../types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The read-back before saving (C19 §۷): the شبا is the largest thing on it, LTR and grouped, with
|
|
||||||
* its bank when known (۴.۲ drops the row otherwise). «ثبت نهایی» saves; «ویرایش», Escape or the
|
|
||||||
* scrim return to the form with the number and the tick kept. A bottom sheet on mobile, a centred
|
|
||||||
* modal on desktop (۸.۲); no ✕, since «ویرایش» is the way back.
|
|
||||||
*/
|
|
||||||
export function ReadBackDialog({ model, layout }: PayoutAccountPartProps) {
|
|
||||||
const { t } = useTranslation('finance');
|
|
||||||
const open = model.phase === 'confirming' || model.phase === 'saving';
|
|
||||||
const code = ibanBankCode(model.readBackIban);
|
|
||||||
const bank = code ? t(`banks.${code}`, { defaultValue: '' }) : '';
|
|
||||||
|
|
||||||
const buttons = (
|
|
||||||
<>
|
|
||||||
<Button
|
|
||||||
variant="primary"
|
|
||||||
size={layout === 'mobile' ? 'lg' : undefined}
|
|
||||||
block
|
|
||||||
isLoading={model.isSaving}
|
|
||||||
onClick={model.confirm}
|
|
||||||
>
|
|
||||||
{t('account.read-back.submit')}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="secondary"
|
|
||||||
size={layout === 'mobile' ? 'lg' : undefined}
|
|
||||||
block
|
|
||||||
disabled={model.isSaving}
|
|
||||||
onClick={model.closeReadBack}
|
|
||||||
>
|
|
||||||
{t('account.read-back.edit')}
|
|
||||||
</Button>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
const body = (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
<Typography variant="body-md">{t('account.read-back.intro')}</Typography>
|
|
||||||
<FlexBox
|
|
||||||
direction="flex-col"
|
|
||||||
gap="gap-2"
|
|
||||||
className="rounded-md bg-surface-sunken p-3"
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col" className="gap-0.5">
|
|
||||||
<Typography tag="span" variant="caption" color="secondary">
|
|
||||||
{t('account.read-back.iban')}
|
|
||||||
</Typography>
|
|
||||||
<Element
|
|
||||||
tag="bdi"
|
|
||||||
dir="ltr"
|
|
||||||
className="block text-start font-latin text-body-lg font-bold whitespace-nowrap tabular-nums"
|
|
||||||
>
|
|
||||||
IR{groupIbanDigits(model.readBackIban)}
|
|
||||||
</Element>
|
|
||||||
</FlexBox>
|
|
||||||
{bank && (
|
|
||||||
<FlexBox
|
|
||||||
alignItems="items-baseline"
|
|
||||||
gap="gap-2"
|
|
||||||
className="border-t border-border-subtle pt-2"
|
|
||||||
>
|
|
||||||
<Typography tag="span" variant="caption" color="secondary">
|
|
||||||
{t('account.read-back.bank')}
|
|
||||||
</Typography>
|
|
||||||
<Typography tag="span" variant="body-sm" className="font-semibold">
|
|
||||||
{bank}
|
|
||||||
</Typography>
|
|
||||||
</FlexBox>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
<Typography variant="body-sm" color="secondary">
|
|
||||||
{t('account.read-back.warning')}
|
|
||||||
</Typography>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
|
|
||||||
const onClose = model.isSaving ? undefined : model.closeReadBack;
|
|
||||||
|
|
||||||
return layout === 'mobile' ? (
|
|
||||||
<Sheet
|
|
||||||
open={open}
|
|
||||||
title={t('account.read-back.title')}
|
|
||||||
footer={buttons}
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
{body}
|
|
||||||
</Sheet>
|
|
||||||
) : (
|
|
||||||
<Modal
|
|
||||||
open={open}
|
|
||||||
title={t('account.read-back.title')}
|
|
||||||
actions={buttons}
|
|
||||||
onClose={onClose}
|
|
||||||
>
|
|
||||||
{body}
|
|
||||||
</Modal>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { Element } from '@lumina/island/primitives/element';
|
|
||||||
import { date } from '@lumina/tools/format';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import { groupIbanDigits } from '../../../../../../../../shared/utils';
|
|
||||||
import type { SavedAccountProps } from '../types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The saved شبا (C19 ۴.۳): the whole number, LTR and grouped, in Latin digits as banks print it,
|
|
||||||
* then its bank when the code is known and when it was last saved.
|
|
||||||
*/
|
|
||||||
export function SavedAccount({ iban, bankCode, savedAt }: SavedAccountProps) {
|
|
||||||
const { t } = useTranslation('finance');
|
|
||||||
const bank = bankCode ? t(`banks.${bankCode}`, { defaultValue: '' }) : '';
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-2">
|
|
||||||
<FlexBox
|
|
||||||
direction="flex-col"
|
|
||||||
className="gap-0.5 rounded-md bg-surface-sunken px-3 py-2"
|
|
||||||
>
|
|
||||||
<Typography tag="span" variant="caption" color="secondary">
|
|
||||||
{t('account.iban')}
|
|
||||||
</Typography>
|
|
||||||
<Element
|
|
||||||
tag="bdi"
|
|
||||||
dir="ltr"
|
|
||||||
className="block text-start font-latin text-body-lg font-bold whitespace-nowrap tabular-nums"
|
|
||||||
>
|
|
||||||
IR{groupIbanDigits(iban)}
|
|
||||||
</Element>
|
|
||||||
</FlexBox>
|
|
||||||
<FlexBox justifyContent="justify-between" gap="gap-3" wrap="flex-wrap">
|
|
||||||
{bank && (
|
|
||||||
<Typography tag="span" variant="caption" color="secondary">
|
|
||||||
{t('account.bank', { name: bank })}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
<Typography tag="span" variant="caption" color="secondary">
|
|
||||||
{t('account.updated', { date: date(savedAt, { time: false }) })}
|
|
||||||
</Typography>
|
|
||||||
</FlexBox>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Icon } from '@lumina/island/atoms/icon';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
|
|
||||||
import type { WarnLineProps } from '../types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An amber note that warns without blocking (C19 ۱.۲, ۳.۳, ۵.۳): ink-dark amber text on the amber
|
|
||||||
* tint, so it passes contrast on white, with the warning icon.
|
|
||||||
*/
|
|
||||||
export function WarnLine({ children }: WarnLineProps) {
|
|
||||||
return (
|
|
||||||
<FlexBox
|
|
||||||
alignItems="items-start"
|
|
||||||
gap="gap-2"
|
|
||||||
className="rounded-md bg-warning-subtle px-3 py-2 text-warning-text"
|
|
||||||
>
|
|
||||||
<Icon name="alert" size={16} className="mt-1 flex-none" />
|
|
||||||
<Typography variant="caption" color="warning">
|
|
||||||
{children}
|
|
||||||
</Typography>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export { PayoutAccount } from './PayoutAccount';
|
|
||||||
export { PayoutAccountSkeleton } from './PayoutAccountSkeleton';
|
|
||||||
export type { PayoutAccountProps, PayoutAccountSkeletonProps } from './types';
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
import type { ReactNode } from 'react';
|
|
||||||
|
|
||||||
import type { PayoutAccountPartModel } from '../../../../../../../features/finance';
|
|
||||||
|
|
||||||
export type PayoutAccountProps = {
|
|
||||||
layout: 'mobile' | 'desktop';
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PayoutAccountSkeletonProps = PayoutAccountProps & {
|
|
||||||
/** Hidden status text: «در حال بارگذاری اطلاعات تسویهحساب…». */
|
|
||||||
label: string;
|
|
||||||
/** Fades in after 300ms, so a fast route never flashes grey. loading.tsx only. */
|
|
||||||
delayed?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PayoutAccountPartProps = {
|
|
||||||
model: PayoutAccountPartModel;
|
|
||||||
layout: 'mobile' | 'desktop';
|
|
||||||
};
|
|
||||||
|
|
||||||
export type SavedAccountProps = {
|
|
||||||
iban: string;
|
|
||||||
bankCode: string | null;
|
|
||||||
savedAt: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type WarnLineProps = {
|
|
||||||
children: ReactNode;
|
|
||||||
};
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { Banner } from '@lumina/island/molecules/banner';
|
|
||||||
|
|
||||||
import type { PayoutScheduleNoticeProps } from './types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* مالی's first block, always (C19 §۱; brief §4): when payouts are made. The same for every creator,
|
|
||||||
* so the server renders it with the page, and it never waits for the creator's own figures.
|
|
||||||
*/
|
|
||||||
export function PayoutScheduleNotice({ labels }: PayoutScheduleNoticeProps) {
|
|
||||||
return (
|
|
||||||
<Banner tone="info" icon="clock">
|
|
||||||
{labels.before}{' '}
|
|
||||||
<Typography
|
|
||||||
tag="strong"
|
|
||||||
variant="inherit"
|
|
||||||
color="inherit"
|
|
||||||
className="font-bold"
|
|
||||||
>
|
|
||||||
{labels.day}
|
|
||||||
</Typography>{' '}
|
|
||||||
{labels.after}
|
|
||||||
</Banner>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
export { PayoutScheduleNotice } from './PayoutScheduleNotice';
|
|
||||||
export type {
|
|
||||||
PayoutScheduleNoticeLabels,
|
|
||||||
PayoutScheduleNoticeProps,
|
|
||||||
} from './types';
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
/** Every text, from the app's server i18n (0020). */
|
|
||||||
export type PayoutScheduleNoticeLabels = {
|
|
||||||
/** «واریز درآمد هر هفته، روزهای». */
|
|
||||||
before: string;
|
|
||||||
/** `{payout_day}`: «پنجشنبه». */
|
|
||||||
day: string;
|
|
||||||
/** «انجام میشود. …». */
|
|
||||||
after: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PayoutScheduleNoticeProps = {
|
|
||||||
labels: PayoutScheduleNoticeLabels;
|
|
||||||
};
|
|
||||||
|
|
@ -4,31 +4,26 @@ import { TabLinks } from '@lumina/island/molecules/tab-links';
|
||||||
import { usePathname } from 'next/navigation';
|
import { usePathname } from 'next/navigation';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { CREATOR_TABS, INVESTOR_TABS } from './constants';
|
import { INVESTOR_TABS } from './constants';
|
||||||
import type { DashboardTabsProps } from './types';
|
import type { DashboardTabsProps } from './types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The داشبورد's section row, full width, the current one underlined: the investor's «اشتراکها» ·
|
* The investor داشبورد's section row: «اشتراکها» · «تراکنشها» · «دنبالشدهها», full width, the
|
||||||
* «تراکنشها» · «دنبالشدهها» (U8 ۴.۱, ۶.۱; U8 ۵.۲), or the creator's «طرحهای اشتراک» · «مالی»
|
* current section underlined (U8 ۴.۱, ۶.۱; U8 ۵.۲). The dashboard layout renders it once, so it
|
||||||
* (Creator Dashboard ۱.۱). The dashboard layout renders it once, so it stays put while a section
|
* stays put while a section loads; the current one comes from the URL, which the server render
|
||||||
* loads; the current one comes from the URL, which the server render already knows.
|
* already knows.
|
||||||
*/
|
*/
|
||||||
export function DashboardTabs({
|
export function DashboardTabs({ layout }: DashboardTabsProps) {
|
||||||
layout,
|
|
||||||
role = 'investor',
|
|
||||||
}: DashboardTabsProps) {
|
|
||||||
const { t } = useTranslation('dashboard');
|
const { t } = useTranslation('dashboard');
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TabLinks
|
<TabLinks
|
||||||
items={(role === 'creator' ? CREATOR_TABS : INVESTOR_TABS).map(
|
items={INVESTOR_TABS.map(({ href, label }) => ({
|
||||||
({ href, label }) => ({
|
|
||||||
href,
|
href,
|
||||||
label: t(label),
|
label: t(label),
|
||||||
isActive: pathname === href || pathname.startsWith(`${href}/`),
|
isActive: pathname === href || pathname.startsWith(`${href}/`),
|
||||||
}),
|
}))}
|
||||||
)}
|
|
||||||
label={t('tabs.label')}
|
label={t('tabs.label')}
|
||||||
fill
|
fill
|
||||||
band={layout === 'mobile'}
|
band={layout === 'mobile'}
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,3 @@ export const INVESTOR_TABS = [
|
||||||
{ href: ROUTES.dashboard.transactions, label: 'tabs.transactions' },
|
{ href: ROUTES.dashboard.transactions, label: 'tabs.transactions' },
|
||||||
{ href: ROUTES.dashboard.following, label: 'tabs.following' },
|
{ href: ROUTES.dashboard.following, label: 'tabs.following' },
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
/** The creator's two tabs, «طرحهای اشتراک» first (Creator Dashboard ۱.۱). */
|
|
||||||
export const CREATOR_TABS = [
|
|
||||||
{ href: ROUTES.dashboard.plans, label: 'creator-tabs.plans' },
|
|
||||||
{ href: ROUTES.dashboard.finance, label: 'creator-tabs.finance' },
|
|
||||||
] as const;
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
export type DashboardTabsProps = {
|
export type DashboardTabsProps = {
|
||||||
/** mobile: the surface band under the top bar. desktop: in the 640 column, under the heading. */
|
/** mobile: the surface band under the top bar. desktop: in the 640 column, under the heading. */
|
||||||
layout: 'mobile' | 'desktop';
|
layout: 'mobile' | 'desktop';
|
||||||
/** Whose داشبورد: the investor's three sections, or the creator's two tabs. Default investor. */
|
|
||||||
role?: 'investor' | 'creator';
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
||||||
'use client';
|
|
||||||
|
|
||||||
import { Button } from '@lumina/island/atoms/button';
|
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { StatusBadge } from '@lumina/island/atoms/status-badge';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { Banner } from '@lumina/island/molecules/banner';
|
|
||||||
import { Card } from '@lumina/island/molecules/card';
|
|
||||||
import { date } from '@lumina/tools/format';
|
|
||||||
import { useId } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import { usePricingCardPart } from '../../../../../../../features/pricing';
|
|
||||||
import { ROUTES } from '../../../../../../navigation/navigation';
|
|
||||||
import { PlanRow } from './components/PlanRow';
|
|
||||||
import type { PricingCardProps } from './types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* طرحهای اشتراک › «قیمت طرحها» (Creator Dashboard ۲.۱–۲.۵): each offered plan with its total and
|
|
||||||
* per-month equivalent, then «ویرایش قیمتها», which opens C7 as a page. With nothing priced it is
|
|
||||||
* one line and «تعیین قیمتها» (۲.۴); during the 7-day lock the notice sits under the plans and
|
|
||||||
* the button stays live, since promotions stay editable (۲.۳). A creator not yet verified, or
|
|
||||||
* rejected, sees that status above the card (۲.۵); prices stay editable.
|
|
||||||
*/
|
|
||||||
export function PricingCard({ layout }: PricingCardProps) {
|
|
||||||
const { t } = useTranslation(['pricing', 'common']);
|
|
||||||
const model = usePricingCardPart();
|
|
||||||
const headingId = useId();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3">
|
|
||||||
{model.verification !== 'approved' && (
|
|
||||||
<FlexBox>
|
|
||||||
<StatusBadge
|
|
||||||
status={`verification.${model.verification}`}
|
|
||||||
aria-label={t('card.verification', {
|
|
||||||
status: t(`common:status.verification.${model.verification}`),
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
{t(`common:status.verification.${model.verification}`)}
|
|
||||||
</StatusBadge>
|
|
||||||
</FlexBox>
|
|
||||||
)}
|
|
||||||
<Card
|
|
||||||
tag="section"
|
|
||||||
aria-labelledby={headingId}
|
|
||||||
padding={layout === 'desktop' ? 'lg' : 'md'}
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col">
|
|
||||||
<Typography
|
|
||||||
tag="h2"
|
|
||||||
id={headingId}
|
|
||||||
variant="heading-sm"
|
|
||||||
className="mb-1"
|
|
||||||
>
|
|
||||||
{t('card.title')}
|
|
||||||
</Typography>
|
|
||||||
{model.isEmpty ? (
|
|
||||||
<FlexBox direction="flex-col" gap="gap-3" className="pt-1">
|
|
||||||
<Typography variant="body-sm" color="secondary">
|
|
||||||
{t('card.empty')}
|
|
||||||
</Typography>
|
|
||||||
<Button href={ROUTES.dashboard.pricing} variant="primary" block>
|
|
||||||
{t('card.set')}
|
|
||||||
</Button>
|
|
||||||
</FlexBox>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<FlexBox tag="ul" direction="flex-col">
|
|
||||||
{model.plans.map((plan, index) => (
|
|
||||||
<PlanRow
|
|
||||||
key={plan.billingPeriod}
|
|
||||||
plan={plan}
|
|
||||||
divided={index > 0}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</FlexBox>
|
|
||||||
{model.lockedUntil && (
|
|
||||||
<Banner tone="info" icon="lock" className="mt-2">
|
|
||||||
{t('card.locked', {
|
|
||||||
date: date(model.lockedUntil, { time: false }),
|
|
||||||
})}
|
|
||||||
</Banner>
|
|
||||||
)}
|
|
||||||
<FlexBox className="pt-2">
|
|
||||||
<Button
|
|
||||||
href={ROUTES.dashboard.pricing}
|
|
||||||
variant="secondary"
|
|
||||||
icon="edit"
|
|
||||||
block
|
|
||||||
>
|
|
||||||
{t('card.edit')}
|
|
||||||
</Button>
|
|
||||||
</FlexBox>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
</Card>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
|
|
||||||
import { Card } from '@lumina/island/molecules/card';
|
|
||||||
|
|
||||||
import type { PricingCardSkeletonProps } from './types';
|
|
||||||
|
|
||||||
/** «قیمت طرحها» before it arrives, row for row: its title, four plans and the button. */
|
|
||||||
export function PricingCardSkeleton({
|
|
||||||
layout,
|
|
||||||
label,
|
|
||||||
delayed,
|
|
||||||
}: PricingCardSkeletonProps) {
|
|
||||||
return (
|
|
||||||
<SkeletonRegion label={label} delayed={delayed}>
|
|
||||||
<Card padding={layout === 'desktop' ? 'lg' : 'md'}>
|
|
||||||
<FlexBox direction="flex-col">
|
|
||||||
<Skeleton width="35%" className="mb-2" />
|
|
||||||
{[0, 1, 2, 3].map((row) => (
|
|
||||||
<FlexBox
|
|
||||||
key={row}
|
|
||||||
alignItems="items-center"
|
|
||||||
justifyContent="justify-between"
|
|
||||||
className="py-2.5"
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col" gap="gap-1" className="w-1/2">
|
|
||||||
<Skeleton width="40%" />
|
|
||||||
<Skeleton width="80%" />
|
|
||||||
</FlexBox>
|
|
||||||
<Skeleton width="28%" height={24} />
|
|
||||||
</FlexBox>
|
|
||||||
))}
|
|
||||||
<Skeleton shape="pill" height={44} className="mt-2" />
|
|
||||||
</FlexBox>
|
|
||||||
</Card>
|
|
||||||
</SkeletonRegion>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,78 +0,0 @@
|
||||||
import { Amount } from '@lumina/island/atoms/amount';
|
|
||||||
import { Countdown } from '@lumina/island/atoms/countdown';
|
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Tag } from '@lumina/island/atoms/tag';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { cn } from '@lumina/island/tools/cn';
|
|
||||||
import { percent, price } from '@lumina/tools/format';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import { promotionCountdownLabels } from '../../../../../../../../shared/labels';
|
|
||||||
import type { PlanRowProps } from '../types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* One offered plan (Creator Dashboard ۲.۱, ۲.۲): its period and per-month equivalent, the period
|
|
||||||
* total at the end. A running promotion adds the red «تخفیف n٪» tag and its countdown, and shows
|
|
||||||
* the struck standing total over the promotional one.
|
|
||||||
*/
|
|
||||||
export function PlanRow({ plan, divided }: PlanRowProps) {
|
|
||||||
const { t } = useTranslation(['pricing', 'common']);
|
|
||||||
const { t: tPayment } = useTranslation('payment');
|
|
||||||
const promo = plan.promotion;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FlexBox
|
|
||||||
tag="li"
|
|
||||||
alignItems="items-center"
|
|
||||||
justifyContent="justify-between"
|
|
||||||
gap="gap-3"
|
|
||||||
className={cn('py-2.5', divided && 'border-t border-border-subtle')}
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col" className="min-w-0 gap-0.5">
|
|
||||||
<FlexBox alignItems="items-center" gap="gap-2" wrap="flex-wrap">
|
|
||||||
<Typography tag="span" className="font-semibold">
|
|
||||||
{t(`common:billing-periods.${plan.billingPeriod}`)}
|
|
||||||
</Typography>
|
|
||||||
{promo && (
|
|
||||||
<Tag variant="discount" icon={null}>
|
|
||||||
{t('card.discount', { percent: percent(promo.percent, 0) })}
|
|
||||||
</Tag>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
<Typography tag="span" variant="caption" color="secondary">
|
|
||||||
{t('card.per-month', {
|
|
||||||
amount: price(promo ? promo.perMonthToman : plan.perMonthToman),
|
|
||||||
})}
|
|
||||||
</Typography>
|
|
||||||
{promo?.endsAt && (
|
|
||||||
<Typography tag="span" variant="caption">
|
|
||||||
<Countdown
|
|
||||||
kind="promotion"
|
|
||||||
endsAt={promo.endsAt}
|
|
||||||
labels={promotionCountdownLabels(tPayment)}
|
|
||||||
/>
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
<FlexBox
|
|
||||||
direction="flex-col"
|
|
||||||
alignItems="items-end"
|
|
||||||
className="flex-none gap-0.5"
|
|
||||||
>
|
|
||||||
{promo && (
|
|
||||||
<Amount
|
|
||||||
value={plan.priceToman}
|
|
||||||
size="caption"
|
|
||||||
struck
|
|
||||||
srLabel={t('card.struck')}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<Amount
|
|
||||||
value={promo ? promo.priceToman : plan.priceToman}
|
|
||||||
size="title"
|
|
||||||
currency={t('common:currency')}
|
|
||||||
/>
|
|
||||||
</FlexBox>
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export { PricingCard } from './PricingCard';
|
|
||||||
export { PricingCardSkeleton } from './PricingCardSkeleton';
|
|
||||||
export type { PricingCardProps, PricingCardSkeletonProps } from './types';
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
import type { PricingPlanRow } from '../../../../../../../features/pricing';
|
|
||||||
|
|
||||||
export type PricingCardProps = {
|
|
||||||
/** mobile: card padding md. desktop: lg, in the 640 column. */
|
|
||||||
layout: 'mobile' | 'desktop';
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PlanRowProps = {
|
|
||||||
plan: PricingPlanRow;
|
|
||||||
/** Every row after the first has a hairline above it. */
|
|
||||||
divided: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PricingCardSkeletonProps = PricingCardProps & {
|
|
||||||
/** Hidden status text: «در حال بارگذاری قیمت طرحها…». */
|
|
||||||
label: string;
|
|
||||||
/** Fades in after 300ms, so a fast route never flashes grey. loading.tsx only. */
|
|
||||||
delayed?: boolean;
|
|
||||||
};
|
|
||||||
|
|
@ -1,140 +0,0 @@
|
||||||
'use client';
|
|
||||||
|
|
||||||
import { Button } from '@lumina/island/atoms/button';
|
|
||||||
import { Element } from '@lumina/island/primitives/element';
|
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Separator } from '@lumina/island/atoms/separator';
|
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
|
||||||
import { Card } from '@lumina/island/molecules/card';
|
|
||||||
import { EmptyState } from '@lumina/island/molecules/empty-state';
|
|
||||||
import { ErrorState } from '@lumina/island/molecules/error-state';
|
|
||||||
import { cn } from '@lumina/island/tools/cn';
|
|
||||||
import { date, number } from '@lumina/tools/format';
|
|
||||||
import { useId } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import { useSubscribersPart } from '../../../../../../../features/overview';
|
|
||||||
import type { SubscriberListProps } from './types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* طرحهای اشتراک › مشترکان (Creator Dashboard ۲.۱): the active count in the header, then each
|
|
||||||
* running subscription by @username only, with its plan, start and end; newest start first, 20 at
|
|
||||||
* a time. Rows aren't tappable, and there is no filter, search or action, until Epic 6. With none,
|
|
||||||
* one quiet line (۲.۴).
|
|
||||||
*/
|
|
||||||
export function SubscriberList({ layout }: SubscriberListProps) {
|
|
||||||
const { t } = useTranslation(['dashboard', 'common', 'errors']);
|
|
||||||
const model = useSubscribersPart();
|
|
||||||
const headingId = useId();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
tag="section"
|
|
||||||
aria-labelledby={headingId}
|
|
||||||
padding={layout === 'desktop' ? 'lg' : 'md'}
|
|
||||||
>
|
|
||||||
<FlexBox direction="flex-col">
|
|
||||||
<FlexBox
|
|
||||||
alignItems="items-baseline"
|
|
||||||
justifyContent="justify-between"
|
|
||||||
gap="gap-3"
|
|
||||||
className="pb-0.5"
|
|
||||||
>
|
|
||||||
<Typography tag="h2" id={headingId} variant="heading-sm">
|
|
||||||
{t('subscribers.title')}
|
|
||||||
</Typography>
|
|
||||||
<Typography tag="span" variant="caption" color="secondary">
|
|
||||||
{t('subscribers.active')}{' '}
|
|
||||||
<Typography
|
|
||||||
tag="span"
|
|
||||||
variant="body-lg"
|
|
||||||
className="font-semibold tabular-nums"
|
|
||||||
>
|
|
||||||
{number(model.activeCount)}
|
|
||||||
</Typography>
|
|
||||||
</Typography>
|
|
||||||
</FlexBox>
|
|
||||||
{model.rows.length === 0 ? (
|
|
||||||
<EmptyState
|
|
||||||
title={t('subscribers.empty')}
|
|
||||||
icon="users"
|
|
||||||
size="inline"
|
|
||||||
className="pt-2"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<FlexBox tag="ul" direction="flex-col">
|
|
||||||
{model.rows.map((row, index) => (
|
|
||||||
<FlexBox
|
|
||||||
key={row.id}
|
|
||||||
tag="li"
|
|
||||||
direction="flex-col"
|
|
||||||
className={cn(
|
|
||||||
'gap-0.5 py-2.5',
|
|
||||||
index > 0 && 'border-t border-border-subtle',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<FlexBox
|
|
||||||
alignItems="items-center"
|
|
||||||
justifyContent="justify-between"
|
|
||||||
gap="gap-3"
|
|
||||||
>
|
|
||||||
<Element
|
|
||||||
tag="bdi"
|
|
||||||
dir="ltr"
|
|
||||||
className="truncate font-semibold"
|
|
||||||
>
|
|
||||||
@{row.username ?? '—'}
|
|
||||||
</Element>
|
|
||||||
{row.billingPeriod && (
|
|
||||||
<Typography
|
|
||||||
tag="span"
|
|
||||||
variant="body-sm"
|
|
||||||
className="flex-none"
|
|
||||||
>
|
|
||||||
{t(`common:billing-periods.${row.billingPeriod}`)}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
<Typography variant="caption" color="secondary">
|
|
||||||
{row.startsAt &&
|
|
||||||
t('subscribers.start', {
|
|
||||||
date: date(row.startsAt, { time: false }),
|
|
||||||
})}
|
|
||||||
{row.startsAt && row.endsAt && <Separator />}
|
|
||||||
{row.endsAt &&
|
|
||||||
t('subscribers.end', {
|
|
||||||
date: date(row.endsAt, { time: false }),
|
|
||||||
})}
|
|
||||||
</Typography>
|
|
||||||
</FlexBox>
|
|
||||||
))}
|
|
||||||
</FlexBox>
|
|
||||||
)}
|
|
||||||
{model.loadMoreError ? (
|
|
||||||
<ErrorState
|
|
||||||
kind={model.loadMoreError}
|
|
||||||
size="inline"
|
|
||||||
title={t(`errors:fallback.${model.loadMoreError}.title`)}
|
|
||||||
description={t('subscribers.more-failed')}
|
|
||||||
onRetry={model.loadMore}
|
|
||||||
retryLabel={t('errors:fallback.retry')}
|
|
||||||
retryingLabel={t('errors:fallback.retrying')}
|
|
||||||
retrying={model.isLoadingMore}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
model.hasMore && (
|
|
||||||
<Button
|
|
||||||
variant="secondary"
|
|
||||||
block
|
|
||||||
onClick={model.loadMore}
|
|
||||||
isLoading={model.isLoadingMore}
|
|
||||||
className="mt-2"
|
|
||||||
>
|
|
||||||
{t('subscribers.more')}
|
|
||||||
</Button>
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
</FlexBox>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
|
||||||
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
|
|
||||||
import { Card } from '@lumina/island/molecules/card';
|
|
||||||
|
|
||||||
import type { SubscriberListSkeletonProps } from './types';
|
|
||||||
|
|
||||||
/** مشترکان before it arrives: its header and three rows of two lines. */
|
|
||||||
export function SubscriberListSkeleton({
|
|
||||||
layout,
|
|
||||||
label,
|
|
||||||
delayed,
|
|
||||||
}: SubscriberListSkeletonProps) {
|
|
||||||
return (
|
|
||||||
<SkeletonRegion label={label} delayed={delayed}>
|
|
||||||
<Card padding={layout === 'desktop' ? 'lg' : 'md'}>
|
|
||||||
<FlexBox direction="flex-col">
|
|
||||||
<FlexBox justifyContent="justify-between" className="pb-1">
|
|
||||||
<Skeleton width="25%" />
|
|
||||||
<Skeleton width="30%" />
|
|
||||||
</FlexBox>
|
|
||||||
{[0, 1, 2].map((row) => (
|
|
||||||
<FlexBox
|
|
||||||
key={row}
|
|
||||||
direction="flex-col"
|
|
||||||
gap="gap-2"
|
|
||||||
className="py-3"
|
|
||||||
>
|
|
||||||
<FlexBox justifyContent="justify-between">
|
|
||||||
<Skeleton width="35%" />
|
|
||||||
<Skeleton width="18%" />
|
|
||||||
</FlexBox>
|
|
||||||
<Skeleton width="60%" />
|
|
||||||
</FlexBox>
|
|
||||||
))}
|
|
||||||
</FlexBox>
|
|
||||||
</Card>
|
|
||||||
</SkeletonRegion>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export { SubscriberList } from './SubscriberList';
|
|
||||||
export { SubscriberListSkeleton } from './SubscriberListSkeleton';
|
|
||||||
export type { SubscriberListProps, SubscriberListSkeletonProps } from './types';
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
export type SubscriberListProps = {
|
|
||||||
layout: 'mobile' | 'desktop';
|
|
||||||
};
|
|
||||||
|
|
||||||
export type SubscriberListSkeletonProps = SubscriberListProps & {
|
|
||||||
/** Hidden status text: «در حال بارگذاری مشترکان…». */
|
|
||||||
label: string;
|
|
||||||
/** Fades in after 300ms, so a fast route never flashes grey. loading.tsx only. */
|
|
||||||
delayed?: boolean;
|
|
||||||
};
|
|
||||||
|
|
@ -24,11 +24,6 @@ export const NOTIFICATION_ART: Record<
|
||||||
access_restored: { icon: 'check', tone: 'brand' },
|
access_restored: { icon: 'check', tone: 'brand' },
|
||||||
account_suspended: { icon: 'ban', tone: 'warning' },
|
account_suspended: { icon: 'ban', tone: 'warning' },
|
||||||
account_reinstated: { icon: 'check', tone: 'brand' },
|
account_reinstated: { icon: 'check', tone: 'brand' },
|
||||||
payout_account_changed: { icon: 'shield-check', tone: 'warning' },
|
|
||||||
payout_created: { icon: 'wallet', tone: 'brand' },
|
|
||||||
payout_cancelled: { icon: 'x-circle', tone: 'warning' },
|
|
||||||
refund_deducted: { icon: 'receipt', tone: 'neutral' },
|
|
||||||
ledger_correction: { icon: 'edit', tone: 'neutral' },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A type this front end doesn't know yet (a newer service, an old row): a plain bell. */
|
/** A type this front end doesn't know yet (a newer service, an old row): a plain bell. */
|
||||||
|
|
@ -54,11 +49,6 @@ export const NOTIFICATION_CTA_TYPES = [
|
||||||
'payment_pending_review',
|
'payment_pending_review',
|
||||||
'creator_suspended',
|
'creator_suspended',
|
||||||
'access_restored',
|
'access_restored',
|
||||||
'payout_account_changed',
|
|
||||||
'payout_created',
|
|
||||||
'payout_cancelled',
|
|
||||||
'refund_deducted',
|
|
||||||
'ledger_correction',
|
|
||||||
] as const satisfies readonly NotificationType[];
|
] as const satisfies readonly NotificationType[];
|
||||||
|
|
||||||
/** Types whose call to action is support itself, opened in place (U5 ۳.۱, ۳.۲). */
|
/** Types whose call to action is support itself, opened in place (U5 ۳.۱, ۳.۲). */
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
import { eventEmitter } from '@lumina/libs/event-emitter';
|
|
||||||
|
|
||||||
import { FINANCE_EVENTS } from '../../constants';
|
|
||||||
import { payoutAccountRepository } from '../../repositories/payout-account';
|
|
||||||
import type {
|
|
||||||
PayoutAccountPayload,
|
|
||||||
SavePayoutAccountArgs,
|
|
||||||
} from '../../repositories/payout-account';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers or changes the creator's شبا after the read-back (C19 §۷). The API tells the creator
|
|
||||||
* by SMS and in-app when the number changed. Emits `finance.payout-account-saved`.
|
|
||||||
*/
|
|
||||||
export async function savePayoutAccount(
|
|
||||||
args: SavePayoutAccountArgs,
|
|
||||||
{ emit = true }: { emit?: boolean } = {},
|
|
||||||
): Promise<PayoutAccountPayload> {
|
|
||||||
const saved = await payoutAccountRepository.save(args);
|
|
||||||
if (emit) eventEmitter.emit(FINANCE_EVENTS.payoutAccountSaved, {});
|
|
||||||
return saved;
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export { savePayoutAccount } from './actions';
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
/** Events finance actions emit when they succeed. */
|
|
||||||
export const FINANCE_EVENTS = {
|
|
||||||
/** The شبا was registered or changed (C19). */
|
|
||||||
payoutAccountSaved: 'finance.payout-account-saved',
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
/** The شبا block's element id: the next-payout line links to it when no شبا is registered. */
|
|
||||||
export const PAYOUT_ACCOUNT_ANCHOR = 'payout-account';
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
export type {
|
|
||||||
LedgerItemEntity,
|
|
||||||
NextPayoutState,
|
|
||||||
PayoutAccountEntity,
|
|
||||||
PayoutAccountState,
|
|
||||||
PayoutStatus,
|
|
||||||
} from './types';
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
import type { BillingPeriod } from '../../../../shared/constants';
|
|
||||||
|
|
||||||
/** C19's lock: verified and not suspended may register or change the شبا. */
|
|
||||||
export type PayoutAccountState = 'open' | 'unverified' | 'suspended';
|
|
||||||
|
|
||||||
/** `EarningsService.toAccount`: the 24 digits after `IR` and when they were last saved. */
|
|
||||||
export type PayoutAccountEntity = { iban: string; savedAt: string };
|
|
||||||
|
|
||||||
/** What the next-payout line says (Appendix B §3). */
|
|
||||||
export type NextPayoutState =
|
|
||||||
| 'scheduled'
|
|
||||||
| 'no_account'
|
|
||||||
| 'nothing'
|
|
||||||
| 'hidden'
|
|
||||||
| 'suspended';
|
|
||||||
|
|
||||||
/** Appendix B §6.5: در حال انجام, انجام شده, لغو شده. */
|
|
||||||
export type PayoutStatus = 'in_progress' | 'completed' | 'cancelled';
|
|
||||||
|
|
||||||
type LedgerItemBase = {
|
|
||||||
id: string;
|
|
||||||
/** Signed whole Toman: + adds to the balance, − takes from it. */
|
|
||||||
amountToman: number;
|
|
||||||
occurredAt: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** `EarningsService.toEntryItem` and `toPayoutItem`: one row of گردش حساب. */
|
|
||||||
export type LedgerItemEntity =
|
|
||||||
| (LedgerItemBase & {
|
|
||||||
kind: 'income';
|
|
||||||
income: {
|
|
||||||
subscriberUsername: string | null;
|
|
||||||
billingPeriod: BillingPeriod | null;
|
|
||||||
planPriceToman: number;
|
|
||||||
discountPercent: number | null;
|
|
||||||
paidToman: number;
|
|
||||||
commissionPercent: number;
|
|
||||||
commissionToman: number;
|
|
||||||
shareToman: number;
|
|
||||||
};
|
|
||||||
})
|
|
||||||
| (LedgerItemBase & {
|
|
||||||
kind: 'refund_deduction';
|
|
||||||
refund: {
|
|
||||||
subscriberUsername: string | null;
|
|
||||||
billingPeriod: BillingPeriod | null;
|
|
||||||
originalPaidAt: string | null;
|
|
||||||
refundedToman: number;
|
|
||||||
deductedToman: number;
|
|
||||||
};
|
|
||||||
})
|
|
||||||
| (LedgerItemBase & { kind: 'correction'; correction: { reason: string } })
|
|
||||||
| (LedgerItemBase & {
|
|
||||||
kind: 'payout';
|
|
||||||
payout: {
|
|
||||||
status: PayoutStatus;
|
|
||||||
ibanCheckDigits: string;
|
|
||||||
ibanTail: string;
|
|
||||||
completedAt: string | null;
|
|
||||||
cancelledAt: string | null;
|
|
||||||
cancelReason: string | null;
|
|
||||||
hasReceipt: boolean;
|
|
||||||
receiptMimeType: string | null;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue