feat(pricing): show the price floor in the editor, plans tab and admin settings
The editor reads the floor from the API, on the final price after any discount, with the spec's hints and errors, and a tier the floor took off sale stays editable through the 7-day lock. The plans tab marks those tiers and links to the fix. Checkout, renew and reactivate handle 409 tier_unavailable. The admin panel gets «تنظیمات» with «کف قیمت اشتراک»: a dry-run preview on a raise and a confirm with an audited reason. Removes the stale esbuild key from the Vitest config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
cac4f8e229
commit
e1ad6056fc
|
|
@ -2,6 +2,9 @@
|
||||||
"name": "@lumina/wall-street-plaza",
|
"name": "@lumina/wall-street-plaza",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"test": "vitest run --config ../../vitest.config.ts"
|
||||||
|
},
|
||||||
"nx": {
|
"nx": {
|
||||||
"name": "wall-street-plaza",
|
"name": "wall-street-plaza",
|
||||||
"sourceRoot": "apps/wall-street-plaza/src",
|
"sourceRoot": "apps/wall-street-plaza/src",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { PageHeader } from '@lumina/island/molecules/page-header';
|
||||||
|
|
||||||
|
import { i18n } from '../../../i18n';
|
||||||
|
import { PriceFloorSkeleton } from './organisms/price-floor-card';
|
||||||
|
|
||||||
|
/** The card before it arrives: the title and subtitle over the skeleton. */
|
||||||
|
export default function Loading() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<PageHeader
|
||||||
|
title={i18n.t('settings:page.title')}
|
||||||
|
subtitle={i18n.t('settings:page.subtitle')}
|
||||||
|
/>
|
||||||
|
<PriceFloorSkeleton label={i18n.t('settings:page.loading')} delayed />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { usePriceFloorPage } from '@lumina/garden-roof';
|
||||||
|
|
||||||
|
import { PriceFloorForm } from './components/PriceFloorForm';
|
||||||
|
|
||||||
|
/** «کف قیمت اشتراک» (J11-11), its model read here so the form renders from props. */
|
||||||
|
export function PriceFloorCard() {
|
||||||
|
return <PriceFloorForm model={usePriceFloorPage()} />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { ReasonDialog } from '@lumina/garden-roof/app/screens';
|
||||||
|
import { Banner } from '@lumina/island/molecules/banner';
|
||||||
|
import { number, price } from '@lumina/tools/format';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import type { PriceFloorPartProps } from '../types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* «تغییر کف قیمت به {x} تومان» (J11-11): the required reason, 10 characters at least, goes to «گزارش
|
||||||
|
* ممیزی», with the raise's warning repeated above it.
|
||||||
|
*/
|
||||||
|
export function ConfirmPriceFloorDialog({ model }: PriceFloorPartProps) {
|
||||||
|
const { t } = useTranslation('settings');
|
||||||
|
const affected =
|
||||||
|
model.preview.status === 'ready' ? model.preview.change : null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ReasonDialog
|
||||||
|
open={model.isConfirming}
|
||||||
|
onClose={model.closeConfirm}
|
||||||
|
title={t('price-floor.confirm.title', {
|
||||||
|
amount: price(model.valueToman),
|
||||||
|
})}
|
||||||
|
placeholder={t('price-floor.confirm.placeholder')}
|
||||||
|
emptyReason={t('price-floor.confirm.empty')}
|
||||||
|
form={model.reasonForm}
|
||||||
|
onSubmit={model.confirm}
|
||||||
|
isSubmitting={model.isSaving}
|
||||||
|
confirmLabel={t('price-floor.confirm.submit')}
|
||||||
|
confirmVariant="primary"
|
||||||
|
>
|
||||||
|
{affected && affected.affectedTiers.length > 0 && (
|
||||||
|
<Banner tone="warning" icon="alert">
|
||||||
|
{t('price-floor.preview.warning', {
|
||||||
|
tiers: number(affected.affectedTiers.length),
|
||||||
|
analysts: number(affected.analystCount),
|
||||||
|
})}
|
||||||
|
</Banner>
|
||||||
|
)}
|
||||||
|
</ReasonDialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,176 @@
|
||||||
|
import type { PriceFloorPageModel } from '@lumina/garden-roof';
|
||||||
|
import { useReasonForm } from '@lumina/garden-roof/shared/utils';
|
||||||
|
import { render, screen, waitFor, within } from '@testing-library/react';
|
||||||
|
import userEvent from '@testing-library/user-event';
|
||||||
|
import { describe, expect, it, vi } from 'vitest';
|
||||||
|
|
||||||
|
import '../../../../../../i18n/i18n.client';
|
||||||
|
import { PriceFloorForm } from './PriceFloorForm';
|
||||||
|
|
||||||
|
const change = {
|
||||||
|
monthlyMin: 250000,
|
||||||
|
analystCount: 1,
|
||||||
|
affectedTiers: [
|
||||||
|
{
|
||||||
|
tierId: 't1',
|
||||||
|
traderId: 'u1',
|
||||||
|
username: 'reza',
|
||||||
|
billingPeriod: 'monthly' as const,
|
||||||
|
labelFa: 'ماهانه',
|
||||||
|
finalMonthlyToman: 200000,
|
||||||
|
activeSubscribers: 4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tierId: 't2',
|
||||||
|
traderId: 'u1',
|
||||||
|
username: null,
|
||||||
|
billingPeriod: 'yearly' as const,
|
||||||
|
labelFa: 'سالانه',
|
||||||
|
finalMonthlyToman: 210000,
|
||||||
|
activeSubscribers: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
function Harness(props: Partial<PriceFloorPageModel>) {
|
||||||
|
const reasonForm = useReasonForm();
|
||||||
|
const model: PriceFloorPageModel = {
|
||||||
|
currentToman: 199000,
|
||||||
|
changedAt: null,
|
||||||
|
text: '250٬000',
|
||||||
|
setText: vi.fn(),
|
||||||
|
error: null,
|
||||||
|
valueToman: 250000,
|
||||||
|
change: 'raise',
|
||||||
|
preview: { status: 'ready', change },
|
||||||
|
blockedReason: null,
|
||||||
|
isConfirming: false,
|
||||||
|
openConfirm: vi.fn(),
|
||||||
|
closeConfirm: vi.fn(),
|
||||||
|
reasonForm,
|
||||||
|
confirm: vi.fn(),
|
||||||
|
isSaving: false,
|
||||||
|
...props,
|
||||||
|
};
|
||||||
|
return <PriceFloorForm model={model} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('PriceFloorForm', () => {
|
||||||
|
it('shows the current value in the hint, and its last change once there is one', () => {
|
||||||
|
const { rerender } = render(<Harness />);
|
||||||
|
expect(screen.getByText(/هنوز تغییری ثبت نشده است/)).toBeTruthy();
|
||||||
|
rerender(<Harness changedAt="2026-10-23T08:00:00.000Z" />);
|
||||||
|
expect(screen.getByText(/آخرین تغییر:/)).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('a raise warns with how many plans and analysts, and lists each', () => {
|
||||||
|
render(<Harness />);
|
||||||
|
expect(
|
||||||
|
screen.getByText('2 طرح از 1 تحلیلگر زیر کف جدید میمانند.'),
|
||||||
|
).toBeTruthy();
|
||||||
|
const table = screen.getByRole('table');
|
||||||
|
expect(within(table).getByText('@reza')).toBeTruthy();
|
||||||
|
expect(within(table).getByText('ماهانه')).toBeTruthy();
|
||||||
|
expect(within(table).getByText('200٬000')).toBeTruthy();
|
||||||
|
expect(within(table).getByText('4')).toBeTruthy();
|
||||||
|
expect(within(table).getByText('حساب نامشخص')).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('a raise that takes nothing says so, with no table', () => {
|
||||||
|
render(
|
||||||
|
<Harness
|
||||||
|
preview={{
|
||||||
|
status: 'ready',
|
||||||
|
change: { monthlyMin: 250000, analystCount: 0, affectedTiers: [] },
|
||||||
|
}}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
expect(screen.getByText('هیچ طرحی زیر کف جدید نمیماند.')).toBeTruthy();
|
||||||
|
expect(screen.queryByRole('table')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('a lower floor says it changes nothing yet, with no preview', () => {
|
||||||
|
render(<Harness change="lower" preview={{ status: 'idle' }} />);
|
||||||
|
expect(screen.getByText(/چیزی تغییر نمیکند/)).toBeTruthy();
|
||||||
|
expect(screen.queryByRole('table')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('a failed preview offers to try again', async () => {
|
||||||
|
const retry = vi.fn();
|
||||||
|
render(<Harness preview={{ status: 'error', retry }} />);
|
||||||
|
await userEvent.click(screen.getByRole('button', { name: 'تلاش دوباره' }));
|
||||||
|
expect(retry).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('«ذخیره» waits and says why while blocked', async () => {
|
||||||
|
const openConfirm = vi.fn();
|
||||||
|
render(
|
||||||
|
<Harness
|
||||||
|
openConfirm={openConfirm}
|
||||||
|
blockedReason="settings:price-floor.blocked.preview"
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
const save = screen.getByText('ذخیره').closest('button')!;
|
||||||
|
expect(save.classList.contains('frozen')).toBe(true);
|
||||||
|
await userEvent.click(save);
|
||||||
|
expect(openConfirm).not.toHaveBeenCalled();
|
||||||
|
expect(
|
||||||
|
screen.getByText(
|
||||||
|
'پیش از ذخیره باید پیشنمایش طرحهای زیر کف آماده باشد.',
|
||||||
|
),
|
||||||
|
).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('«ذخیره» opens the confirmation', async () => {
|
||||||
|
const openConfirm = vi.fn();
|
||||||
|
render(<Harness openConfirm={openConfirm} />);
|
||||||
|
await userEvent.click(screen.getByRole('button', { name: 'ذخیره' }));
|
||||||
|
expect(openConfirm).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('ConfirmPriceFloorDialog', () => {
|
||||||
|
const dialog = () => screen.getByRole('dialog', { hidden: true });
|
||||||
|
|
||||||
|
it('names the new floor and asks a reason before saving', async () => {
|
||||||
|
const confirm = vi.fn();
|
||||||
|
render(<Harness isConfirming confirm={confirm} />);
|
||||||
|
expect(
|
||||||
|
within(dialog()).getByText('تغییر کف قیمت به 250٬000 تومان'),
|
||||||
|
).toBeTruthy();
|
||||||
|
const submit = within(dialog())
|
||||||
|
.getByText('ذخیره و اطلاعرسانی')
|
||||||
|
.closest('button')!;
|
||||||
|
expect(submit.classList.contains('frozen')).toBe(true);
|
||||||
|
await userEvent.click(submit);
|
||||||
|
expect(confirm).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('refuses a reason under 10 characters', async () => {
|
||||||
|
const confirm = vi.fn();
|
||||||
|
render(<Harness isConfirming confirm={confirm} />);
|
||||||
|
await userEvent.type(
|
||||||
|
within(dialog()).getByRole('textbox', { hidden: true }),
|
||||||
|
'کوتاه',
|
||||||
|
);
|
||||||
|
await userEvent.click(
|
||||||
|
within(dialog()).getByText('ذخیره و اطلاعرسانی').closest('button')!,
|
||||||
|
);
|
||||||
|
await waitFor(() => expect(confirm).not.toHaveBeenCalled());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('saves with the trimmed reason', async () => {
|
||||||
|
const confirm = vi.fn();
|
||||||
|
render(<Harness isConfirming confirm={confirm} />);
|
||||||
|
await userEvent.type(
|
||||||
|
within(dialog()).getByRole('textbox', { hidden: true }),
|
||||||
|
' افزایش کف قیمت پس از بازبینی. ',
|
||||||
|
);
|
||||||
|
await userEvent.click(
|
||||||
|
within(dialog()).getByText('ذخیره و اطلاعرسانی').closest('button')!,
|
||||||
|
);
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(confirm).toHaveBeenCalledWith('افزایش کف قیمت پس از بازبینی.'),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { translateMessage } from '@lumina/garden-roof/shared/utils';
|
||||||
|
import { Button } from '@lumina/island/atoms/button';
|
||||||
|
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||||
|
import { Typography } from '@lumina/island/atoms/typography';
|
||||||
|
import { Banner } from '@lumina/island/molecules/banner';
|
||||||
|
import { Card } from '@lumina/island/molecules/card';
|
||||||
|
import { TextInput } from '@lumina/island/molecules/text-input';
|
||||||
|
import { date, price } from '@lumina/tools/format';
|
||||||
|
import { useId } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import type { PriceFloorPartProps } from '../types';
|
||||||
|
import { ConfirmPriceFloorDialog } from './ConfirmPriceFloorDialog';
|
||||||
|
import { PriceFloorPreview } from './PriceFloorPreview';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The card (J11-11): «کف ماهانه» with the current value and its last change as the hint, then what
|
||||||
|
* the typed value does: a raise previews the tiers it takes off sale, a lower floor says it changes
|
||||||
|
* nothing yet. «ذخیره» opens the confirmation once that is known, and says why it waits until then.
|
||||||
|
*/
|
||||||
|
export function PriceFloorForm({ model }: PriceFloorPartProps) {
|
||||||
|
const { t } = useTranslation('settings');
|
||||||
|
const headingId = useId();
|
||||||
|
const current = price(model.currentToman);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Card tag="section" aria-labelledby={headingId} padding="lg">
|
||||||
|
<FlexBox direction="flex-col" gap="gap-4">
|
||||||
|
<FlexBox direction="flex-col" gap="gap-1">
|
||||||
|
<Typography tag="h2" id={headingId} variant="heading-sm">
|
||||||
|
{t('price-floor.title')}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body-sm" color="secondary">
|
||||||
|
{t('price-floor.description')}
|
||||||
|
</Typography>
|
||||||
|
</FlexBox>
|
||||||
|
<TextInput
|
||||||
|
label={t('price-floor.field')}
|
||||||
|
inputMode="numeric"
|
||||||
|
suffix={t('price-floor.currency')}
|
||||||
|
value={model.text}
|
||||||
|
onChange={(event) => model.setText(event.target.value)}
|
||||||
|
error={translateMessage(t, model.error ?? undefined)}
|
||||||
|
hint={
|
||||||
|
model.changedAt
|
||||||
|
? t('price-floor.hint', {
|
||||||
|
current,
|
||||||
|
date: date(model.changedAt, { time: false }),
|
||||||
|
})
|
||||||
|
: t('price-floor.hint-never', { current })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{model.change === 'lower' && (
|
||||||
|
<Banner tone="info" icon="info">
|
||||||
|
{t('price-floor.lower-note')}
|
||||||
|
</Banner>
|
||||||
|
)}
|
||||||
|
<PriceFloorPreview preview={model.preview} />
|
||||||
|
<FlexBox>
|
||||||
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
frozen={model.blockedReason !== null}
|
||||||
|
frozenReason={translateMessage(
|
||||||
|
t,
|
||||||
|
model.blockedReason ?? undefined,
|
||||||
|
)}
|
||||||
|
onClick={model.openConfirm}
|
||||||
|
>
|
||||||
|
{t('price-floor.save')}
|
||||||
|
</Button>
|
||||||
|
</FlexBox>
|
||||||
|
</FlexBox>
|
||||||
|
</Card>
|
||||||
|
<ConfirmPriceFloorDialog model={model} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import type { PriceFloorPreview as PriceFloorPreviewModel } from '@lumina/garden-roof';
|
||||||
|
import { Button } from '@lumina/island/atoms/button';
|
||||||
|
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||||
|
import { Spinner } from '@lumina/island/atoms/spinner';
|
||||||
|
import { Typography } from '@lumina/island/atoms/typography';
|
||||||
|
import { Banner } from '@lumina/island/molecules/banner';
|
||||||
|
import { DataTable } from '@lumina/island/organisms/data-table';
|
||||||
|
import { Element } from '@lumina/island/primitives/element';
|
||||||
|
import { number, price } from '@lumina/tools/format';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What a raise takes off sale (J11-11): the warning with how many plans of how many analysts, and
|
||||||
|
* each plan's analyst, final monthly price and active subscribers. It scrolls sideways on a narrow
|
||||||
|
* column. Nothing while the floor isn't being raised.
|
||||||
|
*/
|
||||||
|
export function PriceFloorPreview({
|
||||||
|
preview,
|
||||||
|
}: {
|
||||||
|
preview: PriceFloorPreviewModel;
|
||||||
|
}) {
|
||||||
|
const { t } = useTranslation('settings');
|
||||||
|
|
||||||
|
if (preview.status === 'idle') return null;
|
||||||
|
if (preview.status === 'loading') {
|
||||||
|
return (
|
||||||
|
<FlexBox tag="output" alignItems="items-center" gap="gap-2">
|
||||||
|
<Spinner />
|
||||||
|
<Typography variant="body-sm" color="secondary">
|
||||||
|
{t('price-floor.preview.loading')}
|
||||||
|
</Typography>
|
||||||
|
</FlexBox>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (preview.status === 'error') {
|
||||||
|
return (
|
||||||
|
<Banner
|
||||||
|
tone="danger"
|
||||||
|
action={
|
||||||
|
<Button variant="secondary" size="sm" onClick={preview.retry}>
|
||||||
|
{t('price-floor.preview.retry')}
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{t('price-floor.preview.error')}
|
||||||
|
</Banner>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { affectedTiers, analystCount } = preview.change;
|
||||||
|
if (affectedTiers.length === 0) {
|
||||||
|
return (
|
||||||
|
<Banner tone="info" icon="check">
|
||||||
|
{t('price-floor.preview.none')}
|
||||||
|
</Banner>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<FlexBox direction="flex-col" gap="gap-3">
|
||||||
|
<Banner tone="warning" icon="alert">
|
||||||
|
{t('price-floor.preview.warning', {
|
||||||
|
tiers: number(affectedTiers.length),
|
||||||
|
analysts: number(analystCount),
|
||||||
|
})}
|
||||||
|
</Banner>
|
||||||
|
<Element className="overflow-x-auto">
|
||||||
|
<DataTable label={t('price-floor.preview.table')}>
|
||||||
|
<DataTable.Head>
|
||||||
|
<DataTable.HeaderCell>
|
||||||
|
{t('price-floor.preview.columns.analyst')}
|
||||||
|
</DataTable.HeaderCell>
|
||||||
|
<DataTable.HeaderCell>
|
||||||
|
{t('price-floor.preview.columns.plan')}
|
||||||
|
</DataTable.HeaderCell>
|
||||||
|
<DataTable.HeaderCell>
|
||||||
|
{t('price-floor.preview.columns.price')}
|
||||||
|
</DataTable.HeaderCell>
|
||||||
|
<DataTable.HeaderCell>
|
||||||
|
{t('price-floor.preview.columns.subscribers')}
|
||||||
|
</DataTable.HeaderCell>
|
||||||
|
</DataTable.Head>
|
||||||
|
<DataTable.Body>
|
||||||
|
{affectedTiers.map((tier) => (
|
||||||
|
<DataTable.Row key={tier.tierId}>
|
||||||
|
<DataTable.Cell>
|
||||||
|
{tier.username ? (
|
||||||
|
<Element tag="bdi" dir="ltr">
|
||||||
|
@{tier.username}
|
||||||
|
</Element>
|
||||||
|
) : (
|
||||||
|
t('price-floor.preview.unknown')
|
||||||
|
)}
|
||||||
|
</DataTable.Cell>
|
||||||
|
<DataTable.Cell>{tier.labelFa}</DataTable.Cell>
|
||||||
|
<DataTable.Cell>{price(tier.finalMonthlyToman)}</DataTable.Cell>
|
||||||
|
<DataTable.Cell>
|
||||||
|
{number(tier.activeSubscribers)}
|
||||||
|
</DataTable.Cell>
|
||||||
|
</DataTable.Row>
|
||||||
|
))}
|
||||||
|
</DataTable.Body>
|
||||||
|
</DataTable>
|
||||||
|
</Element>
|
||||||
|
</FlexBox>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||||
|
|
||||||
|
import type { PriceFloorSkeletonProps } from '../types';
|
||||||
|
|
||||||
|
/** The card before it arrives. */
|
||||||
|
export function PriceFloorSkeleton({
|
||||||
|
label,
|
||||||
|
delayed,
|
||||||
|
}: PriceFloorSkeletonProps) {
|
||||||
|
return <SkeletonPreset preset="form" label={label} delayed={delayed} />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
export { PriceFloorSkeleton } from './components/PriceFloorSkeleton';
|
||||||
|
export { PriceFloorCard } from './PriceFloorCard';
|
||||||
|
export type { PriceFloorPartProps, PriceFloorSkeletonProps } from './types';
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
import type { PriceFloorPageModel } from '@lumina/garden-roof';
|
||||||
|
|
||||||
|
export type PriceFloorPartProps = { model: PriceFloorPageModel };
|
||||||
|
|
||||||
|
export type PriceFloorSkeletonProps = {
|
||||||
|
/** Hidden status text. */
|
||||||
|
label: string;
|
||||||
|
/** Fades in after 300ms: loading.tsx only. */
|
||||||
|
delayed?: boolean;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
import { PartBoundary } from '@lumina/garden-roof/app/error-boundaries';
|
||||||
|
import { AdminGuard } from '@lumina/garden-roof/app/guards';
|
||||||
|
import { PageHeader } from '@lumina/island/molecules/page-header';
|
||||||
|
import type { Metadata } from 'next';
|
||||||
|
import { Suspense } from 'react';
|
||||||
|
|
||||||
|
import { i18n } from '../../../i18n';
|
||||||
|
import { PriceFloorCard, PriceFloorSkeleton } from './organisms/price-floor-card';
|
||||||
|
|
||||||
|
export const metadata: Metadata = { title: i18n.t('settings:page.meta-title') };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* تنظیمات (J11-11): the title on the server; «کف قیمت اشتراک» in the browser once the admin is known
|
||||||
|
* (0062).
|
||||||
|
*/
|
||||||
|
export default function SettingsPage() {
|
||||||
|
const skeleton = (
|
||||||
|
<PriceFloorSkeleton label={i18n.t('settings:page.loading')} />
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<PageHeader
|
||||||
|
title={i18n.t('settings:page.title')}
|
||||||
|
subtitle={i18n.t('settings:page.subtitle')}
|
||||||
|
/>
|
||||||
|
<AdminGuard fallback={skeleton}>
|
||||||
|
<PartBoundary
|
||||||
|
name="settings"
|
||||||
|
description={i18n.t('settings:page.error')}
|
||||||
|
>
|
||||||
|
<Suspense fallback={skeleton}>
|
||||||
|
<PriceFloorCard />
|
||||||
|
</Suspense>
|
||||||
|
</PartBoundary>
|
||||||
|
</AdminGuard>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -85,6 +85,7 @@ Every page renders in the browser behind `AdminGuard` or `GuestGuard` (0062).
|
||||||
- `/invite-codes/requests` · [invite-codes-requests.md](wall-street-plaza/invite-codes-requests.md) · noindex · none · browser: request rows, code dialogs
|
- `/invite-codes/requests` · [invite-codes-requests.md](wall-street-plaza/invite-codes-requests.md) · noindex · none · browser: request rows, code dialogs
|
||||||
- `/payouts` · [payouts.md](wall-street-plaza/payouts.md) · noindex · none · browser: tabs, payout rows, payout detail sheet, create, mark-paid and cancel dialogs
|
- `/payouts` · [payouts.md](wall-street-plaza/payouts.md) · noindex · none · browser: tabs, payout rows, payout detail sheet, create, mark-paid and cancel dialogs
|
||||||
- `/predictions` · [predictions.md](wall-street-plaza/predictions.md) · noindex · none · browser: quote health, queue tabs, queue rows, prediction sheet, prediction dialogs
|
- `/predictions` · [predictions.md](wall-street-plaza/predictions.md) · noindex · none · browser: quote health, queue tabs, queue rows, prediction sheet, prediction dialogs
|
||||||
|
- `/settings` · [settings.md](wall-street-plaza/settings.md) · noindex · none · browser: price floor card, raise preview, confirm dialog
|
||||||
- `/subscriptions` · [subscriptions.md](wall-street-plaza/subscriptions.md) · noindex · none · browser: filter chips, subscription rows, detail sheet, grant dialog
|
- `/subscriptions` · [subscriptions.md](wall-street-plaza/subscriptions.md) · noindex · none · browser: filter chips, subscription rows, detail sheet, grant dialog
|
||||||
- `/verifications` · [verifications.md](wall-street-plaza/verifications.md) · noindex · none · browser: status tabs, search and sort, verification rows
|
- `/verifications` · [verifications.md](wall-street-plaza/verifications.md) · noindex · none · browser: status tabs, search and sort, verification rows
|
||||||
- `/verifications/[id]` · [verifications-id.md](wall-street-plaza/verifications-id.md) · noindex · none · browser: queue nav, banner, facts, decisions, past submissions, ID image, audit log, decision dialogs
|
- `/verifications/[id]` · [verifications-id.md](wall-street-plaza/verifications-id.md) · noindex · none · browser: queue nav, banner, facts, decisions, past submissions, ID image, audit log, decision dialogs
|
||||||
|
|
|
||||||
|
|
@ -28,3 +28,7 @@ In bull's document order. Everything sits in `AuthGuard role="creator"`, whose f
|
||||||
|
|
||||||
- bull: cards 12px apart; bear: 16px apart, desktop card layouts. Same sections in both apps.
|
- bull: cards 12px apart; bear: 16px apart, desktop card layouts. Same sections in both apps.
|
||||||
- The cards' queries run only in the browser: `AuthGuard` returns its fallback on the server, so no `useSuspenseQuery` sends a request from the server.
|
- The cards' queries run only in the browser: `AuthGuard` returns its fallback on the server, so no `useSuspenseQuery` sends a request from the server.
|
||||||
|
|
||||||
|
## Price floor
|
||||||
|
|
||||||
|
A plan the price floor took off sale gets a «خارج از فروش» badge on its row, and a banner above the card, «طرح {tier} شما از فروش خارج شد», with «اصلاح قیمت» to `/dashboard/pricing`. Both read `offSale` from the pricing form, so they load with the card.
|
||||||
|
|
|
||||||
|
|
@ -29,3 +29,8 @@ In bull's document order. `dashboard/pricing/layout.tsx` is only `OnboardingGuar
|
||||||
|
|
||||||
- bull: the form pads itself and pins save to the bottom; bear: the form in the 560 column.
|
- bull: the form pads itself and pins save to the bottom; bear: the form in the 560 column.
|
||||||
- Debt: different H1 per app. bull has no `h1`; add a screen-reader `h1` to `PricingEditor`'s mobile branch (`platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor/PricingEditor.tsx`, the `MobileTopBar` return).
|
- Debt: different H1 per app. bull has no `h1`; add a screen-reader `h1` to `PricingEditor`'s mobile branch (`platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-editor/PricingEditor.tsx`, the `MobileTopBar` return).
|
||||||
|
|
||||||
|
## Price floor
|
||||||
|
|
||||||
|
- The floor comes from `GET /subscriptions/pricing` (`floorTomanPerMonth`), on the final price after any discount; the browser compares exact totals as the API does.
|
||||||
|
- During the 7-day lock a tier the floor took off sale (`offSale`) stays editable and shows «خارج از فروش»; the other tiers stay read-only, and the save reads «ذخیره قیمتگذاری» instead of «ذخیره تخفیف».
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Settings
|
||||||
|
|
||||||
|
`/settings` · `apps/wall-street-plaza/src/app/(panel)/settings/page.tsx` · Type: account (back office) · Layout: [layout-panel.md](layout-panel.md)
|
||||||
|
|
||||||
|
| Field | Value |
|
||||||
|
| ----------- | -------------------------------------------------------- |
|
||||||
|
| Robots | `noindex` (root layout `metadata`, `src/configs/seo.ts`) |
|
||||||
|
| Status | `200` |
|
||||||
|
| loading.tsx | `(panel)/settings/loading.tsx` |
|
||||||
|
| First flush | none |
|
||||||
|
| Canonical | none |
|
||||||
|
| H1 | `settings:page.title` from i18n, in `PageHeader` |
|
||||||
|
| JSON-LD | none |
|
||||||
|
| Scripts | none |
|
||||||
|
|
||||||
|
## Sections
|
||||||
|
|
||||||
|
| Section | Data | HTML | JS | Index | Notes |
|
||||||
|
| -------------- | ------ | ----------- | ------- | ----- | ------------------------------------------------------------------------------------------------- |
|
||||||
|
| PageHeader | config | first flush | none | no | title and subtitle |
|
||||||
|
| PriceFloorCard | viewer | skeleton | hydrate | no | `AdminGuard`, `PartBoundary`, `Suspense`; `GET /admin/settings/price-floor` in the browser (0062) |
|
||||||
|
| Raise preview | viewer | none | hydrate | no | on a raise, a dry run `PUT` once the value stands still 400 ms; warning and table |
|
||||||
|
| Confirm dialog | viewer | none | hydrate | no | `ReasonDialog`, reason of 10 characters at least, audited as `settings.price_floor_changed` |
|
||||||
|
|
||||||
|
- A lower floor shows no preview, since nothing changes until analysts edit.
|
||||||
|
- «ذخیره» stays frozen, with its reason, on an invalid or unchanged value, or until a raise's preview is in.
|
||||||
|
|
@ -2,6 +2,9 @@
|
||||||
"name": "@lumina/garden-roof",
|
"name": "@lumina/garden-roof",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"test": "vitest run --config ../../vitest.config.ts"
|
||||||
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ export const NAV_ITEMS: readonly NavItem[] = [
|
||||||
{ section: 'preds', icon: 'target' },
|
{ section: 'preds', icon: 'target' },
|
||||||
{ section: 'payouts', icon: 'wallet' },
|
{ section: 'payouts', icon: 'wallet' },
|
||||||
{ section: 'featured', icon: 'star' },
|
{ section: 'featured', icon: 'star' },
|
||||||
|
{ section: 'settings', icon: 'settings' },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const SOON_ITEMS: readonly SoonItem[] = [
|
export const SOON_ITEMS: readonly SoonItem[] = [
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ export const ROUTES = {
|
||||||
predictions: '/predictions',
|
predictions: '/predictions',
|
||||||
payouts: '/payouts',
|
payouts: '/payouts',
|
||||||
featured: '/featured',
|
featured: '/featured',
|
||||||
|
settings: '/settings',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/** Where a signed-in admin lands, and where «بازگشت» goes when nothing else fits. */
|
/** Where a signed-in admin lands, and where «بازگشت» goes when nothing else fits. */
|
||||||
|
|
@ -47,6 +48,7 @@ export const SECTION_ROUTES: Record<AdminSection, string> = {
|
||||||
preds: ROUTES.predictions,
|
preds: ROUTES.predictions,
|
||||||
payouts: ROUTES.payouts,
|
payouts: ROUTES.payouts,
|
||||||
featured: ROUTES.featured,
|
featured: ROUTES.featured,
|
||||||
|
settings: ROUTES.settings,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function sectionOf(pathname: string): AdminSection | null {
|
export function sectionOf(pathname: string): AdminSection | null {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ export type AdminSection =
|
||||||
| 'subs'
|
| 'subs'
|
||||||
| 'preds'
|
| 'preds'
|
||||||
| 'payouts'
|
| 'payouts'
|
||||||
| 'featured';
|
| 'featured'
|
||||||
|
| 'settings';
|
||||||
|
|
||||||
/** Sections whose sidebar link shows what waits there. */
|
/** Sections whose sidebar link shows what waits there. */
|
||||||
export type CountedSection = 'verify' | 'codes' | 'preds' | 'payouts';
|
export type CountedSection = 'verify' | 'codes' | 'preds' | 'payouts';
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { eventEmitter } from '@lumina/libs/event-emitter';
|
||||||
|
|
||||||
|
import { SETTINGS_EVENTS } from '../../constants';
|
||||||
|
import { settingsRepository } from '../../repositories/settings';
|
||||||
|
import type {
|
||||||
|
PriceFloorChangePayload,
|
||||||
|
SavePriceFloorArgs,
|
||||||
|
} from '../../repositories/settings';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* «ذخیره و اطلاعرسانی» (J11-11): saves the floor with its audited reason. Emits
|
||||||
|
* `settings.price-floor-changed`.
|
||||||
|
*/
|
||||||
|
export async function savePriceFloor(
|
||||||
|
args: SavePriceFloorArgs,
|
||||||
|
{ emit = true }: { emit?: boolean } = {},
|
||||||
|
): Promise<PriceFloorChangePayload> {
|
||||||
|
const result = await settingsRepository.savePriceFloor(args);
|
||||||
|
if (emit) {
|
||||||
|
eventEmitter.emit(SETTINGS_EVENTS.priceFloorChanged, {
|
||||||
|
monthlyMin: result.monthlyMin,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export { savePriceFloor } from './actions';
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
/** Events settings actions emit when they succeed. */
|
||||||
|
export const SETTINGS_EVENTS = {
|
||||||
|
priceFloorChanged: 'settings.price-floor-changed',
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
/** How long the typed floor must stand still before its preview is asked. */
|
||||||
|
export const PREVIEW_DEBOUNCE_MS = 400;
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export type { AffectedTierEntity } from './types';
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
/** One tier a floor would take off sale (admin-api `PUT /admin/settings/price-floor`). */
|
||||||
|
export type AffectedTierEntity = {
|
||||||
|
tierId: string;
|
||||||
|
traderId: string;
|
||||||
|
/** `null` when the account can no longer be found. */
|
||||||
|
username: string | null;
|
||||||
|
billingPeriod: 'monthly' | 'quarterly' | 'semi_annual' | 'yearly';
|
||||||
|
labelFa: string;
|
||||||
|
/** The lowest price it is committed to, as a month's worth, in Toman. */
|
||||||
|
finalMonthlyToman: number;
|
||||||
|
activeSubscribers: number;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import { http } from '@lumina/libs/http';
|
||||||
|
|
||||||
|
export const settingsHttp = http.extend({});
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
import './types';
|
||||||
|
|
||||||
|
export { savePriceFloor } from './actions/save-price-floor';
|
||||||
|
export { PREVIEW_DEBOUNCE_MS, SETTINGS_EVENTS } from './constants';
|
||||||
|
export type { AffectedTierEntity } from './entities/price-floor';
|
||||||
|
export { usePriceFloorPage } from './models/price-floor';
|
||||||
|
export type {
|
||||||
|
PriceFloorChange,
|
||||||
|
PriceFloorPageModel,
|
||||||
|
PriceFloorPreview,
|
||||||
|
} from './models/price-floor';
|
||||||
|
export {
|
||||||
|
SETTINGS_ENDPOINTS,
|
||||||
|
settingsKeys,
|
||||||
|
settingsRepository,
|
||||||
|
} from './repositories/settings';
|
||||||
|
export type {
|
||||||
|
AffectedTierPayload,
|
||||||
|
PreviewPriceFloorArgs,
|
||||||
|
PriceFloorChangePayload,
|
||||||
|
PriceFloorPayload,
|
||||||
|
SavePriceFloorArgs,
|
||||||
|
} from './repositories/settings';
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
export { usePriceFloorPage } from './use-price-floor-page';
|
||||||
|
export {
|
||||||
|
floorBlockedReason,
|
||||||
|
floorChange,
|
||||||
|
readMonthlyFloor,
|
||||||
|
} from './price-floor-rules';
|
||||||
|
export type {
|
||||||
|
PriceFloorChange,
|
||||||
|
PriceFloorPageModel,
|
||||||
|
PriceFloorPreview,
|
||||||
|
} from './types';
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
|
import {
|
||||||
|
floorBlockedReason,
|
||||||
|
floorChange,
|
||||||
|
readMonthlyFloor,
|
||||||
|
} from './price-floor-rules';
|
||||||
|
|
||||||
|
describe('readMonthlyFloor', () => {
|
||||||
|
it.each([
|
||||||
|
['199000', 199000],
|
||||||
|
['199٬000', 199000],
|
||||||
|
['۱۹۹٬۰۰۰', 199000],
|
||||||
|
['1000', 1000],
|
||||||
|
])('reads %s', (text, value) => {
|
||||||
|
expect(readMonthlyFloor(text)).toEqual({ value, error: null });
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
['', 'settings:price-floor.errors.required'],
|
||||||
|
['12.5', 'settings:price-floor.errors.integer'],
|
||||||
|
['abc', 'settings:price-floor.errors.integer'],
|
||||||
|
['999', 'settings:price-floor.errors.below-min'],
|
||||||
|
])('refuses %j', (text, error) => {
|
||||||
|
expect(readMonthlyFloor(text)).toEqual({ value: null, error });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('floorChange', () => {
|
||||||
|
it('tells a raise, a lower floor and no change apart', () => {
|
||||||
|
expect(floorChange(250000, 199000)).toBe('raise');
|
||||||
|
expect(floorChange(150000, 199000)).toBe('lower');
|
||||||
|
expect(floorChange(199000, 199000)).toBe('none');
|
||||||
|
expect(floorChange(null, 199000)).toBe('none');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('floorBlockedReason', () => {
|
||||||
|
const blocked = (over: Partial<Parameters<typeof floorBlockedReason>[0]>) =>
|
||||||
|
floorBlockedReason({
|
||||||
|
error: null,
|
||||||
|
change: 'raise',
|
||||||
|
previewStatus: 'ready',
|
||||||
|
...over,
|
||||||
|
});
|
||||||
|
|
||||||
|
it('lets a raise through only once its preview is in', () => {
|
||||||
|
expect(blocked({})).toBeNull();
|
||||||
|
expect(blocked({ previewStatus: 'loading' })).toBe(
|
||||||
|
'settings:price-floor.blocked.preview',
|
||||||
|
);
|
||||||
|
expect(blocked({ previewStatus: 'error' })).toBe(
|
||||||
|
'settings:price-floor.blocked.preview',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('lets a lower floor through with no preview', () => {
|
||||||
|
expect(blocked({ change: 'lower', previewStatus: 'idle' })).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('waits on an unchanged or a bad value', () => {
|
||||||
|
expect(blocked({ change: 'none', previewStatus: 'idle' })).toBe(
|
||||||
|
'settings:price-floor.blocked.unchanged',
|
||||||
|
);
|
||||||
|
expect(blocked({ error: 'x', change: 'none' })).toBe(
|
||||||
|
'settings:price-floor.blocked.invalid',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
import * as v from 'valibot';
|
||||||
|
|
||||||
|
import { monthlyFloorSchema } from '../../../../shared/validations';
|
||||||
|
import type { PriceFloorChange } from './types';
|
||||||
|
|
||||||
|
/** The typed floor: its value, or the `settings:` key of why it isn't one. */
|
||||||
|
export function readMonthlyFloor(
|
||||||
|
text: string,
|
||||||
|
): { value: number; error: null } | { value: null; error: string } {
|
||||||
|
const parsed = v.safeParse(monthlyFloorSchema, text);
|
||||||
|
return parsed.success
|
||||||
|
? { value: parsed.output, error: null }
|
||||||
|
: { value: null, error: parsed.issues[0].message };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function floorChange(
|
||||||
|
value: number | null,
|
||||||
|
current: number,
|
||||||
|
): PriceFloorChange {
|
||||||
|
if (value === null || value === current) return 'none';
|
||||||
|
return value > current ? 'raise' : 'lower';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Why «ذخیره» waits: nothing to save, a bad value, or a raise whose effect isn't known yet. */
|
||||||
|
export function floorBlockedReason({
|
||||||
|
error,
|
||||||
|
change,
|
||||||
|
previewStatus,
|
||||||
|
}: {
|
||||||
|
error: string | null;
|
||||||
|
change: PriceFloorChange;
|
||||||
|
previewStatus: 'idle' | 'loading' | 'error' | 'ready';
|
||||||
|
}): string | null {
|
||||||
|
if (error) return 'settings:price-floor.blocked.invalid';
|
||||||
|
if (change === 'none') return 'settings:price-floor.blocked.unchanged';
|
||||||
|
if (change === 'raise' && previewStatus !== 'ready') {
|
||||||
|
return 'settings:price-floor.blocked.preview';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
import type { ReasonForm } from '../../../../shared/utils';
|
||||||
|
import type { PriceFloorChangePayload } from '../../repositories/settings';
|
||||||
|
|
||||||
|
/** What the typed floor does against the current one. */
|
||||||
|
export type PriceFloorChange = 'none' | 'raise' | 'lower';
|
||||||
|
|
||||||
|
/** The raise's preview: asked once the value stands still, and only for a raise. */
|
||||||
|
export type PriceFloorPreview =
|
||||||
|
| { status: 'idle' }
|
||||||
|
| { status: 'loading' }
|
||||||
|
| { status: 'error'; retry: () => void }
|
||||||
|
| { status: 'ready'; change: PriceFloorChangePayload };
|
||||||
|
|
||||||
|
export type PriceFloorPageModel = {
|
||||||
|
currentToman: number;
|
||||||
|
/** When an admin last changed it; `null` while it is still the default. */
|
||||||
|
changedAt: string | null;
|
||||||
|
/** «کف ماهانه» as typed, grouped. */
|
||||||
|
text: string;
|
||||||
|
setText: (text: string) => void;
|
||||||
|
/** A `settings:` key while the typed value is not a floor; `null` otherwise. */
|
||||||
|
error: string | null;
|
||||||
|
/** The typed floor, once valid. */
|
||||||
|
valueToman: number | null;
|
||||||
|
change: PriceFloorChange;
|
||||||
|
preview: PriceFloorPreview;
|
||||||
|
/** Why «ذخیره» waits: a `settings:` key; `null` when it can open the confirmation. */
|
||||||
|
blockedReason: string | null;
|
||||||
|
isConfirming: boolean;
|
||||||
|
openConfirm: () => void;
|
||||||
|
closeConfirm: () => void;
|
||||||
|
reasonForm: ReasonForm;
|
||||||
|
/** «ذخیره و اطلاعرسانی», with the trimmed reason. */
|
||||||
|
confirm: (reason: string) => void;
|
||||||
|
isSaving: boolean;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
import { showToast } from '@lumina/island/molecules/toast';
|
||||||
|
import { latinDigits, number, price } from '@lumina/tools/format';
|
||||||
|
import { useQuery, useQueryClient, useSuspenseQuery } from '@tanstack/react-query';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import {
|
||||||
|
showActionError,
|
||||||
|
useDebouncedValue,
|
||||||
|
useReasonForm,
|
||||||
|
} from '../../../../shared/utils';
|
||||||
|
import { savePriceFloor } from '../../actions/save-price-floor';
|
||||||
|
import { PREVIEW_DEBOUNCE_MS } from '../../constants';
|
||||||
|
import { settingsKeys, settingsRepository } from '../../repositories/settings';
|
||||||
|
import {
|
||||||
|
floorBlockedReason,
|
||||||
|
floorChange,
|
||||||
|
readMonthlyFloor,
|
||||||
|
} from './price-floor-rules';
|
||||||
|
import type { PriceFloorPageModel, PriceFloorPreview } from './types';
|
||||||
|
|
||||||
|
/** A typed amount as the field shows it: digits only, grouped. */
|
||||||
|
function toAmountText(text: string): string {
|
||||||
|
const digits = latinDigits(text).replace(/\D/g, '');
|
||||||
|
return digits === '' ? '' : number(Number(digits));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* «کف قیمت اشتراک» (J11-11). A raise shows what it would take off sale before it can be saved: a
|
||||||
|
* dry run asked once the value stands still, so nothing is confirmed on a stale list. A lower floor
|
||||||
|
* changes nothing until analysts edit, so it has no preview. Saving asks a reason (audited); a
|
||||||
|
* failure keeps the dialog and its text.
|
||||||
|
*/
|
||||||
|
export function usePriceFloorPage(): PriceFloorPageModel {
|
||||||
|
const { t } = useTranslation('settings');
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const { data: floor } = useSuspenseQuery({
|
||||||
|
queryKey: settingsKeys.priceFloor(),
|
||||||
|
queryFn: ({ signal }) => settingsRepository.getPriceFloor({ signal }),
|
||||||
|
});
|
||||||
|
const [text, setText] = useState(() => number(floor.monthlyMin));
|
||||||
|
const [isConfirming, setIsConfirming] = useState(false);
|
||||||
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
|
const reasonForm = useReasonForm();
|
||||||
|
|
||||||
|
const { value, error } = readMonthlyFloor(text);
|
||||||
|
const change = floorChange(value, floor.monthlyMin);
|
||||||
|
const settled = useDebouncedValue(value, PREVIEW_DEBOUNCE_MS);
|
||||||
|
const dryRun = useQuery({
|
||||||
|
queryKey: settingsKeys.preview(value ?? 0),
|
||||||
|
queryFn: ({ signal }) =>
|
||||||
|
settingsRepository.previewPriceFloor(
|
||||||
|
{ monthlyMin: value as number },
|
||||||
|
{ signal },
|
||||||
|
),
|
||||||
|
enabled: change === 'raise' && settled === value,
|
||||||
|
// Each read answers for this moment: another admin or analyst may have changed the tiers.
|
||||||
|
staleTime: 0,
|
||||||
|
gcTime: 0,
|
||||||
|
throwOnError: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const preview: PriceFloorPreview =
|
||||||
|
change !== 'raise'
|
||||||
|
? { status: 'idle' }
|
||||||
|
: dryRun.isError
|
||||||
|
? { status: 'error', retry: () => void dryRun.refetch() }
|
||||||
|
: dryRun.data && settled === value
|
||||||
|
? { status: 'ready', change: dryRun.data }
|
||||||
|
: { status: 'loading' };
|
||||||
|
|
||||||
|
const confirm = async (reason: string) => {
|
||||||
|
if (value === null || isSaving) return;
|
||||||
|
setIsSaving(true);
|
||||||
|
try {
|
||||||
|
const saved = await savePriceFloor({ monthlyMin: value, reason });
|
||||||
|
await queryClient.invalidateQueries({
|
||||||
|
queryKey: settingsKeys.priceFloor(),
|
||||||
|
});
|
||||||
|
setIsConfirming(false);
|
||||||
|
showToast({
|
||||||
|
tone: 'success',
|
||||||
|
message: t('price-floor.saved', { amount: price(saved.monthlyMin) }),
|
||||||
|
});
|
||||||
|
} catch (failure) {
|
||||||
|
showActionError(failure, {
|
||||||
|
t,
|
||||||
|
failedMessage: t('price-floor.save-failed'),
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setIsSaving(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
currentToman: floor.monthlyMin,
|
||||||
|
changedAt: floor.changedAt,
|
||||||
|
text,
|
||||||
|
setText: (next) => setText(toAmountText(next)),
|
||||||
|
error,
|
||||||
|
valueToman: value,
|
||||||
|
change,
|
||||||
|
preview,
|
||||||
|
blockedReason: floorBlockedReason({
|
||||||
|
error,
|
||||||
|
change,
|
||||||
|
previewStatus: preview.status,
|
||||||
|
}),
|
||||||
|
isConfirming,
|
||||||
|
openConfirm: () => setIsConfirming(true),
|
||||||
|
closeConfirm: () => setIsConfirming(false),
|
||||||
|
reasonForm,
|
||||||
|
confirm: (reason) => void confirm(reason),
|
||||||
|
isSaving,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
export const SETTINGS_ENDPOINTS = {
|
||||||
|
priceFloor: '/admin/settings/price-floor',
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const settingsKeys = {
|
||||||
|
all: ['settings'] as const,
|
||||||
|
priceFloor: () => [...settingsKeys.all, 'price-floor'] as const,
|
||||||
|
preview: (monthlyMin: number) =>
|
||||||
|
[...settingsKeys.priceFloor(), 'preview', monthlyMin] as const,
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
export { SETTINGS_ENDPOINTS, settingsKeys } from './constants';
|
||||||
|
export { settingsRepository } from './settings';
|
||||||
|
export type {
|
||||||
|
AffectedTierPayload,
|
||||||
|
PreviewPriceFloorArgs,
|
||||||
|
PriceFloorChangePayload,
|
||||||
|
PriceFloorPayload,
|
||||||
|
SavePriceFloorArgs,
|
||||||
|
} from './types';
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
import type {
|
||||||
|
PreviewPriceFloorArgs,
|
||||||
|
PriceFloorChangePayload,
|
||||||
|
PriceFloorChangeResponseDto,
|
||||||
|
PriceFloorPayload,
|
||||||
|
PriceFloorResponseDto,
|
||||||
|
SavePriceFloorArgs,
|
||||||
|
SavePriceFloorDto,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
|
export function toPriceFloorPayload(
|
||||||
|
dto: PriceFloorResponseDto,
|
||||||
|
): PriceFloorPayload {
|
||||||
|
return { monthlyMin: dto.monthlyMin, changedAt: dto.changedAt };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toPriceFloorChangePayload(
|
||||||
|
dto: PriceFloorChangeResponseDto,
|
||||||
|
): PriceFloorChangePayload {
|
||||||
|
return {
|
||||||
|
monthlyMin: dto.monthlyMin,
|
||||||
|
analystCount: dto.analystCount,
|
||||||
|
affectedTiers: dto.affectedTiers,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toPreviewPriceFloorDto(
|
||||||
|
args: PreviewPriceFloorArgs,
|
||||||
|
): SavePriceFloorDto {
|
||||||
|
return { monthlyMin: args.monthlyMin, dryRun: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toSavePriceFloorDto(
|
||||||
|
args: SavePriceFloorArgs,
|
||||||
|
): SavePriceFloorDto {
|
||||||
|
return { monthlyMin: args.monthlyMin, reason: args.reason };
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
import { settingsHttp } from '../../http';
|
||||||
|
import { SETTINGS_ENDPOINTS } from './constants';
|
||||||
|
import {
|
||||||
|
toPreviewPriceFloorDto,
|
||||||
|
toPriceFloorChangePayload,
|
||||||
|
toPriceFloorPayload,
|
||||||
|
toSavePriceFloorDto,
|
||||||
|
} from './mappers';
|
||||||
|
import type {
|
||||||
|
PreviewPriceFloorArgs,
|
||||||
|
PriceFloorChangePayload,
|
||||||
|
PriceFloorChangeResponseDto,
|
||||||
|
PriceFloorPayload,
|
||||||
|
PriceFloorResponseDto,
|
||||||
|
SavePriceFloorArgs,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
|
/** «تنظیمات» (J11-11): «کف قیمت اشتراک». */
|
||||||
|
export const settingsRepository = {
|
||||||
|
async getPriceFloor({
|
||||||
|
signal,
|
||||||
|
}: { signal?: AbortSignal } = {}): Promise<PriceFloorPayload> {
|
||||||
|
const response = await settingsHttp.get<PriceFloorResponseDto>(
|
||||||
|
SETTINGS_ENDPOINTS.priceFloor,
|
||||||
|
{ signal },
|
||||||
|
);
|
||||||
|
return toPriceFloorPayload(response);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** The tiers this floor would take off sale; a dry run changes nothing. */
|
||||||
|
async previewPriceFloor(
|
||||||
|
args: PreviewPriceFloorArgs,
|
||||||
|
{ signal }: { signal?: AbortSignal } = {},
|
||||||
|
): Promise<PriceFloorChangePayload> {
|
||||||
|
const response = await settingsHttp.put<PriceFloorChangeResponseDto>(
|
||||||
|
SETTINGS_ENDPOINTS.priceFloor,
|
||||||
|
toPreviewPriceFloorDto(args),
|
||||||
|
{ signal },
|
||||||
|
);
|
||||||
|
return toPriceFloorChangePayload(response);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Saves the floor; raising it takes the tiers below it off sale and notifies their analysts. */
|
||||||
|
async savePriceFloor(
|
||||||
|
args: SavePriceFloorArgs,
|
||||||
|
): Promise<PriceFloorChangePayload> {
|
||||||
|
const response = await settingsHttp.put<PriceFloorChangeResponseDto>(
|
||||||
|
SETTINGS_ENDPOINTS.priceFloor,
|
||||||
|
toSavePriceFloorDto(args),
|
||||||
|
);
|
||||||
|
return toPriceFloorChangePayload(response);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
import type { AffectedTierEntity } from '../../entities/price-floor';
|
||||||
|
|
||||||
|
// Money is whole Toman; dates are ISO strings.
|
||||||
|
|
||||||
|
// GET /admin/settings/price-floor
|
||||||
|
|
||||||
|
export type PriceFloorResponseDto = {
|
||||||
|
monthlyMin: number;
|
||||||
|
previousValue: number | null;
|
||||||
|
changedAt: string | null;
|
||||||
|
changedBy: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The floor per month-equivalent, on the final price after any discount, and its last change. */
|
||||||
|
export type PriceFloorPayload = {
|
||||||
|
monthlyMin: number;
|
||||||
|
/** `null` until an admin first changes it. */
|
||||||
|
changedAt: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
// PUT /admin/settings/price-floor
|
||||||
|
|
||||||
|
export type PreviewPriceFloorArgs = { monthlyMin: number };
|
||||||
|
|
||||||
|
export type SavePriceFloorArgs = { monthlyMin: number; reason: string };
|
||||||
|
|
||||||
|
export type SavePriceFloorDto = {
|
||||||
|
monthlyMin: number;
|
||||||
|
reason?: string;
|
||||||
|
dryRun?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PriceFloorChangeResponseDto = {
|
||||||
|
monthlyMin: number;
|
||||||
|
previousValue: number;
|
||||||
|
analystCount: number;
|
||||||
|
affectedTiers: AffectedTierEntity[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AffectedTierPayload = AffectedTierEntity;
|
||||||
|
|
||||||
|
/** What a floor takes, or would take, off sale. */
|
||||||
|
export type PriceFloorChangePayload = {
|
||||||
|
monthlyMin: number;
|
||||||
|
analystCount: number;
|
||||||
|
affectedTiers: AffectedTierPayload[];
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
declare module '@lumina/libs/event-emitter' {
|
||||||
|
interface EventMap {
|
||||||
|
'settings.price-floor-changed': { monthlyMin: number };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {};
|
||||||
|
|
@ -350,6 +350,26 @@ export type {
|
||||||
ReadyPayoutPayload,
|
ReadyPayoutPayload,
|
||||||
ReadyPayoutsPartModel,
|
ReadyPayoutsPartModel,
|
||||||
} from './features/payouts';
|
} from './features/payouts';
|
||||||
|
export {
|
||||||
|
PREVIEW_DEBOUNCE_MS,
|
||||||
|
savePriceFloor,
|
||||||
|
SETTINGS_ENDPOINTS,
|
||||||
|
SETTINGS_EVENTS,
|
||||||
|
settingsKeys,
|
||||||
|
settingsRepository,
|
||||||
|
usePriceFloorPage,
|
||||||
|
} from './features/settings';
|
||||||
|
export type {
|
||||||
|
AffectedTierEntity,
|
||||||
|
AffectedTierPayload,
|
||||||
|
PreviewPriceFloorArgs,
|
||||||
|
PriceFloorChange,
|
||||||
|
PriceFloorChangePayload,
|
||||||
|
PriceFloorPageModel,
|
||||||
|
PriceFloorPayload,
|
||||||
|
PriceFloorPreview,
|
||||||
|
SavePriceFloorArgs,
|
||||||
|
} from './features/settings';
|
||||||
export {
|
export {
|
||||||
addFeatured,
|
addFeatured,
|
||||||
FEATURED_ENDPOINTS,
|
FEATURED_ENDPOINTS,
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
"preds": "سیگنالها",
|
"preds": "سیگنالها",
|
||||||
"payouts": "تسویه تحلیلگران",
|
"payouts": "تسویه تحلیلگران",
|
||||||
"featured": "تحلیلگران منتخب",
|
"featured": "تحلیلگران منتخب",
|
||||||
|
"settings": "تنظیمات",
|
||||||
"soon": "بهزودی",
|
"soon": "بهزودی",
|
||||||
"soon-items": {
|
"soon-items": {
|
||||||
"users": "کاربران",
|
"users": "کاربران",
|
||||||
|
|
@ -132,7 +133,9 @@
|
||||||
"ledger.corrected": "اصلاح موجودی",
|
"ledger.corrected": "اصلاح موجودی",
|
||||||
"featured.added": "به منتخب اضافه شد",
|
"featured.added": "به منتخب اضافه شد",
|
||||||
"featured.removed": "از منتخب حذف شد",
|
"featured.removed": "از منتخب حذف شد",
|
||||||
"featured.reordered": "ترتیب تغییر کرد"
|
"featured.reordered": "ترتیب تغییر کرد",
|
||||||
|
"legal.published": "نسخه تازه سند منتشر شد",
|
||||||
|
"settings.price_floor_changed": "کف قیمت تغییر کرد"
|
||||||
},
|
},
|
||||||
"capacity-up": "افزایش ظرفیت از {{from}} به {{to}}",
|
"capacity-up": "افزایش ظرفیت از {{from}} به {{to}}",
|
||||||
"capacity-down": "کاهش ظرفیت از {{from}} به {{to}}",
|
"capacity-down": "کاهش ظرفیت از {{from}} به {{to}}",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
{
|
||||||
|
"page": {
|
||||||
|
"meta-title": "تنظیمات",
|
||||||
|
"title": "تنظیمات",
|
||||||
|
"subtitle": "مقادیری که بدون انتشار نسخه تازه تغییر میکنند.",
|
||||||
|
"loading": "در حال بارگذاری تنظیمات…",
|
||||||
|
"error": "تنظیمات بارگذاری نشد. دوباره تلاش کنید."
|
||||||
|
},
|
||||||
|
"price-floor": {
|
||||||
|
"title": "کف قیمت اشتراک",
|
||||||
|
"description": "کمترین قیمت نهایی هر طرح به ازای هر ماه، بعد از هر تخفیف.",
|
||||||
|
"field": "کف ماهانه",
|
||||||
|
"currency": "تومان",
|
||||||
|
"hint": "کف فعلی: {{current}} تومان در ماه · آخرین تغییر: {{date}}",
|
||||||
|
"hint-never": "کف فعلی: {{current}} تومان در ماه · هنوز تغییری ثبت نشده است",
|
||||||
|
"errors": {
|
||||||
|
"required": "کف ماهانه را وارد کنید.",
|
||||||
|
"integer": "کف ماهانه باید یک عدد صحیح به تومان باشد.",
|
||||||
|
"below-min": "کف ماهانه نمیتواند کمتر از ۱٬۰۰۰ تومان باشد."
|
||||||
|
},
|
||||||
|
"blocked": {
|
||||||
|
"invalid": "ابتدا مقدار کف ماهانه را اصلاح کنید.",
|
||||||
|
"unchanged": "برای ذخیره، مقدار تازهای وارد کنید.",
|
||||||
|
"preview": "پیش از ذخیره باید پیشنمایش طرحهای زیر کف آماده باشد."
|
||||||
|
},
|
||||||
|
"save": "ذخیره",
|
||||||
|
"lower-note": "با کاهش کف، تا زمانی که تحلیلگران قیمتهایشان را ویرایش نکنند چیزی تغییر نمیکند.",
|
||||||
|
"preview": {
|
||||||
|
"warning": "{{tiers}} طرح از {{analysts}} تحلیلگر زیر کف جدید میمانند.",
|
||||||
|
"none": "هیچ طرحی زیر کف جدید نمیماند.",
|
||||||
|
"loading": "در حال بررسی طرحهای زیر کف جدید…",
|
||||||
|
"error": "پیشنمایش طرحهای زیر کف بارگذاری نشد.",
|
||||||
|
"retry": "تلاش دوباره",
|
||||||
|
"table": "طرحهایی که زیر کف جدید میمانند",
|
||||||
|
"columns": {
|
||||||
|
"analyst": "تحلیلگر",
|
||||||
|
"plan": "طرح",
|
||||||
|
"price": "قیمت نهایی ماهانه",
|
||||||
|
"subscribers": "مشترکان فعال"
|
||||||
|
},
|
||||||
|
"unknown": "حساب نامشخص"
|
||||||
|
},
|
||||||
|
"confirm": {
|
||||||
|
"title": "تغییر کف قیمت به {{amount}} تومان",
|
||||||
|
"submit": "ذخیره و اطلاعرسانی",
|
||||||
|
"placeholder": "چرا کف قیمت تغییر میکند؟",
|
||||||
|
"empty": "ابتدا دلیل تغییر کف قیمت را بنویسید."
|
||||||
|
},
|
||||||
|
"saved": "کف قیمت به {{amount}} تومان تغییر کرد.",
|
||||||
|
"save-failed": "کف قیمت ذخیره نشد"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,6 +7,7 @@ import faFeatured from './fa/featured.json';
|
||||||
import faHealth from './fa/health.json';
|
import faHealth from './fa/health.json';
|
||||||
import faPayouts from './fa/payouts.json';
|
import faPayouts from './fa/payouts.json';
|
||||||
import faPredictions from './fa/predictions.json';
|
import faPredictions from './fa/predictions.json';
|
||||||
|
import faSettings from './fa/settings.json';
|
||||||
import faSubscriptions from './fa/subscriptions.json';
|
import faSubscriptions from './fa/subscriptions.json';
|
||||||
import faVerification from './fa/verification.json';
|
import faVerification from './fa/verification.json';
|
||||||
|
|
||||||
|
|
@ -28,6 +29,7 @@ export const resources = {
|
||||||
predictions: faPredictions,
|
predictions: faPredictions,
|
||||||
payouts: faPayouts,
|
payouts: faPayouts,
|
||||||
featured: faFeatured,
|
featured: faFeatured,
|
||||||
|
settings: faSettings,
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,3 +57,7 @@ export type {
|
||||||
MarkPaidFormOutput,
|
MarkPaidFormOutput,
|
||||||
MarkPaidFormValues,
|
MarkPaidFormValues,
|
||||||
} from './payout-validations';
|
} from './payout-validations';
|
||||||
|
export {
|
||||||
|
monthlyFloorSchema,
|
||||||
|
PRICE_FLOOR_MIN_TOMAN,
|
||||||
|
} from './settings-validations';
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { latinDigits } from '@lumina/tools/format';
|
||||||
|
import * as v from 'valibot';
|
||||||
|
|
||||||
|
/** The least a price floor can be, as admin-api takes it. */
|
||||||
|
export const PRICE_FLOOR_MIN_TOMAN = 1000;
|
||||||
|
|
||||||
|
/** «کف ماهانه», typed in any digits, grouped or not: a whole Toman amount of at least 1,000. */
|
||||||
|
export const monthlyFloorSchema = v.pipe(
|
||||||
|
v.string(),
|
||||||
|
v.transform((value) => latinDigits(value).replace(/[٬,\s]/g, '')),
|
||||||
|
v.nonEmpty('settings:price-floor.errors.required'),
|
||||||
|
v.regex(/^\d+$/, 'settings:price-floor.errors.integer'),
|
||||||
|
v.transform(Number),
|
||||||
|
v.minValue(PRICE_FLOOR_MIN_TOMAN, 'settings:price-floor.errors.below-min'),
|
||||||
|
);
|
||||||
|
|
@ -29,7 +29,7 @@ import type { DatePick, PricingFormProps } from './types';
|
||||||
* once something is saved, the note on existing subscribers. Save is pinned to the bottom on
|
* once something is saved, the note on existing subscribers. Save is pinned to the bottom on
|
||||||
* mobile and sits under the form on desktop; while a broken rule shows it freezes with the line
|
* mobile and sits under the form on desktop; while a broken rule shows it freezes with the line
|
||||||
* above it (۳), and offline it freezes and says why. During the lock it reads «ذخیره تخفیف» (J10-4m,
|
* above it (۳), and offline it freezes and says why. During the lock it reads «ذخیره تخفیف» (J10-4m,
|
||||||
* 0036). The confirmation and the date picker are sheets on mobile and modals on desktop. It
|
* 0036), unless a tier is off sale, whose price can be fixed through the lock. The confirmation and the date picker are sheets on mobile and modals on desktop. It
|
||||||
* reports unsaved changes to the frame and answers its leave sheet (J10-4n): «ذخیره و خروج» closes
|
* reports unsaved changes to the frame and answers its leave sheet (J10-4n): «ذخیره و خروج» closes
|
||||||
* it and saves as the save button does, leaving once «تأیید و ذخیره» went through; a broken rule
|
* it and saves as the save button does, leaving once «تأیید و ذخیره» went through; a broken rule
|
||||||
* or «انصراف» keeps the page.
|
* or «انصراف» keeps the page.
|
||||||
|
|
@ -78,7 +78,7 @@ export function PricingForm({
|
||||||
? { frozen: true, pressableWhenFrozen: true }
|
? { frozen: true, pressableWhenFrozen: true }
|
||||||
: offline)}
|
: offline)}
|
||||||
>
|
>
|
||||||
{t(locked ? 'form.save-promotion' : 'form.save')}
|
{t(locked && !model.hasOffSale ? 'form.save-promotion' : 'form.save')}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,9 @@ export function PromotionBlock({
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
model.setPromotionPercent(period, event.target.value)
|
model.setPromotionPercent(period, event.target.value)
|
||||||
}
|
}
|
||||||
|
hint={t('promotion.floor-hint', {
|
||||||
|
floor: price(tier.floorTomanPerMonth),
|
||||||
|
})}
|
||||||
error={percentError}
|
error={percentError}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
|
import userEvent from '@testing-library/user-event';
|
||||||
|
import { describe, expect, it, vi } from 'vitest';
|
||||||
|
|
||||||
|
import type {
|
||||||
|
PricingPageModel,
|
||||||
|
PricingTierView,
|
||||||
|
} from '../../../../../../../../features/pricing';
|
||||||
|
import { TierCard } from './TierCard';
|
||||||
|
|
||||||
|
vi.mock('react-i18next', () => ({
|
||||||
|
useTranslation: () => ({
|
||||||
|
t: (key: string, options?: Record<string, unknown>) =>
|
||||||
|
options ? `${key}:${JSON.stringify(options)}` : key,
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const tier = (over: Partial<PricingTierView> = {}): PricingTierView => ({
|
||||||
|
billingPeriod: 'quarterly',
|
||||||
|
mandatory: false,
|
||||||
|
enabled: true,
|
||||||
|
priceId: 'price',
|
||||||
|
priceText: '',
|
||||||
|
priceMessage: null,
|
||||||
|
perMonthToman: null,
|
||||||
|
floorTotalToman: 597000,
|
||||||
|
floorTomanPerMonth: 199000,
|
||||||
|
offSale: false,
|
||||||
|
locked: false,
|
||||||
|
disableNoteCount: null,
|
||||||
|
promotion: {
|
||||||
|
enabled: false,
|
||||||
|
percent: '',
|
||||||
|
startsAt: null,
|
||||||
|
endsAt: null,
|
||||||
|
indefinite: true,
|
||||||
|
percentId: 'percent',
|
||||||
|
startsAtId: 'start',
|
||||||
|
endsAtId: 'end',
|
||||||
|
percentMessage: null,
|
||||||
|
startsAtMessage: null,
|
||||||
|
endsAtMessage: null,
|
||||||
|
priceToman: null,
|
||||||
|
perMonthToman: null,
|
||||||
|
percentValue: null,
|
||||||
|
saved: false,
|
||||||
|
running: false,
|
||||||
|
},
|
||||||
|
...over,
|
||||||
|
});
|
||||||
|
|
||||||
|
const model = (over: Partial<PricingPageModel> = {}) =>
|
||||||
|
({
|
||||||
|
firstTimeSetup: false,
|
||||||
|
lockedUntil: '2026-11-09T00:00:00.000Z',
|
||||||
|
setPrice: vi.fn(),
|
||||||
|
setEnabled: vi.fn(),
|
||||||
|
blurPrice: vi.fn(),
|
||||||
|
...over,
|
||||||
|
}) as unknown as PricingPageModel;
|
||||||
|
|
||||||
|
const renderCard = (view: PricingTierView, page = model()) =>
|
||||||
|
render(
|
||||||
|
<TierCard tier={view} model={page} layout="desktop" onPickDate={vi.fn()} />,
|
||||||
|
);
|
||||||
|
|
||||||
|
describe('TierCard during the lock', () => {
|
||||||
|
it('keeps a plain tier read-only', () => {
|
||||||
|
renderCard(tier({ locked: true, priceText: '700٬000' }));
|
||||||
|
expect(screen.getByRole('textbox').hasAttribute('readonly')).toBe(true);
|
||||||
|
expect(screen.queryByText('off-sale.badge')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('lets a tier the floor took off sale be edited, and says it is off sale', async () => {
|
||||||
|
const page = model();
|
||||||
|
renderCard(tier({ offSale: true, locked: false }), page);
|
||||||
|
expect(screen.getByText('off-sale.badge')).toBeTruthy();
|
||||||
|
await userEvent.type(screen.getByRole('textbox'), '6');
|
||||||
|
expect(page.setPrice).toHaveBeenCalledWith('quarterly', '6');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('TierCard floor hint', () => {
|
||||||
|
it('names the total and the month on a long period', () => {
|
||||||
|
renderCard(tier(), model({ lockedUntil: null }));
|
||||||
|
expect(screen.getByText(/form\.floor:/).textContent).toContain('597٬000');
|
||||||
|
expect(screen.getByText(/form\.floor:/).textContent).toContain('199٬000');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('names only the month on the monthly one', () => {
|
||||||
|
renderCard(
|
||||||
|
tier({
|
||||||
|
billingPeriod: 'monthly',
|
||||||
|
mandatory: true,
|
||||||
|
floorTotalToman: 199000,
|
||||||
|
}),
|
||||||
|
model({ lockedUntil: null }),
|
||||||
|
);
|
||||||
|
expect(screen.getByText(/form\.floor-monthly:/)).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||||
|
import { StatusBadge } from '@lumina/island/atoms/status-badge';
|
||||||
import { Switch } from '@lumina/island/atoms/switch';
|
import { Switch } from '@lumina/island/atoms/switch';
|
||||||
import { Tag } from '@lumina/island/atoms/tag';
|
import { Tag } from '@lumina/island/atoms/tag';
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
import { Typography } from '@lumina/island/atoms/typography';
|
||||||
|
|
@ -18,7 +19,8 @@ import { useFieldMessage } from './use-field-message';
|
||||||
* after (۲.۱), the rule it breaks in place of either (۳). Switched off, it collapses to its muted
|
* after (۲.۱), the rule it breaks in place of either (۳). Switched off, it collapses to its muted
|
||||||
* switch row, with a note when subscribers run on it (۲.۲). A priced period carries its promotion
|
* switch row, with a note when subscribers run on it (۲.۲). A priced period carries its promotion
|
||||||
* once the first save is done. During the lock the whole card is read-only at 50%, the total's
|
* once the first save is done. During the lock the whole card is read-only at 50%, the total's
|
||||||
* note is its per-month figure, and the promotion moves to its own live card (۶.۲).
|
* note is its per-month figure, and the promotion moves to its own live card (۶.۲). A tier the floor
|
||||||
|
* took off sale says so and stays editable through the lock, since a valid price puts it back.
|
||||||
*/
|
*/
|
||||||
export function TierCard({ tier, model, layout, onPickDate }: TierCardProps) {
|
export function TierCard({ tier, model, layout, onPickDate }: TierCardProps) {
|
||||||
const { t } = useTranslation(['pricing', 'common']);
|
const { t } = useTranslation(['pricing', 'common']);
|
||||||
|
|
@ -26,7 +28,8 @@ export function TierCard({ tier, model, layout, onPickDate }: TierCardProps) {
|
||||||
const headingId = useId();
|
const headingId = useId();
|
||||||
const period = tier.billingPeriod;
|
const period = tier.billingPeriod;
|
||||||
const periodLabel = t(`common:billing-periods.${period}`);
|
const periodLabel = t(`common:billing-periods.${period}`);
|
||||||
const locked = model.lockedUntil !== null;
|
const locked = tier.locked;
|
||||||
|
const lockRuns = model.lockedUntil !== null;
|
||||||
const priceError = message(tier.priceMessage);
|
const priceError = message(tier.priceMessage);
|
||||||
const belowFloor =
|
const belowFloor =
|
||||||
tier.priceMessage?.kind === 'issue' &&
|
tier.priceMessage?.kind === 'issue' &&
|
||||||
|
|
@ -34,7 +37,14 @@ export function TierCard({ tier, model, layout, onPickDate }: TierCardProps) {
|
||||||
const promo = tier.promotion;
|
const promo = tier.promotion;
|
||||||
// No promotion before the first save, nor on a period without a total (۴.۱).
|
// No promotion before the first save, nor on a period without a total (۴.۱).
|
||||||
const showsPromotion =
|
const showsPromotion =
|
||||||
!locked && !model.firstTimeSetup && tier.perMonthToman !== null;
|
!lockRuns && !model.firstTimeSetup && tier.perMonthToman !== null;
|
||||||
|
const floorHint =
|
||||||
|
period === 'monthly'
|
||||||
|
? t('form.floor-monthly', { floor: price(tier.floorTomanPerMonth) })
|
||||||
|
: t('form.floor', {
|
||||||
|
floor: price(tier.floorTomanPerMonth),
|
||||||
|
total: price(tier.floorTotalToman),
|
||||||
|
});
|
||||||
const showsDiscount =
|
const showsDiscount =
|
||||||
showsPromotion &&
|
showsPromotion &&
|
||||||
promo.enabled &&
|
promo.enabled &&
|
||||||
|
|
@ -69,6 +79,11 @@ export function TierCard({ tier, model, layout, onPickDate }: TierCardProps) {
|
||||||
{t('form.required-tag')}
|
{t('form.required-tag')}
|
||||||
</Tag>
|
</Tag>
|
||||||
)}
|
)}
|
||||||
|
{tier.offSale && (
|
||||||
|
<StatusBadge tone="warning" icon="alert">
|
||||||
|
{t('off-sale.badge')}
|
||||||
|
</StatusBadge>
|
||||||
|
)}
|
||||||
{showsDiscount && promo.percentValue !== null && (
|
{showsDiscount && promo.percentValue !== null && (
|
||||||
<Tag variant="discount" icon={null}>
|
<Tag variant="discount" icon={null}>
|
||||||
{t('card.discount', {
|
{t('card.discount', {
|
||||||
|
|
@ -112,7 +127,7 @@ export function TierCard({ tier, model, layout, onPickDate }: TierCardProps) {
|
||||||
error={priceError}
|
error={priceError}
|
||||||
hint={
|
hint={
|
||||||
tier.perMonthToman === null
|
tier.perMonthToman === null
|
||||||
? t('form.floor', { floor: price(tier.floorTomanPerMonth) })
|
? floorHint
|
||||||
: t('form.per-month', { amount: price(tier.perMonthToman) })
|
: t('form.per-month', { amount: price(tier.perMonthToman) })
|
||||||
}
|
}
|
||||||
locked={locked}
|
locked={locked}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,13 @@ export function useFieldMessage() {
|
||||||
case 'required':
|
case 'required':
|
||||||
return t('form.errors.required');
|
return t('form.errors.required');
|
||||||
case 'below-floor':
|
case 'below-floor':
|
||||||
return t('form.errors.below-floor', { floor: price(issue.floor) });
|
return issue.period === 'monthly'
|
||||||
|
? t('form.errors.below-floor', { floor: price(issue.floor) })
|
||||||
|
: t('form.errors.below-floor-long', {
|
||||||
|
floor: price(issue.floor),
|
||||||
|
total: price(issue.floorTotal),
|
||||||
|
period: t(`form.total-of.${issue.period}`),
|
||||||
|
});
|
||||||
case 'per-month-increase':
|
case 'per-month-increase':
|
||||||
return t('form.errors.per-month-increase', {
|
return t('form.errors.per-month-increase', {
|
||||||
amount: price(issue.amount),
|
amount: price(issue.amount),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
|
|
||||||
|
import type { PricingCardPartModel } from '../../../../../../../features/pricing';
|
||||||
|
import { PricingCard } from './PricingCard';
|
||||||
|
|
||||||
|
const model = vi.hoisted(() => ({ current: null as unknown }));
|
||||||
|
|
||||||
|
vi.mock('../../../../../../../features/pricing', () => ({
|
||||||
|
usePricingCardPart: () => model.current,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('react-i18next', () => ({
|
||||||
|
useTranslation: () => ({
|
||||||
|
t: (key: string, options?: Record<string, string>) =>
|
||||||
|
options?.tier ? `${key}:${options.tier}` : key,
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const plan = (billingPeriod: 'monthly' | 'yearly', offSale = false) => ({
|
||||||
|
billingPeriod,
|
||||||
|
offSale,
|
||||||
|
priceToman: 400000,
|
||||||
|
perMonthToman: 400000,
|
||||||
|
promotion: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
const base: PricingCardPartModel = {
|
||||||
|
isEmpty: false,
|
||||||
|
plans: [plan('monthly'), plan('yearly', true)],
|
||||||
|
offSale: ['yearly'],
|
||||||
|
lockedUntil: null,
|
||||||
|
verification: 'approved',
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('PricingCard off sale', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
model.current = base;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('marks only the plan the floor took off sale', () => {
|
||||||
|
render(<PricingCard layout="desktop" />);
|
||||||
|
expect(screen.getAllByText('off-sale.badge')).toHaveLength(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows a banner per plan, with its name and «اصلاح قیمت» to the editor', () => {
|
||||||
|
render(<PricingCard layout="desktop" />);
|
||||||
|
expect(
|
||||||
|
screen.getByText('off-sale.banner:common:billing-periods.yearly'),
|
||||||
|
).toBeTruthy();
|
||||||
|
const action = screen.getByRole('link', { name: 'off-sale.action' });
|
||||||
|
expect(action.getAttribute('href')).toBe('/dashboard/pricing');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows neither while everything is on sale', () => {
|
||||||
|
model.current = {
|
||||||
|
...base,
|
||||||
|
plans: [plan('monthly')],
|
||||||
|
offSale: [],
|
||||||
|
};
|
||||||
|
render(<PricingCard layout="desktop" />);
|
||||||
|
expect(screen.queryByText('off-sale.badge')).toBeNull();
|
||||||
|
expect(screen.queryByRole('link', { name: 'off-sale.action' })).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -24,7 +24,8 @@ import type { PricingCardProps } from './types';
|
||||||
* notice «قیمتها را هر ۷ روز یکبار میتوانید تغییر دهید.» sits under the plans and the button
|
* notice «قیمتها را هر ۷ روز یکبار میتوانید تغییر دهید.» sits under the plans and the button
|
||||||
* stays live, since promotions stay editable (1c). A creator not yet verified, or rejected, sees
|
* stays live, since promotions stay editable (1c). A creator not yet verified, or rejected, sees
|
||||||
* that status above the card as a link to the identity block (1e), pending with «بررسی معمولاً تا
|
* that status above the card as a link to the identity block (1e), pending with «بررسی معمولاً تا
|
||||||
* ۲۴ ساعت طول میکشد.» beside it; prices stay editable.
|
* ۲۴ ساعت طول میکشد.» beside it; prices stay editable. A plan the price floor took off sale gets a
|
||||||
|
* banner above the card with «اصلاح قیمت» and a badge on its row (J10-1h).
|
||||||
*/
|
*/
|
||||||
export function PricingCard({ layout }: PricingCardProps) {
|
export function PricingCard({ layout }: PricingCardProps) {
|
||||||
const { t } = useTranslation(['pricing', 'common']);
|
const { t } = useTranslation(['pricing', 'common']);
|
||||||
|
|
@ -60,6 +61,26 @@ export function PricingCard({ layout }: PricingCardProps) {
|
||||||
</Link>
|
</Link>
|
||||||
</FlexBox>
|
</FlexBox>
|
||||||
)}
|
)}
|
||||||
|
{model.offSale.map((period) => (
|
||||||
|
<Banner
|
||||||
|
key={period}
|
||||||
|
tone="warning"
|
||||||
|
icon="alert"
|
||||||
|
action={
|
||||||
|
<Button
|
||||||
|
href={ROUTES.dashboard.pricing}
|
||||||
|
variant="secondary"
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
{t('off-sale.action')}
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{t('off-sale.banner', {
|
||||||
|
tier: t(`common:billing-periods.${period}`),
|
||||||
|
})}
|
||||||
|
</Banner>
|
||||||
|
))}
|
||||||
<Card
|
<Card
|
||||||
tag="section"
|
tag="section"
|
||||||
aria-labelledby={headingId}
|
aria-labelledby={headingId}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { Amount } from '@lumina/island/atoms/amount';
|
import { Amount } from '@lumina/island/atoms/amount';
|
||||||
import { Countdown } from '@lumina/island/atoms/countdown';
|
import { Countdown } from '@lumina/island/atoms/countdown';
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
||||||
|
import { StatusBadge } from '@lumina/island/atoms/status-badge';
|
||||||
import { Tag } from '@lumina/island/atoms/tag';
|
import { Tag } from '@lumina/island/atoms/tag';
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
import { Typography } from '@lumina/island/atoms/typography';
|
||||||
import { cn } from '@lumina/island/tools/cn';
|
import { cn } from '@lumina/island/tools/cn';
|
||||||
|
|
@ -13,7 +14,7 @@ import type { PlanRowProps } from '../types';
|
||||||
/**
|
/**
|
||||||
* One offered plan (Creator Dashboard ۲.۱, ۲.۲): its period and per-month equivalent, the period
|
* 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
|
* 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.
|
* the struck standing total over the promotional one. A plan the price floor took off sale says so.
|
||||||
*/
|
*/
|
||||||
export function PlanRow({ plan, divided }: PlanRowProps) {
|
export function PlanRow({ plan, divided }: PlanRowProps) {
|
||||||
const { t } = useTranslation(['pricing', 'common']);
|
const { t } = useTranslation(['pricing', 'common']);
|
||||||
|
|
@ -33,6 +34,11 @@ export function PlanRow({ plan, divided }: PlanRowProps) {
|
||||||
<Typography tag="span" className="font-semibold">
|
<Typography tag="span" className="font-semibold">
|
||||||
{t(`common:billing-periods.${plan.billingPeriod}`)}
|
{t(`common:billing-periods.${plan.billingPeriod}`)}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
{plan.offSale && (
|
||||||
|
<StatusBadge tone="warning" icon="alert">
|
||||||
|
{t('off-sale.badge')}
|
||||||
|
</StatusBadge>
|
||||||
|
)}
|
||||||
{promo && (
|
{promo && (
|
||||||
<Tag variant="discount" icon={null}>
|
<Tag variant="discount" icon={null}>
|
||||||
{t('card.discount', { percent: percent(promo.percent, 0) })}
|
{t('card.discount', { percent: percent(promo.percent, 0) })}
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,11 @@ export function RenewalForm({
|
||||||
<Typography tag="h3" id={headingId} variant="label">
|
<Typography tag="h3" id={headingId} variant="label">
|
||||||
{t('subscriptions.renewal.tiers')}
|
{t('subscriptions.renewal.tiers')}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
{tiers.length === 0 && (
|
||||||
|
<Banner tone="info" icon="info">
|
||||||
|
{t('subscriptions.renewal.none-on-sale')}
|
||||||
|
</Banner>
|
||||||
|
)}
|
||||||
<FlexBox
|
<FlexBox
|
||||||
role="radiogroup"
|
role="radiogroup"
|
||||||
aria-labelledby={headingId}
|
aria-labelledby={headingId}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ export const NOTIFICATION_ART: Record<NotificationType, NotificationArt> = {
|
||||||
// From the admin panel (J11-7d, J11-7e).
|
// From the admin panel (J11-7d, J11-7e).
|
||||||
subscription_extended: { icon: 'calendar', tone: 'brand' },
|
subscription_extended: { icon: 'calendar', tone: 'brand' },
|
||||||
rules_updated: { icon: 'file', tone: 'brand' },
|
rules_updated: { icon: 'file', tone: 'brand' },
|
||||||
|
tier_off_sale: { icon: 'alert', tone: 'warning' },
|
||||||
subscription_refunded: { icon: 'receipt', tone: 'neutral' },
|
subscription_refunded: { icon: 'receipt', tone: 'neutral' },
|
||||||
// Capacity opened, with the investor's code ready (J06-7e).
|
// Capacity opened, with the investor's code ready (J06-7e).
|
||||||
waitlist_capacity: { icon: 'tag', tone: 'brand' },
|
waitlist_capacity: { icon: 'tag', tone: 'brand' },
|
||||||
|
|
|
||||||
|
|
@ -307,6 +307,11 @@ export function useCheckoutPage({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isConnectionError(error)) setIsOffline(true);
|
if (isConnectionError(error)) setIsOffline(true);
|
||||||
|
// The plan just left sale: the list reads again without it, and nothing stays picked.
|
||||||
|
if (code === CHECKOUT_ERROR_CODES.tierUnavailable) {
|
||||||
|
form.setValue('tierId', '');
|
||||||
|
refreshScreen();
|
||||||
|
}
|
||||||
// An active subscription or a payment in flight: reloading sends the investor to the channel.
|
// An active subscription or a payment in flight: reloading sends the investor to the channel.
|
||||||
const options = {
|
const options = {
|
||||||
t,
|
t,
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ export const CHECKOUT_ERROR_CODES = {
|
||||||
paymentPending: 'CHECKOUT_PAYMENT_PENDING',
|
paymentPending: 'CHECKOUT_PAYMENT_PENDING',
|
||||||
/** 403: the creator was suspended (or is no longer approved) since checkout opened. */
|
/** 403: the creator was suspended (or is no longer approved) since checkout opened. */
|
||||||
unavailable: 'CHECKOUT_UNAVAILABLE',
|
unavailable: 'CHECKOUT_UNAVAILABLE',
|
||||||
|
/** 409: the plan is off sale, below the price floor, on subscribe, renew and reactivate alike. */
|
||||||
|
tierUnavailable: 'tier_unavailable',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -48,6 +50,7 @@ export const CHECKOUT_ERROR_COPY = {
|
||||||
alreadyActive: 'errors:checkout.already-active',
|
alreadyActive: 'errors:checkout.already-active',
|
||||||
paymentPending: 'errors:checkout.payment-pending',
|
paymentPending: 'errors:checkout.payment-pending',
|
||||||
unavailable: 'errors:checkout.unavailable',
|
unavailable: 'errors:checkout.unavailable',
|
||||||
|
tierUnavailable: 'errors:checkout.tier-unavailable',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/** Each checkout code's copy, and the `*Args` field it belongs to when it has one. */
|
/** Each checkout code's copy, and the `*Args` field it belongs to when it has one. */
|
||||||
|
|
@ -72,4 +75,7 @@ export const CHECKOUT_ERROR_RULES: Record<
|
||||||
[CHECKOUT_ERROR_CODES.unavailable]: {
|
[CHECKOUT_ERROR_CODES.unavailable]: {
|
||||||
message: CHECKOUT_ERROR_COPY.unavailable,
|
message: CHECKOUT_ERROR_COPY.unavailable,
|
||||||
},
|
},
|
||||||
|
[CHECKOUT_ERROR_CODES.tierUnavailable]: {
|
||||||
|
message: CHECKOUT_ERROR_COPY.tierUnavailable,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { HttpError } from '@lumina/libs/http';
|
||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
|
import { CHECKOUT_ERROR_CODES } from './constants';
|
||||||
|
import { checkoutErrorCode, toCheckoutError } from './errors';
|
||||||
|
|
||||||
|
const refusal = (code: string) =>
|
||||||
|
new HttpError({ code, message: 'server text', status: 409 });
|
||||||
|
|
||||||
|
describe('tier_unavailable', () => {
|
||||||
|
it('gets its own copy and code on subscribe, renew and reactivate alike', () => {
|
||||||
|
const error = toCheckoutError(refusal('tier_unavailable')) as HttpError;
|
||||||
|
expect(error.message).toBe('errors:checkout.tier-unavailable');
|
||||||
|
expect(checkoutErrorCode(error)).toBe(CHECKOUT_ERROR_CODES.tierUnavailable);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('leaves any other code alone', () => {
|
||||||
|
const other = refusal('SOMETHING_ELSE');
|
||||||
|
expect(toCheckoutError(other)).toBe(other);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -36,4 +36,5 @@ export const NOTIFICATION_CATEGORY: Partial<
|
||||||
account_reinstated: 'account',
|
account_reinstated: 'account',
|
||||||
capacity_request_result: 'account',
|
capacity_request_result: 'account',
|
||||||
invite_code_deactivated: 'account',
|
invite_code_deactivated: 'account',
|
||||||
|
tier_off_sale: 'account',
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
* that an admin corrected one of their predictions (with the reason as its body).
|
* that an admin corrected one of their predictions (with the reason as its body).
|
||||||
*
|
*
|
||||||
* `rules_updated` tells every user a major version of the rules is out (links to /terms).
|
* `rules_updated` tells every user a major version of the rules is out (links to /terms).
|
||||||
|
* `tier_off_sale` tells a creator the price floor took a plan off sale (links to طرحهای اشتراک).
|
||||||
*
|
*
|
||||||
* From the admin panel (J11-7): `subscription_extended` tells an investor their subscription got
|
* From the admin panel (J11-7): `subscription_extended` tells an investor their subscription got
|
||||||
* extra days (with the new expiry), `subscription_refunded` that money was paid back and the
|
* extra days (with the new expiry), `subscription_refunded` that money was paid back and the
|
||||||
|
|
@ -32,6 +33,7 @@ export type NotificationType =
|
||||||
| 'subscription_expired_suspended'
|
| 'subscription_expired_suspended'
|
||||||
| 'subscription_extended'
|
| 'subscription_extended'
|
||||||
| 'rules_updated'
|
| 'rules_updated'
|
||||||
|
| 'tier_off_sale'
|
||||||
| 'subscription_refunded'
|
| 'subscription_refunded'
|
||||||
| 'payment_pending_review'
|
| 'payment_pending_review'
|
||||||
| 'waitlist_capacity'
|
| 'waitlist_capacity'
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,6 @@ export const PRICING_EVENTS = {
|
||||||
saved: 'pricing.saved',
|
saved: 'pricing.saved',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/** A promotion's lowest price per month, for every period (C7 ۷.۱). Mirrors the API's floor. */
|
|
||||||
export const PROMO_FLOOR_TOMAN_PER_MONTH = 99_000;
|
|
||||||
|
|
||||||
/** Suggested and promotional prices round down to this step (C7 ۷.۱). */
|
/** Suggested and promotional prices round down to this step (C7 ۷.۱). */
|
||||||
export const PRICE_ROUND_STEP_TOMAN = 1_000;
|
export const PRICE_ROUND_STEP_TOMAN = 1_000;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,10 @@ export type PricingTierEntity = {
|
||||||
perMonthEquivalentFa: string | null;
|
perMonthEquivalentFa: string | null;
|
||||||
floorTomanPerMonth: number;
|
floorTomanPerMonth: number;
|
||||||
floorHelperFa: string;
|
floorHelperFa: string;
|
||||||
|
promoFloorHintFa: string;
|
||||||
|
/** Below the price floor: hidden from buyers until a valid price is saved. */
|
||||||
|
offSale: boolean;
|
||||||
|
offSaleBannerFa: string | null;
|
||||||
priceFieldLabelFa: string;
|
priceFieldLabelFa: string;
|
||||||
suggestedPriceToman: number | null;
|
suggestedPriceToman: number | null;
|
||||||
suggestionHintFa: string | null;
|
suggestionHintFa: string | null;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
import './types';
|
import './types';
|
||||||
|
|
||||||
export { savePricing } from './actions/save-pricing';
|
export { savePricing } from './actions/save-pricing';
|
||||||
export {
|
export { PRICE_ROUND_STEP_TOMAN, PRICING_EVENTS } from './constants';
|
||||||
PRICE_ROUND_STEP_TOMAN,
|
|
||||||
PRICING_EVENTS,
|
|
||||||
PROMO_FLOOR_TOMAN_PER_MONTH,
|
|
||||||
} from './constants';
|
|
||||||
export { usePricingPage } from './models/pricing';
|
export { usePricingPage } from './models/pricing';
|
||||||
export type {
|
export type {
|
||||||
PricingFieldMessage,
|
PricingFieldMessage,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import type {
|
||||||
/** A priced, offered plan as the «قیمت طرحها» card lists it. */
|
/** A priced, offered plan as the «قیمت طرحها» card lists it. */
|
||||||
export type PricingPlanRow = {
|
export type PricingPlanRow = {
|
||||||
billingPeriod: BillingPeriod;
|
billingPeriod: BillingPeriod;
|
||||||
|
/** Below the price floor: hidden from buyers until a valid price is saved. */
|
||||||
|
offSale: boolean;
|
||||||
/** The standing period total. */
|
/** The standing period total. */
|
||||||
priceToman: number;
|
priceToman: number;
|
||||||
perMonthToman: number;
|
perMonthToman: number;
|
||||||
|
|
@ -23,6 +25,8 @@ export type PricingCardPartModel = {
|
||||||
/** Nothing priced yet: one line and «تعیین قیمتها» (۲.۴). */
|
/** Nothing priced yet: one line and «تعیین قیمتها» (۲.۴). */
|
||||||
isEmpty: boolean;
|
isEmpty: boolean;
|
||||||
plans: PricingPlanRow[];
|
plans: PricingPlanRow[];
|
||||||
|
/** The plans the price floor took off sale: each gets a banner with «اصلاح قیمت». */
|
||||||
|
offSale: BillingPeriod[];
|
||||||
/** During the 7-day lock: when standing prices open again (۲.۳). */
|
/** During the 7-day lock: when standing prices open again (۲.۳). */
|
||||||
lockedUntil: string | null;
|
lockedUntil: string | null;
|
||||||
verification: VerificationStatus;
|
verification: VerificationStatus;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import type { PricingCardPartModel, PricingPlanRow } from './types';
|
||||||
/**
|
/**
|
||||||
* طرحهای اشتراک › «قیمت طرحها» (Creator Dashboard ۲.۱–۲.۵): each offered, priced plan with its
|
* طرحهای اشتراک › «قیمت طرحها» (Creator Dashboard ۲.۱–۲.۵): each offered, priced plan with its
|
||||||
* total and per-month equivalent, a running promotion over its struck standing price, the lock's
|
* total and per-month equivalent, a running promotion over its struck standing price, the lock's
|
||||||
* end, and the creator's verification for the badge above. The C7 page reads the same query, so a
|
* end, the tiers the price floor took off sale, and the creator's verification for the badge above. The C7 page reads the same query, so a
|
||||||
* save there shows here at once.
|
* save there shows here at once.
|
||||||
*/
|
*/
|
||||||
export function usePricingCardPart(): PricingCardPartModel {
|
export function usePricingCardPart(): PricingCardPartModel {
|
||||||
|
|
@ -23,6 +23,7 @@ export function usePricingCardPart(): PricingCardPartModel {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
billingPeriod: tier.billingPeriod,
|
billingPeriod: tier.billingPeriod,
|
||||||
|
offSale: tier.offSale,
|
||||||
priceToman: tier.priceToman,
|
priceToman: tier.priceToman,
|
||||||
perMonthToman:
|
perMonthToman:
|
||||||
tier.perMonthToman ?? Math.round(tier.priceToman / months),
|
tier.perMonthToman ?? Math.round(tier.priceToman / months),
|
||||||
|
|
@ -43,6 +44,9 @@ export function usePricingCardPart(): PricingCardPartModel {
|
||||||
return {
|
return {
|
||||||
isEmpty: data.firstTimeSetup || plans.length === 0,
|
isEmpty: data.firstTimeSetup || plans.length === 0,
|
||||||
plans,
|
plans,
|
||||||
|
offSale: plans
|
||||||
|
.filter((plan) => plan.offSale)
|
||||||
|
.map((plan) => plan.billingPeriod),
|
||||||
lockedUntil: data.cooldown.locked ? data.cooldown.editableAt : null,
|
lockedUntil: data.cooldown.locked ? data.cooldown.editableAt : null,
|
||||||
verification: data.verification.status,
|
verification: data.verification.status,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,167 @@
|
||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
|
import { checkPricingDraft, floorTotal, perMonth } from './pricing-rules';
|
||||||
|
import type { PricingFormValues, PricingTierValues } from './types';
|
||||||
|
|
||||||
|
const FLOOR = 199000;
|
||||||
|
|
||||||
|
const tier = (price: string, over: Partial<PricingTierValues> = {}) => ({
|
||||||
|
enabled: price !== '',
|
||||||
|
priceToman: price,
|
||||||
|
promotion: {
|
||||||
|
enabled: false,
|
||||||
|
percent: '',
|
||||||
|
startsAt: null,
|
||||||
|
endsAt: null,
|
||||||
|
indefinite: true,
|
||||||
|
},
|
||||||
|
...over,
|
||||||
|
});
|
||||||
|
const values = (
|
||||||
|
over: Partial<PricingFormValues['tiers']> = {},
|
||||||
|
): PricingFormValues => ({
|
||||||
|
tiers: {
|
||||||
|
monthly: tier('400000'),
|
||||||
|
quarterly: tier(''),
|
||||||
|
semi_annual: tier(''),
|
||||||
|
yearly: tier(''),
|
||||||
|
...over,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const withPromotion = (price: string, percent: string) =>
|
||||||
|
tier(price, {
|
||||||
|
promotion: {
|
||||||
|
enabled: true,
|
||||||
|
percent,
|
||||||
|
startsAt: null,
|
||||||
|
endsAt: null,
|
||||||
|
indefinite: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('floorTotal', () => {
|
||||||
|
it.each([
|
||||||
|
['monthly', 199000],
|
||||||
|
['quarterly', 597000],
|
||||||
|
['semi_annual', 1194000],
|
||||||
|
['yearly', 2388000],
|
||||||
|
] as const)('%s needs %d at 199,000 a month', (period, total) => {
|
||||||
|
expect(floorTotal(FLOOR, period)).toBe(total);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('checkPricingDraft floor', () => {
|
||||||
|
it('passes a price exactly at the floor', () => {
|
||||||
|
expect(
|
||||||
|
checkPricingDraft(values({ monthly: tier('199000') }), FLOOR),
|
||||||
|
).toEqual({});
|
||||||
|
expect(
|
||||||
|
checkPricingDraft(
|
||||||
|
values({ monthly: tier('199000'), quarterly: tier('597000') }),
|
||||||
|
FLOOR,
|
||||||
|
),
|
||||||
|
).toEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('refuses a monthly price under the floor, naming the floor', () => {
|
||||||
|
const issues = checkPricingDraft(
|
||||||
|
values({ monthly: tier('198000') }),
|
||||||
|
FLOOR,
|
||||||
|
);
|
||||||
|
expect(issues['tiers.monthly.priceToman']).toEqual({
|
||||||
|
code: 'below-floor',
|
||||||
|
floor: FLOOR,
|
||||||
|
floorTotal: FLOOR,
|
||||||
|
period: 'monthly',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('compares the exact total, so per-month rounding lets nothing under', () => {
|
||||||
|
expect(perMonth(596999, 'quarterly')).toBe(FLOOR);
|
||||||
|
const issues = checkPricingDraft(
|
||||||
|
values({ quarterly: tier('596999') }),
|
||||||
|
FLOOR,
|
||||||
|
);
|
||||||
|
expect(issues['tiers.quarterly.priceToman']).toEqual({
|
||||||
|
code: 'below-floor',
|
||||||
|
floor: FLOOR,
|
||||||
|
floorTotal: 597000,
|
||||||
|
period: 'quarterly',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('uses the same floor for every period, with no older per-tier one', () => {
|
||||||
|
const issues = checkPricingDraft(
|
||||||
|
values({
|
||||||
|
monthly: tier('250000'),
|
||||||
|
quarterly: tier('600000'),
|
||||||
|
semi_annual: tier('1200000'),
|
||||||
|
yearly: tier('2388000'),
|
||||||
|
}),
|
||||||
|
FLOOR,
|
||||||
|
);
|
||||||
|
expect(issues).toEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('follows a floor the admin raised', () => {
|
||||||
|
const issues = checkPricingDraft(
|
||||||
|
values({ monthly: tier('240000') }),
|
||||||
|
250000,
|
||||||
|
);
|
||||||
|
expect(issues['tiers.monthly.priceToman']).toMatchObject({ floor: 250000 });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores a switched-off period', () => {
|
||||||
|
expect(
|
||||||
|
checkPricingDraft(
|
||||||
|
values({ quarterly: { ...tier('100000'), enabled: false } }),
|
||||||
|
FLOOR,
|
||||||
|
),
|
||||||
|
).toEqual({});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('checkPricingDraft promotion floor', () => {
|
||||||
|
it('refuses a discount that lands under the floor, with the discounted month', () => {
|
||||||
|
const issues = checkPricingDraft(
|
||||||
|
values({ monthly: withPromotion('300000', '50') }),
|
||||||
|
FLOOR,
|
||||||
|
);
|
||||||
|
expect(issues['tiers.monthly.promotion.percent']).toEqual({
|
||||||
|
code: 'promo-floor',
|
||||||
|
amount: 150000,
|
||||||
|
floor: FLOOR,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('passes a discount that lands exactly on the floor', () => {
|
||||||
|
const issues = checkPricingDraft(
|
||||||
|
values({ monthly: withPromotion('398000', '50') }),
|
||||||
|
FLOOR,
|
||||||
|
);
|
||||||
|
expect(issues['tiers.monthly.promotion.percent']).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has no separate, lower promotion floor', () => {
|
||||||
|
const issues = checkPricingDraft(
|
||||||
|
values({ monthly: withPromotion('200000', '10') }),
|
||||||
|
FLOOR,
|
||||||
|
);
|
||||||
|
expect(issues['tiers.monthly.promotion.percent']).toMatchObject({
|
||||||
|
code: 'promo-floor',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('compares the discounted total exactly on a long period', () => {
|
||||||
|
const issues = checkPricingDraft(
|
||||||
|
values({
|
||||||
|
monthly: tier('400000'),
|
||||||
|
quarterly: withPromotion('1192000', '50'),
|
||||||
|
}),
|
||||||
|
FLOOR,
|
||||||
|
);
|
||||||
|
expect(issues['tiers.quarterly.promotion.percent']).toMatchObject({
|
||||||
|
code: 'promo-floor',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -4,10 +4,7 @@ import {
|
||||||
} from '../../../../shared/constants';
|
} from '../../../../shared/constants';
|
||||||
import type { BillingPeriod } from '../../../../shared/constants';
|
import type { BillingPeriod } from '../../../../shared/constants';
|
||||||
import { toPriceNumber } from '../../../../shared/utils';
|
import { toPriceNumber } from '../../../../shared/utils';
|
||||||
import {
|
import { PRICE_ROUND_STEP_TOMAN } from '../../constants';
|
||||||
PRICE_ROUND_STEP_TOMAN,
|
|
||||||
PROMO_FLOOR_TOMAN_PER_MONTH,
|
|
||||||
} from '../../constants';
|
|
||||||
import type {
|
import type {
|
||||||
PricingFieldName,
|
PricingFieldName,
|
||||||
SavePricingArgs,
|
SavePricingArgs,
|
||||||
|
|
@ -15,7 +12,8 @@ import type {
|
||||||
import type { PricingFormValues, PricingIssue } from './types';
|
import type { PricingFormValues, PricingIssue } from './types';
|
||||||
|
|
||||||
// The C7 rules (§۳, §۴, §۷.۱) the API enforces, checked as the creator types so nothing waits for
|
// The C7 rules (§۳, §۴, §۷.۱) the API enforces, checked as the creator types so nothing waits for
|
||||||
// a save to say what is wrong. Same order and same first-message-per-field as the API.
|
// a save to say what is wrong. Same order and same first-message-per-field as the API. The floor is
|
||||||
|
// the one the API reports, compared on the exact total, so rounding per month lets nothing under it.
|
||||||
|
|
||||||
/** A typed total as whole Toman; `null` while empty or not a number. */
|
/** A typed total as whole Toman; `null` while empty or not a number. */
|
||||||
export function toToman(text: string): number | null {
|
export function toToman(text: string): number | null {
|
||||||
|
|
@ -29,6 +27,14 @@ export function perMonth(total: number, period: BillingPeriod): number {
|
||||||
return Math.round(total / BILLING_PERIOD_MONTHS[period]);
|
return Math.round(total / BILLING_PERIOD_MONTHS[period]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The least a total of this period may be at this monthly floor. */
|
||||||
|
export function floorTotal(
|
||||||
|
floorPerMonth: number,
|
||||||
|
period: BillingPeriod,
|
||||||
|
): number {
|
||||||
|
return floorPerMonth * BILLING_PERIOD_MONTHS[period];
|
||||||
|
}
|
||||||
|
|
||||||
/** The promotional total, rounded down to 1,000 so the investor gets at least the advertised discount. */
|
/** The promotional total, rounded down to 1,000 so the investor gets at least the advertised discount. */
|
||||||
export function promotionalTotal(total: number, percent: number): number {
|
export function promotionalTotal(total: number, percent: number): number {
|
||||||
const raw = (total * (100 - percent)) / 100;
|
const raw = (total * (100 - percent)) / 100;
|
||||||
|
|
@ -51,7 +57,7 @@ export type PromotionStartContext = {
|
||||||
|
|
||||||
export function checkPricingDraft(
|
export function checkPricingDraft(
|
||||||
values: PricingFormValues,
|
values: PricingFormValues,
|
||||||
floors: Record<BillingPeriod, number>,
|
floorPerMonth: number,
|
||||||
starts?: PromotionStartContext,
|
starts?: PromotionStartContext,
|
||||||
): Partial<Record<PricingFieldName, PricingIssue>> {
|
): Partial<Record<PricingFieldName, PricingIssue>> {
|
||||||
const issues: Partial<Record<PricingFieldName, PricingIssue>> = {};
|
const issues: Partial<Record<PricingFieldName, PricingIssue>> = {};
|
||||||
|
|
@ -68,10 +74,12 @@ export function checkPricingDraft(
|
||||||
add(`tiers.${period}.priceToman`, { code: 'required' });
|
add(`tiers.${period}.priceToman`, { code: 'required' });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (perMonth(total, period) < floors[period]) {
|
if (total < floorTotal(floorPerMonth, period)) {
|
||||||
add(`tiers.${period}.priceToman`, {
|
add(`tiers.${period}.priceToman`, {
|
||||||
code: 'below-floor',
|
code: 'below-floor',
|
||||||
floor: floors[period],
|
floor: floorPerMonth,
|
||||||
|
floorTotal: floorTotal(floorPerMonth, period),
|
||||||
|
period,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -103,15 +111,12 @@ export function checkPricingDraft(
|
||||||
} else {
|
} else {
|
||||||
const total = toToman(values.tiers[period].priceToman);
|
const total = toToman(values.tiers[period].priceToman);
|
||||||
if (total !== null) {
|
if (total !== null) {
|
||||||
const promoPerMonth = perMonth(
|
const promoTotal = promotionalTotal(total, percent);
|
||||||
promotionalTotal(total, percent),
|
if (promoTotal < floorTotal(floorPerMonth, period)) {
|
||||||
period,
|
|
||||||
);
|
|
||||||
if (promoPerMonth < PROMO_FLOOR_TOMAN_PER_MONTH) {
|
|
||||||
add(`tiers.${period}.promotion.percent`, {
|
add(`tiers.${period}.promotion.percent`, {
|
||||||
code: 'promo-floor',
|
code: 'promo-floor',
|
||||||
amount: promoPerMonth,
|
amount: perMonth(promoTotal, period),
|
||||||
floor: PROMO_FLOOR_TOMAN_PER_MONTH,
|
floor: floorPerMonth,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,12 @@ export type PricingFormValues = {
|
||||||
/** A broken rule, with what its message needs. */
|
/** A broken rule, with what its message needs. */
|
||||||
export type PricingIssue =
|
export type PricingIssue =
|
||||||
| { code: 'required' }
|
| { code: 'required' }
|
||||||
| { code: 'below-floor'; floor: number }
|
| {
|
||||||
|
code: 'below-floor';
|
||||||
|
floor: number;
|
||||||
|
floorTotal: number;
|
||||||
|
period: BillingPeriod;
|
||||||
|
}
|
||||||
| {
|
| {
|
||||||
code: 'per-month-increase';
|
code: 'per-month-increase';
|
||||||
amount: number;
|
amount: number;
|
||||||
|
|
@ -81,7 +86,13 @@ export type PricingTierView = {
|
||||||
priceMessage: PricingFieldMessage | null;
|
priceMessage: PricingFieldMessage | null;
|
||||||
/** The per-month equivalent of a valid total. */
|
/** The per-month equivalent of a valid total. */
|
||||||
perMonthToman: number | null;
|
perMonthToman: number | null;
|
||||||
|
/** The least this period's total may be, after any discount. */
|
||||||
|
floorTotalToman: number;
|
||||||
floorTomanPerMonth: number;
|
floorTomanPerMonth: number;
|
||||||
|
/** Below the floor: hidden from buyers until a valid price is saved («خارج از فروش»). */
|
||||||
|
offSale: boolean;
|
||||||
|
/** Its price and switch are read-only: the lock runs, and the floor didn't take it off sale. */
|
||||||
|
locked: boolean;
|
||||||
/** Switched off while it carries running subscriptions: they run to their end (۲.۲). */
|
/** Switched off while it carries running subscriptions: they run to their end (۲.۲). */
|
||||||
disableNoteCount: number | null;
|
disableNoteCount: number | null;
|
||||||
promotion: PricingPromotionView;
|
promotion: PricingPromotionView;
|
||||||
|
|
@ -102,6 +113,8 @@ export type PricingPageModel = {
|
||||||
prePurchase: boolean;
|
prePurchase: boolean;
|
||||||
/** Standing prices and periods frozen until this date; promotions stay live (۶.۲). */
|
/** Standing prices and periods frozen until this date; promotions stay live (۶.۲). */
|
||||||
lockedUntil: string | null;
|
lockedUntil: string | null;
|
||||||
|
/** A tier is off sale: its price stays editable through the lock, so the save is a full one. */
|
||||||
|
hasOffSale: boolean;
|
||||||
tiers: PricingTierView[];
|
tiers: PricingTierView[];
|
||||||
setEnabled: (period: BillingPeriod, enabled: boolean) => void;
|
setEnabled: (period: BillingPeriod, enabled: boolean) => void;
|
||||||
setPrice: (period: BillingPeriod, text: string) => void;
|
setPrice: (period: BillingPeriod, text: string) => void;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import type {
|
||||||
} from '../../repositories/pricing';
|
} from '../../repositories/pricing';
|
||||||
import {
|
import {
|
||||||
checkPricingDraft,
|
checkPricingDraft,
|
||||||
|
floorTotal,
|
||||||
perMonth,
|
perMonth,
|
||||||
pricingFieldId,
|
pricingFieldId,
|
||||||
promotionalTotal,
|
promotionalTotal,
|
||||||
|
|
@ -88,7 +89,8 @@ function defaultPromotionRange(): { startsAt: string; endsAt: string } {
|
||||||
* enabled period only once a save is tried. On first setup, leaving the monthly field fills the longer periods' suggestions. Save
|
* enabled period only once a save is tried. On first setup, leaving the monthly field fills the longer periods' suggestions. Save
|
||||||
* asks the API to check the draft, then confirms in a dialog that lists every period; «تأیید و
|
* asks the API to check the draft, then confirms in a dialog that lists every period; «تأیید و
|
||||||
* ذخیره» stores it, toasts and leaves the page as saved. During the 7-day lock standing prices and
|
* ذخیره» stores it, toasts and leaves the page as saved. During the 7-day lock standing prices and
|
||||||
* the periods are frozen, promotions not. A save that never reached the API keeps everything and
|
* the periods are frozen, promotions not, and so is a tier the floor took off sale, which a valid
|
||||||
|
* price puts back on sale. A save that never reached the API keeps everything and
|
||||||
* offers to try again from the banner.
|
* offers to try again from the banner.
|
||||||
*/
|
*/
|
||||||
export function usePricingPage(): PricingPageModel {
|
export function usePricingPage(): PricingPageModel {
|
||||||
|
|
@ -121,16 +123,12 @@ export function usePricingPage(): PricingPageModel {
|
||||||
});
|
});
|
||||||
|
|
||||||
const locked = payload.cooldown.locked;
|
const locked = payload.cooldown.locked;
|
||||||
const floors = useMemo(
|
const floorPerMonth = payload.floorTomanPerMonth;
|
||||||
() =>
|
const isPriceLocked = (period: BillingPeriod) =>
|
||||||
Object.fromEntries(
|
locked &&
|
||||||
payload.tiers.map((tier) => [
|
!payload.tiers.some(
|
||||||
tier.billingPeriod,
|
(tier) => tier.billingPeriod === period && tier.offSale,
|
||||||
tier.floorTomanPerMonth,
|
);
|
||||||
]),
|
|
||||||
) as Record<BillingPeriod, number>,
|
|
||||||
[payload.tiers],
|
|
||||||
);
|
|
||||||
const savedStarts = useMemo(
|
const savedStarts = useMemo(
|
||||||
() =>
|
() =>
|
||||||
Object.fromEntries(
|
Object.fromEntries(
|
||||||
|
|
@ -143,11 +141,11 @@ export function usePricingPage(): PricingPageModel {
|
||||||
);
|
);
|
||||||
const issues = useMemo(
|
const issues = useMemo(
|
||||||
() =>
|
() =>
|
||||||
checkPricingDraft(values, floors, {
|
checkPricingDraft(values, floorPerMonth, {
|
||||||
saved: savedStarts,
|
saved: savedStarts,
|
||||||
notBefore: openedAt,
|
notBefore: openedAt,
|
||||||
}),
|
}),
|
||||||
[values, floors, savedStarts, openedAt],
|
[values, floorPerMonth, savedStarts, openedAt],
|
||||||
);
|
);
|
||||||
|
|
||||||
// A rule about a field still empty (an enabled period's price, a promotion's percent or end)
|
// A rule about a field still empty (an enabled period's price, a promotion's percent or end)
|
||||||
|
|
@ -195,7 +193,10 @@ export function usePricingPage(): PricingPageModel {
|
||||||
? messageOf(priceField, current.priceToman !== '')
|
? messageOf(priceField, current.priceToman !== '')
|
||||||
: null,
|
: null,
|
||||||
perMonthToman: total === null ? null : perMonth(total, period),
|
perMonthToman: total === null ? null : perMonth(total, period),
|
||||||
floorTomanPerMonth: tier.floorTomanPerMonth,
|
floorTotalToman: floorTotal(floorPerMonth, period),
|
||||||
|
floorTomanPerMonth: floorPerMonth,
|
||||||
|
offSale: tier.offSale,
|
||||||
|
locked: locked && !tier.offSale,
|
||||||
disableNoteCount:
|
disableNoteCount:
|
||||||
!current.enabled && tier.enabled && tier.activeSubscribers > 0
|
!current.enabled && tier.enabled && tier.activeSubscribers > 0
|
||||||
? tier.activeSubscribers
|
? tier.activeSubscribers
|
||||||
|
|
@ -301,6 +302,8 @@ export function usePricingPage(): PricingPageModel {
|
||||||
const saved = toFormValues(fresh);
|
const saved = toFormValues(fresh);
|
||||||
for (const tier of fresh.tiers) {
|
for (const tier of fresh.tiers) {
|
||||||
const period = tier.billingPeriod;
|
const period = tier.billingPeriod;
|
||||||
|
// The lock never covers a tier the floor took off sale: its edit stays.
|
||||||
|
if (tier.offSale) continue;
|
||||||
form.resetField(`tiers.${period}.enabled`, {
|
form.resetField(`tiers.${period}.enabled`, {
|
||||||
defaultValue: saved.tiers[period].enabled,
|
defaultValue: saved.tiers[period].enabled,
|
||||||
});
|
});
|
||||||
|
|
@ -377,19 +380,20 @@ export function usePricingPage(): PricingPageModel {
|
||||||
verification: payload.verification.status,
|
verification: payload.verification.status,
|
||||||
prePurchase: payload.cooldown.prePurchase,
|
prePurchase: payload.cooldown.prePurchase,
|
||||||
lockedUntil: locked ? payload.cooldown.editableAt : null,
|
lockedUntil: locked ? payload.cooldown.editableAt : null,
|
||||||
|
hasOffSale: payload.tiers.some((tier) => tier.offSale),
|
||||||
tiers,
|
tiers,
|
||||||
setEnabled: (period, enabled) => {
|
setEnabled: (period, enabled) => {
|
||||||
if (locked || period === 'monthly') return;
|
if (isPriceLocked(period) || period === 'monthly') return;
|
||||||
update(`tiers.${period}.enabled`, enabled);
|
update(`tiers.${period}.enabled`, enabled);
|
||||||
},
|
},
|
||||||
setPrice: (period, text) => {
|
setPrice: (period, text) => {
|
||||||
if (locked) return;
|
if (isPriceLocked(period)) return;
|
||||||
update(`tiers.${period}.priceToman`, toAmountText(text));
|
update(`tiers.${period}.priceToman`, toAmountText(text));
|
||||||
},
|
},
|
||||||
blurPrice: (period) => {
|
blurPrice: (period) => {
|
||||||
if (period !== 'monthly' || !payload.firstTimeSetup) return;
|
if (period !== 'monthly' || !payload.firstTimeSetup) return;
|
||||||
const monthly = toToman(form.getValues('tiers.monthly.priceToman'));
|
const monthly = toToman(form.getValues('tiers.monthly.priceToman'));
|
||||||
if (monthly !== null && monthly >= floors.monthly)
|
if (monthly !== null && monthly >= floorPerMonth)
|
||||||
fillSuggestions(monthly);
|
fillSuggestions(monthly);
|
||||||
},
|
},
|
||||||
setPromotionEnabled: (period, enabled) => {
|
setPromotionEnabled: (period, enabled) => {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ function toPricingTierPayload(dto: PricingTierEntity): PricingTierPayload {
|
||||||
enabled: dto.enabled,
|
enabled: dto.enabled,
|
||||||
priceToman: dto.priceToman,
|
priceToman: dto.priceToman,
|
||||||
perMonthToman: dto.perMonthToman,
|
perMonthToman: dto.perMonthToman,
|
||||||
floorTomanPerMonth: dto.floorTomanPerMonth,
|
offSale: dto.offSale,
|
||||||
suggestedPriceToman: dto.suggestedPriceToman,
|
suggestedPriceToman: dto.suggestedPriceToman,
|
||||||
prefillSuggestion: dto.prefillSuggestion,
|
prefillSuggestion: dto.prefillSuggestion,
|
||||||
activeSubscribers: dto.activeSubscribers,
|
activeSubscribers: dto.activeSubscribers,
|
||||||
|
|
@ -46,6 +46,7 @@ export function toPricingFormPayload(
|
||||||
): PricingFormPayload {
|
): PricingFormPayload {
|
||||||
return {
|
return {
|
||||||
firstTimeSetup: dto.firstTimeSetup,
|
firstTimeSetup: dto.firstTimeSetup,
|
||||||
|
floorTomanPerMonth: dto.floorTomanPerMonth,
|
||||||
verification: {
|
verification: {
|
||||||
status: dto.verification.status,
|
status: dto.verification.status,
|
||||||
canBeSubscribedTo: dto.verification.canBeSubscribedTo,
|
canBeSubscribedTo: dto.verification.canBeSubscribedTo,
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ export type PricingFormResponseDto = {
|
||||||
monthlyMandatoryNoteFa: string;
|
monthlyMandatoryNoteFa: string;
|
||||||
existingSubscribersNoteFa: string;
|
existingSubscribersNoteFa: string;
|
||||||
firstTimeSetup: boolean;
|
firstTimeSetup: boolean;
|
||||||
|
/** «کف قیمت»: the least any tier may finally cost per month, after any discount. */
|
||||||
|
floorTomanPerMonth: number;
|
||||||
verification: {
|
verification: {
|
||||||
status: VerificationStatus;
|
status: VerificationStatus;
|
||||||
canBeSubscribedTo: boolean;
|
canBeSubscribedTo: boolean;
|
||||||
|
|
@ -66,8 +68,8 @@ export type PricingTierPayload = {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
priceToman: number | null;
|
priceToman: number | null;
|
||||||
perMonthToman: number | null;
|
perMonthToman: number | null;
|
||||||
/** The lowest allowed price per month for this period. */
|
/** Below the price floor: hidden from buyers, and editable through the 7-day lock. */
|
||||||
floorTomanPerMonth: number;
|
offSale: boolean;
|
||||||
/** Monthly × duration minus the period's discount, from the saved (or previewed) monthly price. */
|
/** Monthly × duration minus the period's discount, from the saved (or previewed) monthly price. */
|
||||||
suggestedPriceToman: number | null;
|
suggestedPriceToman: number | null;
|
||||||
prefillSuggestion: boolean;
|
prefillSuggestion: boolean;
|
||||||
|
|
@ -79,6 +81,8 @@ export type PricingTierPayload = {
|
||||||
export type PricingFormPayload = {
|
export type PricingFormPayload = {
|
||||||
/** Nothing has been priced yet; the longer periods carry the suggestions as prices. */
|
/** Nothing has been priced yet; the longer periods carry the suggestions as prices. */
|
||||||
firstTimeSetup: boolean;
|
firstTimeSetup: boolean;
|
||||||
|
/** «کف قیمت»: the least any tier may finally cost per month, after any discount. */
|
||||||
|
floorTomanPerMonth: number;
|
||||||
verification: {
|
verification: {
|
||||||
status: VerificationStatus;
|
status: VerificationStatus;
|
||||||
canBeSubscribedTo: boolean;
|
canBeSubscribedTo: boolean;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { ROUTES } from '../../../../app/navigation/navigation';
|
import { ROUTES } from '../../../../app/navigation/navigation';
|
||||||
|
import { CHECKOUT_ERROR_CODES, checkoutErrorCode } from '../../../checkout';
|
||||||
import { isConnectionError, showActionError } from '../../../../shared/utils';
|
import { isConnectionError, showActionError } from '../../../../shared/utils';
|
||||||
import { startRenewal } from '../../actions/start-renewal';
|
import { startRenewal } from '../../actions/start-renewal';
|
||||||
import {
|
import {
|
||||||
|
|
@ -22,7 +23,8 @@ import type {
|
||||||
* starts on the current period and extends from the current expiry; reactivate starts with none
|
* starts on the current period and extends from the current expiry; reactivate starts with none
|
||||||
* picked, from today, with no invite code. Paying goes to the bank, and every payment ends on its
|
* picked, from today, with no invite code. Paying goes to the bank, and every payment ends on its
|
||||||
* result page (U10 §۹). A tap that never reached the server keeps the choice and says so. A
|
* result page (U10 §۹). A tap that never reached the server keeps the choice and says so. A
|
||||||
* suspended creator or a payment already in flight is refused with a toast that reloads the list.
|
* suspended creator, a payment already in flight or a plan off sale (below the price floor) is
|
||||||
|
* refused with a toast that reloads the list; an off-sale plan isn't offered at all.
|
||||||
*/
|
*/
|
||||||
export function useRenewalSheet({
|
export function useRenewalSheet({
|
||||||
subscriptionId,
|
subscriptionId,
|
||||||
|
|
@ -55,6 +57,9 @@ export function useRenewalSheet({
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const reload = () => {
|
const reload = () => {
|
||||||
|
void queryClient.invalidateQueries({
|
||||||
|
queryKey: subscriptionKeys.preview(subscriptionId),
|
||||||
|
});
|
||||||
void queryClient.invalidateQueries({
|
void queryClient.invalidateQueries({
|
||||||
queryKey: subscriptionKeys.detail(subscriptionId),
|
queryKey: subscriptionKeys.detail(subscriptionId),
|
||||||
});
|
});
|
||||||
|
|
@ -89,6 +94,11 @@ export function useRenewalSheet({
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setPhase('idle');
|
setPhase('idle');
|
||||||
if (isConnectionError(error)) setIsOffline(true);
|
if (isConnectionError(error)) setIsOffline(true);
|
||||||
|
// The plan just left sale: the list reads again without it, and nothing stays picked.
|
||||||
|
if (checkoutErrorCode(error) === CHECKOUT_ERROR_CODES.tierUnavailable) {
|
||||||
|
setTierId(null);
|
||||||
|
reload();
|
||||||
|
}
|
||||||
showActionError(error, {
|
showActionError(error, {
|
||||||
t,
|
t,
|
||||||
failedMessage:
|
failedMessage:
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,6 @@ export {
|
||||||
PRICING_EVENTS,
|
PRICING_EVENTS,
|
||||||
pricingKeys,
|
pricingKeys,
|
||||||
pricingRepository,
|
pricingRepository,
|
||||||
PROMO_FLOOR_TOMAN_PER_MONTH,
|
|
||||||
savePricing,
|
savePricing,
|
||||||
usePricingCardPart,
|
usePricingCardPart,
|
||||||
usePricingPage,
|
usePricingPage,
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@
|
||||||
"error": "دورههای اشتراک بارگذاری نشد. دوباره تلاش کنید.",
|
"error": "دورههای اشتراک بارگذاری نشد. دوباره تلاش کنید.",
|
||||||
"current": "شما تا {{date}} اشتراک فعال دارید.",
|
"current": "شما تا {{date}} اشتراک فعال دارید.",
|
||||||
"tiers": "دوره اشتراک",
|
"tiers": "دوره اشتراک",
|
||||||
|
"none-on-sale": "این کانال در حال حاضر طرحی برای فروش ندارد. پس از اصلاح قیمتها میتوانید اشتراک را تمدید کنید.",
|
||||||
"from": "تمدید از:",
|
"from": "تمدید از:",
|
||||||
"start": "شروع از:",
|
"start": "شروع از:",
|
||||||
"today": "امروز — {{date}}",
|
"today": "امروز — {{date}}",
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@
|
||||||
"code-invalid": "کد دعوت واردشده معتبر نیست.",
|
"code-invalid": "کد دعوت واردشده معتبر نیست.",
|
||||||
"already-active": "اشتراک شما در این کانال همین حالا فعال است.",
|
"already-active": "اشتراک شما در این کانال همین حالا فعال است.",
|
||||||
"payment-pending": "پرداخت دیگری برای این کانال در حال بررسی است؛ تا روشن شدن نتیجه آن، پرداخت تازهای شروع نمیشود.",
|
"payment-pending": "پرداخت دیگری برای این کانال در حال بررسی است؛ تا روشن شدن نتیجه آن، پرداخت تازهای شروع نمیشود.",
|
||||||
"unavailable": "این کانال در حال حاضر در دسترس نیست."
|
"unavailable": "این کانال در حال حاضر در دسترس نیست.",
|
||||||
|
"tier-unavailable": "این طرح در حال حاضر در فروش نیست. طرح دیگری را انتخاب کنید."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,11 @@
|
||||||
"loading": "در حال بارگذاری قیمت طرحها…",
|
"loading": "در حال بارگذاری قیمت طرحها…",
|
||||||
"error": "قیمت طرحها بارگذاری نشد. دوباره تلاش کنید."
|
"error": "قیمت طرحها بارگذاری نشد. دوباره تلاش کنید."
|
||||||
},
|
},
|
||||||
|
"off-sale": {
|
||||||
|
"badge": "خارج از فروش",
|
||||||
|
"banner": "طرح {{tier}} شما از فروش خارج شد",
|
||||||
|
"action": "اصلاح قیمت"
|
||||||
|
},
|
||||||
"form": {
|
"form": {
|
||||||
"label": "قیمتگذاری اشتراک",
|
"label": "قیمتگذاری اشتراک",
|
||||||
"required-tag": "الزامی",
|
"required-tag": "الزامی",
|
||||||
|
|
@ -26,7 +31,13 @@
|
||||||
"price-label": "قیمت کل دوره",
|
"price-label": "قیمت کل دوره",
|
||||||
"price-label-of": "قیمت کل دوره {{period}}",
|
"price-label-of": "قیمت کل دوره {{period}}",
|
||||||
"currency": "تومان",
|
"currency": "تومان",
|
||||||
"floor": "حداقل قیمت این دوره {{floor}} تومان در ماه است.",
|
"floor": "حداقل {{total}} تومان ({{floor}} در ماه)، حتی بعد از تخفیف.",
|
||||||
|
"floor-monthly": "حداقل {{floor}} تومان در ماه، حتی بعد از تخفیف.",
|
||||||
|
"total-of": {
|
||||||
|
"quarterly": "سه ماه",
|
||||||
|
"semi_annual": "شش ماه",
|
||||||
|
"yearly": "یک سال"
|
||||||
|
},
|
||||||
"per-month": "معادل {{amount}} تومان در ماه",
|
"per-month": "معادل {{amount}} تومان در ماه",
|
||||||
"disable-note": "{{count}} مشترک فعال روی این دوره دارید. با غیرفعال کردن، اشتراک آنها تا پایان دوره ادامه مییابد و فقط این دوره برای کاربران جدید نمایش داده نمیشود.",
|
"disable-note": "{{count}} مشترک فعال روی این دوره دارید. با غیرفعال کردن، اشتراک آنها تا پایان دوره ادامه مییابد و فقط این دوره برای کاربران جدید نمایش داده نمیشود.",
|
||||||
"existing-note": "تغییر قیمت روی مشترکان فعلی تأثیری ندارد. قیمت جدید از زمان تمدید اشتراک آنها اعمال میشود.",
|
"existing-note": "تغییر قیمت روی مشترکان فعلی تأثیری ندارد. قیمت جدید از زمان تمدید اشتراک آنها اعمال میشود.",
|
||||||
|
|
@ -44,9 +55,10 @@
|
||||||
"errors": {
|
"errors": {
|
||||||
"required": "وارد کردن قیمت برای دورههای فعال الزامی است.",
|
"required": "وارد کردن قیمت برای دورههای فعال الزامی است.",
|
||||||
"below-floor": "قیمت این دوره نمیتواند کمتر از {{floor}} تومان در ماه باشد.",
|
"below-floor": "قیمت این دوره نمیتواند کمتر از {{floor}} تومان در ماه باشد.",
|
||||||
|
"below-floor-long": "قیمت این دوره نمیتواند کمتر از {{floor}} تومان در ماه ({{total}} تومان برای {{period}}) باشد.",
|
||||||
"per-month-increase": "قیمت ماهانه این دوره ({{amount}} تومان) نباید بیشتر از دوره {{period}} ({{shorter}} تومان) باشد.",
|
"per-month-increase": "قیمت ماهانه این دوره ({{amount}} تومان) نباید بیشتر از دوره {{period}} ({{shorter}} تومان) باشد.",
|
||||||
"promo-percent": "درصد تخفیف باید بین ۱ تا ۹۹ باشد.",
|
"promo-percent": "درصد تخفیف باید بین ۱ تا ۹۹ باشد.",
|
||||||
"promo-floor": "قیمت با تخفیف ({{amount}} تومان در ماه) نمیتواند کمتر از {{floor}} تومان در ماه باشد.",
|
"promo-floor": "قیمت با تخفیف ({{amount}} تومان در ماه) نمیتواند کمتر از کف {{floor}} تومان در ماه باشد.",
|
||||||
"promo-end-required": "تاریخ و ساعت پایان را انتخاب کنید، یا «بدون تاریخ پایان» را بزنید.",
|
"promo-end-required": "تاریخ و ساعت پایان را انتخاب کنید، یا «بدون تاریخ پایان» را بزنید.",
|
||||||
"promo-start-past": "تاریخ و ساعت شروع نمیتواند در گذشته باشد.",
|
"promo-start-past": "تاریخ و ساعت شروع نمیتواند در گذشته باشد.",
|
||||||
"promo-range": "تاریخ و ساعت پایان باید بعد از شروع باشد."
|
"promo-range": "تاریخ و ساعت پایان باید بعد از شروع باشد."
|
||||||
|
|
@ -59,6 +71,7 @@
|
||||||
"intro": "با فعالکردن، درصد تخفیف و بازه زمانی آن را تعیین میکنید. قیمت پایه این دوره تغییر نمیکند.",
|
"intro": "با فعالکردن، درصد تخفیف و بازه زمانی آن را تعیین میکنید. قیمت پایه این دوره تغییر نمیکند.",
|
||||||
"percent": "درصد تخفیف",
|
"percent": "درصد تخفیف",
|
||||||
"percent-sign": "٪",
|
"percent-sign": "٪",
|
||||||
|
"floor-hint": "قیمت با تخفیف نباید کمتر از {{floor}} تومان در ماه شود.",
|
||||||
"start": "تاریخ و ساعت شروع",
|
"start": "تاریخ و ساعت شروع",
|
||||||
"end": "تاریخ و ساعت پایان",
|
"end": "تاریخ و ساعت پایان",
|
||||||
"indefinite": "بدون تاریخ پایان",
|
"indefinite": "بدون تاریخ پایان",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import { defineConfig } from 'vitest/config';
|
||||||
|
|
||||||
// Component and unit tests of every project; each project's `test` script runs its own folder.
|
// Component and unit tests of every project; each project's `test` script runs its own folder.
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
esbuild: { jsx: 'automatic' },
|
|
||||||
oxc: { jsx: { runtime: 'automatic' } },
|
oxc: { jsx: { runtime: 'automatic' } },
|
||||||
resolve: { conditions: ['@lumina/source'] },
|
resolve: { conditions: ['@lumina/source'] },
|
||||||
test: {
|
test: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue