diff --git a/apps/bear/src/app/(auth)/auth/register/details/page.tsx b/apps/bear/src/app/(auth)/auth/register/details/page.tsx
index 2184ac2..d912169 100644
--- a/apps/bear/src/app/(auth)/auth/register/details/page.tsx
+++ b/apps/bear/src/app/(auth)/auth/register/details/page.tsx
@@ -1,14 +1,6 @@
-// First: the rules sheet reads a server-only namespace, which the server bootstrap adds to i18n
-// when this module loads (0055).
-import '../../../../../bootstrap/bootstrap.server';
-
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { GuestGuard } from '@lumina/market/app/guards/guest-guard';
import { ROUTES } from '@lumina/market/app/navigation';
-import {
- GeneralRules,
- generalRulesLabels,
-} from '@lumina/market/app/screens/organisms/general-rules';
import { RegisterDetailsStep } from '@lumina/market/app/screens/(auth)/auth/register/details/organisms/register-details-step';
import type { Metadata } from 'next';
@@ -37,12 +29,6 @@ export default function RegisterDetailsPage() {
size="md"
supportPlacement="popover"
haltPlacement="modal"
- rules={
-
- }
/>
diff --git a/apps/bear/src/app/(flow)/compose/prediction/page.tsx b/apps/bear/src/app/(flow)/compose/prediction/page.tsx
index 47258de..5bf91aa 100644
--- a/apps/bear/src/app/(flow)/compose/prediction/page.tsx
+++ b/apps/bear/src/app/(flow)/compose/prediction/page.tsx
@@ -13,7 +13,7 @@ export const metadata: Metadata = {
};
/**
- * «پیشبینی جدید» on a direct load (J09-1-D): the 960px composer under the header, in the browser
+ * «سیگنال جدید» on a direct load (J09-1-D): the 960px composer under the header, in the browser
* only. From a page, the `@modal` slot opens it as a dialog over that page instead (0023).
*/
export default function ComposePredictionPage() {
diff --git a/apps/bear/src/app/(flow)/terms/layout.tsx b/apps/bear/src/app/(flow)/terms/(tabs)/layout.tsx
similarity index 81%
rename from apps/bear/src/app/(flow)/terms/layout.tsx
rename to apps/bear/src/app/(flow)/terms/(tabs)/layout.tsx
index 147aef5..5142d87 100644
--- a/apps/bear/src/app/(flow)/terms/layout.tsx
+++ b/apps/bear/src/app/(flow)/terms/(tabs)/layout.tsx
@@ -1,6 +1,6 @@
// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
// adds to i18n when this module loads, whichever module Next loads first (0055).
-import '../../../bootstrap/bootstrap.server';
+import '../../../../bootstrap/bootstrap.server';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { DesktopHeader, DesktopPageTitle } from '@lumina/market/app/navigation';
@@ -8,7 +8,7 @@ import { RulesTabs } from '@lumina/market/app/screens/(flow)/terms/organisms/rul
import type { Metadata } from 'next';
import type { ReactNode } from 'react';
-import { i18n } from '../../../i18n';
+import { i18n } from '../../../../i18n';
// Only the landing is indexed (0071); both tabs inherit this.
export const metadata: Metadata = {
@@ -18,8 +18,8 @@ export const metadata: Metadata = {
};
/**
- * «قوانین لومینا» on desktop (G-2r): the 640 column under the header, with back beside the title
- * «قوانین لومینا» and the tab row «قوانین عمومی» · «شرایط اشتراک»; each tab's text sits in a panel.
+ * «قوانین و مقررات لومینا» on desktop (G-2r): the 640 column under the header, with back beside the title
+ * «قوانین و مقررات لومینا» and the tab row «قوانین و مقررات» · «شرایط اشتراک»; each tab's text sits in a panel.
* Each tab is its own route with its own loading, so the title and the row stay while one loads;
* back returns to where the rules were opened. No nav item is active.
*/
diff --git a/apps/bear/src/app/(flow)/terms/loading.tsx b/apps/bear/src/app/(flow)/terms/(tabs)/loading.tsx
similarity index 79%
rename from apps/bear/src/app/(flow)/terms/loading.tsx
rename to apps/bear/src/app/(flow)/terms/(tabs)/loading.tsx
index b35db5a..ba0c1cf 100644
--- a/apps/bear/src/app/(flow)/terms/loading.tsx
+++ b/apps/bear/src/app/(flow)/terms/(tabs)/loading.tsx
@@ -1,9 +1,9 @@
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
import { Card } from '@lumina/island/molecules/card';
-import { i18n } from '../../../i18n';
+import { i18n } from '../../../../i18n';
-/** «قوانین عمومی» before it arrives, under the section's title and tabs: its panel of lines. */
+/** «قوانین و مقررات» before it arrives, under the section's title and tabs: its panel of lines. */
export default function Loading() {
return (
diff --git a/apps/bear/src/app/(flow)/terms/(tabs)/page.tsx b/apps/bear/src/app/(flow)/terms/(tabs)/page.tsx
new file mode 100644
index 0000000..c670937
--- /dev/null
+++ b/apps/bear/src/app/(flow)/terms/(tabs)/page.tsx
@@ -0,0 +1,23 @@
+// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
+// adds to i18n when this module loads, whichever module Next loads first (0055).
+import '../../../../bootstrap/bootstrap.server';
+
+import { Card } from '@lumina/island/molecules/card';
+import { LegalDocumentView } from '@lumina/market/app/screens/organisms/legal-document';
+import type { Metadata } from 'next';
+
+import { i18n } from '../../../../i18n';
+
+export const metadata: Metadata = {
+ title: i18n.t('rules:meta-title'),
+ description: i18n.t('rules:meta-description'),
+};
+
+/** «قوانین و مقررات», the first tab of «قوانین و مقررات لومینا» (G-2r); its text is read in the browser (0070). */
+export default function RulesPage() {
+ return (
+
+
+
+ );
+}
diff --git a/apps/bear/src/app/(flow)/terms/subscription/loading.tsx b/apps/bear/src/app/(flow)/terms/(tabs)/subscription/loading.tsx
similarity index 93%
rename from apps/bear/src/app/(flow)/terms/subscription/loading.tsx
rename to apps/bear/src/app/(flow)/terms/(tabs)/subscription/loading.tsx
index 6aaccb2..06310df 100644
--- a/apps/bear/src/app/(flow)/terms/subscription/loading.tsx
+++ b/apps/bear/src/app/(flow)/terms/(tabs)/subscription/loading.tsx
@@ -1,7 +1,7 @@
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
import { Card } from '@lumina/island/molecules/card';
-import { i18n } from '../../../../i18n';
+import { i18n } from '../../../../../i18n';
/** The terms before they arrive, under the section's title and tabs: their panel of lines. */
export default function Loading() {
diff --git a/apps/bear/src/app/(flow)/terms/(tabs)/subscription/page.tsx b/apps/bear/src/app/(flow)/terms/(tabs)/subscription/page.tsx
new file mode 100644
index 0000000..0085be8
--- /dev/null
+++ b/apps/bear/src/app/(flow)/terms/(tabs)/subscription/page.tsx
@@ -0,0 +1,23 @@
+// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
+// adds to i18n when this module loads, whichever module Next loads first (0055).
+import '../../../../../bootstrap/bootstrap.server';
+
+import { Card } from '@lumina/island/molecules/card';
+import { SubscriptionTerms } from '@lumina/market/app/screens/(flow)/terms/subscription/organisms/subscription-terms';
+import type { Metadata } from 'next';
+
+import { i18n } from '../../../../../i18n';
+
+export const metadata: Metadata = {
+ title: i18n.t('terms:meta-title'),
+ description: i18n.t('terms:meta-description'),
+};
+
+/** «شرایط اشتراک», the second tab of «قوانین و مقررات لومینا» (S5, G-2); its text is read in the browser (0070). */
+export default function SubscriptionTermsPage() {
+ return (
+
+
+
+ );
+}
diff --git a/apps/bear/src/app/(flow)/terms/analyst-agreement/layout.tsx b/apps/bear/src/app/(flow)/terms/analyst-agreement/layout.tsx
new file mode 100644
index 0000000..642a05b
--- /dev/null
+++ b/apps/bear/src/app/(flow)/terms/analyst-agreement/layout.tsx
@@ -0,0 +1,44 @@
+// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
+// adds to i18n when this module loads, whichever module Next loads first (0055).
+import '../../../../bootstrap/bootstrap.server';
+
+import { FlexBox } from '@lumina/island/atoms/flex-box';
+import { DesktopHeader, DesktopPageTitle } from '@lumina/market/app/navigation';
+import type { Metadata } from 'next';
+import type { ReactNode } from 'react';
+
+import { i18n } from '../../../../i18n';
+
+export const metadata: Metadata = {
+ title: i18n.t('rules:agreement.meta-title'),
+ robots: { index: false },
+};
+
+/** «توافقنامه تحلیلگر» on desktop: the 640 column under the header, with back beside the title. */
+export default function AnalystAgreementLayout({
+ children,
+}: {
+ children: ReactNode;
+}) {
+ const t = i18n.getFixedT(null, 'rules');
+
+ return (
+
+
+
+
+
+ {children}
+
+
+
+ );
+}
diff --git a/apps/bear/src/app/(flow)/terms/analyst-agreement/loading.tsx b/apps/bear/src/app/(flow)/terms/analyst-agreement/loading.tsx
new file mode 100644
index 0000000..693c5d5
--- /dev/null
+++ b/apps/bear/src/app/(flow)/terms/analyst-agreement/loading.tsx
@@ -0,0 +1,8 @@
+import { LegalDocumentSkeleton } from '@lumina/market/app/screens/organisms/legal-document';
+
+import { i18n } from '../../../../i18n';
+
+/** The agreement before it arrives, under the page's bar or title. */
+export default function Loading() {
+ return ;
+}
diff --git a/apps/bear/src/app/(flow)/terms/analyst-agreement/page.tsx b/apps/bear/src/app/(flow)/terms/analyst-agreement/page.tsx
new file mode 100644
index 0000000..82ba0d9
--- /dev/null
+++ b/apps/bear/src/app/(flow)/terms/analyst-agreement/page.tsx
@@ -0,0 +1,22 @@
+import { Card } from '@lumina/island/molecules/card';
+import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
+import { AnalystAgreement } from '@lumina/market/app/screens/(flow)/terms/analyst-agreement/organisms/analyst-agreement';
+import { LegalDocumentSkeleton } from '@lumina/market/app/screens/organisms/legal-document';
+
+import { i18n } from '../../../../i18n';
+
+/** The agreement and the analyst's own record; both read in the browser (0070). Analysts only. */
+export default function AnalystAgreementPage() {
+ return (
+
+ }
+ >
+
+
+
+
+ );
+}
diff --git a/apps/bear/src/app/(flow)/terms/page.tsx b/apps/bear/src/app/(flow)/terms/page.tsx
deleted file mode 100644
index 6ebb630..0000000
--- a/apps/bear/src/app/(flow)/terms/page.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
-// adds to i18n when this module loads, whichever module Next loads first (0055).
-import '../../../bootstrap/bootstrap.server';
-
-import { Card } from '@lumina/island/molecules/card';
-import {
- GeneralRules,
- generalRulesLabels,
-} from '@lumina/market/app/screens/organisms/general-rules';
-import type { Metadata } from 'next';
-
-import { i18n } from '../../../i18n';
-
-export const metadata: Metadata = {
- title: i18n.t('rules:meta-title'),
- description: i18n.t('rules:meta-description'),
-};
-
-/** «قوانین عمومی», the first tab of «قوانین لومینا» on desktop (G-2r): the text in a panel. */
-export default function GeneralRulesPage() {
- return (
-
-
-
- );
-}
diff --git a/apps/bear/src/app/(flow)/terms/subscription/page.tsx b/apps/bear/src/app/(flow)/terms/subscription/page.tsx
deleted file mode 100644
index 6929733..0000000
--- a/apps/bear/src/app/(flow)/terms/subscription/page.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
-// adds to i18n when this module loads, whichever module Next loads first (0055).
-import '../../../../bootstrap/bootstrap.server';
-
-import { Card } from '@lumina/island/molecules/card';
-import {
- SubscriptionTerms,
- subscriptionTermsLabels,
-} from '@lumina/market/app/screens/(flow)/terms/subscription/organisms/subscription-terms';
-import { supportChatUrls } from '@lumina/market/app/screens/organisms/support-entry';
-import { getEnv } from '@lumina/market/env';
-import type { Metadata } from 'next';
-
-import { i18n } from '../../../../i18n';
-
-export const metadata: Metadata = {
- title: i18n.t('terms:meta-title'),
- description: i18n.t('terms:meta-description'),
-};
-
-/**
- * «شرایط اشتراک», the second tab of «قوانین لومینا» on desktop (S5 ۲.۱, G-2): the text in a panel
- * of the section's 640 column, about 75 characters a line; the title and tabs come from the layout.
- */
-export default function SubscriptionTermsPage() {
- const labels = subscriptionTermsLabels(
- i18n.getFixedT(null, 'terms'),
- i18n.getFixedT(null, 'auth'),
- getEnv().supportHours,
- );
-
- return (
-
-
-
- );
-}
diff --git a/apps/bear/src/app/(main)/@modal/(.)compose/prediction/page.tsx b/apps/bear/src/app/(main)/@modal/(.)compose/prediction/page.tsx
index 56eecd5..465c0ff 100644
--- a/apps/bear/src/app/(main)/@modal/(.)compose/prediction/page.tsx
+++ b/apps/bear/src/app/(main)/@modal/(.)compose/prediction/page.tsx
@@ -5,7 +5,7 @@ import {
} from '@lumina/market/app/screens/(flow)/compose/prediction/organisms/prediction-composer';
/**
- * «پیشبینی جدید» opened from a main page (J09-1-D, 0023): the 960px composer dialog over that
+ * «سیگنال جدید» opened from a main page (J09-1-D, 0023): the 960px composer dialog over that
* page, the URL /compose/prediction; a direct load of that URL gets the full page instead. In the
* browser only: the dialog's skeleton until the viewer is known, then the composer for a creator
* who may publish, why not for one who may not, or the no-access state for anyone else.
diff --git a/apps/bear/src/app/(main)/dashboard/(creator)/layout.tsx b/apps/bear/src/app/(main)/dashboard/(creator)/layout.tsx
index 3cb9da8..5688e95 100644
--- a/apps/bear/src/app/(main)/dashboard/(creator)/layout.tsx
+++ b/apps/bear/src/app/(main)/dashboard/(creator)/layout.tsx
@@ -8,7 +8,7 @@ import { i18n } from '../../../../i18n';
/**
* The creator's داشبورد on desktop (Creator Dashboard ۵.۱): the 640 column under the header, with
- * the «داشبورد» heading, the three tabs «طرحهای اشتراک» · «پیشبینیها» · «مالی», then the tab. Each tab is its own
+ * the «داشبورد» heading, the three tabs «طرحهای اشتراک» · «سیگنالها» · «مالی», then the tab. Each tab is its own
* route with its own loading, so the heading and the tabs stay while one loads. Locked until
* registration step 5 is done (0016).
*/
diff --git a/apps/bear/src/app/(main)/dashboard/(creator)/predictions/loading.tsx b/apps/bear/src/app/(main)/dashboard/(creator)/predictions/loading.tsx
index 96cfb88..d49ecb6 100644
--- a/apps/bear/src/app/(main)/dashboard/(creator)/predictions/loading.tsx
+++ b/apps/bear/src/app/(main)/dashboard/(creator)/predictions/loading.tsx
@@ -2,7 +2,7 @@ import { PredictionsTabSkeleton } from '@lumina/market/app/screens/(main)/dashbo
import { i18n } from '../../../../../i18n';
-/** پیشبینیها before it arrives, block for block; the layout keeps the bar and the tabs. */
+/** سیگنالها before it arrives, block for block; the layout keeps the bar and the tabs. */
export default function Loading() {
return (
diff --git a/apps/bear/src/app/(main)/dashboard/(creator)/predictions/page.tsx b/apps/bear/src/app/(main)/dashboard/(creator)/predictions/page.tsx
index 17cd40c..db8e3b5 100644
--- a/apps/bear/src/app/(main)/dashboard/(creator)/predictions/page.tsx
+++ b/apps/bear/src/app/(main)/dashboard/(creator)/predictions/page.tsx
@@ -13,7 +13,7 @@ export const metadata: Metadata = {
};
/**
- * داشبورد › پیشبینیها (J10-3): the creator's record, open and recently closed predictions, in the
+ * داشبورد › سیگنالها (J10-3): the creator's record, open and recently closed predictions, in the
* browser only. Each block loads and fails on its own; the tabs stay.
*/
export default function PredictionsPage() {
diff --git a/apps/bear/src/app/(main)/dashboard/predictions/all/loading.tsx b/apps/bear/src/app/(main)/dashboard/predictions/all/loading.tsx
index 4233c25..1ca9c30 100644
--- a/apps/bear/src/app/(main)/dashboard/predictions/all/loading.tsx
+++ b/apps/bear/src/app/(main)/dashboard/predictions/all/loading.tsx
@@ -4,7 +4,7 @@ import { PredictionListSkeleton } from '@lumina/market/app/screens/(main)/dashbo
import { i18n } from '../../../../../i18n';
-/** «همه پیشبینیها» before it arrives, under its real title. */
+/** «همه سیگنالها» before it arrives, under its real title. */
export default function Loading() {
return (
diff --git a/apps/bear/src/app/(main)/dashboard/predictions/all/page.tsx b/apps/bear/src/app/(main)/dashboard/predictions/all/page.tsx
index 247130e..acdbbc6 100644
--- a/apps/bear/src/app/(main)/dashboard/predictions/all/page.tsx
+++ b/apps/bear/src/app/(main)/dashboard/predictions/all/page.tsx
@@ -17,8 +17,8 @@ export const metadata: Metadata = {
};
/**
- * «همه پیشبینیها» on desktop (J10-3f): the same list in the 640 column, «بازگشت» over its title
- * back to the پیشبینیها tab. The creator's own, in the browser only.
+ * «همه سیگنالها» on desktop (J10-3f): the same list in the 640 column, «بازگشت» over its title
+ * back to the سیگنالها tab. The creator's own, in the browser only.
*/
export default function PredictionListPage() {
const skeleton = (
diff --git a/apps/bear/src/app/organisms/app-providers/AppProviders.tsx b/apps/bear/src/app/organisms/app-providers/AppProviders.tsx
index e6b3522..c27db66 100644
--- a/apps/bear/src/app/organisms/app-providers/AppProviders.tsx
+++ b/apps/bear/src/app/organisms/app-providers/AppProviders.tsx
@@ -12,7 +12,7 @@ import type { AppProvidersProps } from './types';
/** The app's root client component: runs the client bootstrap, then the platform's shell. */
export function AppProviders({ children }: AppProvidersProps) {
return (
-
+
{children}
);
diff --git a/apps/bear/src/bootstrap/bootstrap.client.ts b/apps/bear/src/bootstrap/bootstrap.client.ts
index de32613..3e6efc6 100644
--- a/apps/bear/src/bootstrap/bootstrap.client.ts
+++ b/apps/bear/src/bootstrap/bootstrap.client.ts
@@ -9,6 +9,7 @@ import {
AUTH_EVENTS,
endSuspendedSession,
isSessionSuspended,
+ noteAgreementRequired,
suspendedSessionOf,
} from '@lumina/market/features/auth';
@@ -45,6 +46,7 @@ http.configure({
http.interceptors.response.use(undefined, (error) => {
const suspension = suspendedSessionOf(error);
if (suspension) endSuspendedSession(suspension);
+ noteAgreementRequired(error);
return error;
});
configureErrorHandler(ERROR_HANDLER_CONFIG);
diff --git a/apps/bull/src/app/(auth)/auth/register/details/page.tsx b/apps/bull/src/app/(auth)/auth/register/details/page.tsx
index 285969f..16ac215 100644
--- a/apps/bull/src/app/(auth)/auth/register/details/page.tsx
+++ b/apps/bull/src/app/(auth)/auth/register/details/page.tsx
@@ -1,14 +1,6 @@
-// First: the rules sheet reads a server-only namespace, which the server bootstrap adds to i18n
-// when this module loads (0055).
-import '../../../../../bootstrap/bootstrap.server';
-
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { GuestGuard } from '@lumina/market/app/guards/guest-guard';
import { ROUTES } from '@lumina/market/app/navigation';
-import {
- GeneralRules,
- generalRulesLabels,
-} from '@lumina/market/app/screens/organisms/general-rules';
import { RegisterDetailsStep } from '@lumina/market/app/screens/(auth)/auth/register/details/organisms/register-details-step';
import type { Metadata } from 'next';
@@ -45,12 +37,6 @@ export default function RegisterDetailsPage() {
size="lg"
supportPlacement="bottom"
haltPlacement="sheet"
- rules={
-
- }
/>
diff --git a/apps/bull/src/app/(flow)/compose/prediction/page.tsx b/apps/bull/src/app/(flow)/compose/prediction/page.tsx
index 07eb10e..f730c90 100644
--- a/apps/bull/src/app/(flow)/compose/prediction/page.tsx
+++ b/apps/bull/src/app/(flow)/compose/prediction/page.tsx
@@ -10,7 +10,7 @@ export const metadata: Metadata = {
robots: { index: false },
};
-/** «پیشبینی جدید» (J09-1): the creator's own task flow, in the browser only, with no bottom nav. */
+/** «سیگنال جدید» (J09-1): the creator's own task flow, in the browser only, with no bottom nav. */
export default function ComposePredictionPage() {
return (
diff --git a/apps/bull/src/app/(flow)/terms/(tabs)/page.tsx b/apps/bull/src/app/(flow)/terms/(tabs)/page.tsx
new file mode 100644
index 0000000..0ce5136
--- /dev/null
+++ b/apps/bull/src/app/(flow)/terms/(tabs)/page.tsx
@@ -0,0 +1,18 @@
+// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
+// adds to i18n when this module loads, whichever module Next loads first (0055).
+import '../../../../bootstrap/bootstrap.server';
+
+import { LegalDocumentView } from '@lumina/market/app/screens/organisms/legal-document';
+import type { Metadata } from 'next';
+
+import { i18n } from '../../../../i18n';
+
+export const metadata: Metadata = {
+ title: i18n.t('rules:meta-title'),
+ description: i18n.t('rules:meta-description'),
+};
+
+/** «قوانین و مقررات», the first tab of «قوانین و مقررات لومینا» (G-2r); its text is read in the browser (0070). */
+export default function RulesPage() {
+ return ;
+}
diff --git a/apps/bull/src/app/(flow)/terms/subscription/loading.tsx b/apps/bull/src/app/(flow)/terms/(tabs)/subscription/loading.tsx
similarity index 92%
rename from apps/bull/src/app/(flow)/terms/subscription/loading.tsx
rename to apps/bull/src/app/(flow)/terms/(tabs)/subscription/loading.tsx
index 097d60f..b923aad 100644
--- a/apps/bull/src/app/(flow)/terms/subscription/loading.tsx
+++ b/apps/bull/src/app/(flow)/terms/(tabs)/subscription/loading.tsx
@@ -1,6 +1,6 @@
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
-import { i18n } from '../../../../i18n';
+import { i18n } from '../../../../../i18n';
/** The terms before they arrive, under the section's bar and tabs: a few paragraphs' worth of lines. */
export default function Loading() {
diff --git a/apps/bull/src/app/(flow)/terms/(tabs)/subscription/page.tsx b/apps/bull/src/app/(flow)/terms/(tabs)/subscription/page.tsx
new file mode 100644
index 0000000..3fd5909
--- /dev/null
+++ b/apps/bull/src/app/(flow)/terms/(tabs)/subscription/page.tsx
@@ -0,0 +1,18 @@
+// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
+// adds to i18n when this module loads, whichever module Next loads first (0055).
+import '../../../../../bootstrap/bootstrap.server';
+
+import { SubscriptionTerms } from '@lumina/market/app/screens/(flow)/terms/subscription/organisms/subscription-terms';
+import type { Metadata } from 'next';
+
+import { i18n } from '../../../../../i18n';
+
+export const metadata: Metadata = {
+ title: i18n.t('terms:meta-title'),
+ description: i18n.t('terms:meta-description'),
+};
+
+/** «شرایط اشتراک», the second tab of «قوانین و مقررات لومینا» (S5, G-2); its text is read in the browser (0070). */
+export default function SubscriptionTermsPage() {
+ return ;
+}
diff --git a/apps/bull/src/app/(flow)/terms/analyst-agreement/layout.tsx b/apps/bull/src/app/(flow)/terms/analyst-agreement/layout.tsx
new file mode 100644
index 0000000..e7c242a
--- /dev/null
+++ b/apps/bull/src/app/(flow)/terms/analyst-agreement/layout.tsx
@@ -0,0 +1,37 @@
+// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
+// adds to i18n when this module loads, whichever module Next loads first (0055).
+import '../../../../bootstrap/bootstrap.server';
+
+import { FlexBox } from '@lumina/island/atoms/flex-box';
+import { MobileTopBar } from '@lumina/market/app/navigation';
+import type { Metadata } from 'next';
+import type { ReactNode } from 'react';
+
+import { i18n } from '../../../../i18n';
+
+export const metadata: Metadata = {
+ title: i18n.t('rules:agreement.meta-title'),
+ robots: { index: false },
+};
+
+/** «توافقنامه تحلیلگر» on mobile: a task page pushed from حساب کاربری, with back and no bottom nav. */
+export default function AnalystAgreementLayout({
+ children,
+}: {
+ children: ReactNode;
+}) {
+ const t = i18n.getFixedT(null, 'rules');
+
+ return (
+
+
+
+ {children}
+
+
+ );
+}
diff --git a/apps/bull/src/app/(flow)/terms/analyst-agreement/loading.tsx b/apps/bull/src/app/(flow)/terms/analyst-agreement/loading.tsx
new file mode 100644
index 0000000..693c5d5
--- /dev/null
+++ b/apps/bull/src/app/(flow)/terms/analyst-agreement/loading.tsx
@@ -0,0 +1,8 @@
+import { LegalDocumentSkeleton } from '@lumina/market/app/screens/organisms/legal-document';
+
+import { i18n } from '../../../../i18n';
+
+/** The agreement before it arrives, under the page's bar or title. */
+export default function Loading() {
+ return ;
+}
diff --git a/apps/bull/src/app/(flow)/terms/analyst-agreement/page.tsx b/apps/bull/src/app/(flow)/terms/analyst-agreement/page.tsx
new file mode 100644
index 0000000..3d2ebee
--- /dev/null
+++ b/apps/bull/src/app/(flow)/terms/analyst-agreement/page.tsx
@@ -0,0 +1,19 @@
+import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
+import { AnalystAgreement } from '@lumina/market/app/screens/(flow)/terms/analyst-agreement/organisms/analyst-agreement';
+import { LegalDocumentSkeleton } from '@lumina/market/app/screens/organisms/legal-document';
+
+import { i18n } from '../../../../i18n';
+
+/** The agreement and the analyst's own record; both read in the browser (0070). Analysts only. */
+export default function AnalystAgreementPage() {
+ return (
+
+ }
+ >
+
+
+ );
+}
diff --git a/apps/bull/src/app/(flow)/terms/page.tsx b/apps/bull/src/app/(flow)/terms/page.tsx
deleted file mode 100644
index 2ead918..0000000
--- a/apps/bull/src/app/(flow)/terms/page.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
-// adds to i18n when this module loads, whichever module Next loads first (0055).
-import '../../../bootstrap/bootstrap.server';
-
-import {
- GeneralRules,
- generalRulesLabels,
-} from '@lumina/market/app/screens/organisms/general-rules';
-import type { Metadata } from 'next';
-
-import { i18n } from '../../../i18n';
-
-export const metadata: Metadata = {
- title: i18n.t('rules:meta-title'),
- description: i18n.t('rules:meta-description'),
-};
-
-/** «قوانین عمومی», the first tab of «قوانین لومینا» on mobile (G-2r), under the section's bar. */
-export default function GeneralRulesPage() {
- return (
-
- );
-}
diff --git a/apps/bull/src/app/(flow)/terms/subscription/page.tsx b/apps/bull/src/app/(flow)/terms/subscription/page.tsx
deleted file mode 100644
index c7db727..0000000
--- a/apps/bull/src/app/(flow)/terms/subscription/page.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-// First: the static `metadata` below reads a server-only namespace, which the server bootstrap
-// adds to i18n when this module loads, whichever module Next loads first (0055).
-import '../../../../bootstrap/bootstrap.server';
-
-import {
- SubscriptionTerms,
- subscriptionTermsLabels,
-} from '@lumina/market/app/screens/(flow)/terms/subscription/organisms/subscription-terms';
-import { supportChatUrls } from '@lumina/market/app/screens/organisms/support-entry';
-import { getEnv } from '@lumina/market/env';
-import type { Metadata } from 'next';
-
-import { i18n } from '../../../../i18n';
-
-export const metadata: Metadata = {
- title: i18n.t('terms:meta-title'),
- description: i18n.t('terms:meta-description'),
-};
-
-/**
- * «شرایط اشتراک», the second tab of «قوانین لومینا» on mobile (S5 ۱.۱, G-2): the section's bar and
- * tabs come from its layout; back returns to where the rules were opened (checkout, a suspended
- * card, the support sheet).
- */
-export default function SubscriptionTermsPage() {
- const labels = subscriptionTermsLabels(
- i18n.getFixedT(null, 'terms'),
- i18n.getFixedT(null, 'auth'),
- getEnv().supportHours,
- );
-
- return (
-
- );
-}
diff --git a/apps/bull/src/app/(main)/dashboard/(creator)/layout.tsx b/apps/bull/src/app/(main)/dashboard/(creator)/layout.tsx
index 7ddd577..5cc8db8 100644
--- a/apps/bull/src/app/(main)/dashboard/(creator)/layout.tsx
+++ b/apps/bull/src/app/(main)/dashboard/(creator)/layout.tsx
@@ -8,7 +8,7 @@ import { i18n } from '../../../../i18n';
/**
* The creator's داشبورد on mobile (Creator Dashboard ۱.۱, 0034): the tab bar «داشبورد», the three
- * tabs «طرحهای اشتراک» · «پیشبینیها» · «مالی», then the tab. Each tab is its own route with its own loading, so the
+ * tabs «طرحهای اشتراک» · «سیگنالها» · «مالی», then the tab. Each tab is its own route with its own loading, so the
* bar and the tabs stay while one loads. Locked until registration step 5 is done (0016).
*/
export default function CreatorDashboardLayout({
diff --git a/apps/bull/src/app/(main)/dashboard/(creator)/predictions/loading.tsx b/apps/bull/src/app/(main)/dashboard/(creator)/predictions/loading.tsx
index 96cfb88..d49ecb6 100644
--- a/apps/bull/src/app/(main)/dashboard/(creator)/predictions/loading.tsx
+++ b/apps/bull/src/app/(main)/dashboard/(creator)/predictions/loading.tsx
@@ -2,7 +2,7 @@ import { PredictionsTabSkeleton } from '@lumina/market/app/screens/(main)/dashbo
import { i18n } from '../../../../../i18n';
-/** پیشبینیها before it arrives, block for block; the layout keeps the bar and the tabs. */
+/** سیگنالها before it arrives, block for block; the layout keeps the bar and the tabs. */
export default function Loading() {
return (
diff --git a/apps/bull/src/app/(main)/dashboard/(creator)/predictions/page.tsx b/apps/bull/src/app/(main)/dashboard/(creator)/predictions/page.tsx
index a6208b0..fdfb1b4 100644
--- a/apps/bull/src/app/(main)/dashboard/(creator)/predictions/page.tsx
+++ b/apps/bull/src/app/(main)/dashboard/(creator)/predictions/page.tsx
@@ -13,7 +13,7 @@ export const metadata: Metadata = {
};
/**
- * داشبورد › پیشبینیها (J10-3): the creator's record, open and recently closed predictions, in the
+ * داشبورد › سیگنالها (J10-3): the creator's record, open and recently closed predictions, in the
* browser only. Each block loads and fails on its own; the tabs stay.
*/
export default function PredictionsPage() {
diff --git a/apps/bull/src/app/(main)/dashboard/predictions/all/loading.tsx b/apps/bull/src/app/(main)/dashboard/predictions/all/loading.tsx
index b3ed4aa..5a2480b 100644
--- a/apps/bull/src/app/(main)/dashboard/predictions/all/loading.tsx
+++ b/apps/bull/src/app/(main)/dashboard/predictions/all/loading.tsx
@@ -4,7 +4,7 @@ import { PredictionListSkeleton } from '@lumina/market/app/screens/(main)/dashbo
import { i18n } from '../../../../../i18n';
-/** «همه پیشبینیها» before it arrives, under its real bar. */
+/** «همه سیگنالها» before it arrives, under its real bar. */
export default function Loading() {
return (
<>
diff --git a/apps/bull/src/app/(main)/dashboard/predictions/all/page.tsx b/apps/bull/src/app/(main)/dashboard/predictions/all/page.tsx
index dd58d31..e375cee 100644
--- a/apps/bull/src/app/(main)/dashboard/predictions/all/page.tsx
+++ b/apps/bull/src/app/(main)/dashboard/predictions/all/page.tsx
@@ -17,8 +17,8 @@ export const metadata: Metadata = {
};
/**
- * «همه پیشبینیها» on mobile (J10-3f, J10-3g): a page pushed from the پیشبینیها tab, back ·
- * «پیشبینیها» · support, with the nav kept on داشبورد. The creator's own, in the browser only;
+ * «همه سیگنالها» on mobile (J10-3f, J10-3g): a page pushed from the سیگنالها tab, back ·
+ * «سیگنالها» · support, with the nav kept on داشبورد. The creator's own, in the browser only;
* opened on its own, back goes to the tab.
*/
export default function PredictionListPage() {
diff --git a/apps/bull/src/app/organisms/app-providers/AppProviders.tsx b/apps/bull/src/app/organisms/app-providers/AppProviders.tsx
index e6b3522..7a7dd6f 100644
--- a/apps/bull/src/app/organisms/app-providers/AppProviders.tsx
+++ b/apps/bull/src/app/organisms/app-providers/AppProviders.tsx
@@ -12,7 +12,7 @@ import type { AppProvidersProps } from './types';
/** The app's root client component: runs the client bootstrap, then the platform's shell. */
export function AppProviders({ children }: AppProvidersProps) {
return (
-
+
{children}
);
diff --git a/apps/bull/src/bootstrap/bootstrap.client.ts b/apps/bull/src/bootstrap/bootstrap.client.ts
index de32613..3e6efc6 100644
--- a/apps/bull/src/bootstrap/bootstrap.client.ts
+++ b/apps/bull/src/bootstrap/bootstrap.client.ts
@@ -9,6 +9,7 @@ import {
AUTH_EVENTS,
endSuspendedSession,
isSessionSuspended,
+ noteAgreementRequired,
suspendedSessionOf,
} from '@lumina/market/features/auth';
@@ -45,6 +46,7 @@ http.configure({
http.interceptors.response.use(undefined, (error) => {
const suspension = suspendedSessionOf(error);
if (suspension) endSuspendedSession(suspension);
+ noteAgreementRequired(error);
return error;
});
configureErrorHandler(ERROR_HANDLER_CONFIG);
diff --git a/apps/wall-street-plaza/package.json b/apps/wall-street-plaza/package.json
index 73ffad2..b7ad51e 100644
--- a/apps/wall-street-plaza/package.json
+++ b/apps/wall-street-plaza/package.json
@@ -2,6 +2,9 @@
"name": "@lumina/wall-street-plaza",
"version": "0.0.1",
"private": true,
+ "scripts": {
+ "test": "vitest run --config ../../vitest.config.ts"
+ },
"nx": {
"name": "wall-street-plaza",
"sourceRoot": "apps/wall-street-plaza/src",
diff --git a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/PredictionQueues.tsx b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/PredictionQueues.tsx
index c02ed48..8cc845b 100644
--- a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/PredictionQueues.tsx
+++ b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/PredictionQueues.tsx
@@ -19,7 +19,7 @@ import { QuoteHealth } from './components/QuoteHealth';
import { QuoteHealthSkeleton } from './components/QuoteHealthSkeleton';
/**
- * پیشبینیها (J11-8): the quote sources' health, refreshed every minute, then the queue tabs
+ * سیگنالها (J11-8): the quote sources' health, refreshed every minute, then the queue tabs
* (نیاز به تأیید with its count) in the URL. Each part loads and fails on its own; a queue change
* remounts the rows behind the table skeleton. The detail opens beside the table and the dialogs
* over it.
diff --git a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/ConfirmCloseDialog.tsx b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/ConfirmCloseDialog.tsx
index 7b05179..5c83f7e 100644
--- a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/ConfirmCloseDialog.tsx
+++ b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/ConfirmCloseDialog.tsx
@@ -28,7 +28,7 @@ import { OutcomeValue } from './OutcomeValue';
import { PredictionCardView } from './PredictionCardView';
/**
- * «تأیید بستن پیشبینی» (J11-8b): the card, what the system detected at what price, from where and
+ * «تأیید بستن سیگنال» (J11-8b): the card, what the system detected at what price, from where and
* when, and the outcome it would record. «اصلاح قیمت» turns it into J11-8g: a corrected price from
* the same source with a reason (the analyst's correction notice carries it), the outcome following
* the typed price, and «لغو اصلاح» back.
diff --git a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/FlagDialog.tsx b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/FlagDialog.tsx
index 1775834..760beaf 100644
--- a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/FlagDialog.tsx
+++ b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/FlagDialog.tsx
@@ -20,7 +20,7 @@ import { useRetained } from '../use-retained';
import { DialogSubject } from './DialogSubject';
/**
- * «پرچمگذاری پیشبینی» (J11-8e): one reason chip and an optional note («سایر» needs one). Flags
+ * «پرچمگذاری سیگنال» (J11-8e): one reason chip and an optional note («سایر» needs one). Flags
* are internal: they change nothing on the card, the track record or the outcome.
*/
export function FlagDialog({ actions }: ActionsProps) {
diff --git a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/OpenRowButton.tsx b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/OpenRowButton.tsx
index 5608a75..4130492 100644
--- a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/OpenRowButton.tsx
+++ b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/OpenRowButton.tsx
@@ -4,7 +4,7 @@ import type { PredictionPayload } from '@lumina/garden-roof/features/predictions
import { Button } from '@lumina/island/atoms/button';
import { useTranslation } from 'react-i18next';
-/** The row's keyboard way into «جزئیات پیشبینی»; a pointer can click anywhere on the row. */
+/** The row's keyboard way into «جزئیات سیگنال»; a pointer can click anywhere on the row. */
export function OpenRowButton({
prediction,
href,
diff --git a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/OverrideDialog.tsx b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/OverrideDialog.tsx
index d35d5dc..f5713a8 100644
--- a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/OverrideDialog.tsx
+++ b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/OverrideDialog.tsx
@@ -42,9 +42,9 @@ function Change({ from, to }: { from: ReactNode; to: ReactNode | null }) {
}
/**
- * «اصلاح نتیجه پیشبینی» (J11-8d): a closed prediction's new close price from the same source,
+ * «اصلاح نتیجه سیگنال» (J11-8d): a closed prediction's new close price from the same source,
* with what changes (price, outcome, ROI), a «دلیل», and what investors and the analyst's track
- * record will show. On an open prediction it is «بستن پیشبینی با قیمت ادمین»: the close price and
+ * record will show. On an open prediction it is «بستن سیگنال با قیمت ادمین»: the close price and
* outcome it would record, closing now (a symbol with no quote is never proposed). Either way the
* analyst's correction notice carries the reason. The win-rate change shows when the track record
* is known (opened from the detail).
diff --git a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/PredictionSheet.tsx b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/PredictionSheet.tsx
index b09c22d..196d68e 100644
--- a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/PredictionSheet.tsx
+++ b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/components/PredictionSheet.tsx
@@ -10,7 +10,7 @@ import type { PageModelProps } from '../types';
import { PredictionDetail } from './PredictionDetail';
/**
- * «جزئیات پیشبینی» (J11-8c) beside the table, open while the URL has `?id=`. Its content loads
+ * «جزئیات سیگنال» (J11-8c) beside the table, open while the URL has `?id=`. Its content loads
* on its own: a failed read errors inside the panel and leaves the queue as it was.
*/
export function PredictionSheet({ model }: PageModelProps) {
diff --git a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/labels.tsx b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/labels.tsx
index ed531ef..453a32e 100644
--- a/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/labels.tsx
+++ b/apps/wall-street-plaza/src/app/(panel)/predictions/organisms/prediction-queues/labels.tsx
@@ -37,10 +37,14 @@ export function predictionCardLabels(
toFinalTarget: t('card.to-final-target'),
toStop: t('card.to-stop'),
riskReward: t('card.risk-reward'),
+ riskRewardRange: (worst, best) =>
+ t('card.risk-reward-range', { worst, best }),
levels: {
stop: t('card.levels.stop'),
entry: t('card.levels.entry'),
base: t('card.levels.base'),
+ range: t('card.levels.range'),
+ entryRange: t('card.levels.entry-range'),
target,
finalTarget: t('card.levels.final-target'),
close: t('card.levels.close'),
diff --git a/apps/wall-street-plaza/src/app/(panel)/predictions/page.tsx b/apps/wall-street-plaza/src/app/(panel)/predictions/page.tsx
index b0b0826..a65cced 100644
--- a/apps/wall-street-plaza/src/app/(panel)/predictions/page.tsx
+++ b/apps/wall-street-plaza/src/app/(panel)/predictions/page.tsx
@@ -14,7 +14,7 @@ export const metadata: Metadata = {
};
/**
- * پیشبینیها (J11-8): the title and the rule that nothing closes without ops on the server; the
+ * سیگنالها (J11-8): the title and the rule that nothing closes without ops on the server; the
* queues in the browser once the admin is known (0062).
*/
export default function PredictionsPage() {
diff --git a/apps/wall-street-plaza/src/app/(panel)/settings/loading.tsx b/apps/wall-street-plaza/src/app/(panel)/settings/loading.tsx
new file mode 100644
index 0000000..8e5b57e
--- /dev/null
+++ b/apps/wall-street-plaza/src/app/(panel)/settings/loading.tsx
@@ -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 (
+ <>
+
+
+ >
+ );
+}
diff --git a/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/PriceFloorCard.tsx b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/PriceFloorCard.tsx
new file mode 100644
index 0000000..26c5dd2
--- /dev/null
+++ b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/PriceFloorCard.tsx
@@ -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 ;
+}
diff --git a/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/ConfirmPriceFloorDialog.tsx b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/ConfirmPriceFloorDialog.tsx
new file mode 100644
index 0000000..e15e7e1
--- /dev/null
+++ b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/ConfirmPriceFloorDialog.tsx
@@ -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 (
+
+ {affected && affected.affectedTiers.length > 0 && (
+
+ {t('price-floor.preview.warning', {
+ tiers: number(affected.affectedTiers.length),
+ analysts: number(affected.analystCount),
+ })}
+
+ )}
+
+ );
+}
diff --git a/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/PriceFloorForm.test.tsx b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/PriceFloorForm.test.tsx
new file mode 100644
index 0000000..1210533
--- /dev/null
+++ b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/PriceFloorForm.test.tsx
@@ -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) {
+ 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 ;
+}
+
+describe('PriceFloorForm', () => {
+ it('shows the current value in the hint, and its last change once there is one', () => {
+ const { rerender } = render( );
+ expect(screen.getByText(/هنوز تغییری ثبت نشده است/)).toBeTruthy();
+ rerender( );
+ expect(screen.getByText(/آخرین تغییر:/)).toBeTruthy();
+ });
+
+ it('a raise warns with how many plans and analysts, and lists each', () => {
+ render( );
+ 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(
+ ,
+ );
+ expect(screen.getByText('هیچ طرحی زیر کف جدید نمیماند.')).toBeTruthy();
+ expect(screen.queryByRole('table')).toBeNull();
+ });
+
+ it('a lower floor says it changes nothing yet, with no preview', () => {
+ render( );
+ expect(screen.getByText(/چیزی تغییر نمیکند/)).toBeTruthy();
+ expect(screen.queryByRole('table')).toBeNull();
+ });
+
+ it('a failed preview offers to try again', async () => {
+ const retry = vi.fn();
+ render( );
+ await userEvent.click(screen.getByRole('button', { name: 'تلاش دوباره' }));
+ expect(retry).toHaveBeenCalled();
+ });
+
+ it('«ذخیره» waits and says why while blocked', async () => {
+ const openConfirm = vi.fn();
+ render(
+ ,
+ );
+ 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( );
+ 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( );
+ 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( );
+ 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( );
+ await userEvent.type(
+ within(dialog()).getByRole('textbox', { hidden: true }),
+ ' افزایش کف قیمت پس از بازبینی. ',
+ );
+ await userEvent.click(
+ within(dialog()).getByText('ذخیره و اطلاعرسانی').closest('button')!,
+ );
+ await waitFor(() =>
+ expect(confirm).toHaveBeenCalledWith('افزایش کف قیمت پس از بازبینی.'),
+ );
+ });
+});
diff --git a/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/PriceFloorForm.tsx b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/PriceFloorForm.tsx
new file mode 100644
index 0000000..015b015
--- /dev/null
+++ b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/PriceFloorForm.tsx
@@ -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 (
+ <>
+
+
+
+
+ {t('price-floor.title')}
+
+
+ {t('price-floor.description')}
+
+
+ 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' && (
+
+ {t('price-floor.lower-note')}
+
+ )}
+
+
+
+ {t('price-floor.save')}
+
+
+
+
+
+ >
+ );
+}
diff --git a/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/PriceFloorPreview.tsx b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/PriceFloorPreview.tsx
new file mode 100644
index 0000000..2af5322
--- /dev/null
+++ b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/PriceFloorPreview.tsx
@@ -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 (
+
+
+
+ {t('price-floor.preview.loading')}
+
+
+ );
+ }
+ if (preview.status === 'error') {
+ return (
+
+ {t('price-floor.preview.retry')}
+
+ }
+ >
+ {t('price-floor.preview.error')}
+
+ );
+ }
+
+ const { affectedTiers, analystCount } = preview.change;
+ if (affectedTiers.length === 0) {
+ return (
+
+ {t('price-floor.preview.none')}
+
+ );
+ }
+ return (
+
+
+ {t('price-floor.preview.warning', {
+ tiers: number(affectedTiers.length),
+ analysts: number(analystCount),
+ })}
+
+
+
+
+
+ {t('price-floor.preview.columns.analyst')}
+
+
+ {t('price-floor.preview.columns.plan')}
+
+
+ {t('price-floor.preview.columns.price')}
+
+
+ {t('price-floor.preview.columns.subscribers')}
+
+
+
+ {affectedTiers.map((tier) => (
+
+
+ {tier.username ? (
+
+ @{tier.username}
+
+ ) : (
+ t('price-floor.preview.unknown')
+ )}
+
+ {tier.labelFa}
+ {price(tier.finalMonthlyToman)}
+
+ {number(tier.activeSubscribers)}
+
+
+ ))}
+
+
+
+
+ );
+}
diff --git a/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/PriceFloorSkeleton.tsx b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/PriceFloorSkeleton.tsx
new file mode 100644
index 0000000..dcc7d87
--- /dev/null
+++ b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/components/PriceFloorSkeleton.tsx
@@ -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 ;
+}
diff --git a/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/index.ts b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/index.ts
new file mode 100644
index 0000000..63b685b
--- /dev/null
+++ b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/index.ts
@@ -0,0 +1,3 @@
+export { PriceFloorSkeleton } from './components/PriceFloorSkeleton';
+export { PriceFloorCard } from './PriceFloorCard';
+export type { PriceFloorPartProps, PriceFloorSkeletonProps } from './types';
diff --git a/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/types.ts b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/types.ts
new file mode 100644
index 0000000..3edd52a
--- /dev/null
+++ b/apps/wall-street-plaza/src/app/(panel)/settings/organisms/price-floor-card/types.ts
@@ -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;
+};
diff --git a/apps/wall-street-plaza/src/app/(panel)/settings/page.tsx b/apps/wall-street-plaza/src/app/(panel)/settings/page.tsx
new file mode 100644
index 0000000..0611a1b
--- /dev/null
+++ b/apps/wall-street-plaza/src/app/(panel)/settings/page.tsx
@@ -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 = (
+
+ );
+
+ return (
+ <>
+
+
+
+
+
+
+
+
+ >
+ );
+}
diff --git a/docs/pages/README.md b/docs/pages/README.md
index 0e34535..77289b6 100644
--- a/docs/pages/README.md
+++ b/docs/pages/README.md
@@ -6,13 +6,13 @@ bull (mobile) and bear (desktop) share one doc per route under `market/`, with b
## market
-Only `/` is indexable (0071), and it is the only page whose content the server renders (0070). Every other page is `noindex`; all but the rules pages render their content in the browser.
+Only `/` is indexable (0071), and it is the only page whose content the server renders (0070). Every other page is `noindex` and renders its content in the browser.
Layouts and error pages:
- root layout · [layout.md](market/layout.md) · — · — · browser: NetworkStatus, Toaster, ToastPlacementMarker (bear)
- `(main)` layout · [layout-main.md](market/layout-main.md) · — · — · browser: bear header nav, search field, publish menu, notification bell, notification panel, login button or account menu, `@modal` slot; bull BottomNav
-- `(flow)/terms` layout · [layout-terms.md](market/layout-terms.md) · — · — · browser: MobileTopBar title (bull), DesktopHeader viewer parts (bear)
+- `(flow)/terms/(tabs)` layout · [layout-terms.md](market/layout-terms.md) · — · — · browser: MobileTopBar title (bull), DesktopHeader viewer parts (bear)
- `(main)/dashboard/(creator)` layout · [layout-dashboard-creator.md](market/layout-dashboard-creator.md) · — · — · browser: OnboardingGuard redirect, notification bell and account avatar (bull)
- `(main)/dashboard/(investor)` layout · [layout-dashboard-investor.md](market/layout-dashboard-investor.md) · — · — · browser: notification bell and account avatar (bull)
- not-found and error · [not-found.md](market/not-found.md) · noindex · none · browser: not-found top bar, every group `error.tsx`, `global-error.tsx`
@@ -20,8 +20,6 @@ Layouts and error pages:
Rendered on the server:
- `/` · [home.md](market/home.md) · index · FAQPage · browser: LandingRedirect
-- `/terms` · [terms.md](market/terms.md) · noindex · none · browser: none
-- `/terms/subscription` · [terms-subscription.md](market/terms-subscription.md) · noindex · none · browser: none
`(main)`:
@@ -44,6 +42,9 @@ Rendered on the server:
`(flow)`:
+- `/terms` · [terms.md](market/terms.md) · noindex · none · browser: LegalDocumentView
+- `/terms/subscription` · [terms-subscription.md](market/terms-subscription.md) · noindex · none · browser: SubscriptionTerms
+- `/terms/analyst-agreement` · [terms-analyst-agreement.md](market/terms-analyst-agreement.md) · noindex · none · browser: top-bar title, AnalystAgreement
- `/account/profile` · [account-profile.md](market/account-profile.md) · noindex · none · browser: AccountProfile (investor form or creator profile edit), LeaveDialog
- `/checkout/[username]` · [checkout-username.md](market/checkout-username.md) · noindex · none · browser: CheckoutCreator, CheckoutPanel, CheckoutForm (tiers, code, pay footer), CheckoutHalts, NoCodeSheet
- `/compose/post` · [compose-post.md](market/compose-post.md) · noindex · none · browser: PostComposer, ComposerForm, LeaveConfirm, PostComposerDialog (bear `@modal`)
@@ -84,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
- `/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
+- `/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
- `/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
diff --git a/docs/pages/market/account.md b/docs/pages/market/account.md
index 5d09208..0764c48 100644
--- a/docs/pages/market/account.md
+++ b/docs/pages/market/account.md
@@ -17,17 +17,17 @@
In bull's document order.
-| Section | Data | HTML | JS | Index | Notes |
-| ------------------------------- | ------------- | ----------- | ------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| MobileTopBar (bull) | config | first flush | hydrate | no | a pushed page's bar: back and support |
-| ↳ Title or login link (bull) | viewer | skeleton | hydrate | no | |
-| DesktopPageTitle (bear) | config | first flush | hydrate | no | «بازگشت» and the H1 |
-| AccountOverview | viewer | skeleton | hydrate | no | `AuthGuard` with `AccountOverviewSkeleton`, in `PartBoundary name="account-overview"`; bear: `framed` |
-| ↳ IdentityCard, CreatorFacts | viewer, query | skeleton | hydrate | no | creators also get the review badge, followers and subscribers: browser `useQuery`s that never throw and leave out what fails |
-| ↳ PrivacyNote | config | skeleton | hydrate | no | investors only |
-| ↳ Settings and help lists | viewer | skeleton | hydrate | no | `ListRow` links to `/account/profile`, `/dashboard/finance#…` (creators), `/account/notifications`, `/account/install` (not in the installed app), `/terms`; پشتیبانی opens `SupportDialog` |
-| ↳ Sign-out button | — | skeleton | hydrate | no | `SignOutConfirm` asks first (0041) |
-| ↳ SupportDialog, SignOutConfirm | — | none | hydrate | no | rendered with `open`; statically imported |
+| Section | Data | HTML | JS | Index | Notes |
+| ------------------------------- | ------------- | ----------- | ------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| MobileTopBar (bull) | config | first flush | hydrate | no | a pushed page's bar: back and support |
+| ↳ Title or login link (bull) | viewer | skeleton | hydrate | no | |
+| DesktopPageTitle (bear) | config | first flush | hydrate | no | «بازگشت» and the H1 |
+| AccountOverview | viewer | skeleton | hydrate | no | `AuthGuard` with `AccountOverviewSkeleton`, in `PartBoundary name="account-overview"`; bear: `framed` |
+| ↳ IdentityCard, CreatorFacts | viewer, query | skeleton | hydrate | no | creators also get the review badge, followers and subscribers: browser `useQuery`s that never throw and leave out what fails |
+| ↳ PrivacyNote | config | skeleton | hydrate | no | investors only |
+| ↳ Settings and help lists | viewer | skeleton | hydrate | no | `ListRow` links to `/account/profile`, `/dashboard/finance#…` (creators), `/account/notifications`, `/account/install` (not in the installed app), `/terms`, `/terms/analyst-agreement` (creators, with version and date from `GET /me/legal-acceptances`); پشتیبانی opens `SupportDialog` |
+| ↳ Sign-out button | — | skeleton | hydrate | no | `SignOutConfirm` asks first (0041) |
+| ↳ SupportDialog, SignOutConfirm | — | none | hydrate | no | rendered with `open`; statically imported |
## Notes
diff --git a/docs/pages/market/auth-login.md b/docs/pages/market/auth-login.md
index 8ac2b18..5bc63a8 100644
--- a/docs/pages/market/auth-login.md
+++ b/docs/pages/market/auth-login.md
@@ -26,6 +26,7 @@ In bull's document order.
| ↳ SupportDialog | config | none | hydrate | no | island `Dialog` mounts its content only while open |
| NetworkBar | — | none | hydrate | no | under the bar, only while offline or reconnecting |
| LoginStep | viewer | skeleton | hydrate | no | `GuestGuard` shows `SkeletonPreset preset="form"` until the viewer is known; guest: H1, phone form, register link, support; member: replaced to `?redirect=`, home, or step 5 when `needsProfile` |
+| ↳ RulesCaption | config | none | hydrate | no | under the submit button; its link opens `LegalDocumentDialog`, which reads `GET /legal/platform_rules` only when opened; a sheet on bull, a modal on bear |
## Notes
diff --git a/docs/pages/market/auth-register-details.md b/docs/pages/market/auth-register-details.md
index 07a258d..461ad3a 100644
--- a/docs/pages/market/auth-register-details.md
+++ b/docs/pages/market/auth-register-details.md
@@ -17,21 +17,20 @@
In bull's document order.
-| Section | Data | HTML | JS | Index | Notes |
-| -------------------------- | ------ | ----------- | ------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| AuthTopBar (bull) | config | first flush | none | no | back button and `auth:register.header` |
-| ↳ BackButton (bull) | URL | first flush | hydrate | no | ``, keeping `?redirect=` |
-| AuthTemplate header (bear) | config | first flush | none | no | brand ` ` |
-| StepBack (bear) | URL | first flush | hydrate | no | «بازگشت» above the card to `/` |
-| SupportEntry | — | first flush | hydrate | no | in the bar; the dialog mounts only when open |
-| NetworkBar | — | none | hydrate | no | under the bar, only while offline or reconnecting |
-| RegisterDetailsStep | viewer | skeleton | hydrate | no | `GuestGuard` fallback `SkeletonPreset preset="form" count={3}`; investor: `InvestorDetailsForm`; creator: `CreatorIdentityForm`, both in `DetailsFrame` |
-| ↳ ExpiryWarning | clock | none | hydrate | no | two minutes before the token ends; `Countdown kind="otp"` and «تمدید زمان» |
-| ↳ ExpiryHalt | viewer | none | hydrate | no | when the token ends; bull: sheet; bear: modal |
-| ↳ LeaveRegistrationDialog | — | none | hydrate | no | back asks whether to leave and resume later (J02-3f) |
-| ↳ RulesSheet | config | none | hydrate | no | «قوانین لومینا» in `TermsLine`; `GeneralRules` rendered on the server and passed as `rules`; bull: sheet; bear: modal; mounts when opened |
+| Section | Data | HTML | JS | Index | Notes |
+| -------------------------- | ------ | ----------- | ------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| AuthTopBar (bull) | config | first flush | none | no | back button and `auth:register.header` |
+| ↳ BackButton (bull) | URL | first flush | hydrate | no | ` `, keeping `?redirect=` |
+| AuthTemplate header (bear) | config | first flush | none | no | brand ` ` |
+| StepBack (bear) | URL | first flush | hydrate | no | «بازگشت» above the card to `/` |
+| SupportEntry | — | first flush | hydrate | no | in the bar; the dialog mounts only when open |
+| NetworkBar | — | none | hydrate | no | under the bar, only while offline or reconnecting |
+| RegisterDetailsStep | viewer | skeleton | hydrate | no | `GuestGuard` fallback `SkeletonPreset preset="form" count={3}`; investor: `InvestorDetailsForm`; creator: `CreatorIdentityForm`, both in `DetailsFrame` |
+| ↳ ExpiryWarning | clock | none | hydrate | no | two minutes before the token ends; `Countdown kind="otp"` and «تمدید زمان» |
+| ↳ ExpiryHalt | viewer | none | hydrate | no | when the token ends; bull: sheet; bear: modal |
+| ↳ LeaveRegistrationDialog | — | none | hydrate | no | back asks whether to leave and resume later (J02-3f) |
+| ↳ AgreementBlock (creator) | query | none | hydrate | no | the first block for an analyst: `GET /legal/analyst_agreement`, «خواندن متن» opens `LegalDocumentDialog`, the checkbox unfreezes «ثبت و ادامه», and the version goes with the form |
## Notes
- Decision 0013: the step renders only in the browser on the 15-minute token, held in memory.
-- `GeneralRules` is a Server Component passed into the client step, so its text is in the RSC payload of every response, though it reaches the DOM only when the sheet opens.
diff --git a/docs/pages/market/auth-register-phone.md b/docs/pages/market/auth-register-phone.md
index f351635..0d1afab 100644
--- a/docs/pages/market/auth-register-phone.md
+++ b/docs/pages/market/auth-register-phone.md
@@ -17,15 +17,16 @@
In bull's document order.
-| Section | Data | HTML | JS | Index | Notes |
-| -------------------------- | ------ | ----------- | ------- | ----- | -------------------------------------------------------------------------------------------------------- |
-| AuthTopBar (bull) | config | first flush | none | no | back button and `auth:register.header` |
-| ↳ BackButton (bull) | URL | first flush | hydrate | no | ` ` to `/auth/register`, keeping `?redirect=` |
-| AuthTemplate header (bear) | config | first flush | none | no | brand ` ` |
-| StepBack (bear) | URL | first flush | hydrate | no | «بازگشت» above the card to `/auth/register` |
-| SupportEntry | — | first flush | hydrate | no | in the bar; the dialog mounts only when open |
-| NetworkBar | — | none | hydrate | no | under the bar, only while offline or reconnecting |
-| RegisterPhoneStep | viewer | skeleton | hydrate | no | `GuestGuard` fallback `SkeletonPreset preset="form" count={1}`; guest: progress, H1, phone form, support |
+| Section | Data | HTML | JS | Index | Notes |
+| -------------------------- | ------ | ----------- | ------- | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| AuthTopBar (bull) | config | first flush | none | no | back button and `auth:register.header` |
+| ↳ BackButton (bull) | URL | first flush | hydrate | no | ` ` to `/auth/register`, keeping `?redirect=` |
+| AuthTemplate header (bear) | config | first flush | none | no | brand ` ` |
+| StepBack (bear) | URL | first flush | hydrate | no | «بازگشت» above the card to `/auth/register` |
+| SupportEntry | — | first flush | hydrate | no | in the bar; the dialog mounts only when open |
+| NetworkBar | — | none | hydrate | no | under the bar, only while offline or reconnecting |
+| RegisterPhoneStep | viewer | skeleton | hydrate | no | `GuestGuard` fallback `SkeletonPreset preset="form" count={1}`; guest: progress, H1, phone form, support |
+| ↳ RulesCaption | config | none | hydrate | no | under the submit button; its link opens `LegalDocumentDialog`, which reads `GET /legal/platform_rules` only when opened; a sheet on bull, a modal on bear |
## Notes
diff --git a/docs/pages/market/compose-prediction.md b/docs/pages/market/compose-prediction.md
index 2b94573..ffbee71 100644
--- a/docs/pages/market/compose-prediction.md
+++ b/docs/pages/market/compose-prediction.md
@@ -17,16 +17,17 @@
In bull's document order. `compose/layout.tsx` is only `OnboardingGuard` (0016): it renders nothing, and sends a creator who hasn't finished step 5 to the creator profile.
-| Section | Data | HTML | JS | Index | Notes |
-| ------------------------------- | ------ | ----------- | ----------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| DesktopHeader (bear) | viewer | first flush | hydrate | no | the page renders it itself; rows as in [layout-main.md](layout-main.md) |
-| PredictionComposer | viewer | skeleton | hydrate | no | `AuthGuard role="creator"`, fallback `SkeletonPreset form`; `usePublishAccess`: pending keeps the skeleton, blocked sends the creator to their channel (J09-1e, 0060) |
-| ↳ ComposerPage | viewer | skeleton | hydrate | no | bull: `MobileTopBar`, the «انصراف» row, the fields, the preview, and «انتشار پیشبینی» pinned; bear: a 960 card drawn as the dialog, with its `h1`, the fields beside the preview; published, it replaces itself with the creator's channel |
-| ↳ SymbolPicker | query | none | hydrate | no | «انتخاب نماد»: bull: a sheet; bear: a modal; mounts on open, then searches symbols in the browser |
-| ↳ ConfirmPublish, LeaveConfirm | — | none | hydrate | no | mount on publish and on leaving with something to lose |
-| PredictionComposerDialog (bear) | viewer | none | interaction | no | the `@modal` intercept (J09-1-D, 0023), on a soft navigation from a main page: the 960 dialog over that page; fallback `PredictionComposerDialogSkeleton`; anyone but a creator gets no-access inside the dialog |
+| Section | Data | HTML | JS | Index | Notes |
+| ------------------------------- | ------ | ----------- | ----------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| DesktopHeader (bear) | viewer | first flush | hydrate | no | the page renders it itself; rows as in [layout-main.md](layout-main.md) |
+| PredictionComposer | viewer | skeleton | hydrate | no | `AuthGuard role="creator"`, fallback `SkeletonPreset form`; `usePublishAccess`: pending keeps the skeleton, blocked sends the creator to their channel (J09-1e, 0060) |
+| ↳ ComposerPage | viewer | skeleton | hydrate | no | bull: `MobileTopBar`, the «انصراف» row, the fields, the preview, and «انتشار سیگنال» pinned; bear: a 960 card drawn as the dialog, with its `h1`, the fields beside the preview; published, it replaces itself with the creator's channel |
+| ↳ SymbolPicker | query | none | hydrate | no | «انتخاب نماد»: bull: a sheet; bear: a modal; mounts on open, then searches symbols in the browser |
+| ↳ ConfirmPublish, LeaveConfirm | — | none | hydrate | no | mount on publish and on leaving with something to lose |
+| PredictionComposerDialog (bear) | viewer | none | interaction | no | the `@modal` intercept (J09-1-D, 0023), on a soft navigation from a main page: the 960 dialog over that page; fallback `PredictionComposerDialogSkeleton`; anyone but a creator gets no-access inside the dialog |
## Notes
+- The analyst states the entry: «قیمت دقیق» (prefilled from the live quote, following it until edited) or «بازه», and a required stop-loss. Levels are checked against that entry in the browser and again by the API (`docs/plans/pre-launch-tasks.md`, Task 2). The confirm step sends what it showed, even if the quote has moved since.
- A hard load or refresh gets the full page; a soft navigation from a `(main)` page gets the dialog over it (see [compose-post.md](compose-post.md)).
- Debt: different H1 per app. bull has no `h1`; add a screen-reader `h1` to `ComposerPage`'s mobile branch (`platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerPage.tsx:57`).
diff --git a/docs/pages/market/dashboard-plans.md b/docs/pages/market/dashboard-plans.md
index 86d5e46..63798c0 100644
--- a/docs/pages/market/dashboard-plans.md
+++ b/docs/pages/market/dashboard-plans.md
@@ -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.
- 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.
diff --git a/docs/pages/market/dashboard-predictions-all.md b/docs/pages/market/dashboard-predictions-all.md
index ceb85a7..e728c02 100644
--- a/docs/pages/market/dashboard-predictions-all.md
+++ b/docs/pages/market/dashboard-predictions-all.md
@@ -9,7 +9,7 @@
| loading.tsx | `dashboard/predictions/all/loading.tsx`: the real top bar (bull) or page title (bear) over `PredictionListSkeleton`, `delayed` |
| First flush | none |
| Canonical | none: `noindex` |
-| H1 | bull: none, the bar's «همه پیشبینیها» is a ``; bear: «همه پیشبینیها» in `DesktopPageTitle` |
+| H1 | bull: none, the bar's «همه سیگنالها» is a ``; bear: «همه سیگنالها» in `DesktopPageTitle` |
| JSON-LD | none |
| Scripts | none beyond the layout's |
diff --git a/docs/pages/market/dashboard-predictions.md b/docs/pages/market/dashboard-predictions.md
index c645312..a24c82f 100644
--- a/docs/pages/market/dashboard-predictions.md
+++ b/docs/pages/market/dashboard-predictions.md
@@ -17,15 +17,16 @@
In bull's document order. Everything sits in `AuthGuard role="creator"`, whose fallback is `PredictionsTabSkeleton`.
-| Section | Data | HTML | JS | Index | Notes |
-| --------------------------------------- | ------ | -------- | ----------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------- |
-| PredictionsTab | viewer | skeleton | hydrate | no | `useQuery` for open and closed; before the first prediction, only the empty state with «پیشبینی جدید» to `/compose/prediction` (J10-3c) |
-| ↳ TrackRecord | viewer | skeleton | hydrate | no | the record or its progress to public; own `PartBoundary` and `` |
-| ↳ PredictionSection «باز» | viewer | skeleton | hydrate | no | every open prediction as `OwnPredictionCard`; not drawn when empty; loads and fails on its own |
-| ↳↳ ClosePredictionSheet | viewer | none | interaction | no | `next/dynamic`, rendered on the first «بستن زودهنگام» tap; its price poll loads with it |
-| ↳ PredictionSection «بستهشدههای اخیر» | viewer | skeleton | hydrate | no | the two closed most recently; then «همه پیشبینیها», an `` to `/dashboard/predictions/all` |
+| Section | Data | HTML | JS | Index | Notes |
+| --------------------------------------- | ------ | -------- | ----------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| PredictionsTab | viewer | skeleton | hydrate | no | `useQuery` for open and closed; before the first prediction, only the empty state with «سیگنال جدید» to `/compose/prediction` (J10-3c) |
+| ↳ SignalPerformance | viewer | skeleton | hydrate | no | «عملکرد سیگنالها» from `GET /me/signal-stats`: four tiles, outcome split, risk to reward, progress to public; before the first nightly evaluation a message, never zeros; own `PartBoundary` and `` |
+| ↳ PredictionSection «باز» | viewer | skeleton | hydrate | no | every open prediction as `OwnPredictionCard`; not drawn when empty; loads and fails on its own |
+| ↳↳ ClosePredictionSheet | viewer | none | interaction | no | `next/dynamic`, rendered on the first «بستن زودهنگام» tap; its price poll loads with it |
+| ↳ PredictionSection «بستهشدههای اخیر» | viewer | skeleton | hydrate | no | the two closed most recently; then «همه سیگنالها», an `` to `/dashboard/predictions/all` |
## Notes
- bull and bear differ only in `layout` (card and sheet placement). A card's tap opens its post.
- `/dashboard/predictions/all` is a separate page outside the `(creator)` group, under its own `OnboardingGuard` layout: [dashboard-predictions-all.md](dashboard-predictions-all.md).
+- The tiles, progress and pending state are `dashboard/organisms/signal-stat-tiles`, `signal-progress` and `signal-stats-pending`, read through `useSignalStatsPart`, so «نمای کلی» can show the same numbers. Tips (`withTips`) appear only on this tab.
diff --git a/docs/pages/market/dashboard-pricing.md b/docs/pages/market/dashboard-pricing.md
index 5cff442..405f6f9 100644
--- a/docs/pages/market/dashboard-pricing.md
+++ b/docs/pages/market/dashboard-pricing.md
@@ -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.
- 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 «ذخیره تخفیف».
diff --git a/docs/pages/market/feed.md b/docs/pages/market/feed.md
index a3372e8..27bcef9 100644
--- a/docs/pages/market/feed.md
+++ b/docs/pages/market/feed.md
@@ -32,4 +32,4 @@ In bull's document order.
## Notes
- bear: `@modal/feed/page.tsx` renders null, so a «پست جدید» dialog closes when a navigation lands on خانه (0023).
-- Debt: no H1 in either app. Give the page an `sr-only` H1, as `GeneralRules` does.
+- Debt: no H1 in either app. Give the page an `sr-only` H1, as `LegalDocumentView` does.
diff --git a/docs/pages/market/layout-dashboard-creator.md b/docs/pages/market/layout-dashboard-creator.md
index abc6c7c..0042270 100644
--- a/docs/pages/market/layout-dashboard-creator.md
+++ b/docs/pages/market/layout-dashboard-creator.md
@@ -8,7 +8,7 @@
| MobileTopBar (bull) | config | first flush | hydrate | no | `isTab`: the brand and «داشبورد» centred, in a ``; support entry; the connection bar under it (0040) |
| ↳ NotificationBell and account avatar (bull) | viewer | none | hydrate | no | member only; while the viewer is unknown, the guest's «ورود/ثبتنام» holds the end of the bar, invisible |
| «داشبورد» `
diff --git a/packages/island/src/organisms/creator-stats/types.ts b/packages/island/src/organisms/creator-stats/types.ts
index f24aeff..8b1b46b 100644
--- a/packages/island/src/organisms/creator-stats/types.ts
+++ b/packages/island/src/organisms/creator-stats/types.ts
@@ -22,8 +22,11 @@ export type CreatorStatsData = {
/** Closed outcomes in `trendOrder`. Only the last 10 are drawn. */
accuracyTrend: TrendOutcome[];
/** The all-time split. The bar shows only when `wins` and `losses` both arrive. */
+ /** «رسیده به هدف». */
wins?: number;
+ /** «خورده به حد ضرر». */
losses?: number;
+ /** «پایان مهلت». */
breakeven?: number;
};
@@ -32,35 +35,37 @@ export type CreatorStatsData = {
* formatted (`1٬234`, `62٫9٪`), so the translation only places them.
*/
export type CreatorStatsLabels = {
- /** «عملکرد پیشبینیها». */
+ /** «عملکرد سیگنالها». */
title: ReactNode;
/** «مشاهده کارنامه کامل». */
viewRecord: ReactNode;
/** «نرخ موفقیت». */
winRate: ReactNode;
- /** Under the rate, once the split is known: `(count) => \`از ${count} پیشبینی بستهشده\``. */
+ /** Under the rate, once the split is known: `(count) => \`از ${count} سیگنال بستهشده\``. */
closedCount: (count: string) => ReactNode;
- /** Each outcome in words, for the legend, the key, the tooltips and the curve's sentence: «موفق», «ناموفق», «سربهسر». */
+ /** A signal's return at close in words, for the key, the tooltips and the curve's sentence: «موفق», «ناموفق», «سربهسر». */
outcomes: Record;
- /** One legend entry, `count` already bold: `(count, outcome) => <>{count} {outcome}>` → «۲۲ موفق». */
+ /** How signals ended in the split's legend: «رسیده به هدف» (`wins`), «خورده به حد ضرر» (`losses`), «پایان مهلت» (`breakeven`). */
+ splitOutcomes: Record;
+ /** One legend entry, `count` already bold: `(count, outcome) => <>{count} {outcome}>` → «۲۲ رسیده به هدف». */
splitLegend: (count: ReactNode, outcome: string) => ReactNode;
- /** The split bar as one sentence: `({ win, breakeven, loss }) => \`${win} موفق، ${breakeven} سربهسر، ${loss} ناموفق\``. */
+ /** The split bar as one sentence: `({ win, breakeven, loss }) => \`${win} رسیده به هدف، ${breakeven} پایان مهلت، ${loss} خورده به حد ضرر\``. */
splitSentence: (counts: Record) => string;
/** «بازدهی میانگین». */
avgRoi: ReactNode;
- /** «کل پیشبینیها». */
+ /** «کل سیگنالها». */
total: ReactNode;
- /** «پیشبینیهای فعال». */
+ /** «سیگنالهای فعال». */
active: ReactNode;
/** «روند دقت». */
trendTitle: ReactNode;
- /** Beside the trend title: `(count) => \`${count} پیشبینی اخیر\``. */
+ /** Beside the trend title: `(count) => \`${count} سیگنال اخیر\``. */
trendWindow: (count: string) => ReactNode;
/** `(wins, total) => \`${wins} از ${total} موفق\`` → «۷ از ۱۰ موفق». */
tally: (wins: string, total: string) => ReactNode;
/**
* The curve's one image label, every outcome in order plus how to read it:
- * `(count, outcomes) => \`منحنی نتیجه ${count} پیشبینی اخیر، از قدیمیترین به جدیدترین: ${outcomes.join('، ')}. هر موفق یک پله بالا، هر ناموفق یک پله پایین.\``.
+ * `(count, outcomes) => \`منحنی نتیجه ${count} سیگنال اخیر، از قدیمیترین به جدیدترین: ${outcomes.join('، ')}. هر موفق یک پله بالا، هر ناموفق یک پله پایین.\``.
*/
curveLabel: (count: string, outcomes: string[]) => string;
/** The newest point's tooltip: `(outcome) => \`${outcome} (جدیدترین)\``. */
@@ -112,7 +117,7 @@ export type OutcomeSplitProps = {
counts: Record;
labels: Pick<
CreatorStatsLabels,
- 'outcomes' | 'splitLegend' | 'splitSentence'
+ 'splitOutcomes' | 'splitLegend' | 'splitSentence'
>;
};
diff --git a/packages/island/src/organisms/post-card/types.ts b/packages/island/src/organisms/post-card/types.ts
index 8bf7992..de5fac5 100644
--- a/packages/island/src/organisms/post-card/types.ts
+++ b/packages/island/src/organisms/post-card/types.ts
@@ -37,11 +37,11 @@ export type PostCardOwner = {
onDelete?: () => void;
/** «مشاهده به عنوان کاربر», on premium posts only. */
onPreview?: () => void;
- /** The embedded open prediction's «بستن پیشبینی». */
+ /** The embedded open prediction's «بستن سیگنال». */
onClosePrediction?: () => void;
/**
* The embedded open prediction's close waiting for ops (J09-5): PredictionCard's `pendingClose`
- * detail, which freezes «بستن پیشبینی».
+ * detail, which freezes «بستن سیگنال».
*/
pendingClose?: ReactNode;
/** 15 minutes after publishing: the edit icon stays, frozen, and explains itself. */
diff --git a/packages/island/src/organisms/prediction-card/PredictionCard.test.tsx b/packages/island/src/organisms/prediction-card/PredictionCard.test.tsx
new file mode 100644
index 0000000..dd5fb3d
--- /dev/null
+++ b/packages/island/src/organisms/prediction-card/PredictionCard.test.tsx
@@ -0,0 +1,117 @@
+import { render, screen, within } from '@testing-library/react';
+import { describe, expect, it } from 'vitest';
+
+import { PredictionCard } from './PredictionCard';
+import type { PredictionCardLabels, PredictionData } from './types';
+
+const labels = {
+ status: { open: 'فعال', win: 'موفق', loss: 'ناموفق', breakeven: 'سربهسر' },
+ direction: { long: 'خرید', short: 'فروش' },
+ horizon: (horizon: string) => horizon,
+ timeLeft: { daysLeft: (n: string) => n, underDays: (n: string) => n },
+ roi: 'بازدهی',
+ closedPrice: (price: unknown) => price,
+ heldFor: (duration: string) => duration,
+ toTarget: 'تا هدف',
+ toFinalTarget: 'تا هدف نهایی',
+ toStop: 'تا حد ضرر',
+ riskReward: 'ریسک به ریوارد',
+ riskRewardRange: (worst: string, best: string) => `${worst} تا ${best}`,
+ levels: {
+ stop: 'حد ضرر',
+ entry: 'ورود',
+ base: 'مبنا',
+ range: 'بازه',
+ entryRange: 'ورود (بازه)',
+ target: () => 'هدف',
+ finalTarget: 'هدف نهایی',
+ close: 'بستهشدن',
+ horizon: 'افق',
+ },
+ ladder: {
+ level: 'سطح',
+ price: 'قیمت',
+ change: 'تغییر از ورود',
+ state: 'وضعیت',
+ reached: 'رسید',
+ missed: 'نرسید',
+ triggered: 'فعال شد',
+ notTriggered: 'فعال نشد',
+ },
+ rangeLabel: ({ entry }: { entry: string }) => `محدوده ${entry}`,
+ horizonElapsed: (duration: string) => duration,
+ horizonEnd: (end: string) => end,
+ horizonProgress: 'زمان',
+ seal: (at: unknown) => at,
+ immutable: 'غیرقابل ویرایش',
+ locked: { title: 't', description: 'd', hidden: 'h' },
+} as unknown as PredictionCardLabels;
+
+const exact: PredictionData = {
+ symbol: 'XAUUSD',
+ direction: 'long',
+ entryPrice: 100,
+ targetPrices: [120],
+ stopLoss: 90,
+ horizon: '1w',
+ status: 'open',
+};
+const range: PredictionData = {
+ ...exact,
+ entryPrice: 68000,
+ entryLow: 67500,
+ entryHigh: 68500,
+ targetPrices: [70000],
+ stopLoss: 67000,
+};
+const card = (prediction: PredictionData, variant?: 'expanded') =>
+ render(
+ ,
+ );
+const riskRewardText = () =>
+ screen.getByText('ریسک به ریوارد').parentElement!.textContent ?? '';
+
+describe('PredictionCard entry', () => {
+ it('shows an exact entry with «مبنا» and one ratio', () => {
+ card(exact);
+ expect(screen.getByText('مبنا')).toBeTruthy();
+ expect(screen.queryByText('بازه')).toBeNull();
+ expect(riskRewardText()).not.toContain('تا ');
+ });
+
+ it('shows a range with both ends, «بازه» instead of «مبنا», and worst to best', () => {
+ card(range);
+ expect(screen.getByText('67٬500 – 68٬500')).toBeTruthy();
+ expect(screen.getByText('بازه')).toBeTruthy();
+ expect(screen.queryByText('مبنا')).toBeNull();
+ const text = riskRewardText();
+ expect(text.indexOf('1٫0')).toBeLessThan(text.indexOf('5٫0'));
+ expect(text).toContain(' تا ');
+ });
+
+ it('names the range in the bar, measured from its middle', () => {
+ card(range);
+ expect(
+ screen.getByRole('img', { name: 'محدوده 67٬500 – 68٬500' }),
+ ).toBeTruthy();
+ });
+
+ it('calls the ladder row «ورود (بازه)» on an expanded card', () => {
+ card(range, 'expanded');
+ const row = screen.getByText('ورود (بازه)').closest('tr')!;
+ expect(within(row).getByText('67٬500 – 68٬500')).toBeTruthy();
+ expect(within(row).getByText('بازه')).toBeTruthy();
+ });
+
+ it('keeps «ورود» and «مبنا» in an exact ladder row', () => {
+ card(exact, 'expanded');
+ const row = screen.getByText('مبنا').closest('tr')!;
+ expect(within(row).getByText('ورود')).toBeTruthy();
+ });
+});
diff --git a/packages/island/src/organisms/prediction-card/components/OpenKpis.tsx b/packages/island/src/organisms/prediction-card/components/OpenKpis.tsx
index 7c7bc30..4aaa7e6 100644
--- a/packages/island/src/organisms/prediction-card/components/OpenKpis.tsx
+++ b/packages/island/src/organisms/prediction-card/components/OpenKpis.tsx
@@ -37,7 +37,12 @@ export function OpenKpis({ prediction, math, labels }: PredictionPartProps) {
)}
{riskReward != null && (
- {ratio(1, riskReward)}
+ {riskReward.worst === riskReward.best
+ ? ratio(1, riskReward.worst)
+ : labels.riskRewardRange(
+ ratio(1, riskReward.worst),
+ ratio(1, riskReward.best),
+ )}
)}
diff --git a/packages/island/src/organisms/prediction-card/components/PredictionLadder.tsx b/packages/island/src/organisms/prediction-card/components/PredictionLadder.tsx
index 727fb6f..09444e8 100644
--- a/packages/island/src/organisms/prediction-card/components/PredictionLadder.tsx
+++ b/packages/island/src/organisms/prediction-card/components/PredictionLadder.tsx
@@ -6,7 +6,7 @@ import { Element } from '../../../primitives/element';
import { cn } from '../../../tools/cn';
import { CLOSE_SORT_NUDGE, EMPTY_VALUE, TREND_COLORS } from '../constants';
import type { LadderRow, PredictionPartProps } from '../types';
-import { trendOf } from '../utils';
+import { entryText, isRangeEntry, trendOf } from '../utils';
import { ladderCellVariants, ladderHeadVariants } from '../variants';
import { LevelGlyph } from './LevelGlyph';
@@ -24,6 +24,7 @@ export function PredictionLadder({
const { closed, closeFav, risk, hits, targetsFav, stopHit } = math;
const { levels, ladder } = labels;
const many = targetPrices.length > 1;
+ const isRange = isRangeEntry(prediction);
const rows: LadderRow[] = targetPrices.map((target, index) => ({
key: `t${index}`,
@@ -44,9 +45,10 @@ export function PredictionLadder({
order: 0,
change: null,
glyph: ,
- label: levels.entry,
+ label: isRange ? levels.entryRange : levels.entry,
price: entryPrice,
- state: levels.base,
+ priceText: isRange ? entryText(prediction) : undefined,
+ state: isRange ? levels.range : levels.base,
});
if (stopLoss != null && risk != null) {
rows.push({
@@ -145,7 +147,7 @@ export function PredictionLadder({
variant="body-sm"
className={cn(cell, 'text-end font-bold')}
>
- {price(row.price)}
+ {row.priceText ?? price(row.price)}
1;
+ const isRange = isRangeEntry(prediction);
- const value = (level: number, change: number | null) => (
+ const value = (level: string, change: number | null) => (
<>
- {price(level)}
+ {level}
{change == null ? (
- {labels.levels.base}
+ {isRange ? labels.levels.range : labels.levels.base}
) : (
{stopLoss != null && (
@@ -59,14 +64,14 @@ export function PredictionLevels({
glyph={ }
label={labels.levels.stop}
>
- {value(stopLoss, math.risk)}
+ {value(price(stopLoss), math.risk)}
)}
}
label={labels.levels.entry}
>
- {value(entryPrice, null)}
+ {value(entryText(prediction), null)}
{targetPrices.map((target, index) => (
- {value(target, math.targetsFav[index])}
+ {value(price(target), math.targetsFav[index])}
))}
diff --git a/packages/island/src/organisms/prediction-card/components/PredictionRange.tsx b/packages/island/src/organisms/prediction-card/components/PredictionRange.tsx
index 07dac3d..18d7d54 100644
--- a/packages/island/src/organisms/prediction-card/components/PredictionRange.tsx
+++ b/packages/island/src/organisms/prediction-card/components/PredictionRange.tsx
@@ -6,7 +6,7 @@ import { Typography } from '../../../atoms/typography';
import { Element } from '../../../primitives/element';
import { OUTCOME_TRENDS } from '../constants';
import type { PredictionRangeProps } from '../types';
-import { atPosition, bandBetween, trendOf } from '../utils';
+import { atPosition, bandBetween, entryText, trendOf } from '../utils';
import { markerVariants, rangeBandVariants, rangeVariants } from '../variants';
import { ClosePin } from './ClosePin';
@@ -14,7 +14,7 @@ import { ClosePin } from './ClosePin';
* Where the prediction stands between its stop loss (inline start, the right in RTL) and its final
* target (inline end): the risk and reward zones, entry, numbered targets that fill once reached,
* and on a closed card a fill from entry with a pin at the close. Without a stop loss the bar
- * starts at entry.
+ * starts at entry. A range entry is drawn at its middle.
*/
export function PredictionRange({
prediction,
@@ -22,8 +22,7 @@ export function PredictionRange({
labels,
expanded,
}: PredictionRangeProps) {
- const { entryPrice, targetPrices, stopLoss, closedPrice, outcome } =
- prediction;
+ const { targetPrices, stopLoss, closedPrice, outcome } = prediction;
const { position, risk, reward, closed, closeFav, targetsFav, hits } = math;
const hasStop = risk != null;
const entry = position(0);
@@ -38,7 +37,7 @@ export function PredictionRange({
const label = labels.rangeLabel({
stop: hasStop ? price(stopLoss) : undefined,
- entry: price(entryPrice),
+ entry: entryText(prediction),
targets: targetPrices.map(price),
close: closed ? price(closedPrice) : undefined,
});
diff --git a/packages/island/src/organisms/prediction-card/index.ts b/packages/island/src/organisms/prediction-card/index.ts
index b46dcf4..2ab1133 100644
--- a/packages/island/src/organisms/prediction-card/index.ts
+++ b/packages/island/src/organisms/prediction-card/index.ts
@@ -1,4 +1,5 @@
export { PredictionCard } from './PredictionCard';
+export { entryText, isRangeEntry } from './utils';
export type {
PredictionCardLabels,
PredictionCardProps,
diff --git a/packages/island/src/organisms/prediction-card/types.ts b/packages/island/src/organisms/prediction-card/types.ts
index c322470..24e28ca 100644
--- a/packages/island/src/organisms/prediction-card/types.ts
+++ b/packages/island/src/organisms/prediction-card/types.ts
@@ -28,7 +28,11 @@ export type PredictionData = {
/** The market's label from the translations: «کریپتو», «طلا», «بورس». */
market?: ReactNode;
direction: PredictionDirection;
+ /** The exact entry, or the middle of a range: every distance and return reads this. */
entryPrice: number;
+ /** A range entry: both, low below high. */
+ entryLow?: number | null;
+ entryHigh?: number | null;
/** One or more, nearest first; designed for up to three. The last one is the final target. */
targetPrices: number[];
/** Optional: without it there is no stop marker, risk zone, level or «تا حد ضرر». */
@@ -90,6 +94,8 @@ export type PredictionCardLabels = {
toStop: ReactNode;
/** «ریسک به ریوارد», against the first target. */
riskReward: ReactNode;
+ /** A range entry's lower and higher ratio, already formatted: «۱ : ۱٫۴ تا ۱ : ۳٫۰». */
+ riskRewardRange: (worst: string, best: string) => ReactNode;
/** The names of the price levels, in the levels grid, the ladder and the range axis. */
levels: {
/** «حد ضرر». */
@@ -98,6 +104,10 @@ export type PredictionCardLabels = {
entry: ReactNode;
/** Entry's reference mark in place of a % change: «مبنا». */
base: ReactNode;
+ /** The same mark on a range entry: «بازه». */
+ range: ReactNode;
+ /** The ladder's row for a range entry: «ورود (بازه)». */
+ entryRange: ReactNode;
/** A target, numbered only when there are several: `(n) => (n ? <>هدف {n}> : 'هدف')`. */
target: (n?: string) => ReactNode;
/** «هدف نهایی», the range axis's end when there are several targets. */
@@ -122,7 +132,7 @@ export type PredictionCardLabels = {
notTriggered: ReactNode;
};
/**
- * The range bar's `aria-label`: «محدوده پیشبینی: حد ضرر ۹۵٬۰۰۰، ورود ۱۰۰٬۰۰۰، هدف ۱ ۱۱۰٬۰۰۰،
+ * The range bar's `aria-label`: «محدوده سیگنال: حد ضرر ۹۵٬۰۰۰، ورود ۱۰۰٬۰۰۰، هدف ۱ ۱۱۰٬۰۰۰،
* بستهشدن ۱۰۸٬۰۰۰».
*/
rangeLabel: (values: PredictionRangeValues) => string;
@@ -141,7 +151,7 @@ export type PredictionCardLabels = {
/** The owner's pending-close row title, in bold: «در انتظار تأیید بستهشدن» (J09-5). */
pendingClose?: ReactNode;
/**
- * Why «بستن زودهنگام» is frozen while a close waits for ops: «این پیشبینی بهزودی بهصورت خودکار
+ * Why «بستن زودهنگام» is frozen while a close waits for ops: «این سیگنال بهزودی بهصورت خودکار
* بسته میشود.» (J10-3f).
*/
closeFrozen?: ReactNode;
@@ -171,7 +181,7 @@ export type PredictionCardLabels = {
};
/** A premium card for a viewer without access. */
locked: {
- /** «پیشبینی پریمیوم». */
+ /** «سیگنال پریمیوم». */
title: ReactNode;
/** «دارایی، جهت، ورود، اهداف و حد ضرر پنهان است.» */
description: ReactNode;
@@ -235,6 +245,8 @@ export type PredictionCardProps = PredictionCardOwnProps &
}
);
+export type RiskReward = { worst: number; best: number };
+
/** Every number the card shows, computed once from the prediction. */
export type PredictionMath = {
targetsFav: number[];
@@ -242,8 +254,8 @@ export type PredictionMath = {
risk: number | null;
/** The final target's favourable %. */
reward: number | null;
- /** x in «۱ : x», against the first target. */
- riskReward: number | null;
+ /** Rewards per unit of risk to the first target: one answer for an exact entry, or a range's two ends. */
+ riskReward: RiskReward | null;
/** Closed with a close price: the range draws a fill and a pin. */
closed: boolean;
closeFav: number | null;
@@ -358,6 +370,8 @@ export type LadderRow = {
glyph: ReactNode;
label: ReactNode;
price: number;
+ /** In place of `price`: a range entry's two ends. */
+ priceText?: string;
state: ReactNode;
/** A target the close reached. */
hit?: boolean;
diff --git a/packages/island/src/organisms/prediction-card/utils.test.ts b/packages/island/src/organisms/prediction-card/utils.test.ts
new file mode 100644
index 0000000..621e3c2
--- /dev/null
+++ b/packages/island/src/organisms/prediction-card/utils.test.ts
@@ -0,0 +1,81 @@
+import { describe, expect, it } from 'vitest';
+
+import type { PredictionData } from './types';
+import { entryText, isRangeEntry, predictionMath, riskRewardOf } from './utils';
+
+const exact: PredictionData = {
+ symbol: 'XAUUSD',
+ direction: 'long',
+ entryPrice: 100,
+ targetPrices: [120],
+ stopLoss: 90,
+ horizon: '1w',
+};
+const range: PredictionData = {
+ ...exact,
+ entryPrice: 68000,
+ entryLow: 67500,
+ entryHigh: 68500,
+ targetPrices: [70000],
+ stopLoss: 67000,
+};
+
+describe('riskRewardOf', () => {
+ it('has one answer for an exact entry', () => {
+ expect(riskRewardOf(exact)).toEqual({ worst: 2, best: 2 });
+ });
+
+ it('works a long range out at both ends, the lower ratio first', () => {
+ // From the top: 1500 of reward for 1500 of risk. From the bottom: 2500 for 500.
+ expect(riskRewardOf(range)).toEqual({ worst: 1, best: 5 });
+ });
+
+ it('mirrors for a short', () => {
+ const short: PredictionData = {
+ ...exact,
+ direction: 'short',
+ entryPrice: 100,
+ entryLow: 98,
+ entryHigh: 102,
+ targetPrices: [90],
+ stopLoss: 110,
+ };
+ expect(riskRewardOf(short)).toEqual({ worst: 8 / 12, best: 12 / 8 });
+ });
+
+ it('reads the first target, not the final one', () => {
+ expect(riskRewardOf({ ...exact, targetPrices: [110, 200] })).toEqual({
+ worst: 1,
+ best: 1,
+ });
+ });
+
+ it.each([
+ ['no stop', { stopLoss: null }],
+ ['no target', { targetPrices: [] }],
+ ['a stop on the wrong side', { stopLoss: 105 }],
+ ['a stop on the entry', { stopLoss: 100 }],
+ ['a target on the wrong side', { targetPrices: [95] }],
+ ])('is null with %s', (_name, over) => {
+ expect(riskRewardOf({ ...exact, ...over })).toBeNull();
+ });
+});
+
+describe('the entry', () => {
+ it('knows a range only when both ends are there', () => {
+ expect(isRangeEntry(range)).toBe(true);
+ expect(isRangeEntry(exact)).toBe(false);
+ expect(isRangeEntry({ entryLow: 1, entryHigh: null })).toBe(false);
+ });
+
+ it('writes both ends of a range, low first', () => {
+ expect(entryText(range)).toBe('67٬500 – 68٬500');
+ expect(entryText(exact)).toBe('100');
+ });
+
+ it('measures every distance from the middle of a range', () => {
+ const math = predictionMath(range);
+ expect(math.targetsFav[0]).toBeCloseTo((2000 / 68000) * 100);
+ expect(math.risk).toBeCloseTo((-1000 / 68000) * 100);
+ });
+});
diff --git a/packages/island/src/organisms/prediction-card/utils.ts b/packages/island/src/organisms/prediction-card/utils.ts
index 63cd675..1ac02f6 100644
--- a/packages/island/src/organisms/prediction-card/utils.ts
+++ b/packages/island/src/organisms/prediction-card/utils.ts
@@ -13,6 +13,7 @@ import type {
PredictionOutcome,
PredictionStatus,
PredictionTrend,
+ RiskReward,
} from './types';
export function toTime(value: DateInput): number {
@@ -48,6 +49,46 @@ export function resolveStatus(
: 'open';
}
+/** The entry is a range, not one price. */
+export function isRangeEntry(
+ prediction: Pick,
+): boolean {
+ return prediction.entryLow != null && prediction.entryHigh != null;
+}
+
+/** The entry as text: one price, or a range's two ends, low first: `۶۷٬۵۰۰ – ۶۸٬۵۰۰`. */
+export function entryText(
+ prediction: Pick,
+): string {
+ return isRangeEntry(prediction)
+ ? `${price(prediction.entryLow)} – ${price(prediction.entryHigh)}`
+ : price(prediction.entryPrice);
+}
+
+/**
+ * Reward per unit of risk to the first target, as the API works it out. An exact entry has one
+ * answer; a range is worked out at both ends, `worst` being the lower ratio and `best` the higher.
+ * Null without a stop or a target, or when a level isn't on its side of the entry.
+ */
+export function riskRewardOf(prediction: PredictionData): RiskReward | null {
+ const { direction, targetPrices, stopLoss } = prediction;
+ const target = targetPrices[0];
+ if (stopLoss == null || target == null) return null;
+ const sign = direction === 'short' ? -1 : 1;
+ const ends = isRangeEntry(prediction)
+ ? [prediction.entryLow as number, prediction.entryHigh as number]
+ : [prediction.entryPrice];
+ const ratios = ends.map(
+ (end) => ((target - end) * sign) / ((end - stopLoss) * sign),
+ );
+ const onSide = ends.every(
+ (end) => (target - end) * sign > 0 && (end - stopLoss) * sign > 0,
+ );
+ return onSide
+ ? { worst: Math.min(...ratios), best: Math.max(...ratios) }
+ : null;
+}
+
/**
* Every value is a "favourable %": the move from entry in the prediction's own direction, so a
* positive number always points toward the targets, for a long and a short alike.
@@ -72,12 +113,6 @@ export function predictionMath(prediction: PredictionData): PredictionMath {
const targetsFav = targetPrices.map(fav);
const risk = stopLoss != null ? fav(stopLoss) : null;
const reward = targetsFav.at(-1) ?? null;
- const firstReward = targetsFav[0] ?? null;
- // Risk to reward reads against the first target: the one most likely to be reached.
- const riskReward =
- risk != null && risk < 0 && firstReward != null && firstReward > 0
- ? firstReward / -risk
- : null;
const points = [0, ...targetsFav];
if (risk != null) points.push(risk);
@@ -91,7 +126,8 @@ export function predictionMath(prediction: PredictionData): PredictionMath {
targetsFav,
risk,
reward,
- riskReward,
+ // Against the first target: the one most likely to be reached.
+ riskReward: riskRewardOf(prediction),
closed: closeFav != null,
closeFav,
roi,
diff --git a/packages/island/src/organisms/prediction-card/variants.ts b/packages/island/src/organisms/prediction-card/variants.ts
index e6f877c..d54705b 100644
--- a/packages/island/src/organisms/prediction-card/variants.ts
+++ b/packages/island/src/organisms/prediction-card/variants.ts
@@ -121,8 +121,13 @@ export const levelsVariants = cva('m-0', {
true: 'grid-cols-[repeat(auto-fit,minmax(6rem,1fr))]',
false: 'grid-cols-[repeat(auto-fit,minmax(4.5rem,1fr))]',
},
+ /** A range entry's two ends need a tile of their own width. */
+ range: {
+ true: 'grid-cols-[repeat(auto-fit,minmax(10.5rem,1fr))]',
+ false: '',
+ },
},
- defaultVariants: { wide: false },
+ defaultVariants: { wide: false, range: false },
});
export const ladderHeadVariants = cva(
diff --git a/packages/island/src/styles/theme.css b/packages/island/src/styles/theme.css
index e808ad9..2236c36 100644
--- a/packages/island/src/styles/theme.css
+++ b/packages/island/src/styles/theme.css
@@ -275,6 +275,14 @@
--action-primary-subtle: var(--indigo-50);
--action-primary-muted: var(--indigo-100);
--action-primary-text: var(--indigo-700);
+ /* «دنبال کردن»: dark beside the indigo «اشتراک», so the two never compete. */
+ --action-dark: var(--indigo-950);
+ --action-dark-hover: #2a2d78;
+ /* «دنبال میکنید»: a quiet state, not a call to act. */
+ --action-quiet: #f6f9fc;
+ --action-quiet-hover: #edf1f6;
+ --action-quiet-border: #e3e8ee;
+ --action-quiet-text: #273951;
--premium: var(--indigo-950);
--premium-on: var(--saffron-300);
--premium-accent: var(--saffron-600);
@@ -344,6 +352,12 @@
--color-action-primary-subtle: var(--action-primary-subtle);
--color-action-primary-muted: var(--action-primary-muted);
--color-action-primary-text: var(--action-primary-text);
+ --color-action-dark: var(--action-dark);
+ --color-action-dark-hover: var(--action-dark-hover);
+ --color-action-quiet: var(--action-quiet);
+ --color-action-quiet-hover: var(--action-quiet-hover);
+ --color-action-quiet-border: var(--action-quiet-border);
+ --color-action-quiet-text: var(--action-quiet-text);
--color-premium: var(--premium);
--color-premium-on: var(--premium-on);
--color-premium-accent: var(--premium-accent);
diff --git a/packages/tools/src/format/format.ts b/packages/tools/src/format/format.ts
index af184e3..8e1e2b1 100644
--- a/packages/tools/src/format/format.ts
+++ b/packages/tools/src/format/format.ts
@@ -156,6 +156,11 @@ export function ratio(a: number, b: number, decimals = 1): string {
return iso(`${number(a)} : ${number(b, decimals)}`);
}
+/** A document's version: `1٫0`; the font shows Persian digits but not the decimal point. */
+export function version(value: string): string {
+ return value.replaceAll('.', DECIMAL_SEPARATOR);
+}
+
/** Shamsi date in Tehran time: `15 خرداد 1404، ساعت 14:30`, or `15 خرداد 1404` with `{ time: false }`. */
export function date(
value: DateInput,
diff --git a/packages/tools/src/format/index.ts b/packages/tools/src/format/index.ts
index 0d07ee9..70fab13 100644
--- a/packages/tools/src/format/index.ts
+++ b/packages/tools/src/format/index.ts
@@ -16,6 +16,7 @@ export {
signed,
signedPercent,
time,
+ version,
} from './format';
export { LOCALE, TIME_ZONE } from './constants';
export type { DateFormatOptions, DateInput, ShebaFormatOptions } from './types';
diff --git a/platforms/garden-roof/package.json b/platforms/garden-roof/package.json
index b497393..3a326b8 100644
--- a/platforms/garden-roof/package.json
+++ b/platforms/garden-roof/package.json
@@ -2,6 +2,9 @@
"name": "@lumina/garden-roof",
"version": "0.0.1",
"private": true,
+ "scripts": {
+ "test": "vitest run --config ../../vitest.config.ts"
+ },
"type": "module",
"sideEffects": false,
"exports": {
diff --git a/platforms/garden-roof/src/app/error-boundaries/part-boundary/types.ts b/platforms/garden-roof/src/app/error-boundaries/part-boundary/types.ts
index 9dadbce..8f545c5 100644
--- a/platforms/garden-roof/src/app/error-boundaries/part-boundary/types.ts
+++ b/platforms/garden-roof/src/app/error-boundaries/part-boundary/types.ts
@@ -2,7 +2,7 @@ export type PartBoundaryProps = {
/** The part, for the error report: «creator-stats», «feed». Never personal data. */
name: string;
/**
- * The part's own failure copy, such as «عملکرد پیشبینیها بارگذاری نشد» / «بقیه کانال در دسترس
+ * The part's own failure copy, such as «عملکرد سیگنالها بارگذاری نشد» / «بقیه کانال در دسترس
* است…» (S3); without it the fallback says what every part says.
*/
title?: string;
diff --git a/platforms/garden-roof/src/app/navigation/constants.ts b/platforms/garden-roof/src/app/navigation/constants.ts
index 1c98289..6c8bccc 100644
--- a/platforms/garden-roof/src/app/navigation/constants.ts
+++ b/platforms/garden-roof/src/app/navigation/constants.ts
@@ -10,6 +10,7 @@ export const NAV_ITEMS: readonly NavItem[] = [
{ section: 'preds', icon: 'target' },
{ section: 'payouts', icon: 'wallet' },
{ section: 'featured', icon: 'star' },
+ { section: 'settings', icon: 'settings' },
];
export const SOON_ITEMS: readonly SoonItem[] = [
diff --git a/platforms/garden-roof/src/app/navigation/navigation.ts b/platforms/garden-roof/src/app/navigation/navigation.ts
index 93fa451..a75b8e2 100644
--- a/platforms/garden-roof/src/app/navigation/navigation.ts
+++ b/platforms/garden-roof/src/app/navigation/navigation.ts
@@ -15,6 +15,7 @@ export const ROUTES = {
predictions: '/predictions',
payouts: '/payouts',
featured: '/featured',
+ settings: '/settings',
} as const;
/** Where a signed-in admin lands, and where «بازگشت» goes when nothing else fits. */
@@ -47,6 +48,7 @@ export const SECTION_ROUTES: Record = {
preds: ROUTES.predictions,
payouts: ROUTES.payouts,
featured: ROUTES.featured,
+ settings: ROUTES.settings,
};
export function sectionOf(pathname: string): AdminSection | null {
diff --git a/platforms/garden-roof/src/app/navigation/types.ts b/platforms/garden-roof/src/app/navigation/types.ts
index fe1cbcc..b9f1f01 100644
--- a/platforms/garden-roof/src/app/navigation/types.ts
+++ b/platforms/garden-roof/src/app/navigation/types.ts
@@ -9,7 +9,8 @@ export type AdminSection =
| 'subs'
| 'preds'
| 'payouts'
- | 'featured';
+ | 'featured'
+ | 'settings';
/** Sections whose sidebar link shows what waits there. */
export type CountedSection = 'verify' | 'codes' | 'preds' | 'payouts';
diff --git a/platforms/garden-roof/src/features/predictions/actions/override-prediction/actions.ts b/platforms/garden-roof/src/features/predictions/actions/override-prediction/actions.ts
index f1f84eb..8f13a67 100644
--- a/platforms/garden-roof/src/features/predictions/actions/override-prediction/actions.ts
+++ b/platforms/garden-roof/src/features/predictions/actions/override-prediction/actions.ts
@@ -6,7 +6,7 @@ import type { OverridePredictionArgs } from '../../repositories/predictions';
/**
* «ثبت اصلاح» (J11-8d): a closed prediction's close price changes from the same source. On an open
- * prediction, «بستن پیشبینی» closes it now at the admin's price (a symbol with no quote is never
+ * prediction, «بستن سیگنال» closes it now at the admin's price (a symbol with no quote is never
* proposed). Either way investors see «علت: اصلاح توسط ادمین» (J09-5d) and the analyst's track
* record follows the outcome. Emits `prediction.overridden`.
*/
diff --git a/platforms/garden-roof/src/features/predictions/models/queues/use-prediction-detail-part.ts b/platforms/garden-roof/src/features/predictions/models/queues/use-prediction-detail-part.ts
index 179b313..836377d 100644
--- a/platforms/garden-roof/src/features/predictions/models/queues/use-prediction-detail-part.ts
+++ b/platforms/garden-roof/src/features/predictions/models/queues/use-prediction-detail-part.ts
@@ -6,7 +6,7 @@ import {
} from '../../repositories/predictions';
import type { PredictionDetailPartModel } from './types';
-/** «جزئیات پیشبینی» (J11-8c): the card, «خط زمانی» and «گزارش ممیزی»; refetched after each action. */
+/** «جزئیات سیگنال» (J11-8c): the card, «خط زمانی» and «گزارش ممیزی»; refetched after each action. */
export function usePredictionDetailPart(id: string): PredictionDetailPartModel {
const { data } = useSuspenseQuery({
queryKey: predictionKeys.detail(id),
diff --git a/platforms/garden-roof/src/features/predictions/models/queues/use-predictions-page.ts b/platforms/garden-roof/src/features/predictions/models/queues/use-predictions-page.ts
index 9896d04..9b80f98 100644
--- a/platforms/garden-roof/src/features/predictions/models/queues/use-predictions-page.ts
+++ b/platforms/garden-roof/src/features/predictions/models/queues/use-predictions-page.ts
@@ -10,7 +10,7 @@ import type { PredictionsPageModel } from './types';
import { usePredictionActions } from './use-prediction-actions';
/**
- * پیشبینیها (J11-8): the queue (نیاز به تأیید by default, with the sidebar's count), its page and
+ * سیگنالها (J11-8): the queue (نیاز به تأیید by default, with the sidebar's count), its page and
* the prediction open beside the table (J11-8c) live in the URL, so a reload or a shared link
* keeps them. Closing never happens without ops: a detected close waits in نیاز به تأیید while the
* card stays «فعال».
diff --git a/platforms/garden-roof/src/features/settings/actions/save-price-floor/actions.ts b/platforms/garden-roof/src/features/settings/actions/save-price-floor/actions.ts
new file mode 100644
index 0000000..c8409f6
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/actions/save-price-floor/actions.ts
@@ -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 {
+ const result = await settingsRepository.savePriceFloor(args);
+ if (emit) {
+ eventEmitter.emit(SETTINGS_EVENTS.priceFloorChanged, {
+ monthlyMin: result.monthlyMin,
+ });
+ }
+ return result;
+}
diff --git a/platforms/garden-roof/src/features/settings/actions/save-price-floor/index.ts b/platforms/garden-roof/src/features/settings/actions/save-price-floor/index.ts
new file mode 100644
index 0000000..f503a6e
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/actions/save-price-floor/index.ts
@@ -0,0 +1 @@
+export { savePriceFloor } from './actions';
diff --git a/platforms/garden-roof/src/features/settings/constants.ts b/platforms/garden-roof/src/features/settings/constants.ts
new file mode 100644
index 0000000..118fed4
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/constants.ts
@@ -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;
diff --git a/platforms/garden-roof/src/features/settings/entities/price-floor/index.ts b/platforms/garden-roof/src/features/settings/entities/price-floor/index.ts
new file mode 100644
index 0000000..65ef958
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/entities/price-floor/index.ts
@@ -0,0 +1 @@
+export type { AffectedTierEntity } from './types';
diff --git a/platforms/garden-roof/src/features/settings/entities/price-floor/types.ts b/platforms/garden-roof/src/features/settings/entities/price-floor/types.ts
new file mode 100644
index 0000000..3fa1d29
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/entities/price-floor/types.ts
@@ -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;
+};
diff --git a/platforms/garden-roof/src/features/settings/http.ts b/platforms/garden-roof/src/features/settings/http.ts
new file mode 100644
index 0000000..179cffd
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/http.ts
@@ -0,0 +1,3 @@
+import { http } from '@lumina/libs/http';
+
+export const settingsHttp = http.extend({});
diff --git a/platforms/garden-roof/src/features/settings/index.ts b/platforms/garden-roof/src/features/settings/index.ts
new file mode 100644
index 0000000..3b6cacc
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/index.ts
@@ -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';
diff --git a/platforms/garden-roof/src/features/settings/models/price-floor/index.ts b/platforms/garden-roof/src/features/settings/models/price-floor/index.ts
new file mode 100644
index 0000000..e54492f
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/models/price-floor/index.ts
@@ -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';
diff --git a/platforms/garden-roof/src/features/settings/models/price-floor/price-floor-rules.test.ts b/platforms/garden-roof/src/features/settings/models/price-floor/price-floor-rules.test.ts
new file mode 100644
index 0000000..6af3c75
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/models/price-floor/price-floor-rules.test.ts
@@ -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[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',
+ );
+ });
+});
diff --git a/platforms/garden-roof/src/features/settings/models/price-floor/price-floor-rules.ts b/platforms/garden-roof/src/features/settings/models/price-floor/price-floor-rules.ts
new file mode 100644
index 0000000..4767ca9
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/models/price-floor/price-floor-rules.ts
@@ -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;
+}
diff --git a/platforms/garden-roof/src/features/settings/models/price-floor/types.ts b/platforms/garden-roof/src/features/settings/models/price-floor/types.ts
new file mode 100644
index 0000000..6c313ba
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/models/price-floor/types.ts
@@ -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;
+};
diff --git a/platforms/garden-roof/src/features/settings/models/price-floor/use-price-floor-page.ts b/platforms/garden-roof/src/features/settings/models/price-floor/use-price-floor-page.ts
new file mode 100644
index 0000000..bab3a94
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/models/price-floor/use-price-floor-page.ts
@@ -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,
+ };
+}
diff --git a/platforms/garden-roof/src/features/settings/repositories/settings/constants.ts b/platforms/garden-roof/src/features/settings/repositories/settings/constants.ts
new file mode 100644
index 0000000..348f722
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/repositories/settings/constants.ts
@@ -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,
+};
diff --git a/platforms/garden-roof/src/features/settings/repositories/settings/index.ts b/platforms/garden-roof/src/features/settings/repositories/settings/index.ts
new file mode 100644
index 0000000..b0eb83c
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/repositories/settings/index.ts
@@ -0,0 +1,9 @@
+export { SETTINGS_ENDPOINTS, settingsKeys } from './constants';
+export { settingsRepository } from './settings';
+export type {
+ AffectedTierPayload,
+ PreviewPriceFloorArgs,
+ PriceFloorChangePayload,
+ PriceFloorPayload,
+ SavePriceFloorArgs,
+} from './types';
diff --git a/platforms/garden-roof/src/features/settings/repositories/settings/mappers.ts b/platforms/garden-roof/src/features/settings/repositories/settings/mappers.ts
new file mode 100644
index 0000000..85ff443
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/repositories/settings/mappers.ts
@@ -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 };
+}
diff --git a/platforms/garden-roof/src/features/settings/repositories/settings/settings.ts b/platforms/garden-roof/src/features/settings/repositories/settings/settings.ts
new file mode 100644
index 0000000..18e08e7
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/repositories/settings/settings.ts
@@ -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 {
+ const response = await settingsHttp.get(
+ 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 {
+ const response = await settingsHttp.put(
+ 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 {
+ const response = await settingsHttp.put(
+ SETTINGS_ENDPOINTS.priceFloor,
+ toSavePriceFloorDto(args),
+ );
+ return toPriceFloorChangePayload(response);
+ },
+};
diff --git a/platforms/garden-roof/src/features/settings/repositories/settings/types.ts b/platforms/garden-roof/src/features/settings/repositories/settings/types.ts
new file mode 100644
index 0000000..d6e0ec4
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/repositories/settings/types.ts
@@ -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[];
+};
diff --git a/platforms/garden-roof/src/features/settings/types.ts b/platforms/garden-roof/src/features/settings/types.ts
new file mode 100644
index 0000000..50eaaa0
--- /dev/null
+++ b/platforms/garden-roof/src/features/settings/types.ts
@@ -0,0 +1,7 @@
+declare module '@lumina/libs/event-emitter' {
+ interface EventMap {
+ 'settings.price-floor-changed': { monthlyMin: number };
+ }
+}
+
+export {};
diff --git a/platforms/garden-roof/src/index.ts b/platforms/garden-roof/src/index.ts
index cf48a9f..5bfee09 100644
--- a/platforms/garden-roof/src/index.ts
+++ b/platforms/garden-roof/src/index.ts
@@ -350,6 +350,26 @@ export type {
ReadyPayoutPayload,
ReadyPayoutsPartModel,
} 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 {
addFeatured,
FEATURED_ENDPOINTS,
diff --git a/platforms/garden-roof/src/shared/locales/fa/common.json b/platforms/garden-roof/src/shared/locales/fa/common.json
index cec21cf..4ef97d7 100644
--- a/platforms/garden-roof/src/shared/locales/fa/common.json
+++ b/platforms/garden-roof/src/shared/locales/fa/common.json
@@ -13,9 +13,10 @@
"analysts": "مدیریت تحلیلگران",
"codes": "کدهای دعوت",
"subs": "اشتراکها",
- "preds": "پیشبینیها",
+ "preds": "سیگنالها",
"payouts": "تسویه تحلیلگران",
"featured": "تحلیلگران منتخب",
+ "settings": "تنظیمات",
"soon": "بهزودی",
"soon-items": {
"users": "کاربران",
@@ -132,7 +133,9 @@
"ledger.corrected": "اصلاح موجودی",
"featured.added": "به منتخب اضافه شد",
"featured.removed": "از منتخب حذف شد",
- "featured.reordered": "ترتیب تغییر کرد"
+ "featured.reordered": "ترتیب تغییر کرد",
+ "legal.published": "نسخه تازه سند منتشر شد",
+ "settings.price_floor_changed": "کف قیمت تغییر کرد"
},
"capacity-up": "افزایش ظرفیت از {{from}} به {{to}}",
"capacity-down": "کاهش ظرفیت از {{from}} به {{to}}",
diff --git a/platforms/garden-roof/src/shared/locales/fa/featured.json b/platforms/garden-roof/src/shared/locales/fa/featured.json
index ec46390..d8491a0 100644
--- a/platforms/garden-roof/src/shared/locales/fa/featured.json
+++ b/platforms/garden-roof/src/shared/locales/fa/featured.json
@@ -83,7 +83,7 @@
"verified": "تأییدشده",
"markets": "بازارهای تخصصی",
"win-rate": "نرخ موفقیت",
- "predictions": "پیشبینی",
+ "predictions": "سیگنال",
"avg-roi": "میانگین بازده",
"no-record": "کارنامه عمومی هنوز فعال نشده است.",
"followers": "{{followers}} دنبالکننده",
diff --git a/platforms/garden-roof/src/shared/locales/fa/health.json b/platforms/garden-roof/src/shared/locales/fa/health.json
index 8bdbae2..68e5f95 100644
--- a/platforms/garden-roof/src/shared/locales/fa/health.json
+++ b/platforms/garden-roof/src/shared/locales/fa/health.json
@@ -29,7 +29,7 @@
"labels": {
"active_analysts": "تحلیلگران فعال",
"avg_paid_subscribers": "میانگین مشترک پرداختی هر تحلیلگر",
- "publishing_analysts": "تحلیلگرانی که پیشبینی منتشر کردهاند",
+ "publishing_analysts": "تحلیلگرانی که سیگنال منتشر کردهاند",
"paid_subscribers": "کل مشترکان پرداختی"
},
"value": "{{value}} / {{target}}",
@@ -58,7 +58,7 @@
"payment_result": "پرداخت موفق",
"kyc_submitted": "ارسال مدارک احراز هویت",
"verification_approved": "تأیید احراز هویت",
- "first_prediction_published": "اولین پیشبینی منتشرشده"
+ "first_prediction_published": "اولین سیگنال منتشرشده"
}
},
"timeline": {
@@ -82,7 +82,7 @@
"columns": {
"analyst": "تحلیلگر",
"paid": "مشترک پرداختی",
- "predictions": "پیشبینی منتشرشده",
+ "predictions": "سیگنال منتشرشده",
"capacity": "ظرفیت کد",
"completion": "نرخ تکمیل پرداخت"
},
@@ -103,7 +103,7 @@
"onboarding": {
"label": "زمان آمادهسازی تحلیلگر",
"value": "{{days}} روز",
- "hint": "میانه، از ثبتنام تا اولین پیشبینی منتشرشده"
+ "hint": "میانه، از ثبتنام تا اولین سیگنال منتشرشده"
},
"churn": {
"label": "ریزش ماه اول",
@@ -114,8 +114,8 @@
"hint": "{{completed}} پرداخت موفق از {{started}} ورود به درگاه"
},
"pace": {
- "label": "پیشبینی هر تحلیلگر در ماه",
- "hint": "{{predictions}} پیشبینی در {{days}} روز، {{analysts}} تحلیلگر فعال"
+ "label": "سیگنال هر تحلیلگر در ماه",
+ "hint": "{{predictions}} سیگنال در {{days}} روز، {{analysts}} تحلیلگر فعال"
},
"views": {
"label": "بازدید کارنامه",
diff --git a/platforms/garden-roof/src/shared/locales/fa/predictions.json b/platforms/garden-roof/src/shared/locales/fa/predictions.json
index 0e65c48..c8aa8a0 100644
--- a/platforms/garden-roof/src/shared/locales/fa/predictions.json
+++ b/platforms/garden-roof/src/shared/locales/fa/predictions.json
@@ -1,9 +1,9 @@
{
"page": {
- "title": "پیشبینیها",
- "meta-title": "پیشبینیها",
- "subtitle": "بستن خودکار تا تأیید ادمین منتشر نمیشود؛ پیشبینی تا آن زمان «فعال» میماند.",
- "loading": "در حال بارگذاری پیشبینیها…"
+ "title": "سیگنالها",
+ "meta-title": "سیگنالها",
+ "subtitle": "بستن خودکار تا تأیید ادمین منتشر نمیشود؛ سیگنال تا آن زمان «فعال» میماند.",
+ "loading": "در حال بارگذاری سیگنالها…"
},
"health": {
"title": "وضعیت منابع قیمت",
@@ -15,7 +15,7 @@
"fresh": "بهروز",
"stale": "{{minutes}} دقیقه بدون قیمت",
"stale-no-price": "بدون قیمت",
- "banner": "پیشنهاد بستن پیشبینیهای {{markets}} تا رسیدن قیمت تازه منتظر میماند و در این صف نمایش داده نمیشود. این پیشبینیها تا آن زمان باز میمانند.",
+ "banner": "پیشنهاد بستن سیگنالهای {{markets}} تا رسیدن قیمت تازه منتظر میماند و در این صف نمایش داده نمیشود. این سیگنالها تا آن زمان باز میمانند.",
"loading": "در حال بررسی منابع قیمت…",
"error": "وضعیت منابع قیمت بارگذاری نشد."
},
@@ -49,7 +49,7 @@
"other": "سایر"
},
"queues": {
- "label": "صفهای پیشبینی",
+ "label": "صفهای سیگنال",
"tabs": {
"needs_review": "نیاز به تأیید",
"open": "باز",
@@ -57,8 +57,8 @@
"flagged": "پرچمخورده"
},
"count": "{{count}} پیشنهاد در انتظار تأیید",
- "loading": "در حال بارگذاری پیشبینیها…",
- "error": "فهرست پیشبینیها بارگذاری نشد.",
+ "loading": "در حال بارگذاری سیگنالها…",
+ "error": "فهرست سیگنالها بارگذاری نشد.",
"columns": {
"symbol": "نماد",
"analyst": "تحلیلگر",
@@ -82,16 +82,16 @@
"flag": "پرچمگذاری",
"open": "جزئیات"
},
- "open-row": "جزئیات پیشبینی {{symbol}} از {{name}}",
+ "open-row": "جزئیات سیگنال {{symbol}} از {{name}}",
"pending": "پیشنهاد بستن در انتظار تأیید",
"held": "در انتظار قیمت {{source}}",
"review": "بررسی و بستن",
"close-admin": "بستن با قیمت ادمین",
"flag": "پرچمگذاری",
- "flag-row": "پرچمگذاری پیشبینی {{symbol}} از {{name}}",
+ "flag-row": "پرچمگذاری سیگنال {{symbol}} از {{name}}",
"unflag": "برداشتن پرچم",
"order": {
- "needs_review": "ترتیب: قدیمیترین رویداد اول. پیشبینی تا تأیید ادمین باز میماند.",
+ "needs_review": "ترتیب: قدیمیترین رویداد اول. سیگنال تا تأیید ادمین باز میماند.",
"open": "جدیدترین انتشار اول",
"closed": "ترتیب: جدیدترین بستهشدن اول.",
"flagged": "ترتیب: جدیدترین پرچم اول."
@@ -104,24 +104,24 @@
"description": "بستنهای خودکار تازه پیش از انتشار اینجا منتظر تأیید میمانند."
},
"open": {
- "title": "پیشبینی بازی نیست",
- "description": "پیشبینیهای منتشرشده تا بسته شدن اینجا نمایش داده میشوند."
+ "title": "سیگنال بازی نیست",
+ "description": "سیگنالهای منتشرشده تا بسته شدن اینجا نمایش داده میشوند."
},
"closed": {
- "title": "هنوز پیشبینیای بسته نشده است",
- "description": "پیشبینیهای بستهشده با نتیجهشان اینجا نمایش داده میشوند."
+ "title": "هنوز سیگنالی بسته نشده است",
+ "description": "سیگنالهای بستهشده با نتیجهشان اینجا نمایش داده میشوند."
},
"flagged": {
- "title": "پیشبینی پرچمخوردهای نیست",
- "description": "پیشبینیهایی که پرچم بخورند اینجا نمایش داده میشوند."
+ "title": "سیگنال پرچمخوردهای نیست",
+ "description": "سیگنالهایی که پرچم بخورند اینجا نمایش داده میشوند."
}
}
},
"detail": {
- "title": "جزئیات پیشبینی",
+ "title": "جزئیات سیگنال",
"channel": "کانال",
- "loading": "در حال بارگذاری پیشبینی…",
- "error": "پیشبینی بارگذاری نشد.",
+ "loading": "در حال بارگذاری سیگنال…",
+ "error": "سیگنال بارگذاری نشد.",
"review": "بررسی و بستن",
"override": "اصلاح نتیجه",
"close-admin": "بستن با قیمت ادمین",
@@ -148,7 +148,7 @@
}
},
"confirm": {
- "title": "تأیید بستن پیشبینی",
+ "title": "تأیید بستن سیگنال",
"fields": {
"event": "رویداد",
"proposed": "قیمت پیشنهادی",
@@ -162,8 +162,8 @@
"reject": "رد پیشنهاد",
"lock": "پس از تأیید، نتیجه روی کارت و در کارنامه تحلیلگر ثبت میشود و فقط با «اصلاح نتیجه» تغییر میکند.",
"confirm": "تأیید و بستن",
- "done": "پیشبینی بسته شد.",
- "failed": "بستن پیشبینی انجام نشد"
+ "done": "سیگنال بسته شد.",
+ "failed": "بستن سیگنال انجام نشد"
},
"correct": {
"price": "قیمت اصلاحشده",
@@ -173,18 +173,18 @@
"price-required": "قیمت اصلاحشده را بنویسید.",
"price-invalid": "قیمت را بهصورت یک عدد مثبت بنویسید.",
"price-same": "قیمت اصلاحشده با قیمت ثبتشده یکی است؛ برای همین قیمت «لغو اصلاح» را بزنید.",
- "done": "پیشبینی با قیمت اصلاحشده بسته شد."
+ "done": "سیگنال با قیمت اصلاحشده بسته شد."
},
"reject": {
"title": "رد پیشنهاد بستن",
- "banner": "پیشبینی باز میماند و بررسی قیمت ادامه پیدا میکند. قیمت ثبتشده حذف نمیشود و در گزارش ممیزی میماند.",
+ "banner": "سیگنال باز میماند و بررسی قیمت ادامه پیدا میکند. قیمت ثبتشده حذف نمیشود و در گزارش ممیزی میماند.",
"empty": "ابتدا دلیل رد پیشنهاد را بنویسید.",
"confirm": "رد پیشنهاد",
"done": "پیشنهاد بستن رد شد.",
"failed": "رد پیشنهاد انجام نشد"
},
"override": {
- "title": "اصلاح نتیجه پیشبینی",
+ "title": "اصلاح نتیجه سیگنال",
"compare": "فعلی ← پس از اصلاح",
"fields": {
"closed-price": "قیمت بستهشدن",
@@ -194,7 +194,7 @@
"price": "قیمت بستهشدن جدید",
"source-fixed": "منبع ثابت است: {{source}}",
"source-fixed-horizon": "منبع ثابت است: {{source}}، قیمت پایان افق ({{time}})",
- "impact": "سرمایهگذاران روی کارت این پیشبینی میبینند: «علت: اصلاح توسط ادمین».",
+ "impact": "سرمایهگذاران روی کارت این سیگنال میبینند: «علت: اصلاح توسط ادمین».",
"impact-record": "کارنامه {{name}} تغییر میکند: نرخ موفقیت {{before}} ← {{after}}.",
"confirm": "ثبت اصلاح",
"price-required": "قیمت بستهشدن را بنویسید.",
@@ -204,22 +204,22 @@
"failed": "اصلاح نتیجه انجام نشد"
},
"close-admin": {
- "title": "بستن پیشبینی با قیمت ادمین",
+ "title": "بستن سیگنال با قیمت ادمین",
"compare": "پس از بستن",
"fields": {
"entry": "قیمت ورود"
},
"price": "قیمت بستهشدن",
"hint": "زمان بستهشدن همین لحظه ثبت میشود.",
- "impact": "پیشبینی با این قیمت بسته میشود و دوباره باز نمیشود. سرمایهگذاران روی کارت میبینند: «علت: اصلاح توسط ادمین» و تحلیلگر و دنبالکنندگان اعلان بستهشدن میگیرند.",
- "impact-pending": "پیشنهاد بستن در انتظار این پیشبینی هم کنار گذاشته میشود.",
- "confirm": "بستن پیشبینی",
- "done": "پیشبینی با قیمت ادمین بسته شد.",
- "failed": "بستن پیشبینی انجام نشد"
+ "impact": "سیگنال با این قیمت بسته میشود و دوباره باز نمیشود. سرمایهگذاران روی کارت میبینند: «علت: اصلاح توسط ادمین» و تحلیلگر و دنبالکنندگان اعلان بستهشدن میگیرند.",
+ "impact-pending": "پیشنهاد بستن در انتظار این سیگنال هم کنار گذاشته میشود.",
+ "confirm": "بستن سیگنال",
+ "done": "سیگنال با قیمت ادمین بسته شد.",
+ "failed": "بستن سیگنال انجام نشد"
},
"flag": {
- "title": "پرچمگذاری پیشبینی",
- "banner": "پرچمها داخلیاند: روی کارت، کارنامه و نتیجهٔ این پیشبینی اثری ندارند و فقط ادمینها آنها را میبینند.",
+ "title": "پرچمگذاری سیگنال",
+ "banner": "پرچمها داخلیاند: روی کارت، کارنامه و نتیجهٔ این سیگنال اثری ندارند و فقط ادمینها آنها را میبینند.",
"reason": "دلیل",
"reason-label": "دلیل پرچم",
"note": "توضیح",
@@ -236,7 +236,7 @@
"done": "پرچم برداشته شد.",
"failed": "برداشتن پرچم انجام نشد"
},
- "conflict": "این پیشبینی پیشتر بسته یا بررسی شده است؛ اطلاعات بهروز شد.",
+ "conflict": "این سیگنال پیشتر بسته یا بررسی شده است؛ اطلاعات بهروز شد.",
"card": {
"status": {
"open": "فعال",
@@ -263,7 +263,9 @@
"target-n": "هدف {{n}}",
"final-target": "هدف نهایی",
"close": "بستهشدن",
- "horizon": "افق"
+ "horizon": "افق",
+ "range": "بازه",
+ "entry-range": "ورود (بازه)"
},
"ladder": {
"level": "سطح",
@@ -276,7 +278,7 @@
"not-triggered": "فعال نشد"
},
"range": {
- "label": "محدوده پیشبینی: {{values}}",
+ "label": "محدوده سیگنال: {{values}}",
"stop": "حد ضرر {{price}}",
"entry": "ورود {{price}}",
"target": "هدف {{price}}",
@@ -299,10 +301,11 @@
"price-source": "منبع قیمت:"
},
"locked": {
- "title": "پیشبینی پریمیوم",
+ "title": "سیگنال پریمیوم",
"description": "دارایی، جهت، ورود، اهداف و حد ضرر پنهان است.",
"hidden": "پنهان",
"content": "محتوای پریمیوم"
- }
+ },
+ "risk-reward-range": "{{worst}} تا {{best}}"
}
}
diff --git a/platforms/garden-roof/src/shared/locales/fa/settings.json b/platforms/garden-roof/src/shared/locales/fa/settings.json
new file mode 100644
index 0000000..5d6bf4f
--- /dev/null
+++ b/platforms/garden-roof/src/shared/locales/fa/settings.json
@@ -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": "کف قیمت ذخیره نشد"
+ }
+}
diff --git a/platforms/garden-roof/src/shared/locales/resources.ts b/platforms/garden-roof/src/shared/locales/resources.ts
index 99d33f1..efc64dc 100644
--- a/platforms/garden-roof/src/shared/locales/resources.ts
+++ b/platforms/garden-roof/src/shared/locales/resources.ts
@@ -7,6 +7,7 @@ import faFeatured from './fa/featured.json';
import faHealth from './fa/health.json';
import faPayouts from './fa/payouts.json';
import faPredictions from './fa/predictions.json';
+import faSettings from './fa/settings.json';
import faSubscriptions from './fa/subscriptions.json';
import faVerification from './fa/verification.json';
@@ -28,6 +29,7 @@ export const resources = {
predictions: faPredictions,
payouts: faPayouts,
featured: faFeatured,
+ settings: faSettings,
},
} as const;
diff --git a/platforms/garden-roof/src/shared/validations/index.ts b/platforms/garden-roof/src/shared/validations/index.ts
index 673be05..9013774 100644
--- a/platforms/garden-roof/src/shared/validations/index.ts
+++ b/platforms/garden-roof/src/shared/validations/index.ts
@@ -57,3 +57,7 @@ export type {
MarkPaidFormOutput,
MarkPaidFormValues,
} from './payout-validations';
+export {
+ monthlyFloorSchema,
+ PRICE_FLOOR_MIN_TOMAN,
+} from './settings-validations';
diff --git a/platforms/garden-roof/src/shared/validations/settings-validations.ts b/platforms/garden-roof/src/shared/validations/settings-validations.ts
new file mode 100644
index 0000000..488c159
--- /dev/null
+++ b/platforms/garden-roof/src/shared/validations/settings-validations.ts
@@ -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'),
+);
diff --git a/platforms/market/package.json b/platforms/market/package.json
index ae48a33..fdc4382 100644
--- a/platforms/market/package.json
+++ b/platforms/market/package.json
@@ -2,6 +2,9 @@
"name": "@lumina/market",
"version": "0.0.1",
"private": true,
+ "scripts": {
+ "test": "vitest run --config ../../vitest.config.ts"
+ },
"type": "module",
"sideEffects": false,
"exports": {
diff --git a/platforms/market/src/app/app-shell/AppShell.tsx b/platforms/market/src/app/app-shell/AppShell.tsx
index 8120d73..1072c46 100644
--- a/platforms/market/src/app/app-shell/AppShell.tsx
+++ b/platforms/market/src/app/app-shell/AppShell.tsx
@@ -5,6 +5,7 @@ import { QueryClientProvider } from '@tanstack/react-query';
import { useEffect } from 'react';
import { I18nextProvider } from 'react-i18next';
+import { AgreementGate } from '../screens/organisms/agreement-gate';
import { useCheckoutDraftStore } from '../../stores/checkout-draft';
import { usePostDraftStore } from '../../stores/post-draft';
import { NetworkBoundary } from './components/NetworkBoundary';
@@ -23,9 +24,15 @@ import type { AppShellProps } from './types';
*
* The toasts sit above whatever the screen declares with island's `useToastPlacement`: the bottom
* nav (80px), a pinned footer (152px), the desktop app (32px, declared by bear's root layout), and
- * low (24px) on a task page or over a sheet.
+ * low (24px) on a task page or over a sheet. An analyst who owes a newer major agreement gets its
+ * blocking modal over any page (J01-4).
*/
-export function AppShell({ queryClient, i18n, children }: AppShellProps) {
+export function AppShell({
+ queryClient,
+ i18n,
+ layout,
+ children,
+}: AppShellProps) {
useSession(queryClient);
useSuspendedHalt();
useSettleAbandonedPayment(queryClient);
@@ -40,6 +47,7 @@ export function AppShell({ queryClient, i18n, children }: AppShellProps) {
{children}
+
standing === 'pending' || standing === 'rejected' || standing === 'suspended';
/**
- * «انتشار» (C4 ۱.۱, ۱.۲, ۷.۱): a verified creator gets the menu, «پست جدید» or «پیشبینی جدید». A
+ * «انتشار» (C4 ۱.۱, ۱.۲, ۷.۱): a verified creator gets the menu, «پست جدید» or «سیگنال جدید». A
* creator who can't publish sees it frozen, and a press explains why instead of a tooltip. On
* mobile the open menu sits centred over the nav, on a light scrim that dims the page down to the
* nav; a press on the scrim closes it, and the FAB turns into an icon-only ✕ «بستن» (J08-1b). A
diff --git a/platforms/market/src/app/navigation/navigation.ts b/platforms/market/src/app/navigation/navigation.ts
index 6fff006..fcce5aa 100644
--- a/platforms/market/src/app/navigation/navigation.ts
+++ b/platforms/market/src/app/navigation/navigation.ts
@@ -57,10 +57,10 @@ export const ROUTES = {
subscriptions: '/dashboard/subscriptions',
transactions: '/dashboard/transactions',
following: '/dashboard/following',
- /** The creator's داشبورد: «طرحهای اشتراک» (the default tab), «پیشبینیها» and «مالی». */
+ /** The creator's داشبورد: «طرحهای اشتراک» (the default tab), «سیگنالها» and «مالی». */
plans: '/dashboard/plans',
predictions: '/dashboard/predictions',
- /** «همه پیشبینیها», pushed from the «پیشبینیها» tab; `?status=closed|all`. */
+ /** «همه سیگنالها», pushed from the «سیگنالها» tab; `?status=closed|all`. */
predictionsAll: '/dashboard/predictions/all',
finance: '/dashboard/finance',
/** C7, pushed from the «قیمت طرحها» card. */
@@ -72,10 +72,11 @@ export const ROUTES = {
creatorProfileDone: '/onboarding/creator-profile/done',
investorProfile: '/onboarding/investor-profile',
},
- /** «قوانین لومینا» (G-2r): «قوانین عمومی» and «شرایط اشتراک», one tab each. */
+ /** «قوانین و مقررات لومینا» (G-2r): «قوانین و مقررات» and «شرایط اشتراک», one tab each. */
rules: {
general: '/terms',
subscription: '/terms/subscription',
+ analystAgreement: '/terms/analyst-agreement',
},
} as const;
diff --git a/platforms/market/src/app/screens/(auth)/auth/login/organisms/login-step/LoginStep.tsx b/platforms/market/src/app/screens/(auth)/auth/login/organisms/login-step/LoginStep.tsx
index ec60d72..1e8bc3d 100644
--- a/platforms/market/src/app/screens/(auth)/auth/login/organisms/login-step/LoginStep.tsx
+++ b/platforms/market/src/app/screens/(auth)/auth/login/organisms/login-step/LoginStep.tsx
@@ -14,6 +14,7 @@ import { useLoginPage } from '../../../../../../../features/auth';
import { translateMessage } from '../../../../../../../shared/utils';
import { useAuthRoutes } from '../../../../../../navigation';
import { SupportEntry } from '../../../../../organisms/support-entry';
+import { RulesCaption } from '../../../organisms/rules-caption';
import type { LoginStepProps } from './types';
/**
@@ -108,6 +109,7 @@ export function LoginStep({ size, supportPlacement }: LoginStepProps) {
>
{t('login.submit')}
+
({
+ legalRepository: { getDocument: vi.fn() },
+}));
+
+const i18n = createInstance();
+void i18n.use(initReactI18next).init({
+ lng: 'fa',
+ resources,
+ interpolation: { escapeValue: false },
+});
+
+const wrapper = ({ children }: { children: ReactNode }) => (
+
+ {children}
+
+);
+
+describe('RulesCaption', () => {
+ beforeEach(() => {
+ vi.mocked(legalRepository.getDocument).mockResolvedValue({
+ key: 'platform_rules',
+ version: '1.0',
+ title: 'قوانین و مقررات لومینا',
+ bodyMd: '## قوانین پلتفرم\n\nمتن قوانین',
+ isMajor: false,
+ changeSummary: null,
+ publishedAt: '2026-11-01T00:00:00Z',
+ effectiveAt: '2026-11-01T00:00:00Z',
+ });
+ });
+
+ it('says signing in accepts the rules, with no checkbox and no read yet', () => {
+ const { container } = render( , {
+ wrapper,
+ });
+ expect(container.textContent).toContain(
+ 'ورود یا ثبتنام به معنی پذیرش قوانین و مقررات لومینا است.',
+ );
+ expect(screen.queryByRole('checkbox')).toBeNull();
+ expect(legalRepository.getDocument).not.toHaveBeenCalled();
+ });
+
+ it('opens the rules with «متوجه شدم» from its link', async () => {
+ render( , { wrapper });
+ await userEvent.click(
+ screen.getByRole('button', { name: 'قوانین و مقررات لومینا' }),
+ );
+ expect(await screen.findByText('متن قوانین')).toBeTruthy();
+ expect(screen.getByText('متوجه شدم')).toBeTruthy();
+ expect(legalRepository.getDocument).toHaveBeenCalledWith(
+ { key: 'platform_rules' },
+ expect.anything(),
+ );
+ });
+});
diff --git a/platforms/market/src/app/screens/(auth)/auth/organisms/rules-caption/RulesCaption.tsx b/platforms/market/src/app/screens/(auth)/auth/organisms/rules-caption/RulesCaption.tsx
new file mode 100644
index 0000000..ce42ef1
--- /dev/null
+++ b/platforms/market/src/app/screens/(auth)/auth/organisms/rules-caption/RulesCaption.tsx
@@ -0,0 +1,46 @@
+'use client';
+
+import { LinkButton } from '@lumina/island/atoms/link-button';
+import { Typography } from '@lumina/island/atoms/typography';
+import { useState } from 'react';
+import { Trans, useTranslation } from 'react-i18next';
+
+import { LegalDocumentDialog } from '../../../../organisms/legal-document';
+import type { RulesCaptionProps } from './types';
+
+/**
+ * Under «دریافت کد» on the login and sign-up phone pages: signing in or up accepts the rules, with
+ * no checkbox. The link opens them over the page, so the typed number stays.
+ */
+export function RulesCaption({ placement }: RulesCaptionProps) {
+ const { t } = useTranslation(['auth', 'legal']);
+ const [isOpen, setIsOpen] = useState(false);
+
+ return (
+ <>
+
+ setIsOpen(true)}
+ >
+ {t('legal:dialog.rules-title')}
+
+ ),
+ }}
+ />
+
+ setIsOpen(false)}
+ />
+ >
+ );
+}
diff --git a/platforms/market/src/app/screens/(auth)/auth/organisms/rules-caption/index.ts b/platforms/market/src/app/screens/(auth)/auth/organisms/rules-caption/index.ts
new file mode 100644
index 0000000..c23b29b
--- /dev/null
+++ b/platforms/market/src/app/screens/(auth)/auth/organisms/rules-caption/index.ts
@@ -0,0 +1,2 @@
+export { RulesCaption } from './RulesCaption';
+export type { RulesCaptionProps } from './types';
diff --git a/platforms/market/src/app/screens/(auth)/auth/organisms/rules-caption/types.ts b/platforms/market/src/app/screens/(auth)/auth/organisms/rules-caption/types.ts
new file mode 100644
index 0000000..d45fa94
--- /dev/null
+++ b/platforms/market/src/app/screens/(auth)/auth/organisms/rules-caption/types.ts
@@ -0,0 +1,4 @@
+export type RulesCaptionProps = {
+ /** A bottom sheet on mobile, a modal on desktop. */
+ placement: 'sheet' | 'modal';
+};
diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/AgreementBlock.tsx b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/AgreementBlock.tsx
new file mode 100644
index 0000000..d82230e
--- /dev/null
+++ b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/AgreementBlock.tsx
@@ -0,0 +1,66 @@
+'use client';
+
+import { Checkbox } from '@lumina/island/atoms/checkbox';
+import { FlexBox } from '@lumina/island/atoms/flex-box';
+import { LinkButton } from '@lumina/island/atoms/link-button';
+import { Typography } from '@lumina/island/atoms/typography';
+import { Card } from '@lumina/island/molecules/card';
+import { ErrorState } from '@lumina/island/molecules/error-state';
+import { useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { LegalDocumentDialog } from '../../../../../../../organisms/legal-document';
+import type { AgreementBlockProps } from '../types';
+
+/**
+ * The first block of the analyst's sign-up (J02-4), before any identity data: read the agreement
+ * over the form, so nothing typed is lost, and tick that you accept it. The box can't be ticked
+ * until the version it accepts is known.
+ */
+export function AgreementBlock({ agreement, placement }: AgreementBlockProps) {
+ const { t } = useTranslation(['legal', 'errors']);
+ const [isReading, setIsReading] = useState(false);
+
+ return (
+
+
+
+
+ {t('agreement.kyc.title')}
+
+
+ {t('agreement.kyc.text')}
+
+
+ setIsReading(true)}>
+ {t('agreement.kyc.read')}
+
+ {agreement.isError && (
+
+ )}
+ agreement.setTicked(event.target.checked)}
+ >
+ {t('agreement.kyc.checkbox')}
+
+
+ setIsReading(false)}
+ />
+
+ );
+}
diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/CreatorIdentityForm.tsx b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/CreatorIdentityForm.tsx
index 6936129..dd1d1b8 100644
--- a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/CreatorIdentityForm.tsx
+++ b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/CreatorIdentityForm.tsx
@@ -1,6 +1,5 @@
'use client';
-import { Button } from '@lumina/island/atoms/button';
import { FileField } from '@lumina/island/molecules/file-field';
import { FormSection } from '@lumina/island/molecules/form-section';
import { TextInput } from '@lumina/island/molecules/text-input';
@@ -15,15 +14,16 @@ import {
ID_CARD_SIDES,
} from '../../../../../../../../../shared/validations';
import type { DetailsFormProps } from '../types';
+import { AgreementBlock } from './AgreementBlock';
import { DetailsFrame } from './DetailsFrame';
+import { IdentitySubmit } from './IdentitySubmit';
import { NameFields } from './NameFields';
-import { TermsLine } from './TermsLine';
import { UsernameField } from './UsernameField';
const BYTES_PER_MB = 1024 * 1024;
/**
- * Step 4 for a creator: the public username, then the private identity (names, national code,
+ * Step 4 for a creator: the analyst agreement before any identity data, the public username, then the private identity (names, national code,
* both sides of the ID card) for the admin review. The images upload with a bar; repeat taps are
* ignored while sending, and a failure keeps every value and image.
*/
@@ -39,6 +39,7 @@ export function CreatorIdentityForm(props: DetailsFormProps) {
progress,
draft,
leave,
+ agreement,
} = useCreatorIdentityPart(props.partOptions);
return (
@@ -51,24 +52,14 @@ export function CreatorIdentityForm(props: DetailsFormProps) {
leave={leave}
onSubmit={() => void submit()}
footer={
- <>
-
- {t('register.identity.submit')}
-
-
- >
+
}
>
+
{/* What investors see, and what only the review sees (its heading carries the lock). */}
({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+const agreement = (isTicked: boolean) => ({
+ version: '1.0',
+ isLoading: false,
+ isError: false,
+ isReloading: false,
+ reload: vi.fn(),
+ isTicked,
+ setTicked: vi.fn(),
+});
+
+const submit = () =>
+ screen.getByText('register.identity.submit').closest('button')!;
+
+describe('IdentitySubmit', () => {
+ it('stays frozen with its reason until the agreement is ticked', () => {
+ render(
+ ,
+ );
+ expect(submit().classList.contains('frozen')).toBe(true);
+ expect(submit().getAttribute('type')).not.toBe('submit');
+ expect(screen.getByText('legal:agreement.kyc.frozen')).toBeTruthy();
+ });
+
+ it('submits once it is ticked', () => {
+ render(
+ ,
+ );
+ expect(submit().classList.contains('frozen')).toBe(false);
+ expect(submit().getAttribute('type')).toBe('submit');
+ });
+});
diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/IdentitySubmit.tsx b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/IdentitySubmit.tsx
new file mode 100644
index 0000000..cab85c8
--- /dev/null
+++ b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/IdentitySubmit.tsx
@@ -0,0 +1,27 @@
+import { Button } from '@lumina/island/atoms/button';
+import { useTranslation } from 'react-i18next';
+
+import type { IdentitySubmitProps } from '../types';
+
+/** «ثبت و ادامه», frozen with its reason until the agreement is ticked. */
+export function IdentitySubmit({
+ agreement,
+ size,
+ isSubmitting,
+}: IdentitySubmitProps) {
+ const { t } = useTranslation(['auth', 'legal']);
+
+ return (
+
+ {t('register.identity.submit')}
+
+ );
+}
diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/InvestorDetailsForm.tsx b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/InvestorDetailsForm.tsx
index a6c4d81..032f6a4 100644
--- a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/InvestorDetailsForm.tsx
+++ b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/InvestorDetailsForm.tsx
@@ -7,7 +7,6 @@ import { useInvestorDetailsPart } from '../../../../../../../../../features/auth
import type { DetailsFormProps } from '../types';
import { DetailsFrame } from './DetailsFrame';
import { NameFields } from './NameFields';
-import { TermsLine } from './TermsLine';
import { UsernameField } from './UsernameField';
/** Step 4 for an investor: name, last name and username, then «ساخت حساب». */
@@ -26,22 +25,15 @@ export function InvestorDetailsForm(props: DetailsFormProps) {
leave={leave}
onSubmit={() => void submit()}
footer={
- <>
-
- {t('register.details.submit')}
-
-
- >
+
+ {t('register.details.submit')}
+
}
>
diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/TermsLine.tsx b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/TermsLine.tsx
deleted file mode 100644
index 4daf212..0000000
--- a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/TermsLine.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-'use client';
-
-import { LinkButton } from '@lumina/island/atoms/link-button';
-import { Typography } from '@lumina/island/atoms/typography';
-import { useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import type { TermsLineProps } from '../types';
-import { RulesSheet } from './RulesSheet';
-
-/**
- * Accepting the rules by submitting, with no checkbox. «قوانین لومینا» opens the general rules in
- * a sheet over the form (G-2s), so nothing typed is lost.
- */
-export function TermsLine({ before, rules, placement }: TermsLineProps) {
- const { t } = useTranslation('auth');
- const [isOpen, setIsOpen] = useState(false);
-
- return (
- <>
-
- {before}
- setIsOpen(true)}>
- {t('register.terms-link')}
-
- {t('register.terms-after')}
-
- setIsOpen(false)}
- >
- {rules}
-
- >
- );
-}
diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/types.ts b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/types.ts
index 54ba16e..4e23525 100644
--- a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/types.ts
+++ b/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/types.ts
@@ -2,6 +2,7 @@ import type { ReactNode } from 'react';
import type { Control, FieldValues, Path } from 'react-hook-form';
import type {
+ CreatorIdentityPartModel,
RegisterDetailsPageModel,
RegisterLeaveModel,
UseDetailsPartOptions,
@@ -14,12 +15,10 @@ export type RegisterDetailsStepProps = {
size: 'md' | 'lg';
supportPlacement: SupportEntryProps['placement'];
/**
- * The halt when the token runs out, the leave dialog and the rules: a bottom sheet on mobile, a
- * modal on desktop.
+ * The halt when the token runs out, the leave dialog and the agreement: a bottom sheet on mobile,
+ * a modal on desktop.
*/
haltPlacement: 'sheet' | 'modal';
- /** «قوانین عمومی», rendered on the server, for the terms line's rules sheet (G-2s). */
- rules: ReactNode;
};
/** What each account type's form gets from the step. */
@@ -65,22 +64,6 @@ export type ExpiryHaltProps = {
onConfirm: () => void;
};
-export type TermsLineProps = {
- /** «با ساخت حساب، » or «با ثبت اطلاعات، ». */
- before: string;
- /** The general rules the link opens. */
- rules: ReactNode;
- placement: RegisterDetailsStepProps['haltPlacement'];
-};
-
-export type RulesSheetProps = {
- open: boolean;
- placement: RegisterDetailsStepProps['haltPlacement'];
- onClose: () => void;
- /** The rules' text. */
- children: ReactNode;
-};
-
export type UsernameFieldProps = {
control: Control;
name: Path;
@@ -98,3 +81,14 @@ export type NameFieldsProps = {
/** Side by side on desktop. */
isPaired: boolean;
};
+
+export type AgreementBlockProps = {
+ agreement: CreatorIdentityPartModel['agreement'];
+ placement: RegisterDetailsStepProps['haltPlacement'];
+};
+
+export type IdentitySubmitProps = {
+ agreement: CreatorIdentityPartModel['agreement'];
+ size: RegisterDetailsStepProps['size'];
+ isSubmitting: boolean;
+};
diff --git a/platforms/market/src/app/screens/(auth)/auth/register/phone/organisms/register-phone-step/RegisterPhoneStep.tsx b/platforms/market/src/app/screens/(auth)/auth/register/phone/organisms/register-phone-step/RegisterPhoneStep.tsx
index 9c10ada..89b2a62 100644
--- a/platforms/market/src/app/screens/(auth)/auth/register/phone/organisms/register-phone-step/RegisterPhoneStep.tsx
+++ b/platforms/market/src/app/screens/(auth)/auth/register/phone/organisms/register-phone-step/RegisterPhoneStep.tsx
@@ -17,6 +17,7 @@ import { translateMessage } from '../../../../../../../../shared/utils';
import { useAuthRoutes } from '../../../../../../../navigation';
import { SupportEntry } from '../../../../../../organisms/support-entry';
import { RegisterProgress } from '../../../../../../organisms/register-progress';
+import { RulesCaption } from '../../../../organisms/rules-caption';
import type { RegisterPhoneStepProps } from './types';
/**
@@ -149,6 +150,7 @@ export function RegisterPhoneStep({
>
{t('register.phone.submit')}
+
- {/* «انتشار پیشبینی» is the retry, with the same key while nothing changes. */}
+ {/* «انتشار سیگنال» is the retry, with the same key while nothing changes. */}
{model.publishError && (
)}
diff --git a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerFrame.tsx b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerFrame.tsx
index fa46561..48fc218 100644
--- a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerFrame.tsx
+++ b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerFrame.tsx
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
import type { ComposerFrameProps } from '../types';
/**
- * The «پیشبینی جدید» dialog's frame (J09-1-D, 0023): 960px over the page, the title with a ghost
+ * The «سیگنال جدید» dialog's frame (J09-1-D, 0023): 960px over the page, the title with a ghost
* «انصراف» at the end of its header row, and the workspace edge to edge under the hairline.
* While publishing, Escape, the scrim and «انصراف» do nothing.
*/
diff --git a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerPage.tsx b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerPage.tsx
index 480e6a9..e0072df 100644
--- a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerPage.tsx
+++ b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerPage.tsx
@@ -21,8 +21,8 @@ import { LeaveConfirm } from './LeaveConfirm';
import { PublishButton } from './PublishButton';
/**
- * «پیشبینی جدید» on its own page. Mobile (J09-1-M): back · title · support, the ghost «انصراف»
- * row, the fields, the preview, and «انتشار پیشبینی» pinned to the bottom; back and «انصراف» ask
+ * «سیگنال جدید» on its own page. Mobile (J09-1-M): back · title · support, the ghost «انصراف»
+ * row, the fields, the preview, and «انتشار سیگنال» pinned to the bottom; back and «انصراف» ask
* first about something to lose (J09-3e). Desktop, on a direct load: a 960px card drawn as the
* dialog (J09-1-D). Published, it lands on the creator's channel in the composer's place, the new
* prediction on top (J09-3c); left, it goes back.
diff --git a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerPreview.tsx b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerPreview.tsx
index 6476d6a..2617a4e 100644
--- a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerPreview.tsx
+++ b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerPreview.tsx
@@ -40,6 +40,8 @@ export function ComposerPreview({ model }: Pick) {
market: t(`common:markets.${summary.market}`),
direction: summary.direction,
entryPrice: summary.entryPrice,
+ entryLow: summary.entryLow,
+ entryHigh: summary.entryHigh,
targetPrices: summary.targetPrices,
stopLoss: summary.stopLoss,
horizon: summary.horizon,
diff --git a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerWorkspace.tsx b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerWorkspace.tsx
index 3dd51b1..a3ffb93 100644
--- a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerWorkspace.tsx
+++ b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ComposerWorkspace.tsx
@@ -11,7 +11,7 @@ import { PublishButton } from './PublishButton';
/**
* The desktop composer under its header row (J09-1-D), the same in the 960px dialog and on the
* full page: the fields beside a 400px sunken «پیشنمایش» panel, scrolling together, and
- * «انتشار پیشبینی» at the end of the footer bar.
+ * «انتشار سیگنال» at the end of the footer bar.
*/
export function ComposerWorkspace({ model }: ComposerWorkspaceProps) {
const { t } = useTranslation('predictions');
diff --git a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ConfirmPublish.test.tsx b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ConfirmPublish.test.tsx
new file mode 100644
index 0000000..5b45852
--- /dev/null
+++ b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ConfirmPublish.test.tsx
@@ -0,0 +1,65 @@
+import { render, screen } from '@testing-library/react';
+import { describe, expect, it, vi } from 'vitest';
+
+import type {
+ ComposerSummary,
+ PredictionComposerPageModel,
+} from '../../../../../../../../features/prediction';
+import { ConfirmPublish } from './ConfirmPublish';
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+const summary: ComposerSummary = {
+ symbol: 'BTCUSDT',
+ market: 'crypto',
+ direction: 'long',
+ entryMode: 'exact',
+ entryPrice: 68000,
+ entryLow: null,
+ entryHigh: null,
+ targetPrices: [70000],
+ stopLoss: 67000,
+ horizon: '1w',
+ expiresAt: '2026-01-08T00:00:00Z',
+ accessLevel: 'free',
+};
+const open = (confirmSummary: ComposerSummary) =>
+ render(
+ ,
+ );
+
+describe('ConfirmPublish', () => {
+ it('shows an exact entry with «قیمت دقیق» next to it', () => {
+ open(summary);
+ expect(screen.getByText('68٬000')).toBeTruthy();
+ expect(screen.getByText('composer.confirm.entry-exact')).toBeTruthy();
+ });
+
+ it('shows a range as its two ends', () => {
+ open({
+ ...summary,
+ entryMode: 'range',
+ entryLow: 67500,
+ entryHigh: 68500,
+ });
+ expect(screen.getByText('67٬500 – 68٬500')).toBeTruthy();
+ expect(screen.queryByText('composer.confirm.entry-exact')).toBeNull();
+ });
+
+ it('always carries the lock line', () => {
+ open(summary);
+ expect(screen.getByText('composer.confirm.warning')).toBeTruthy();
+ });
+});
diff --git a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ConfirmPublish.tsx b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ConfirmPublish.tsx
index 4a9d253..ac8bf39 100644
--- a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ConfirmPublish.tsx
+++ b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/ConfirmPublish.tsx
@@ -8,14 +8,15 @@ import { DetailRow } from '@lumina/island/molecules/detail-row';
import { KeyValue } from '@lumina/island/molecules/key-value';
import { Modal } from '@lumina/island/molecules/modal';
import { Sheet } from '@lumina/island/molecules/sheet';
+import { entryText } from '@lumina/island/organisms/prediction-card';
import { date, number, price } from '@lumina/tools/format';
import { useTranslation } from 'react-i18next';
import type { ComposerPartProps } from '../types';
/**
- * «انتشار پیشبینی» (J09-3, J09-3b): what goes live, row by row (a field left empty has none), the
- * entry as «≈» the live price since the API stamps its own, and that it can't be edited or
+ * «انتشار سیگنال» (J09-3, J09-3b): what goes live, row by row (a field left empty has none), the
+ * entry as the number with «قیمت دقیق» beside it, or the range, and that it can't be edited or
* deleted afterwards. While it publishes «انتشار» spins, «ادامه ویرایش» freezes and nothing
* dismisses it. A bottom sheet on mobile, a 420px modal on desktop.
*/
@@ -45,14 +46,16 @@ export function ConfirmPublish({ model, layout }: ComposerPartProps) {
- {t('composer.confirm.entry-value', {
- price: price(summary.entryPrice),
- })}
-
-
-
- {t('composer.confirm.entry-note')}
+ {entryText(summary)}
+ {summary.entryMode === 'exact' && (
+ <>
+
+
+ {t('composer.confirm.entry-exact')}
+
+ >
+ )}
{summary.targetPrices.map((target, index) => (
({
+ useTranslation: () => ({
+ t: (key: string, values?: object) =>
+ values ? `${key} ${JSON.stringify(values)}` : key,
+ }),
+}));
+
+function Harness({ over }: { over: Partial }) {
+ const form = useForm({
+ defaultValues: {
+ entryMode: 'exact',
+ entryPrice: '100',
+ entryLow: '',
+ entryHigh: '',
+ } as PredictionComposerFormValues,
+ });
+ const model = {
+ entryMode: 'exact',
+ setEntryMode: vi.fn(),
+ markEntryEdited: vi.fn(),
+ retryQuote: vi.fn(),
+ phase: 'idle',
+ symbol: 'BTCUSDT',
+ quote: { status: 'none' },
+ ...over,
+ } as unknown as PredictionComposerPageModel;
+ return ;
+}
+
+const ready = {
+ status: 'ready',
+ price: 68000,
+ at: '2026-01-01T10:00:00Z',
+ source: 'Binance',
+} as const;
+
+describe('EntryField', () => {
+ it('offers an editable exact entry with the live price under it', async () => {
+ const markEntryEdited = vi.fn();
+ render( );
+ const input = screen.getByLabelText(
+ 'composer.entry-price',
+ );
+ expect(input.value).toBe('100');
+ expect(input.readOnly).toBe(false);
+ await userEvent.type(input, '5');
+ expect(markEntryEdited).toHaveBeenCalled();
+ expect(screen.getByText(/composer\.entry-hint/).textContent).toContain(
+ 'Binance',
+ );
+ });
+
+ it('switches to the range through the segmented control', async () => {
+ const setEntryMode = vi.fn();
+ render( );
+ await userEvent.click(
+ screen.getByRole('radio', { name: 'composer.entry-range' }),
+ );
+ expect(setEntryMode).toHaveBeenCalledWith('range');
+ });
+
+ it('shows «از» and «تا» for a range', () => {
+ render( );
+ expect(screen.getByLabelText('composer.entry-from')).toBeTruthy();
+ expect(screen.getByLabelText('composer.entry-to')).toBeTruthy();
+ expect(screen.queryByLabelText('composer.entry-price')).toBeNull();
+ });
+
+ it('says there is no price now and offers a retry, keeping the field', async () => {
+ const retryQuote = vi.fn();
+ render(
+ ,
+ );
+ expect(screen.getByRole('alert').textContent).toBe(
+ 'composer.quote-unavailable',
+ );
+ expect(screen.getByLabelText('composer.entry-price')).toBeTruthy();
+ await userEvent.click(
+ screen.getByRole('button', { name: 'composer.retry' }),
+ );
+ expect(retryQuote).toHaveBeenCalled();
+ });
+
+ it('says the price comes once a symbol is picked', () => {
+ render( );
+ expect(screen.getByText('composer.entry-pending')).toBeTruthy();
+ });
+});
diff --git a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/EntryField.tsx b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/EntryField.tsx
index ed9eec2..56a5011 100644
--- a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/EntryField.tsx
+++ b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/EntryField.tsx
@@ -1,77 +1,113 @@
import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
+import { GridBox } from '@lumina/island/atoms/grid-box';
import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
import { Typography } from '@lumina/island/atoms/typography';
+import { SegmentedChoice } from '@lumina/island/molecules/segmented-choice';
import { TextInput } from '@lumina/island/molecules/text-input';
import { price, time } from '@lumina/tools/format';
import { useTranslation } from 'react-i18next';
+import type { EntryMode } from '../../../../../../../../shared/validations';
+import { translateMessage } from '../../../../../../../../shared/utils';
import type { ComposerPartProps } from '../types';
+import { FieldGroup } from './FieldGroup';
/**
- * «قیمت ورود» (J09-1, J09-2c): locked, since the API stamps the market price at publish; it shows
- * the live price with its source and time, «—» before a symbol, a skeleton line while the price
- * loads, or that there is no price now with «تلاش مجدد».
+ * «ورود» (J09-1, J09-2c): «قیمت دقیق», prefilled from the live quote and editable, or «بازه» with
+ * «از» and «تا». Under it, the live price with its source and time, a skeleton line while it loads,
+ * or that there is no price now with «تلاش مجدد». An exact entry waits for a symbol.
*/
export function EntryField({ model }: Pick) {
- const { t } = useTranslation('predictions');
- const { quote } = model;
- const stamp = (
-
- {t('composer.entry-stamp')}
-
- );
+ const { t } = useTranslation(['predictions', 'content']);
+ const { form, quote, entryMode, phase, symbol } = model;
+ const { errors } = form.formState;
+ const busy = phase === 'publishing';
- if (quote.status === 'loading') {
- return (
-
-
- {t('composer.entry')}
-
-
-
-
- {stamp}
-
- );
- }
+ const input = (name: 'entryPrice' | 'entryLow' | 'entryHigh') =>
+ ({
+ dir: 'ltr',
+ inputMode: 'decimal',
+ autoComplete: 'off',
+ frozen: busy,
+ error: translateMessage(t, errors[name]?.message),
+ }) as const;
return (
-
- {quote.status === 'unavailable' && (
-
-
- {t('composer.retry')}
-
-
+
+
+ label={t('composer.entry')}
+ options={[
+ { value: 'exact', label: t('composer.entry-exact') },
+ { value: 'range', label: t('composer.entry-range') },
+ ]}
+ value={entryMode}
+ onChange={model.setEntryMode}
+ tone="neutral"
+ block
+ disabled={busy}
+ />
+
+ {entryMode === 'exact' ? (
+
+ ) : (
+
+
+
+
+ )}
+ {quote.status === 'loading' && (
+
+
+
+ )}
+ {quote.status === 'none' && (
+
+ {t('composer.entry-pending')}
+
+ )}
+ {quote.status === 'ready' && (
+
+ {t('composer.entry-hint', {
+ price: price(quote.price),
+ source: quote.source,
+ time: time(quote.at),
+ })}
+
+ )}
+ {quote.status === 'unavailable' && (
+ <>
+
+ {t('composer.quote-unavailable')}
+
+
+
+ {t('composer.retry')}
+
+
+ >
)}
- {stamp}
);
}
diff --git a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/PublishButton.tsx b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/PublishButton.tsx
index f332597..2292e6b 100644
--- a/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/PublishButton.tsx
+++ b/platforms/market/src/app/screens/(flow)/compose/prediction/organisms/prediction-composer/components/PublishButton.tsx
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
import type { ComposerPartProps } from '../types';
/**
- * «انتشار پیشبینی»: frozen until the form can publish, saying why (J09-1b, J09-2, J09-2c); a
+ * «انتشار سیگنال»: frozen until the form can publish, saying why (J09-1b, J09-2, J09-2c); a
* press checks the form, then asks to confirm (J09-3). Offline it freezes and says why (0043).
*/
export function PublishButton({ model, layout }: ComposerPartProps) {
diff --git a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/PricingForm.tsx b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/PricingForm.tsx
index 9eb754b..9de3db3 100644
--- a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/PricingForm.tsx
+++ b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/PricingForm.tsx
@@ -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
* 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,
- * 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
* it and saves as the save button does, leaving once «تأیید و ذخیره» went through; a broken rule
* or «انصراف» keeps the page.
@@ -78,7 +78,7 @@ export function PricingForm({
? { frozen: true, pressableWhenFrozen: true }
: offline)}
>
- {t(locked ? 'form.save-promotion' : 'form.save')}
+ {t(locked && !model.hasOffSale ? 'form.save-promotion' : 'form.save')}
);
diff --git a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/PromotionBlock.tsx b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/PromotionBlock.tsx
index 69925f1..dccf272 100644
--- a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/PromotionBlock.tsx
+++ b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/PromotionBlock.tsx
@@ -77,6 +77,9 @@ export function PromotionBlock({
onChange={(event) =>
model.setPromotionPercent(period, event.target.value)
}
+ hint={t('promotion.floor-hint', {
+ floor: price(tier.floorTomanPerMonth),
+ })}
error={percentError}
/>
);
diff --git a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/TierCard.test.tsx b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/TierCard.test.tsx
new file mode 100644
index 0000000..657d856
--- /dev/null
+++ b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/TierCard.test.tsx
@@ -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) =>
+ options ? `${key}:${JSON.stringify(options)}` : key,
+ }),
+}));
+
+const tier = (over: Partial = {}): 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 = {}) =>
+ ({
+ 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(
+ ,
+ );
+
+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();
+ });
+});
diff --git a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/TierCard.tsx b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/TierCard.tsx
index 27f9cd0..bf64bc6 100644
--- a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/TierCard.tsx
+++ b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/TierCard.tsx
@@ -1,4 +1,5 @@
import { FlexBox } from '@lumina/island/atoms/flex-box';
+import { StatusBadge } from '@lumina/island/atoms/status-badge';
import { Switch } from '@lumina/island/atoms/switch';
import { Tag } from '@lumina/island/atoms/tag';
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
* 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
- * 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) {
const { t } = useTranslation(['pricing', 'common']);
@@ -26,7 +28,8 @@ export function TierCard({ tier, model, layout, onPickDate }: TierCardProps) {
const headingId = useId();
const period = tier.billingPeriod;
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 belowFloor =
tier.priceMessage?.kind === 'issue' &&
@@ -34,7 +37,14 @@ export function TierCard({ tier, model, layout, onPickDate }: TierCardProps) {
const promo = tier.promotion;
// No promotion before the first save, nor on a period without a total (۴.۱).
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 =
showsPromotion &&
promo.enabled &&
@@ -69,6 +79,11 @@ export function TierCard({ tier, model, layout, onPickDate }: TierCardProps) {
{t('form.required-tag')}
)}
+ {tier.offSale && (
+
+ {t('off-sale.badge')}
+
+ )}
{showsDiscount && promo.percentValue !== null && (
{t('card.discount', {
@@ -112,7 +127,7 @@ export function TierCard({ tier, model, layout, onPickDate }: TierCardProps) {
error={priceError}
hint={
tier.perMonthToman === null
- ? t('form.floor', { floor: price(tier.floorTomanPerMonth) })
+ ? floorHint
: t('form.per-month', { amount: price(tier.perMonthToman) })
}
locked={locked}
diff --git a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/use-field-message.ts b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/use-field-message.ts
index 2ed7225..ccb0229 100644
--- a/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/use-field-message.ts
+++ b/platforms/market/src/app/screens/(flow)/dashboard/pricing/organisms/pricing-form/components/use-field-message.ts
@@ -15,7 +15,13 @@ export function useFieldMessage() {
case 'required':
return t('form.errors.required');
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':
return t('form.errors.per-month-increase', {
amount: price(issue.amount),
diff --git a/platforms/market/src/app/screens/(flow)/terms/analyst-agreement/organisms/analyst-agreement/AnalystAgreement.tsx b/platforms/market/src/app/screens/(flow)/terms/analyst-agreement/organisms/analyst-agreement/AnalystAgreement.tsx
new file mode 100644
index 0000000..52bfded
--- /dev/null
+++ b/platforms/market/src/app/screens/(flow)/terms/analyst-agreement/organisms/analyst-agreement/AnalystAgreement.tsx
@@ -0,0 +1,29 @@
+'use client';
+
+import { Typography } from '@lumina/island/atoms/typography';
+import { date, time, version } from '@lumina/tools/format';
+import { useTranslation } from 'react-i18next';
+
+import { useAgreementAcceptance } from '../../../../../../../features/legal';
+import { LegalDocumentView } from '../../../../../organisms/legal-document';
+import type { AnalystAgreementProps } from './types';
+
+/** «توافقنامه تحلیلگر» with the analyst's own record: which version they accepted, and when. */
+export function AnalystAgreement({ layout }: AnalystAgreementProps) {
+ const { t } = useTranslation('legal');
+ const acceptance = useAgreementAcceptance();
+
+ return (
+
+ {acceptance && (
+
+ {t('agreement.record', {
+ version: version(acceptance.version),
+ date: date(acceptance.acceptedAt, { time: false }),
+ time: time(acceptance.acceptedAt),
+ })}
+
+ )}
+
+ );
+}
diff --git a/platforms/market/src/app/screens/(flow)/terms/analyst-agreement/organisms/analyst-agreement/index.ts b/platforms/market/src/app/screens/(flow)/terms/analyst-agreement/organisms/analyst-agreement/index.ts
new file mode 100644
index 0000000..493cb90
--- /dev/null
+++ b/platforms/market/src/app/screens/(flow)/terms/analyst-agreement/organisms/analyst-agreement/index.ts
@@ -0,0 +1,2 @@
+export { AnalystAgreement } from './AnalystAgreement';
+export type { AnalystAgreementProps } from './types';
diff --git a/platforms/market/src/app/screens/(flow)/terms/analyst-agreement/organisms/analyst-agreement/types.ts b/platforms/market/src/app/screens/(flow)/terms/analyst-agreement/organisms/analyst-agreement/types.ts
new file mode 100644
index 0000000..be62799
--- /dev/null
+++ b/platforms/market/src/app/screens/(flow)/terms/analyst-agreement/organisms/analyst-agreement/types.ts
@@ -0,0 +1,3 @@
+export type AnalystAgreementProps = {
+ layout: 'mobile' | 'desktop';
+};
diff --git a/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/RulesTabs.tsx b/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/RulesTabs.tsx
index dc54a99..522860a 100644
--- a/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/RulesTabs.tsx
+++ b/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/RulesTabs.tsx
@@ -7,7 +7,7 @@ import { ROUTES } from '../../../../../navigation';
import type { RulesTabsProps } from './types';
/**
- * «قوانین لومینا»'s two tabs (G-2r): «قوانین عمومی» · «شرایط اشتراک», the current one from the URL,
+ * «قوانین و مقررات لومینا»'s two tabs (G-2r): «قوانین و مقررات» · «شرایط اشتراک», the current one from the URL,
* which the server render already knows. The section's layout renders it once, so it stays put
* while a tab loads. A tab replaces the history entry, so back still returns to the page that
* opened the rules.
diff --git a/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/types.ts b/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/types.ts
index 843797a..b986591 100644
--- a/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/types.ts
+++ b/platforms/market/src/app/screens/(flow)/terms/organisms/rules-tabs/types.ts
@@ -1,7 +1,7 @@
export type RulesTabsLabels = {
- /** The nav's name: «قوانین لومینا». */
+ /** The nav's name: «قوانین و مقررات لومینا». */
label: string;
- /** «قوانین عمومی». */
+ /** «قوانین و مقررات». */
general: string;
/** «شرایط اشتراک». */
subscription: string;
diff --git a/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/SubscriptionTerms.tsx b/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/SubscriptionTerms.tsx
index ecd05f6..a389e71 100644
--- a/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/SubscriptionTerms.tsx
+++ b/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/SubscriptionTerms.tsx
@@ -1,85 +1,39 @@
+'use client';
+
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Typography } from '@lumina/island/atoms/typography';
import { SupportSheet } from '@lumina/island/organisms/support-sheet';
-import { Element } from '@lumina/island/primitives/element';
+import { useTranslation } from 'react-i18next';
+import { getEnv } from '../../../../../../../env';
+import { LegalDocumentView } from '../../../../../organisms/legal-document';
+import { supportChatUrls } from '../../../../../organisms/support-entry';
import type { SubscriptionTermsProps } from './types';
-/**
- * «شرایط اشتراک» (S5): eight numbered sections, verbatim. In §۳ the two options sit as a numbered
- * list on a sunken panel with bold lead-ins, between its first paragraph and the rest; §۸ ends with
- * the support hours and the two chat rows. The same for every visitor, so it renders on the server.
- */
-export function SubscriptionTerms({
- layout,
- chats,
- labels,
-}: SubscriptionTermsProps) {
- const last = labels.sections.length - 1;
+/** «شرایط اشتراک» (S5): the versioned text, then the support hours and the two chat rows. */
+export function SubscriptionTerms({ layout }: SubscriptionTermsProps) {
+ const { t } = useTranslation(['legal', 'auth']);
+ const chats = supportChatUrls();
return (
-
- {/* Desktop's column title is the h1; the mobile bar's name is not a heading. */}
- {layout === 'mobile' && (
-
- {labels.title}
+
+
+
+ {t('subscription.hours', { hours: getEnv().supportHours })}
- )}
- {labels.sections.map((section, index) => {
- const [first, ...rest] = section.paragraphs;
- const titleId = `terms-${section.id}`;
- return (
-
-
- {section.title}
-
- {first}
- {section.options && (
-
- {section.options.map((option) => (
-
-
-
- {option.lead}
- {' '}
- {option.text}
-
-
- ))}
-
- )}
- {rest.map((paragraph) => (
- {paragraph}
- ))}
- {index === last && (
- <>
- {labels.hours}
-
- >
- )}
-
- );
- })}
-
+
+
+
);
}
diff --git a/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/index.ts b/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/index.ts
index 4dc14ab..b8d29e1 100644
--- a/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/index.ts
+++ b/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/index.ts
@@ -1,7 +1,2 @@
-export { subscriptionTermsLabels } from './labels';
export { SubscriptionTerms } from './SubscriptionTerms';
-export type {
- SubscriptionTermsLabels,
- SubscriptionTermsProps,
- TermsSection,
-} from './types';
+export type { SubscriptionTermsProps } from './types';
diff --git a/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/labels.ts b/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/labels.ts
deleted file mode 100644
index 8fbdb99..0000000
--- a/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/labels.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import type { TFunction } from 'i18next';
-
-import type { SubscriptionTermsLabels, TermsSection } from './types';
-
-/** The terms' text, from the server's translations (0020), verbatim from S5. */
-export function subscriptionTermsLabels(
- t: TFunction<'terms'>,
- tAuth: TFunction<'auth'>,
- hours: string,
-): SubscriptionTermsLabels {
- const sections: TermsSection[] = [
- { id: 's1', title: t('s1.title'), paragraphs: [t('s1.p1'), t('s1.p2')] },
- {
- id: 's2',
- title: t('s2.title'),
- paragraphs: [t('s2.p1'), t('s2.p2'), t('s2.p3')],
- },
- {
- id: 's3',
- title: t('s3.title'),
- paragraphs: [t('s3.p1'), t('s3.p2'), t('s3.p3'), t('s3.p4')],
- options: [
- { lead: t('s3.refund-lead'), text: t('s3.refund') },
- { lead: t('s3.wait-lead'), text: t('s3.wait') },
- ],
- },
- { id: 's4', title: t('s4.title'), paragraphs: [t('s4.p1'), t('s4.p2')] },
- {
- id: 's5',
- title: t('s5.title'),
- paragraphs: [t('s5.p1'), t('s5.p2'), t('s5.p3')],
- },
- {
- id: 's6',
- title: t('s6.title'),
- paragraphs: [t('s6.p1'), t('s6.p2'), t('s6.p3')],
- },
- { id: 's7', title: t('s7.title'), paragraphs: [t('s7.p1'), t('s7.p2')] },
- { id: 's8', title: t('s8.title'), paragraphs: [t('s8.p1')] },
- ];
-
- return {
- title: t('title'),
- sections,
- hours: t('s8.hours', { hours }),
- support: {
- title: tAuth('support.title'),
- bale: tAuth('support.bale'),
- telegram: tAuth('support.telegram'),
- close: tAuth('support.close'),
- opensNewTab: tAuth('support.opens-new-tab'),
- },
- };
-}
diff --git a/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/types.ts b/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/types.ts
index 94e32f2..ea8596b 100644
--- a/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/types.ts
+++ b/platforms/market/src/app/screens/(flow)/terms/subscription/organisms/subscription-terms/types.ts
@@ -1,29 +1,3 @@
-import type { SupportSheetLabels } from '@lumina/island/organisms/support-sheet';
-
-/** One numbered section: its paragraphs, and §۳'s two options after its first paragraph. */
-export type TermsSection = {
- id: string;
- title: string;
- paragraphs: string[];
- options?: { lead: string; text: string }[];
-};
-
-export type SubscriptionTermsLabels = {
- /** The page's name: «شرایط اشتراک». */
- title: string;
- sections: TermsSection[];
- /** §۸'s line: «زمان پاسخگویی: …» with the configured hours. */
- hours: string;
- support: SupportSheetLabels;
-};
-
export type SubscriptionTermsProps = {
- /**
- * Mobile adds the page's h1 for screen readers, since its bar names the page in plain text;
- * desktop's column title (DesktopPageTitle) is the h1.
- */
layout: 'mobile' | 'desktop';
- /** The support chats' addresses, from config. */
- chats: { bale: string; telegram: string };
- labels: SubscriptionTermsLabels;
};
diff --git a/platforms/market/src/app/screens/(main)/account/organisms/account-overview/AccountOverview.tsx b/platforms/market/src/app/screens/(main)/account/organisms/account-overview/AccountOverview.tsx
index 74cb173..c979341 100644
--- a/platforms/market/src/app/screens/(main)/account/organisms/account-overview/AccountOverview.tsx
+++ b/platforms/market/src/app/screens/(main)/account/organisms/account-overview/AccountOverview.tsx
@@ -4,11 +4,13 @@ import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Typography } from '@lumina/island/atoms/typography';
import { List, ListRow } from '@lumina/island/molecules/list-row';
+import { date, version } from '@lumina/tools/format';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useAccountOverview } from '../../../../../../features/account';
import { PAYOUT_ACCOUNT_ANCHOR } from '../../../../../../features/finance';
+import { useAgreementAcceptance } from '../../../../../../features/legal';
import { useIsStandalone } from '../../../../../navigation/hooks/use-is-standalone';
import { ROUTES } from '../../../../../navigation/navigation';
import { SignOutConfirm } from '../../../../organisms/sign-out-confirm';
@@ -21,7 +23,7 @@ import type { AccountOverviewProps } from './types';
* حساب کاربری (J12-1, J12-1b), the member's own page: whose account it is, then اطلاعات کاربری,
* an analyst's اطلاعات تسویهحساب (their شبا on داشبورد › مالی, or its empty state), تنظیمات
* اعلانها and نصب اپلیکیشن (hidden in the installed app); then پشتیبانی, which opens the support
- * sheet, and قوانین و مقررات; then «خروج از حساب», which asks first (J12-1d), and the version.
+ * sheet, قوانین و مقررات لومینا and an analyst's توافقنامه تحلیلگر; then «خروج از حساب», which asks first (J12-1d), and the version.
*/
export function AccountOverview({ layout }: AccountOverviewProps) {
const { t } = useTranslation('account');
@@ -30,6 +32,7 @@ export function AccountOverview({ layout }: AccountOverviewProps) {
const [isSupportOpen, setSupportOpen] = useState(false);
const [isSigningOut, setSigningOut] = useState(false);
const { creator } = model;
+ const acceptance = useAgreementAcceptance();
return (
+ {creator && (
+
+ )}
)}
{followsToSubscribe ? (
-
+
{t('actions.follow')}
) : (
diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/InvestorActions.test.tsx b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/InvestorActions.test.tsx
new file mode 100644
index 0000000..942cd31
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/InvestorActions.test.tsx
@@ -0,0 +1,55 @@
+import { render, screen } from '@testing-library/react';
+import { describe, expect, it, vi } from 'vitest';
+
+import type { InvestorActionsProps } from '../types';
+import { InvestorActions } from './InvestorActions';
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+const props = (standing: object) =>
+ ({
+ username: 'analyst',
+ layout: 'desktop',
+ standing: { following: false, subscribed: false, ...standing },
+ follow: vi.fn(),
+ askUnfollow: vi.fn(),
+ isConfirmingUnfollow: false,
+ confirmUnfollow: vi.fn(),
+ cancelUnfollow: vi.fn(),
+ leaveWaitlist: vi.fn(),
+ isLeavingWaitlist: false,
+ requestSaleNotice: vi.fn(),
+ cancelSaleNotice: vi.fn(),
+ }) as unknown as InvestorActionsProps;
+
+const followControl = (label: string) =>
+ screen.getByText(label).closest('button')!;
+
+describe('InvestorActions follow control', () => {
+ it('not following: on-dark «دنبال کردن»', () => {
+ render( );
+ const control = followControl('actions.follow');
+ expect(control.className).toContain('bg-action-dark');
+ expect(control.classList.contains('frozen')).toBe(false);
+ });
+
+ it('following: live following button that asks first', () => {
+ render( );
+ const control = followControl('actions.following');
+ expect(control.className).toContain('bg-action-quiet');
+ expect(control.getAttribute('aria-haspopup')).toBe('dialog');
+ expect(control.classList.contains('frozen')).toBe(false);
+ });
+
+ it('subscriber: frozen following button with the reason', () => {
+ render(
+ ,
+ );
+ const control = followControl('actions.following');
+ expect(control.className).toContain('bg-action-quiet');
+ expect(control.classList.contains('frozen')).toBe(true);
+ expect(screen.getByText('actions.unfollow-frozen')).toBeTruthy();
+ });
+});
diff --git a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/InvestorActions.tsx b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/InvestorActions.tsx
index dd80a2b..969d48d 100644
--- a/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/InvestorActions.tsx
+++ b/platforms/market/src/app/screens/(main)/channels/[username]/organisms/channel-actions/components/InvestorActions.tsx
@@ -95,26 +95,34 @@ export function InvestorActions({
const followControl = standing.subscribed ? (
- {t('actions.unfollow')}
+ {t('actions.following')}
) : standing.following ? (
- {t('actions.unfollow')}
+ {t('actions.following')}
) : (
-
+
{t('actions.follow')}
);
diff --git a/platforms/market/src/app/screens/(main)/dashboard/following/organisms/following-list/components/FollowingRow.tsx b/platforms/market/src/app/screens/(main)/dashboard/following/organisms/following-list/components/FollowingRow.tsx
index c9fba36..c9919c0 100644
--- a/platforms/market/src/app/screens/(main)/dashboard/following/organisms/following-list/components/FollowingRow.tsx
+++ b/platforms/market/src/app/screens/(main)/dashboard/following/organisms/following-list/components/FollowingRow.tsx
@@ -10,7 +10,7 @@ import type { FollowingRowProps } from '../types';
/**
* One followed creator as a list row (U8 ۴.۱, ۶.۱, J07-4): the avatar, the @username left to
- * right with the display name under it, and «دنبال نکردن» at the end. The handle is a link stretched over the row, so a tap
+ * right with the display name under it, and «دنبال میکنید» at the end. The handle is a link stretched over the row, so a tap
* anywhere but the button opens the channel. A suspended creator's row is dimmed, opens nothing
* and says why under the handle, while the unfollow stays live (U8 ۴.۴, J07-4c). An active
* subscription freezes the unfollow, suspended or not, because the API refuses it (U8 ۴.۷); so
@@ -58,7 +58,8 @@ export function FollowingRow({ row, offline, onUnfollow }: FollowingRowProps) {
{subscribed || offline ? (
- {t('channel:actions.unfollow')}
+ {t('channel:actions.following')}
) : (
- {t('channel:actions.unfollow')}
+ {t('channel:actions.following')}
)}
diff --git a/platforms/market/src/app/screens/(main)/dashboard/organisms/dashboard-tabs/DashboardTabs.tsx b/platforms/market/src/app/screens/(main)/dashboard/organisms/dashboard-tabs/DashboardTabs.tsx
index 5703aa7..7426b6d 100644
--- a/platforms/market/src/app/screens/(main)/dashboard/organisms/dashboard-tabs/DashboardTabs.tsx
+++ b/platforms/market/src/app/screens/(main)/dashboard/organisms/dashboard-tabs/DashboardTabs.tsx
@@ -10,7 +10,7 @@ import type { DashboardTabsProps } from './types';
/**
* The داشبورد's section row, full width, the current one underlined: the investor's «اشتراکها» ·
* «تراکنشها» · «دنبالشدهها» (U8 ۴.۱, ۶.۱; U8 ۵.۲), or the creator's «طرحهای اشتراک» ·
- * «پیشبینیها» · «مالی» (Creator Dashboard ۱.۱, J10-0, 0034). The dashboard layout renders it once, so it stays put while a section
+ * «سیگنالها» · «مالی» (Creator Dashboard ۱.۱, J10-0, 0034). The dashboard layout renders it once, so it stays put while a section
* loads; the current one comes from the URL, which the server render already knows.
*/
export function DashboardTabs({
diff --git a/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-progress/SignalProgress.tsx b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-progress/SignalProgress.tsx
new file mode 100644
index 0000000..fc59e40
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-progress/SignalProgress.tsx
@@ -0,0 +1,52 @@
+'use client';
+
+import { FlexBox } from '@lumina/island/atoms/flex-box';
+import { Icon } from '@lumina/island/atoms/icon';
+import { Typography } from '@lumina/island/atoms/typography';
+import { Meter } from '@lumina/island/molecules/meter';
+import { number } from '@lumina/tools/format';
+import { useTranslation } from 'react-i18next';
+
+import type { SignalProgressProps } from './types';
+
+/**
+ * How far the record is from public: the closed signals against the required ones and the days
+ * left to a month of activity while there are any; or that it is public, once it is.
+ */
+export function SignalProgress({ progress }: SignalProgressProps) {
+ const { t } = useTranslation('predictions');
+
+ if (progress.isPublic) {
+ return (
+
+
+
+ {t('performance.public')}
+
+
+ );
+ }
+ return (
+
+
+ {progress.daysLeft !== null && (
+
+
+
+ {t('performance.days-left', { n: number(progress.daysLeft) })}
+
+
+ )}
+
+ );
+}
diff --git a/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-progress/index.ts b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-progress/index.ts
new file mode 100644
index 0000000..7d5bcf1
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-progress/index.ts
@@ -0,0 +1,2 @@
+export { SignalProgress } from './SignalProgress';
+export type { SignalProgressProps } from './types';
diff --git a/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-progress/types.ts b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-progress/types.ts
new file mode 100644
index 0000000..9c258ea
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-progress/types.ts
@@ -0,0 +1,5 @@
+import type { SignalProgressPayload } from '../../../../../../features/prediction';
+
+export type SignalProgressProps = {
+ progress: SignalProgressPayload;
+};
diff --git a/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stat-tiles/SignalStatTiles.tsx b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stat-tiles/SignalStatTiles.tsx
new file mode 100644
index 0000000..3c6436a
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stat-tiles/SignalStatTiles.tsx
@@ -0,0 +1,72 @@
+'use client';
+
+import { GridBox } from '@lumina/island/atoms/grid-box';
+import { InfoTip } from '@lumina/island/molecules/info-tip';
+import { StatTile } from '@lumina/island/molecules/stat-tile';
+import { Element } from '@lumina/island/primitives/element';
+import { iso, number, percent, signedPercent } from '@lumina/tools/format';
+import { useTranslation } from 'react-i18next';
+
+import type { SignalStatTilesProps } from './types';
+
+/** The four numbers the channel, نمای کلی and سیگنالها all show, from one snapshot. */
+export function SignalStatTiles({
+ stats,
+ layout,
+ withTips = false,
+}: SignalStatTilesProps) {
+ const { t } = useTranslation('predictions');
+
+ return (
+
+
+ {t('performance.tiles.win-rate')}
+ {withTips && (
+
+ {t('performance.tips.win-rate')}
+
+ )}
+ >
+ }
+ value={iso(percent(stats.winRate))}
+ />
+
+ {t('performance.tiles.avg-roi')}
+ {withTips && (
+
+ {t('performance.tips.avg-roi')}
+
+ )}
+ >
+ }
+ value={
+
+ {signedPercent(stats.avgRoi)}
+
+ }
+ valueTone={
+ stats.avgRoi > 0 ? 'success' : stats.avgRoi < 0 ? 'danger' : 'default'
+ }
+ />
+
+
+
+ );
+}
diff --git a/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stat-tiles/index.ts b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stat-tiles/index.ts
new file mode 100644
index 0000000..ccde967
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stat-tiles/index.ts
@@ -0,0 +1,2 @@
+export { SignalStatTiles } from './SignalStatTiles';
+export type { SignalStatTilesProps } from './types';
diff --git a/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stat-tiles/types.ts b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stat-tiles/types.ts
new file mode 100644
index 0000000..beaa0da
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stat-tiles/types.ts
@@ -0,0 +1,9 @@
+import type { SignalNumbersPayload } from '../../../../../../features/prediction';
+
+export type SignalStatTilesProps = {
+ stats: Pick;
+ /** mobile: two by two; desktop: one row. */
+ layout: 'mobile' | 'desktop';
+ /** The ⓘ beside the rate and the return: only on سیگنالها, never on نمای کلی. */
+ withTips?: boolean;
+};
diff --git a/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stats-pending/SignalStatsPending.tsx b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stats-pending/SignalStatsPending.tsx
new file mode 100644
index 0000000..91542bf
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stats-pending/SignalStatsPending.tsx
@@ -0,0 +1,19 @@
+'use client';
+
+import { StateMessage } from '@lumina/island/molecules/state-message';
+import { useTranslation } from 'react-i18next';
+
+/** In place of the numbers before the first nightly evaluation: never zeros, which would be false. */
+export function SignalStatsPending() {
+ const { t } = useTranslation('predictions');
+
+ return (
+
+ );
+}
diff --git a/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stats-pending/index.ts b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stats-pending/index.ts
new file mode 100644
index 0000000..34707ff
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/dashboard/organisms/signal-stats-pending/index.ts
@@ -0,0 +1 @@
+export { SignalStatsPending } from './SignalStatsPending';
diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/pricing-card/PricingCard.test.tsx b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/pricing-card/PricingCard.test.tsx
new file mode 100644
index 0000000..740f1d6
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/pricing-card/PricingCard.test.tsx
@@ -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) =>
+ 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( );
+ expect(screen.getAllByText('off-sale.badge')).toHaveLength(1);
+ });
+
+ it('shows a banner per plan, with its name and «اصلاح قیمت» to the editor', () => {
+ render( );
+ 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( );
+ expect(screen.queryByText('off-sale.badge')).toBeNull();
+ expect(screen.queryByRole('link', { name: 'off-sale.action' })).toBeNull();
+ });
+});
diff --git a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/pricing-card/PricingCard.tsx b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/pricing-card/PricingCard.tsx
index e07d052..3c3da85 100644
--- a/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/pricing-card/PricingCard.tsx
+++ b/platforms/market/src/app/screens/(main)/dashboard/plans/organisms/pricing-card/PricingCard.tsx
@@ -24,7 +24,8 @@ import type { PricingCardProps } from './types';
* notice «قیمتها را هر ۷ روز یکبار میتوانید تغییر دهید.» sits under the plans and the button
* stays live, since promotions stay editable (1c). A creator not yet verified, or rejected, sees
* that status above the card 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) {
const { t } = useTranslation(['pricing', 'common']);
@@ -60,6 +61,26 @@ export function PricingCard({ layout }: PricingCardProps) {
)}
+ {model.offSale.map((period) => (
+
+ {t('off-sale.action')}
+
+ }
+ >
+ {t('off-sale.banner', {
+ tier: t(`common:billing-periods.${period}`),
+ })}
+
+ ))}
{t(`common:billing-periods.${plan.billingPeriod}`)}
+ {plan.offSale && (
+
+ {t('off-sale.badge')}
+
+ )}
{promo && (
{t('card.discount', { percent: percent(promo.percent, 0) })}
diff --git a/platforms/market/src/app/screens/(main)/dashboard/predictions/all/organisms/prediction-list/PredictionList.tsx b/platforms/market/src/app/screens/(main)/dashboard/predictions/all/organisms/prediction-list/PredictionList.tsx
index aee0c12..b75fdef 100644
--- a/platforms/market/src/app/screens/(main)/dashboard/predictions/all/organisms/prediction-list/PredictionList.tsx
+++ b/platforms/market/src/app/screens/(main)/dashboard/predictions/all/organisms/prediction-list/PredictionList.tsx
@@ -17,7 +17,7 @@ import type { PredictionListProps } from './types';
const FILTERS: readonly OwnPredictionsStatus[] = ['open', 'closed', 'all'];
/**
- * «همه پیشبینیها» (J10-3f, J10-3g): «باز» · «بستهشده» · «همه» with the API's totals, open ones
+ * «همه سیگنالها» (J10-3f, J10-3g): «باز» · «بستهشده» · «همه» with the API's totals, open ones
* with «بستن زودهنگام», closed ones with why and at whose price they closed, 20 at a time with
* «نمایش بیشتر». The cards stay while another chip's list or the next page loads; a failed page
* says so in place of «نمایش بیشتر».
diff --git a/platforms/market/src/app/screens/(main)/dashboard/predictions/all/organisms/prediction-list/PredictionListSkeleton.tsx b/platforms/market/src/app/screens/(main)/dashboard/predictions/all/organisms/prediction-list/PredictionListSkeleton.tsx
index 5edf86d..ce8a8d1 100644
--- a/platforms/market/src/app/screens/(main)/dashboard/predictions/all/organisms/prediction-list/PredictionListSkeleton.tsx
+++ b/platforms/market/src/app/screens/(main)/dashboard/predictions/all/organisms/prediction-list/PredictionListSkeleton.tsx
@@ -4,7 +4,7 @@ import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import type { PredictionListSkeletonProps } from './types';
-/** «همه پیشبینیها» before it arrives: the chips' row, then the cards. */
+/** «همه سیگنالها» before it arrives: the chips' row, then the cards. */
export function PredictionListSkeleton({
label,
delayed,
diff --git a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/PredictionsTab.tsx b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/PredictionsTab.tsx
index dae3ab8..4e32ab1 100644
--- a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/PredictionsTab.tsx
+++ b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/PredictionsTab.tsx
@@ -12,14 +12,14 @@ import { usePredictionsTabPart } from '../../../../../../../features/prediction'
import { PartBoundary } from '../../../../../../error-boundaries';
import { ROUTES } from '../../../../../../navigation/navigation';
import { PredictionSection } from './components/PredictionSection';
-import { TrackRecord } from './components/TrackRecord';
+import { SignalPerformance } from './components/SignalPerformance';
import { PredictionsTabSkeleton } from './PredictionsTabSkeleton';
import type { PredictionsTabProps } from './types';
/**
- * داشبورد › پیشبینیها (J10-3), the creator's own, in the browser only: the record or its progress
- * to public, every open prediction with «بستن زودهنگام», the two closed most recently and
- * «همه پیشبینیها». Each block loads and fails on its own (J10-3e). Before the first prediction,
+ * داشبورد › سیگنالها (J10-3), the creator's own, in the browser only: «عملکرد سیگنالها», every
+ * open prediction with «بستن زودهنگام», the two closed most recently and
+ * «همه سیگنالها». Each block loads and fails on its own (J10-3e). Before the first prediction,
* only the way to publish one (J10-3c). No edit or delete: a published prediction is final.
*/
export function PredictionsTab({ layout }: PredictionsTabProps) {
@@ -46,16 +46,16 @@ export function PredictionsTab({ layout }: PredictionsTabProps) {
return (
+
}
>
-
+
diff --git a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/PredictionsTabSkeleton.tsx b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/PredictionsTabSkeleton.tsx
index c915970..f76e466 100644
--- a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/PredictionsTabSkeleton.tsx
+++ b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/PredictionsTabSkeleton.tsx
@@ -3,7 +3,7 @@ import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import type { PredictionsTabSkeletonProps } from './types';
-/** داشبورد › پیشبینیها before it arrives, block for block: the record, then two cards. */
+/** داشبورد › سیگنالها before it arrives, block for block: the numbers, then two cards. */
export function PredictionsTabSkeleton({
label,
delayed,
diff --git a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/PredictionSection.tsx b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/PredictionSection.tsx
index b5dd920..3234a46 100644
--- a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/PredictionSection.tsx
+++ b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/PredictionSection.tsx
@@ -10,7 +10,7 @@ import type { PredictionSectionProps } from '../types';
import { SectionCards } from './SectionCards';
/**
- * «پیشبینیهای باز (۳)» or «بستهشدههای اخیر» (J10-3): its title stays over its cards, or over its
+ * «سیگنالهای باز (۳)» or «بستهشدههای اخیر» (J10-3): its title stays over its cards, or over its
* own error in a card, the count dropped (J10-3e); it loads and fails on its own. A section with
* nothing in it isn't drawn.
*/
diff --git a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/SignalPerformance.test.tsx b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/SignalPerformance.test.tsx
new file mode 100644
index 0000000..f02c74c
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/SignalPerformance.test.tsx
@@ -0,0 +1,196 @@
+import { render, screen, within } from '@testing-library/react';
+import { number, ratio } from '@lumina/tools/format';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import type { SignalStatsPayload } from '../../../../../../../../features/prediction';
+import predictions from '../../../../../../../../shared/locales/fa/predictions.json';
+import { SignalProgress } from '../../../../organisms/signal-progress';
+import { SignalStatTiles } from '../../../../organisms/signal-stat-tiles';
+import { riskRewardText } from '../utils';
+import { SignalPerformance } from './SignalPerformance';
+
+let answer: SignalStatsPayload;
+
+vi.mock('../../../../../../../../features/prediction', () => ({
+ useSignalStatsPart: () => answer,
+}));
+
+// The real Persian strings, so the spec's exact wording is what's tested.
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({
+ t: (key: string, values: Record = {}) => {
+ const text = key
+ .split('.')
+ .reduce((node: any, part) => node?.[part], predictions) as string;
+ return text.replace(/{{(\w+)}}/g, (_, name) => values[name]);
+ },
+ }),
+}));
+
+const ready = (
+ over: Partial> = {},
+) =>
+ ({
+ status: 'ready',
+ stats: {
+ winRate: 60,
+ avgRoi: 4.2,
+ total: 12,
+ active: 2,
+ outcomes: { target: 6, stop: 3, expired: 1, active: 2, voided: 0 },
+ riskReward: { worst: 1.4, best: 3 },
+ },
+ progress: { isPublic: false, closed: 4, required: 10, daysLeft: 18 },
+ ...over,
+ }) as SignalStatsPayload;
+
+describe('SignalPerformance', () => {
+ beforeEach(() => {
+ answer = ready();
+ });
+
+ it('shows the message and no numbers before the first evaluation', () => {
+ answer = { status: 'pending' };
+ render( );
+ expect(
+ screen.getByText('ارزیابی عملکرد سیگنالها بهزودی فعال میشود.'),
+ ).toBeTruthy();
+ expect(
+ screen.getByText('عددها پس از اولین ارزیابی شبانه نمایش داده میشوند.'),
+ ).toBeTruthy();
+ expect(screen.queryByText('نرخ موفقیت')).toBeNull();
+ expect(screen.queryByText('رسیده به هدف')).toBeNull();
+ expect(screen.queryByRole('progressbar')).toBeNull();
+ });
+
+ it('shows the owner the numbers below the threshold, with the way to public', () => {
+ render( );
+ for (const label of [
+ 'نرخ موفقیت',
+ 'بازدهی میانگین',
+ 'کل سیگنالها',
+ 'سیگنالهای فعال',
+ ]) {
+ expect(screen.getByText(label)).toBeTruthy();
+ }
+ expect(
+ screen.getByText(
+ `${number(4)} از ${number(10)} سیگنال بستهشده تا نمایش عمومی`,
+ ),
+ ).toBeTruthy();
+ expect(screen.getByText(`${number(18)} روز تا یک ماه فعالیت`)).toBeTruthy();
+ expect(screen.queryByText('کارنامه عمومی شما فعال است')).toBeNull();
+ });
+
+ it('says the record is public once it is', () => {
+ answer = ready({
+ progress: { isPublic: true, closed: 10, required: 10, daysLeft: null },
+ });
+ render( );
+ expect(screen.getByText('کارنامه عمومی شما فعال است')).toBeTruthy();
+ expect(screen.queryByText(/تا نمایش عمومی/)).toBeNull();
+ });
+
+ it('lists every outcome', () => {
+ render( );
+ for (const label of [
+ 'رسیده به هدف',
+ 'خورده به حد ضرر',
+ 'پایان مهلت',
+ 'فعال',
+ 'باطلشده',
+ ]) {
+ expect(screen.getByText(label)).toBeTruthy();
+ }
+ });
+
+ it('shows risk to reward as worst to best', () => {
+ render( );
+ expect(screen.getByText(`${ratio(1, 1.4)} تا ${ratio(1, 3)}`)).toBeTruthy();
+ });
+
+ it('shows a dash with no risk to reward', () => {
+ const base = ready() as Extract;
+ answer = { ...base, stats: { ...base.stats, riskReward: null } };
+ render( );
+ expect(screen.getByText('—')).toBeTruthy();
+ });
+
+ it.each([
+ [
+ 'توضیح نرخ موفقیت',
+ 'سیگنالهایی که با پایان مهلت بسته شدهاند، ناموفق حساب میشوند.',
+ ],
+ [
+ 'توضیح بازدهی میانگین',
+ 'بازدهی هر سیگنال با تقسیم مساوی سرمایه بین هدفها محاسبه میشود.',
+ ],
+ [
+ 'توضیح ریسک به ریوارد',
+ 'بدترین و بهترین حالت: در سیگنالهای بازهای، ورود در دورترین و نزدیکترین نقطهٔ بازه به هدف.',
+ ],
+ ['توضیح پایان مهلت', 'در نرخ موفقیت، ناموفق حساب میشود.'],
+ ['توضیح باطلشده', 'در نرخ موفقیت و بازدهی حساب نمیشود.'],
+ ])('%s explains itself', (label, text) => {
+ render( );
+ const button = screen.getByRole('button', { name: label });
+ const tip = document.getElementById(
+ button.getAttribute('aria-describedby')!,
+ )!;
+ expect(within(tip.parentElement!).getByRole('tooltip').textContent).toBe(
+ text,
+ );
+ });
+});
+
+describe('SignalStatTiles', () => {
+ const stats = { winRate: 50, avgRoi: 0, total: 0, active: 0 };
+
+ it('has no tips unless asked, as on نمای کلی', () => {
+ render( );
+ expect(screen.queryByRole('button')).toBeNull();
+ });
+
+ it.each([
+ [4.2, 'text-success-text'],
+ [-3, 'text-danger-text'],
+ [0, 'text-text-primary'],
+ ])('colours a return of %d', (avgRoi, tone) => {
+ const { container } = render(
+ ,
+ );
+ const value = container.querySelector('bdi')!.parentElement!;
+ expect(value.className).toContain(tone);
+ expect(container.querySelector('bdi')!.getAttribute('dir')).toBe('ltr');
+ });
+});
+
+describe('SignalProgress', () => {
+ it('leaves the days out once the month is met', () => {
+ render(
+ ,
+ );
+ expect(screen.queryByText(/یک ماه فعالیت/)).toBeNull();
+ });
+});
+
+describe('riskRewardText', () => {
+ const range = ({ worst, best }: { worst: string; best: string }) =>
+ `${worst} تا ${best}`;
+
+ it('reads one ratio when the two read the same', () => {
+ expect(riskRewardText({ worst: 2, best: 2.01 }, range)).toBe(ratio(1, 2));
+ });
+
+ it('reads worst to best', () => {
+ expect(riskRewardText({ worst: 1.4, best: 3 }, range)).toBe(
+ `${ratio(1, 1.4)} تا ${ratio(1, 3)}`,
+ );
+ });
+
+ it('is a dash with nothing to read', () => {
+ expect(riskRewardText(null, range)).toBe('—');
+ });
+});
diff --git a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/SignalPerformance.tsx b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/SignalPerformance.tsx
new file mode 100644
index 0000000..c94659f
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/SignalPerformance.tsx
@@ -0,0 +1,104 @@
+'use client';
+
+import { FlexBox } from '@lumina/island/atoms/flex-box';
+import { Typography } from '@lumina/island/atoms/typography';
+import { Card } from '@lumina/island/molecules/card';
+import { DetailRow } from '@lumina/island/molecules/detail-row';
+import { InfoTip } from '@lumina/island/molecules/info-tip';
+import { KeyValue } from '@lumina/island/molecules/key-value';
+import { number } from '@lumina/tools/format';
+import { useId } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useSignalStatsPart } from '../../../../../../../../features/prediction';
+import { SignalProgress } from '../../../../organisms/signal-progress';
+import { SignalStatTiles } from '../../../../organisms/signal-stat-tiles';
+import { SignalStatsPending } from '../../../../organisms/signal-stats-pending';
+import type { SignalPerformanceProps } from '../types';
+import { riskRewardText } from '../utils';
+
+/**
+ * «عملکرد سیگنالها» at the top of the tab: the four numbers, how signals ended, risk to reward and
+ * the way to a public record, with an ⓘ on what isn't obvious. The owner sees the numbers below the
+ * public threshold too. Before the first nightly evaluation, a message in their place.
+ */
+export function SignalPerformance({ layout }: SignalPerformanceProps) {
+ const { t } = useTranslation('predictions');
+ const headingId = useId();
+ const performance = useSignalStatsPart();
+
+ return (
+
+
+
+ {t('performance.title')}
+
+ {performance.status === 'pending' ? (
+
+ ) : (
+ <>
+
+
+
+ {number(performance.stats.outcomes.target)}
+
+
+ {number(performance.stats.outcomes.stop)}
+
+
+ {t('performance.outcomes.expired')}
+
+ {t('performance.tips.expired')}
+
+ >
+ }
+ >
+ {number(performance.stats.outcomes.expired)}
+
+
+ {number(performance.stats.outcomes.active)}
+
+
+ {t('performance.outcomes.voided')}
+
+ {t('performance.tips.voided')}
+
+ >
+ }
+ >
+ {number(performance.stats.outcomes.voided)}
+
+
+ {t('performance.risk-reward')}
+
+ {t('performance.tips.risk-reward')}
+
+ >
+ }
+ >
+ {riskRewardText(performance.stats.riskReward, (range) =>
+ t('performance.risk-reward-range', range),
+ )}
+
+
+
+ >
+ )}
+
+
+ );
+}
diff --git a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/TrackRecord.tsx b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/TrackRecord.tsx
deleted file mode 100644
index 0cecfd5..0000000
--- a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/TrackRecord.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { CreatorStats } from '@lumina/island/organisms/creator-stats';
-import { useMemo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { useTrackRecordPart } from '../../../../../../../../features/prediction';
-import { creatorStatsLabels } from '../../../../../../../../shared/labels';
-import { TrackRecordProgress } from './TrackRecordProgress';
-
-/**
- * The tab's record (J10-3, J10-3b): «کارنامه شما» with the creator's own numbers once public, or
- * «کارنامه عمومی» with how far it is from public, since the channel shows none yet.
- */
-export function TrackRecord() {
- const { t } = useTranslation('predictions');
- const { t: tContent } = useTranslation('content');
- const labels = useMemo(
- () => ({ ...creatorStatsLabels(tContent), title: t('tab.record.title') }),
- [t, tContent],
- );
- const record = useTrackRecordPart();
-
- return record.kind === 'public' ? (
-
- ) : (
-
- );
-}
diff --git a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/TrackRecordProgress.tsx b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/TrackRecordProgress.tsx
deleted file mode 100644
index a320585..0000000
--- a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/components/TrackRecordProgress.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import { FlexBox } from '@lumina/island/atoms/flex-box';
-import { Icon } from '@lumina/island/atoms/icon';
-import { Typography } from '@lumina/island/atoms/typography';
-import { Card } from '@lumina/island/molecules/card';
-import { Meter } from '@lumina/island/molecules/meter';
-import { number } from '@lumina/tools/format';
-import { useId } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import type { TrackRecordProgressProps } from '../types';
-
-/**
- * «کارنامه عمومی» below the threshold (J10-3b): when it goes public, the closed predictions so far
- * against the required ones, and the days left to a month of activity while there are any.
- */
-export function TrackRecordProgress({
- closed,
- required,
- daysLeft,
-}: TrackRecordProgressProps) {
- const { t } = useTranslation('predictions');
- const headingId = useId();
-
- return (
-
-
-
- {t('tab.record.public-title')}
-
-
- {t('tab.record.threshold', { required: number(required) })}
-
-
- {daysLeft !== null && (
-
-
-
- {t('tab.record.days-left', { n: number(daysLeft) })}
-
-
- )}
-
-
- );
-}
diff --git a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/types.ts b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/types.ts
index eed6095..33f680a 100644
--- a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/types.ts
+++ b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/types.ts
@@ -18,9 +18,6 @@ export type PredictionSectionProps = {
export type SectionCardsProps = PredictionSectionProps;
-export type TrackRecordProgressProps = {
- closed: number;
- required: number;
- /** `null` once a month of activity is met. */
- daysLeft: number | null;
+export type SignalPerformanceProps = {
+ layout: 'mobile' | 'desktop';
};
diff --git a/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/utils.ts b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/utils.ts
new file mode 100644
index 0000000..35be21e
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/dashboard/predictions/organisms/predictions-tab/utils.ts
@@ -0,0 +1,16 @@
+import { ratio } from '@lumina/tools/format';
+
+import type { SignalNumbersPayload } from '../../../../../../../features/prediction';
+
+type RangeText = (range: { worst: string; best: string }) => string;
+
+/** «۱ : ۱٫۴ تا ۱ : ۳٫۰», one ratio when the two read the same, or a dash with nothing to read. */
+export function riskRewardText(
+ riskReward: SignalNumbersPayload['riskReward'],
+ rangeText: RangeText,
+): string {
+ if (!riskReward) return '—';
+ const worst = ratio(1, riskReward.worst);
+ const best = ratio(1, riskReward.best);
+ return worst === best ? worst : rangeText({ worst, best });
+}
diff --git a/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/renewal-sheet/components/RenewalForm.tsx b/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/renewal-sheet/components/RenewalForm.tsx
index 1f63553..831546a 100644
--- a/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/renewal-sheet/components/RenewalForm.tsx
+++ b/platforms/market/src/app/screens/(main)/dashboard/subscriptions/organisms/renewal-sheet/components/RenewalForm.tsx
@@ -112,6 +112,11 @@ export function RenewalForm({
{t('subscriptions.renewal.tiers')}
+ {tiers.length === 0 && (
+
+ {t('subscriptions.renewal.none-on-sale')}
+
+ )}
= {
subscription_expired_suspended: { icon: 'ban', tone: 'warning' },
// From the admin panel (J11-7d, J11-7e).
subscription_extended: { icon: 'calendar', tone: 'brand' },
+ rules_updated: { icon: 'file', tone: 'brand' },
+ tier_off_sale: { icon: 'alert', tone: 'warning' },
subscription_refunded: { icon: 'receipt', tone: 'neutral' },
// Capacity opened, with the investor's code ready (J06-7e).
waitlist_capacity: { icon: 'tag', tone: 'brand' },
diff --git a/platforms/market/src/app/screens/(main)/organisms/analyst-list/AnalystList.tsx b/platforms/market/src/app/screens/(main)/organisms/analyst-list/AnalystList.tsx
index c632a14..1945879 100644
--- a/platforms/market/src/app/screens/(main)/organisms/analyst-list/AnalystList.tsx
+++ b/platforms/market/src/app/screens/(main)/organisms/analyst-list/AnalystList.tsx
@@ -10,7 +10,6 @@ import { useTranslation } from 'react-i18next';
import { useAnalystFollowPart } from '../../../../../features/discovery';
import type { CreatorSummaryPayload } from '../../../../../features/discovery';
import { ROUTES } from '../../../../navigation/navigation';
-import { UnfollowConfirm } from '../unfollow-confirm';
import { AnalystFollowButton } from './components/AnalystFollowButton';
import { DESKTOP_COLUMNS } from './constants';
import { analystCardLabels } from './labels';
@@ -21,7 +20,7 @@ import type { AnalystListProps } from './types';
* and search. One per row on mobile, a grid on desktop. The list is the same for every visitor and
* renders on the server; an investor's follow buttons join in the browser once their follows are
* read (`useAnalystFollowPart`), in the card's foot, which keeps its height meanwhile. A guest and a
- * creator get none. Unfollow asks first: a sheet on mobile, a modal on desktop (J04-3c).
+ * creator get none. A followed analyst shows a label; unfollowing is not offered here.
*/
export function AnalystList({
analysts,
@@ -44,65 +43,51 @@ export function AnalystList({
};
return (
- <>
-
- {analysts.map((analyst) => {
- const state = follow.stateOf(analyst.creatorId);
- return (
-
-
- tCommon(`markets.${market}`),
- ),
- bio: analyst.bio,
- followers: analyst.followersCount,
- stats: analyst.stats,
- }}
- href={ROUTES.channel(analyst.username)}
- action={
- state === 'follow' ||
- state === 'following' ||
- state === 'frozen' ? (
-
- ) : undefined
- }
- labels={labels}
- className="h-full"
- />
-
- );
- })}
-
- {follow.unfollowTarget && (
-
- )}
- >
+
+ {analysts.map((analyst) => {
+ const state = follow.stateOf(analyst.creatorId);
+ return (
+
+
+ tCommon(`markets.${market}`),
+ ),
+ bio: analyst.bio,
+ followers: analyst.followersCount,
+ stats: analyst.stats,
+ }}
+ href={ROUTES.channel(analyst.username)}
+ action={
+ state === 'follow' || state === 'following' ? (
+
+ ) : undefined
+ }
+ labels={labels}
+ className="h-full"
+ />
+
+ );
+ })}
+
);
}
diff --git a/platforms/market/src/app/screens/(main)/organisms/analyst-list/components/AnalystFollowButton.test.tsx b/platforms/market/src/app/screens/(main)/organisms/analyst-list/components/AnalystFollowButton.test.tsx
new file mode 100644
index 0000000..ea5108f
--- /dev/null
+++ b/platforms/market/src/app/screens/(main)/organisms/analyst-list/components/AnalystFollowButton.test.tsx
@@ -0,0 +1,41 @@
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { describe, expect, it, vi } from 'vitest';
+
+import type { CreatorSummaryPayload } from '../../../../../../features/discovery';
+import { AnalystFollowButton } from './AnalystFollowButton';
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+const analyst = { creatorId: '1' } as CreatorSummaryPayload;
+
+describe('AnalystFollowButton', () => {
+ it('offers a follow on the dark button', async () => {
+ const onFollow = vi.fn();
+ render(
+ ,
+ );
+ const button = screen.getByRole('button', { name: 'actions.follow' });
+ expect(button.className).toContain('bg-action-dark');
+ await userEvent.click(button);
+ expect(onFollow).toHaveBeenCalledWith(analyst);
+ });
+
+ it('shows a followed analyst as a label with nothing to press', () => {
+ render(
+ ,
+ );
+ expect(screen.queryByRole('button')).toBeNull();
+ expect(screen.getByText('actions.following')).toBeTruthy();
+ });
+});
diff --git a/platforms/market/src/app/screens/(main)/organisms/analyst-list/components/AnalystFollowButton.tsx b/platforms/market/src/app/screens/(main)/organisms/analyst-list/components/AnalystFollowButton.tsx
index 4fa809c..e45c144 100644
--- a/platforms/market/src/app/screens/(main)/organisms/analyst-list/components/AnalystFollowButton.tsx
+++ b/platforms/market/src/app/screens/(main)/organisms/analyst-list/components/AnalystFollowButton.tsx
@@ -1,5 +1,6 @@
'use client';
+import { ActionLabel } from '@lumina/island/atoms/action-label';
import { Button } from '@lumina/island/atoms/button';
import { useOfflineFreeze } from '@lumina/island/hooks/use-online';
import { useTranslation } from 'react-i18next';
@@ -7,55 +8,30 @@ import { useTranslation } from 'react-i18next';
import type { AnalystFollowButtonProps } from '../types';
/**
- * A card's follow control (DS AnalystCard): «دنبال کردن» with a plus, or «دنبال نکردن», which asks
- * first; frozen with its reason while a subscription to the channel is active, or offline.
+ * A card's follow control (DS AnalystCard): «دنبال کردن» with a plus, or the plain «دنبال میکنید»
+ * label once followed. Unfollowing happens only on the channel or in دنبالشدهها.
*/
export function AnalystFollowButton({
analyst,
state,
onFollow,
- onUnfollow,
}: AnalystFollowButtonProps) {
const { t } = useTranslation(['channel', 'common']);
const offline = useOfflineFreeze(t('common:network.frozen'));
- if (state === 'follow') {
- return (
- onFollow(analyst)}
- frozenAlign="end"
- {...offline}
- >
- {t('actions.follow')}
-
- );
- }
- if (state === 'frozen') {
- return (
-
- {t('actions.unfollow')}
-
- );
+ if (state === 'following') {
+ return {t('actions.following')} ;
}
return (
onUnfollow(analyst)}
+ icon="plus"
+ onClick={() => onFollow(analyst)}
frozenAlign="end"
{...offline}
>
- {t('actions.unfollow')}
+ {t('actions.follow')}
);
}
diff --git a/platforms/market/src/app/screens/(main)/organisms/analyst-list/types.ts b/platforms/market/src/app/screens/(main)/organisms/analyst-list/types.ts
index 47b2b2e..ef38816 100644
--- a/platforms/market/src/app/screens/(main)/organisms/analyst-list/types.ts
+++ b/platforms/market/src/app/screens/(main)/organisms/analyst-list/types.ts
@@ -32,7 +32,6 @@ export type AnalystListSkeletonProps = {
export type AnalystFollowButtonProps = {
analyst: CreatorSummaryPayload;
- state: 'follow' | 'following' | 'frozen';
+ state: 'follow' | 'following';
onFollow: (analyst: CreatorSummaryPayload) => void;
- onUnfollow: (analyst: CreatorSummaryPayload) => void;
};
diff --git a/platforms/market/src/app/screens/(main)/organisms/close-prediction-sheet/components/PredictionSummary.tsx b/platforms/market/src/app/screens/(main)/organisms/close-prediction-sheet/components/PredictionSummary.tsx
index 6dc2f28..0ab3f6f 100644
--- a/platforms/market/src/app/screens/(main)/organisms/close-prediction-sheet/components/PredictionSummary.tsx
+++ b/platforms/market/src/app/screens/(main)/organisms/close-prediction-sheet/components/PredictionSummary.tsx
@@ -1,6 +1,7 @@
import { Icon } from '@lumina/island/atoms/icon';
import { Separator } from '@lumina/island/atoms/separator';
import { Typography } from '@lumina/island/atoms/typography';
+import { entryText } from '@lumina/island/organisms/prediction-card';
import { DetailRow } from '@lumina/island/molecules/detail-row';
import { KeyValue } from '@lumina/island/molecules/key-value';
import { price } from '@lumina/tools/format';
@@ -33,7 +34,7 @@ export function PredictionSummary({ post, children }: PredictionSummaryProps) {
- {price(prediction.entryPrice)}
+ {entryText(prediction)}
{finalTarget != null && (
diff --git a/platforms/market/src/app/screens/organisms/agreement-gate/AgreementGate.test.tsx b/platforms/market/src/app/screens/organisms/agreement-gate/AgreementGate.test.tsx
new file mode 100644
index 0000000..2e4c3b3
--- /dev/null
+++ b/platforms/market/src/app/screens/organisms/agreement-gate/AgreementGate.test.tsx
@@ -0,0 +1,126 @@
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { createInstance } from 'i18next';
+import type { ReactNode } from 'react';
+import { I18nextProvider, initReactI18next } from 'react-i18next';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { legalRepository } from '../../../../features/legal/repositories/legal/legal';
+import { resources } from '../../../../shared/locales/resources';
+import { useAuthStore } from '../../../../stores/auth';
+import { AgreementGate } from './AgreementGate';
+
+vi.mock('../../../../features/legal/repositories/legal/legal', () => ({
+ legalRepository: {
+ getDocument: vi.fn(),
+ accept: vi.fn(),
+ listAcceptances: vi.fn(),
+ },
+}));
+vi.mock('../sign-out-confirm', () => ({
+ SignOutConfirm: ({ open }: { open: boolean }) =>
+ open ? sign-out-confirm
: null,
+}));
+
+const i18n = createInstance();
+void i18n.use(initReactI18next).init({
+ lng: 'fa',
+ resources,
+ interpolation: { escapeValue: false },
+});
+
+const wrapper = ({ children }: { children: ReactNode }) => (
+
+ {children}
+
+);
+
+const session = (agreementRequired: boolean) =>
+ useAuthStore.getState().setSession({
+ account: { id: 'c1', role: 'creator' } as never,
+ needsProfile: false,
+ agreementRequired,
+ });
+
+const acceptButton = () => screen.getByText('پذیرش و ادامه').closest('button')!;
+
+describe('AgreementGate', () => {
+ beforeEach(() => {
+ vi.mocked(legalRepository.getDocument).mockResolvedValue({
+ key: 'analyst_agreement',
+ version: '2.0',
+ title: 'توافقنامه تحلیلگر',
+ bodyMd: 'متن کامل توافقنامه',
+ isMajor: true,
+ changeSummary: 'تغییر کمیسیون',
+ publishedAt: '2026-11-01T00:00:00Z',
+ effectiveAt: '2026-11-01T00:00:00Z',
+ });
+ vi.mocked(legalRepository.accept).mockResolvedValue({
+ document: 'analyst_agreement',
+ version: '2.0',
+ acceptedAt: '2026-11-02T00:00:00Z',
+ agreementRequired: false,
+ });
+ vi.mocked(legalRepository.listAcceptances).mockResolvedValue([]);
+ });
+
+ it('renders nothing while no major agreement is owed', () => {
+ session(false);
+ render( , { wrapper });
+ expect(screen.queryByText('توافقنامه تحلیلگر بهروزرسانی شد')).toBeNull();
+ expect(legalRepository.getDocument).not.toHaveBeenCalled();
+ });
+
+ it('unticked: blocks, with no close and «پذیرش و ادامه» frozen with its reason', async () => {
+ session(true);
+ render( , { wrapper });
+ expect(await screen.findByText('تغییرات مهم نسخه 2٫0')).toBeTruthy();
+ expect(screen.getByText('تغییر کمیسیون')).toBeTruthy();
+ expect(screen.queryByRole('button', { name: /بستن/ })).toBeNull();
+ expect(acceptButton().classList.contains('frozen')).toBe(true);
+ expect(screen.getByText('ابتدا توافقنامه را بپذیرید.')).toBeTruthy();
+ await userEvent.click(acceptButton());
+ expect(legalRepository.accept).not.toHaveBeenCalled();
+ });
+
+ it('ticked: accepts the version read, and lifts the block', async () => {
+ session(true);
+ render( , { wrapper });
+ await userEvent.click(
+ await screen.findByLabelText(
+ 'نسخهٔ جدید توافقنامه تحلیلگر را خواندهام و میپذیرم.',
+ ),
+ );
+ expect(acceptButton().classList.contains('frozen')).toBe(false);
+ await userEvent.click(acceptButton());
+ await waitFor(() =>
+ expect(legalRepository.accept).toHaveBeenCalledWith({
+ document: 'analyst_agreement',
+ version: '2.0',
+ }),
+ );
+ await waitFor(() =>
+ expect(useAuthStore.getState().session?.agreementRequired).toBe(false),
+ );
+ });
+
+ it('shows the whole text inside the dialog and comes back', async () => {
+ session(true);
+ render( , { wrapper });
+ await userEvent.click(await screen.findByText('خواندن متن کامل'));
+ expect(screen.getByText('متن کامل توافقنامه')).toBeTruthy();
+ await userEvent.click(screen.getByText('بازگشت به خلاصه تغییرات'));
+ expect(screen.getByText('تغییر کمیسیون')).toBeTruthy();
+ });
+
+ it('asks before signing out', async () => {
+ session(true);
+ render( , { wrapper });
+ await userEvent.click(await screen.findByText('خروج از حساب'));
+ expect(screen.getByText('sign-out-confirm')).toBeTruthy();
+ });
+});
diff --git a/platforms/market/src/app/screens/organisms/agreement-gate/AgreementGate.tsx b/platforms/market/src/app/screens/organisms/agreement-gate/AgreementGate.tsx
new file mode 100644
index 0000000..ee71dfd
--- /dev/null
+++ b/platforms/market/src/app/screens/organisms/agreement-gate/AgreementGate.tsx
@@ -0,0 +1,54 @@
+'use client';
+
+import { Modal } from '@lumina/island/molecules/modal';
+import { Sheet } from '@lumina/island/molecules/sheet';
+import { useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useAgreementGate } from '../../../../features/legal';
+import { SignOutConfirm } from '../sign-out-confirm';
+import { GateActions } from './components/GateActions';
+import { GateBody } from './components/GateBody';
+import type { AgreementGateProps } from './types';
+
+/**
+ * «توافقنامه تحلیلگر بهروزرسانی شد» (J01-4): over any page while an analyst owes a newer major
+ * agreement, with no ✕ and no dismissing by Escape or the scrim. It closes by accepting, or by
+ * signing out, which asks first as it does everywhere. A bottom sheet on mobile, a modal on desktop.
+ */
+export function AgreementGate({ layout }: AgreementGateProps) {
+ const { t } = useTranslation('legal');
+ const model = useAgreementGate();
+ const [isSigningOut, setSigningOut] = useState(false);
+
+ if (!model.isOpen) return null;
+
+ const title = t('agreement.gate.title');
+ const body = ;
+ const actions = (
+ setSigningOut(true)}
+ />
+ );
+
+ return (
+ <>
+ {layout === 'mobile' ? (
+
+ {body}
+
+ ) : (
+
+ {body}
+
+ )}
+ setSigningOut(false)}
+ layout={layout}
+ />
+ >
+ );
+}
diff --git a/platforms/market/src/app/screens/organisms/agreement-gate/components/GateActions.tsx b/platforms/market/src/app/screens/organisms/agreement-gate/components/GateActions.tsx
new file mode 100644
index 0000000..ba8f025
--- /dev/null
+++ b/platforms/market/src/app/screens/organisms/agreement-gate/components/GateActions.tsx
@@ -0,0 +1,35 @@
+import { Button } from '@lumina/island/atoms/button';
+import { useTranslation } from 'react-i18next';
+
+import type { GateActionsProps } from '../types';
+
+/** «پذیرش و ادامه» frozen with its reason until ticked, and the only other way out: signing out. */
+export function GateActions({ model, layout, onSignOut }: GateActionsProps) {
+ const { t } = useTranslation('legal');
+ const size = layout === 'mobile' ? 'lg' : undefined;
+
+ return (
+ <>
+
+ {t('agreement.gate.accept')}
+
+
+ {t('agreement.gate.sign-out')}
+
+ >
+ );
+}
diff --git a/platforms/market/src/app/screens/organisms/agreement-gate/components/GateBody.tsx b/platforms/market/src/app/screens/organisms/agreement-gate/components/GateBody.tsx
new file mode 100644
index 0000000..2a82c32
--- /dev/null
+++ b/platforms/market/src/app/screens/organisms/agreement-gate/components/GateBody.tsx
@@ -0,0 +1,80 @@
+import { Checkbox } from '@lumina/island/atoms/checkbox';
+import { FlexBox } from '@lumina/island/atoms/flex-box';
+import { LinkButton } from '@lumina/island/atoms/link-button';
+import { Skeleton } from '@lumina/island/atoms/skeleton';
+import { Typography } from '@lumina/island/atoms/typography';
+import { ErrorState } from '@lumina/island/molecules/error-state';
+import { version } from '@lumina/tools/format';
+import { useTranslation } from 'react-i18next';
+
+import { LegalDocumentBody } from '../../legal-document';
+import type { GateBodyProps } from '../types';
+
+/**
+ * What the analyst reads and ticks: what changed in this version, the way to the whole text, which
+ * opens inside the dialog so the block never lifts, and the checkbox.
+ */
+export function GateBody({ model }: GateBodyProps) {
+ const { t } = useTranslation(['legal', 'errors']);
+ const { agreement } = model;
+ const { document } = agreement;
+
+ if (agreement.isLoading) return ;
+ if (!document) {
+ return (
+ void agreement.reload()}
+ retryLabel={t('errors:fallback.retry')}
+ retryingLabel={t('errors:fallback.retrying')}
+ retrying={agreement.isReloading}
+ />
+ );
+ }
+
+ if (model.view === 'full') {
+ return (
+
+
+ {t('agreement.gate.back')}
+
+
+
+
+
+ );
+ }
+
+ return (
+
+ {t('agreement.gate.body')}
+ {document.changeSummary && (
+
+
+ {t('agreement.gate.changes', {
+ version: version(document.version),
+ })}
+
+
+ {document.changeSummary}
+
+
+ )}
+
+ {t('agreement.gate.read')}
+
+ model.setTicked(event.target.checked)}
+ >
+ {t('agreement.gate.checkbox')}
+
+
+ );
+}
diff --git a/platforms/market/src/app/screens/organisms/agreement-gate/index.ts b/platforms/market/src/app/screens/organisms/agreement-gate/index.ts
new file mode 100644
index 0000000..b7a3971
--- /dev/null
+++ b/platforms/market/src/app/screens/organisms/agreement-gate/index.ts
@@ -0,0 +1,2 @@
+export { AgreementGate } from './AgreementGate';
+export type { AgreementGateProps } from './types';
diff --git a/platforms/market/src/app/screens/organisms/agreement-gate/types.ts b/platforms/market/src/app/screens/organisms/agreement-gate/types.ts
new file mode 100644
index 0000000..f4dfb81
--- /dev/null
+++ b/platforms/market/src/app/screens/organisms/agreement-gate/types.ts
@@ -0,0 +1,11 @@
+import type { AgreementGateModel } from '../../../../features/legal';
+
+export type AgreementGateProps = { layout: 'mobile' | 'desktop' };
+
+export type GateBodyProps = { model: AgreementGateModel };
+
+export type GateActionsProps = {
+ model: AgreementGateModel;
+ layout: AgreementGateProps['layout'];
+ onSignOut: () => void;
+};
diff --git a/platforms/market/src/app/screens/organisms/general-rules/GeneralRules.tsx b/platforms/market/src/app/screens/organisms/general-rules/GeneralRules.tsx
deleted file mode 100644
index d34fda8..0000000
--- a/platforms/market/src/app/screens/organisms/general-rules/GeneralRules.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import { FlexBox } from '@lumina/island/atoms/flex-box';
-import { Typography } from '@lumina/island/atoms/typography';
-
-import type { GeneralRulesProps } from './types';
-
-/**
- * «قوانین عمومی» of «قوانین لومینا» (G-2r): seven numbered sections, verbatim, then when they last
- * changed. The same for every visitor, so it renders on the server: on its tab, and inside the
- * registration form's rules sheet (G-2s), which gets it rendered.
- */
-export function GeneralRules({ layout, labels }: GeneralRulesProps) {
- return (
-
- {/* Desktop's column title is the h1; the mobile bar's name is not a heading. */}
- {layout === 'mobile' && (
-
- {labels.title}
-
- )}
- {labels.sections.map((section) => {
- const titleId = `rules-${layout}-${section.id}`;
- return (
-
-
- {section.title}
-
- {section.paragraphs.map((paragraph) => (
- {paragraph}
- ))}
-
- );
- })}
-
- {labels.updated}
-
-
- );
-}
diff --git a/platforms/market/src/app/screens/organisms/general-rules/index.ts b/platforms/market/src/app/screens/organisms/general-rules/index.ts
deleted file mode 100644
index 6791983..0000000
--- a/platforms/market/src/app/screens/organisms/general-rules/index.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-export { GeneralRules } from './GeneralRules';
-export { generalRulesLabels } from './labels';
-export type {
- GeneralRulesLabels,
- GeneralRulesProps,
- RulesSection,
-} from './types';
diff --git a/platforms/market/src/app/screens/organisms/general-rules/labels.ts b/platforms/market/src/app/screens/organisms/general-rules/labels.ts
deleted file mode 100644
index 335114c..0000000
--- a/platforms/market/src/app/screens/organisms/general-rules/labels.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import type { TFunction } from 'i18next';
-
-import type { GeneralRulesLabels, RulesSection } from './types';
-
-/** «قوانین عمومی»'s text, from the server's translations (0020), verbatim from G-2r. */
-export function generalRulesLabels(t: TFunction<'rules'>): GeneralRulesLabels {
- const sections: RulesSection[] = [
- { id: 's1', title: t('s1.title'), paragraphs: [t('s1.p1'), t('s1.p2')] },
- { id: 's2', title: t('s2.title'), paragraphs: [t('s2.p1')] },
- { id: 's3', title: t('s3.title'), paragraphs: [t('s3.p1')] },
- { id: 's4', title: t('s4.title'), paragraphs: [t('s4.p1')] },
- { id: 's5', title: t('s5.title'), paragraphs: [t('s5.p1')] },
- { id: 's6', title: t('s6.title'), paragraphs: [t('s6.p1')] },
- { id: 's7', title: t('s7.title'), paragraphs: [t('s7.p1')] },
- ];
- return { title: t('title'), sections, updated: t('updated') };
-}
diff --git a/platforms/market/src/app/screens/organisms/general-rules/types.ts b/platforms/market/src/app/screens/organisms/general-rules/types.ts
deleted file mode 100644
index 0327458..0000000
--- a/platforms/market/src/app/screens/organisms/general-rules/types.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-/** One numbered section of the general rules: its title and paragraphs. */
-export type RulesSection = {
- id: string;
- title: string;
- paragraphs: string[];
-};
-
-export type GeneralRulesLabels = {
- /** The page's name: «قوانین لومینا». */
- title: string;
- sections: RulesSection[];
- /** «آخرین بهروزرسانی: …», the caption last. */
- updated: string;
-};
-
-export type GeneralRulesProps = {
- /**
- * mobile: adds the page's h1 for screen readers, since its bar names the page in plain text.
- * desktop: the column title is the h1. sheet: the sheet's title names it.
- */
- layout: 'mobile' | 'desktop' | 'sheet';
- labels: GeneralRulesLabels;
-};
diff --git a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/RulesSheet.tsx b/platforms/market/src/app/screens/organisms/legal-document/LegalDocumentDialog.tsx
similarity index 63%
rename from platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/RulesSheet.tsx
rename to platforms/market/src/app/screens/organisms/legal-document/LegalDocumentDialog.tsx
index 60faabf..5f19c31 100644
--- a/platforms/market/src/app/screens/(auth)/auth/register/details/organisms/register-details-step/components/RulesSheet.tsx
+++ b/platforms/market/src/app/screens/organisms/legal-document/LegalDocumentDialog.tsx
@@ -6,21 +6,25 @@ import { Modal } from '@lumina/island/molecules/modal';
import { Sheet } from '@lumina/island/molecules/sheet';
import { useTranslation } from 'react-i18next';
-import type { RulesSheetProps } from '../types';
+import { LegalDocumentView } from './LegalDocumentView';
+import type { LegalDocumentDialogProps } from './types';
/**
- * «قوانین لومینا» over the registration form (G-2s): the general rules, rendered on the server and
- * passed in, with one «متوجه شدم» that closes it. A bottom sheet on mobile, the 640 modal on
- * desktop; Escape and the scrim close it too.
+ * A legal document over the page, so nothing typed under it is lost (G-2s, G-2u): one «متوجه شدم»
+ * closes it. A bottom sheet on mobile, the 640 modal on desktop; Escape and the scrim close it too.
+ * It reads the document only once it opens.
*/
-export function RulesSheet({
+export function LegalDocumentDialog({
+ documentKey,
+ title,
open,
placement,
onClose,
- children,
-}: RulesSheetProps) {
- const { t } = useTranslation('auth');
- const title = t('register.rules-title');
+}: LegalDocumentDialogProps) {
+ const { t } = useTranslation('legal');
+ const body = open && (
+
+ );
const close = (
- {t('register.rules-close')}
+ {t('dialog.close')}
);
if (placement === 'sheet') {
return (
- {children}
+ {body}
);
}
@@ -46,7 +50,7 @@ export function RulesSheet({
direction="flex-col"
className="min-h-0 flex-1 overflow-auto p-6"
>
- {children}
+ {body}
;
+ if (isError || !document) {
+ return (
+ void reload()}
+ retryLabel={t('errors:fallback.retry')}
+ retryingLabel={t('errors:fallback.retrying')}
+ retrying={isReloading}
+ />
+ );
+ }
+
+ return (
+
+ {layout === 'mobile' && (
+
+ {document.title}
+
+ )}
+
+ {children}
+
+ {t('document.footer', {
+ version: version(document.version),
+ date: date(document.publishedAt, { time: false }),
+ })}
+
+
+ );
+}
diff --git a/platforms/market/src/app/screens/organisms/legal-document/components/LegalDocumentBody.tsx b/platforms/market/src/app/screens/organisms/legal-document/components/LegalDocumentBody.tsx
new file mode 100644
index 0000000..969a2b7
--- /dev/null
+++ b/platforms/market/src/app/screens/organisms/legal-document/components/LegalDocumentBody.tsx
@@ -0,0 +1,94 @@
+import { FlexBox } from '@lumina/island/atoms/flex-box';
+import { Typography } from '@lumina/island/atoms/typography';
+import { Element } from '@lumina/island/primitives/element';
+import { useMemo } from 'react';
+
+import { parseLegalMarkdown } from '../../../../../features/legal';
+import type { LegalInline } from '../../../../../features/legal';
+import type { LegalDocumentBodyProps } from '../types';
+
+function Inlines({ inlines }: { inlines: LegalInline[] }) {
+ return inlines.map((inline, index) =>
+ inline.bold ? (
+ // The text never changes while it is shown, so its place is its identity.
+ // oxlint-disable-next-line react/no-array-index-key
+
+ {inline.text}
+
+ ) : (
+ inline.text
+ ),
+ );
+}
+
+/** A legal document's text, parsed rather than injected, so it can never carry markup. */
+export function LegalDocumentBody({ bodyMd }: LegalDocumentBodyProps) {
+ const blocks = useMemo(() => parseLegalMarkdown(bodyMd), [bodyMd]);
+
+ return (
+
+ {blocks.map((block, index) => {
+ // Blocks of one version never reorder, and their text may repeat.
+ const key = `${block.kind}-${index}`;
+ switch (block.kind) {
+ case 'section':
+ return (
+
+
+
+ );
+ case 'subsection':
+ return (
+
+
+
+ );
+ case 'quote':
+ return (
+
+
+
+ );
+ case 'list':
+ return (
+
+ {block.items.map((item, itemIndex) => (
+ // oxlint-disable-next-line react/no-array-index-key
+
+
+
+
+
+ ))}
+
+ );
+ default:
+ return (
+
+
+
+ );
+ }
+ })}
+
+ );
+}
diff --git a/platforms/market/src/app/screens/organisms/legal-document/components/LegalDocumentSkeleton.tsx b/platforms/market/src/app/screens/organisms/legal-document/components/LegalDocumentSkeleton.tsx
new file mode 100644
index 0000000..35b50ed
--- /dev/null
+++ b/platforms/market/src/app/screens/organisms/legal-document/components/LegalDocumentSkeleton.tsx
@@ -0,0 +1,15 @@
+import { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
+
+/** A document's place while it loads: a few sections' worth of lines. */
+export function LegalDocumentSkeleton({ label }: { label: string }) {
+ return (
+
+
+
+
+
+
+
+
+ );
+}
diff --git a/platforms/market/src/app/screens/organisms/legal-document/index.ts b/platforms/market/src/app/screens/organisms/legal-document/index.ts
new file mode 100644
index 0000000..7bffc45
--- /dev/null
+++ b/platforms/market/src/app/screens/organisms/legal-document/index.ts
@@ -0,0 +1,9 @@
+export { LegalDocumentBody } from './components/LegalDocumentBody';
+export { LegalDocumentSkeleton } from './components/LegalDocumentSkeleton';
+export { LegalDocumentDialog } from './LegalDocumentDialog';
+export { LegalDocumentView } from './LegalDocumentView';
+export type {
+ LegalDocumentBodyProps,
+ LegalDocumentDialogProps,
+ LegalDocumentViewProps,
+} from './types';
diff --git a/platforms/market/src/app/screens/organisms/legal-document/types.ts b/platforms/market/src/app/screens/organisms/legal-document/types.ts
new file mode 100644
index 0000000..4c8a09b
--- /dev/null
+++ b/platforms/market/src/app/screens/organisms/legal-document/types.ts
@@ -0,0 +1,25 @@
+import type { ReactNode } from 'react';
+
+import type { LegalDocumentKey } from '../../../../features/legal';
+
+export type LegalDocumentBodyProps = { bodyMd: string };
+
+export type LegalDocumentViewProps = {
+ documentKey: LegalDocumentKey;
+ /**
+ * mobile adds the document's title as an h1 for screen readers, since its bar names the page in
+ * plain text. desktop's column title and a dialog's title are the heading already.
+ */
+ layout: 'mobile' | 'desktop' | 'dialog';
+ /** Under the text, such as the analyst's own record or the support chats. */
+ children?: ReactNode;
+};
+
+export type LegalDocumentDialogProps = {
+ documentKey: LegalDocumentKey;
+ title: string;
+ open: boolean;
+ /** A bottom sheet on mobile, the 640 modal on desktop. */
+ placement: 'sheet' | 'modal';
+ onClose: () => void;
+};
diff --git a/platforms/market/src/features/auth/actions/agreement-required/actions.ts b/platforms/market/src/features/auth/actions/agreement-required/actions.ts
new file mode 100644
index 0000000..5f54135
--- /dev/null
+++ b/platforms/market/src/features/auth/actions/agreement-required/actions.ts
@@ -0,0 +1,19 @@
+import { isHttpError } from '@lumina/libs/http';
+
+import { useAuthStore } from '../../../../stores/auth';
+
+const AGREEMENT_REQUIRED = 'agreement_required';
+
+/**
+ * A 403 `agreement_required` on any call means a newer major agreement came out during the session:
+ * the shell's blocking modal opens. The 422 of the same code belongs to the sign-up form.
+ */
+export function noteAgreementRequired(error: unknown): void {
+ if (
+ isHttpError(error) &&
+ error.status === 403 &&
+ error.code === AGREEMENT_REQUIRED
+ ) {
+ useAuthStore.getState().setAgreementRequired(true);
+ }
+}
diff --git a/platforms/market/src/features/auth/actions/agreement-required/index.ts b/platforms/market/src/features/auth/actions/agreement-required/index.ts
new file mode 100644
index 0000000..6ab5aff
--- /dev/null
+++ b/platforms/market/src/features/auth/actions/agreement-required/index.ts
@@ -0,0 +1 @@
+export { noteAgreementRequired } from './actions';
diff --git a/platforms/market/src/features/auth/actions/register-creator/actions.ts b/platforms/market/src/features/auth/actions/register-creator/actions.ts
index 313d26d..47a2df8 100644
--- a/platforms/market/src/features/auth/actions/register-creator/actions.ts
+++ b/platforms/market/src/features/auth/actions/register-creator/actions.ts
@@ -37,6 +37,8 @@ export async function registerCreator(
useAuthStore.getState().setSession({
account: registration.account,
needsProfile: registration.profileSetupRequired,
+ // Registration itself accepted the latest agreement.
+ agreementRequired: false,
});
if (emit) {
eventEmitter.emit(AUTH_EVENTS.register, {
diff --git a/platforms/market/src/features/auth/actions/restore-session/actions.ts b/platforms/market/src/features/auth/actions/restore-session/actions.ts
index 5698e08..3f0b7dd 100644
--- a/platforms/market/src/features/auth/actions/restore-session/actions.ts
+++ b/platforms/market/src/features/auth/actions/restore-session/actions.ts
@@ -29,7 +29,8 @@ export async function restoreSession({
const { setSession, clearSession } = useAuthStore.getState();
let status: ViewerStatus;
try {
- const { account, needsProfile } = await authRepository.getSession();
+ const { account, needsProfile, agreementRequired } =
+ await authRepository.getSession();
if (account?.status === 'suspended') {
// An API that still answers the session of a suspended account: close it, then halt (J01-3d).
void authRepository
@@ -40,7 +41,7 @@ export async function restoreSession({
endSuspendedSession({ role: account.role, reason: null });
status = 'guest';
} else if (account) {
- setSession({ account, needsProfile });
+ setSession({ account, needsProfile, agreementRequired });
status = 'member';
} else {
clearSession();
diff --git a/platforms/market/src/features/auth/index.ts b/platforms/market/src/features/auth/index.ts
index 9a7760a..adf61f6 100644
--- a/platforms/market/src/features/auth/index.ts
+++ b/platforms/market/src/features/auth/index.ts
@@ -5,6 +5,7 @@ export {
isSessionSuspended,
suspendedSessionOf,
} from './actions/end-suspended-session';
+export { noteAgreementRequired } from './actions/agreement-required';
export { login } from './actions/login';
export type { LoginOutcome } from './actions/login';
export { logout } from './actions/logout';
diff --git a/platforms/market/src/features/auth/models/register-details/types.ts b/platforms/market/src/features/auth/models/register-details/types.ts
index 0af4cbe..490fc20 100644
--- a/platforms/market/src/features/auth/models/register-details/types.ts
+++ b/platforms/market/src/features/auth/models/register-details/types.ts
@@ -94,6 +94,17 @@ export type CreatorIdentityPartModel = {
pickImage: (side: IdCardSide, file: File | null) => void;
/** 0–100 while the images upload. */
progress: number | undefined;
+ /** The analyst agreement, ticked before anything is sent. */
+ agreement: {
+ /** The version the tick accepts; null until it has been read. */
+ version: string | null;
+ isLoading: boolean;
+ isError: boolean;
+ isReloading: boolean;
+ reload: () => void;
+ isTicked: boolean;
+ setTicked: (ticked: boolean) => void;
+ };
draft: () => RegistrationDraft;
leave: RegisterLeaveModel;
};
diff --git a/platforms/market/src/features/auth/models/register-details/use-creator-identity-part.ts b/platforms/market/src/features/auth/models/register-details/use-creator-identity-part.ts
index fc91384..a330a55 100644
--- a/platforms/market/src/features/auth/models/register-details/use-creator-identity-part.ts
+++ b/platforms/market/src/features/auth/models/register-details/use-creator-identity-part.ts
@@ -1,5 +1,6 @@
import { valibotResolver } from '@hookform/resolvers/valibot';
import { showToast } from '@lumina/island/molecules/toast';
+import { isHttpError } from '@lumina/libs/http';
import { useRouter } from 'next/navigation';
import { useState } from 'react';
import { useForm } from 'react-hook-form';
@@ -16,6 +17,7 @@ import type {
CreatorIdentityFormValues,
} from '../../../../shared/validations';
import { useAuthFlowStore } from '../../../../stores/auth-flow';
+import { LEGAL_ERROR_CODES, useLegalDocument } from '../../../legal';
import { registerCreator } from '../../actions/register-creator';
import {
AUTH_ERROR_CODES,
@@ -52,13 +54,14 @@ type Submission =
* with progress; repeat taps are ignored while sending. Errors show on blur and on submit, the username's also as
* it is typed. The username stands in for the display name the API wants now; the profile step
* sets the real one. The text fields are saved as a draft on the server (never the images), and
- * leaving asks first (J02-3f).
+ * leaving asks first (J02-3f). The analyst agreement is ticked first and travels with the version
+ * read, which the API checks is still the latest.
*/
export function useCreatorIdentityPart({
profileHref,
onExpired,
}: UseDetailsPartOptions): CreatorIdentityPartModel {
- const { t } = useTranslation('auth');
+ const { t } = useTranslation(['auth', 'legal']);
const router = useRouter();
const [draft] = useState(() => useAuthFlowStore.getState().draft);
const [submission, setSubmission] = useState({ phase: 'idle' });
@@ -80,6 +83,9 @@ export function useCreatorIdentityPart({
idCardBack: draft?.idCardBack ?? null,
},
});
+ const agreementDocument = useLegalDocument('analyst_agreement');
+ const [agreementTicked, setAgreementTicked] = useState(false);
+ const agreementVersion = agreementDocument.document?.version;
const username = useUsernameAvailability(form);
const { errors, isSubmitting } = form.formState;
const saveDraft = useRegistrationAutosave(form);
@@ -104,6 +110,7 @@ export function useCreatorIdentityPart({
};
const submit = form.handleSubmit(async (values) => {
+ if (!agreementTicked || agreementVersion === undefined) return;
const { phone, registration } = useAuthFlowStore.getState();
if (!phone || !registration) {
onExpired();
@@ -131,6 +138,7 @@ export function useCreatorIdentityPart({
nationalIdNumber: values.nationalId,
nationalIdFrontImage: values.idCardFront,
nationalIdBackImage: values.idCardBack,
+ agreementVersion,
},
{
signal,
@@ -149,6 +157,16 @@ export function useCreatorIdentityPart({
onExpired();
return;
}
+ // A newer version came out while the form was open: it reads again and asks again.
+ if (
+ isHttpError(error) &&
+ error.code === LEGAL_ERROR_CODES.agreementRequired
+ ) {
+ setAgreementTicked(false);
+ void agreementDocument.reload();
+ showToast({ tone: 'error', message: t('legal:agreement.kyc.changed') });
+ return;
+ }
applyServerErrors(form, renameFieldErrors(error, FORM_FIELDS), {
t,
failedMessage: t('register.identity.failed'),
@@ -167,5 +185,14 @@ export function useCreatorIdentityPart({
submission.phase === 'uploading' ? submission.progress : undefined,
draft: () => form.getValues(),
leave,
+ agreement: {
+ version: agreementVersion ?? null,
+ isLoading: agreementDocument.isLoading,
+ isError: agreementDocument.isError,
+ isReloading: agreementDocument.isReloading,
+ reload: () => void agreementDocument.reload(),
+ isTicked: agreementTicked,
+ setTicked: setAgreementTicked,
+ },
};
}
diff --git a/platforms/market/src/features/auth/repositories/auth/mappers.ts b/platforms/market/src/features/auth/repositories/auth/mappers.ts
index 05a2a1d..1dbfd3e 100644
--- a/platforms/market/src/features/auth/repositories/auth/mappers.ts
+++ b/platforms/market/src/features/auth/repositories/auth/mappers.ts
@@ -58,6 +58,7 @@ export function toRegisterCreatorFormData(args: RegisterCreatorArgs): FormData {
...toRegisterInvestorDto(args),
displayName: args.displayName.trim(),
nationalIdNumber: args.nationalIdNumber.trim(),
+ agreementVersion: args.agreementVersion,
};
for (const [name, value] of Object.entries(fields)) form.append(name, value);
form.append('nationalIdFrontImage', args.nationalIdFrontImage);
@@ -144,6 +145,7 @@ export function toSessionPayload(dto: SessionResponseDto): SessionPayload {
return {
account: toAccountPayload(dto.user),
needsProfile: needsProfileOf(dto),
+ agreementRequired: dto.agreementRequired ?? false,
};
}
@@ -151,8 +153,12 @@ export function toSessionStatePayload(
dto: SessionStateResponseDto,
): SessionStatePayload {
return dto.user
- ? { account: toAccountPayload(dto.user), needsProfile: needsProfileOf(dto) }
- : { account: null, needsProfile: false };
+ ? {
+ account: toAccountPayload(dto.user),
+ needsProfile: needsProfileOf(dto),
+ agreementRequired: dto.agreementRequired ?? false,
+ }
+ : { account: null, needsProfile: false, agreementRequired: false };
}
export function toCreatorRegisteredPayload(
diff --git a/platforms/market/src/features/auth/repositories/auth/types.ts b/platforms/market/src/features/auth/repositories/auth/types.ts
index fb4595f..fb54963 100644
--- a/platforms/market/src/features/auth/repositories/auth/types.ts
+++ b/platforms/market/src/features/auth/repositories/auth/types.ts
@@ -108,6 +108,8 @@ export type RegisterCreatorArgs = RegisterInvestorArgs & {
nationalIdNumber: string;
nationalIdFrontImage: File;
nationalIdBackImage: File;
+ /** The agreement version the creator ticked; the API refuses anything but the latest. */
+ agreementVersion: string;
};
/** Sign-in and registration set the HttpOnly session cookies; the body carries the account. */
@@ -116,18 +118,32 @@ export type SessionResponseDto = {
userType: UserRole;
/** Missing from an older gateway. */
needsProfile?: boolean;
+ agreementRequired?: boolean;
+};
+/**
+ * `needsProfile`: a creator who has not finished registration step 5. `agreementRequired`: a
+ * creator who owes a newer major agreement. Both always false for an investor.
+ */
+export type SessionPayload = {
+ account: AccountPayload;
+ needsProfile: boolean;
+ agreementRequired: boolean;
};
-/** `needsProfile`: a creator who has not finished registration step 5; always false for an investor. */
-export type SessionPayload = { account: AccountPayload; needsProfile: boolean };
/** A guest gets `{ user: null }`, never a 401, so a guest never starts a refresh. */
export type SessionStateResponseDto =
- | { user: UserEntity; userType: UserRole; needsProfile?: boolean }
+ | {
+ user: UserEntity;
+ userType: UserRole;
+ needsProfile?: boolean;
+ agreementRequired?: boolean;
+ }
| { user: null };
-/** A guest is `{ account: null, needsProfile: false }`. */
+/** A guest is `{ account: null, needsProfile: false, agreementRequired: false }`. */
export type SessionStatePayload = {
account: AccountPayload | null;
needsProfile: boolean;
+ agreementRequired: boolean;
};
export type CreatorRegisteredResponseDto = {
diff --git a/platforms/market/src/features/checkout/models/checkout/use-checkout-page.ts b/platforms/market/src/features/checkout/models/checkout/use-checkout-page.ts
index ef682f6..f76c1dc 100644
--- a/platforms/market/src/features/checkout/models/checkout/use-checkout-page.ts
+++ b/platforms/market/src/features/checkout/models/checkout/use-checkout-page.ts
@@ -307,6 +307,11 @@ export function useCheckoutPage({
return;
}
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.
const options = {
t,
diff --git a/platforms/market/src/features/checkout/repositories/checkout/constants.ts b/platforms/market/src/features/checkout/repositories/checkout/constants.ts
index d5125ff..5741223 100644
--- a/platforms/market/src/features/checkout/repositories/checkout/constants.ts
+++ b/platforms/market/src/features/checkout/repositories/checkout/constants.ts
@@ -33,6 +33,8 @@ export const CHECKOUT_ERROR_CODES = {
paymentPending: 'CHECKOUT_PAYMENT_PENDING',
/** 403: the creator was suspended (or is no longer approved) since checkout opened. */
unavailable: 'CHECKOUT_UNAVAILABLE',
+ /** 409: the plan is off sale, below the price floor, on subscribe, renew and reactivate alike. */
+ tierUnavailable: 'tier_unavailable',
} as const;
/**
@@ -48,6 +50,7 @@ export const CHECKOUT_ERROR_COPY = {
alreadyActive: 'errors:checkout.already-active',
paymentPending: 'errors:checkout.payment-pending',
unavailable: 'errors:checkout.unavailable',
+ tierUnavailable: 'errors:checkout.tier-unavailable',
} as const;
/** 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]: {
message: CHECKOUT_ERROR_COPY.unavailable,
},
+ [CHECKOUT_ERROR_CODES.tierUnavailable]: {
+ message: CHECKOUT_ERROR_COPY.tierUnavailable,
+ },
};
diff --git a/platforms/market/src/features/checkout/repositories/checkout/errors.test.ts b/platforms/market/src/features/checkout/repositories/checkout/errors.test.ts
new file mode 100644
index 0000000..a8b15b7
--- /dev/null
+++ b/platforms/market/src/features/checkout/repositories/checkout/errors.test.ts
@@ -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);
+ });
+});
diff --git a/platforms/market/src/features/discovery/models/analyst-follow/types.ts b/platforms/market/src/features/discovery/models/analyst-follow/types.ts
index 222fd0c..b73623f 100644
--- a/platforms/market/src/features/discovery/models/analyst-follow/types.ts
+++ b/platforms/market/src/features/discovery/models/analyst-follow/types.ts
@@ -2,15 +2,10 @@ import type { CreatorSummaryPayload } from '../../repositories/discovery';
/**
* An analyst card's follow control. `hidden`: no control (a guest, a creator, or the viewer's
- * follows couldn't be read). `pending`: the viewer or their follows are on their way. `frozen`:
- * followed with an active subscription, so unfollow can't be used and says why.
+ * follows couldn't be read). `pending`: the viewer or their follows are on their way. `following`:
+ * a plain label, since unfollowing happens only on the channel or in دنبالشدهها.
*/
-export type AnalystFollowState =
- | 'hidden'
- | 'pending'
- | 'follow'
- | 'following'
- | 'frozen';
+export type AnalystFollowState = 'hidden' | 'pending' | 'follow' | 'following';
export type UseAnalystFollowPartOptions = {
/**
@@ -24,12 +19,4 @@ export type AnalystFollowPartModel = {
stateOf: (creatorId: string) => AnalystFollowState;
/** Follows at once (optimistic); a failure turns it back and says so. */
follow: (analyst: CreatorSummaryPayload) => void;
- /** Opens the unfollow question for this analyst. */
- askUnfollow: (analyst: CreatorSummaryPayload) => void;
- /** The analyst asked about; it stays after the question closes, so it closes on the same name. */
- unfollowTarget: CreatorSummaryPayload | null;
- isConfirmingUnfollow: boolean;
- /** Unfollows at once (optimistic) and closes the question. */
- confirmUnfollow: () => void;
- cancelUnfollow: () => void;
};
diff --git a/platforms/market/src/features/discovery/models/analyst-follow/use-analyst-follow-part.ts b/platforms/market/src/features/discovery/models/analyst-follow/use-analyst-follow-part.ts
index 2ffba2f..6e9ab29 100644
--- a/platforms/market/src/features/discovery/models/analyst-follow/use-analyst-follow-part.ts
+++ b/platforms/market/src/features/discovery/models/analyst-follow/use-analyst-follow-part.ts
@@ -1,5 +1,3 @@
-import { showToast } from '@lumina/island/molecules/toast';
-import { isHttpError } from '@lumina/libs/http';
import {
useInfiniteQuery,
useMutation,
@@ -16,7 +14,6 @@ import {
FOLLOWING_PAGE_LIMIT,
followKeys,
followRepository,
- unfollowCreator,
} from '../../../follow';
import type { CreatorSummaryPayload } from '../../repositories/discovery';
import type {
@@ -25,17 +22,15 @@ import type {
UseAnalystFollowPartOptions,
} from './types';
-type FollowChange = { analyst: CreatorSummaryPayload; following: boolean };
-
/**
- * Follow and unfollow on analyst cards (empty خانه, «تحلیلگران منتخب», search). Only an investor
- * gets the control. Whom they follow is their following list, read in the browser and merged per
- * card, never kept with the analysts, which are the same for every visitor. Both changes show at
- * once and turn back with the one error toast if the request fails (U8); unfollow asks first. A
- * 409 means a subscription freezes the unfollow: the list is read again, so the card freezes too.
- * Changes go one at a time, in the order tapped; each one refreshes the channel, the following
- * list and the follower counts, and marks خانه's feed stale for its next visit; a follow with
- * `onFollowed` (the empty خانه) also tells the caller, which reads the feed again in place (J04-2b).
+ * Follow on analyst cards (empty خانه, «تحلیلگران منتخب», search). Only an investor gets the
+ * control. Whom they follow is their following list, read in the browser and merged per card, never
+ * kept with the analysts, which are the same for every visitor. A follow shows at once and turns
+ * back with the one error toast if the request fails (U8). A followed analyst shows a plain label:
+ * unfollowing happens only on the channel or in دنبالشدهها. Follows go one at a time, in the order
+ * tapped; each one refreshes the channel, the following list and the follower counts, and marks
+ * خانه's feed stale for its next visit; with `onFollowed` (the empty خانه) it also tells the caller,
+ * which reads the feed again in place (J04-2b).
*/
export function useAnalystFollowPart({
onFollowed,
@@ -45,10 +40,7 @@ export function useAnalystFollowPart({
const status = useViewerStatus();
const account = useCurrentAccount();
const isInvestor = status === 'member' && account?.role === 'investor';
- const [changes, setChanges] = useState>({});
- const [unfollowTarget, setUnfollowTarget] =
- useState(null);
- const [isConfirmingUnfollow, setIsConfirmingUnfollow] = useState(false);
+ const [followedNow, setFollowedNow] = useState>({});
const following = useInfiniteQuery({
queryKey: followKeys.following(),
@@ -63,19 +55,18 @@ export function useAnalystFollowPart({
enabled: isInvestor,
throwOnError: false,
});
- // Whom they follow, and whether a subscription freezes the unfollow.
const followed = useMemo(
() =>
- new Map(
+ new Set(
following.data?.pages
.flatMap((page) => page.items)
- .map((row) => [row.creatorId, row.subscribed]),
+ .map((row) => row.creatorId),
),
[following.data],
);
const forget = (creatorId: string) =>
- setChanges((current) => {
+ setFollowedNow((current) => {
const next = { ...current };
delete next[creatorId];
return next;
@@ -85,37 +76,19 @@ export function useAnalystFollowPart({
const change = useMutation({
scope: { id: 'discovery-follow' },
- mutationFn: ({ analyst, following: next }: FollowChange) =>
- next
- ? followCreator({ creatorId: analyst.creatorId })
- : unfollowCreator({ creatorId: analyst.creatorId }),
- onMutate: ({ analyst, following: next }) =>
- setChanges((current) => ({ ...current, [analyst.creatorId]: next })),
- onSuccess: (_change, { analyst, following: next }) => {
+ mutationFn: (analyst: CreatorSummaryPayload) =>
+ followCreator({ creatorId: analyst.creatorId }),
+ onMutate: (analyst) =>
+ setFollowedNow((current) => ({ ...current, [analyst.creatorId]: true })),
+ onSuccess: (_change, analyst) => {
syncFollowCaches(queryClient, {
creatorId: analyst.creatorId,
- following: next,
+ following: true,
});
- if (next) {
- onFollowed?.(analyst);
- } else {
- showToast({
- tone: 'success',
- message: t('follow.unfollowed', { username: analyst.username }),
- });
- }
+ onFollowed?.(analyst);
},
- onError: (error, { analyst }) => {
+ onError: (error, analyst) => {
forget(analyst.creatorId);
- if (isHttpError(error) && error.status === 409) {
- reloadFollowing();
- showToast({
- tone: 'error',
- message: t('follow.failed'),
- description: t('actions.unfollow-frozen'),
- });
- return;
- }
showActionError(error, {
t,
failedMessage: t('follow.failed'),
@@ -129,26 +102,13 @@ export function useAnalystFollowPart({
if (!isInvestor) return 'hidden';
if (following.isPending) return 'pending';
if (following.isError) return 'hidden';
- const subscribed = followed.get(creatorId);
- if (!(changes[creatorId] ?? subscribed !== undefined)) return 'follow';
- return subscribed ? 'frozen' : 'following';
+ return followedNow[creatorId] || followed.has(creatorId)
+ ? 'following'
+ : 'follow';
};
return {
stateOf,
- follow: (analyst) => change.mutate({ analyst, following: true }),
- askUnfollow: (analyst) => {
- setUnfollowTarget(analyst);
- setIsConfirmingUnfollow(true);
- },
- unfollowTarget,
- isConfirmingUnfollow,
- confirmUnfollow: () => {
- setIsConfirmingUnfollow(false);
- if (unfollowTarget) {
- change.mutate({ analyst: unfollowTarget, following: false });
- }
- },
- cancelUnfollow: () => setIsConfirmingUnfollow(false),
+ follow: (analyst) => change.mutate(analyst),
};
}
diff --git a/platforms/market/src/features/legal/actions/accept-agreement/actions.ts b/platforms/market/src/features/legal/actions/accept-agreement/actions.ts
new file mode 100644
index 0000000..c473f90
--- /dev/null
+++ b/platforms/market/src/features/legal/actions/accept-agreement/actions.ts
@@ -0,0 +1,28 @@
+import { eventEmitter } from '@lumina/libs/event-emitter';
+
+import { useAuthStore } from '../../../../stores/auth';
+import { LEGAL_EVENTS } from '../../constants';
+import { legalRepository } from '../../repositories/legal';
+import type {
+ AcceptDocumentArgs,
+ AcceptedDocumentPayload,
+} from '../../repositories/legal';
+
+/**
+ * Accepts a version of a document and, when nothing newer is owed, lifts the agreement's block on
+ * the session. Emits `legal.agreement-accepted`.
+ */
+export async function acceptAgreement(
+ args: AcceptDocumentArgs,
+ { emit = true }: { emit?: boolean } = {},
+): Promise {
+ const accepted = await legalRepository.accept(args);
+ useAuthStore.getState().setAgreementRequired(accepted.agreementRequired);
+ if (emit) {
+ eventEmitter.emit(LEGAL_EVENTS.agreementAccepted, {
+ document: accepted.document,
+ version: accepted.version,
+ });
+ }
+ return accepted;
+}
diff --git a/platforms/market/src/features/legal/actions/accept-agreement/index.ts b/platforms/market/src/features/legal/actions/accept-agreement/index.ts
new file mode 100644
index 0000000..ecf5f56
--- /dev/null
+++ b/platforms/market/src/features/legal/actions/accept-agreement/index.ts
@@ -0,0 +1 @@
+export { acceptAgreement } from './actions';
diff --git a/platforms/market/src/features/legal/constants.ts b/platforms/market/src/features/legal/constants.ts
new file mode 100644
index 0000000..97bb1b9
--- /dev/null
+++ b/platforms/market/src/features/legal/constants.ts
@@ -0,0 +1,9 @@
+export const LEGAL_EVENTS = {
+ agreementAccepted: 'legal.agreement-accepted',
+} as const;
+
+/** The API's refusal when the agreement version sent isn't the one that counts. */
+export const LEGAL_ERROR_CODES = {
+ agreementRequired: 'agreement_required',
+ versionOutdated: 'agreement_version_outdated',
+} as const;
diff --git a/platforms/market/src/features/legal/entities/legal-document/index.ts b/platforms/market/src/features/legal/entities/legal-document/index.ts
new file mode 100644
index 0000000..6077617
--- /dev/null
+++ b/platforms/market/src/features/legal/entities/legal-document/index.ts
@@ -0,0 +1,5 @@
+export type {
+ LegalAcceptanceEntity,
+ LegalDocumentEntity,
+ LegalDocumentKey,
+} from './types';
diff --git a/platforms/market/src/features/legal/entities/legal-document/types.ts b/platforms/market/src/features/legal/entities/legal-document/types.ts
new file mode 100644
index 0000000..f7bc314
--- /dev/null
+++ b/platforms/market/src/features/legal/entities/legal-document/types.ts
@@ -0,0 +1,22 @@
+/** The back end's three versioned documents. */
+export type LegalDocumentKey =
+ | 'platform_rules'
+ | 'analyst_agreement'
+ | 'subscription_terms';
+
+export type LegalDocumentEntity = {
+ key: LegalDocumentKey;
+ version: string;
+ title: string;
+ bodyMd: string;
+ isMajor: boolean;
+ changeSummary: string | null;
+ publishedAt: string;
+ effectiveAt: string;
+};
+
+export type LegalAcceptanceEntity = {
+ document: LegalDocumentKey;
+ version: string;
+ acceptedAt: string;
+};
diff --git a/platforms/market/src/features/legal/http.ts b/platforms/market/src/features/legal/http.ts
new file mode 100644
index 0000000..3b8eb8d
--- /dev/null
+++ b/platforms/market/src/features/legal/http.ts
@@ -0,0 +1,3 @@
+import { http } from '@lumina/libs/http';
+
+export const legalHttp = http.extend({});
diff --git a/platforms/market/src/features/legal/index.ts b/platforms/market/src/features/legal/index.ts
new file mode 100644
index 0000000..9f22926
--- /dev/null
+++ b/platforms/market/src/features/legal/index.ts
@@ -0,0 +1,26 @@
+import './types';
+
+export { acceptAgreement } from './actions/accept-agreement';
+export { LEGAL_ERROR_CODES, LEGAL_EVENTS } from './constants';
+export type {
+ LegalAcceptanceEntity,
+ LegalDocumentEntity,
+ LegalDocumentKey,
+} from './entities/legal-document';
+export { useAgreementAcceptance } from './models/agreement-acceptance';
+export { useAgreementGate } from './models/agreement-gate';
+export type {
+ AgreementGateModel,
+ AgreementGateView,
+} from './models/agreement-gate';
+export { useLegalDocument } from './models/legal-document';
+export type { LegalDocumentModel } from './models/legal-document';
+export { legalKeys, legalRepository } from './repositories/legal';
+export type {
+ AcceptDocumentArgs,
+ AcceptedDocumentPayload,
+ LegalAcceptancePayload,
+ LegalDocumentPayload,
+} from './repositories/legal';
+export { parseLegalMarkdown } from './utils/parse-legal-markdown';
+export type { LegalBlock, LegalInline } from './utils/parse-legal-markdown';
diff --git a/platforms/market/src/features/legal/models/agreement-acceptance/index.ts b/platforms/market/src/features/legal/models/agreement-acceptance/index.ts
new file mode 100644
index 0000000..2373fb8
--- /dev/null
+++ b/platforms/market/src/features/legal/models/agreement-acceptance/index.ts
@@ -0,0 +1 @@
+export { useAgreementAcceptance } from './use-agreement-acceptance';
diff --git a/platforms/market/src/features/legal/models/agreement-acceptance/use-agreement-acceptance.ts b/platforms/market/src/features/legal/models/agreement-acceptance/use-agreement-acceptance.ts
new file mode 100644
index 0000000..44aa99c
--- /dev/null
+++ b/platforms/market/src/features/legal/models/agreement-acceptance/use-agreement-acceptance.ts
@@ -0,0 +1,20 @@
+import { useQuery } from '@tanstack/react-query';
+
+import { useViewerStatus } from '../../../../stores/auth';
+import { legalKeys, legalRepository } from '../../repositories/legal';
+import type { LegalAcceptancePayload } from '../../repositories/legal';
+
+/** The newest analyst agreement this analyst accepted; null while unknown or when there is none. */
+export function useAgreementAcceptance(): LegalAcceptancePayload | null {
+ const status = useViewerStatus();
+ const { data } = useQuery({
+ queryKey: legalKeys.acceptances(),
+ queryFn: ({ signal }) => legalRepository.listAcceptances({ signal }),
+ enabled: status === 'member',
+ throwOnError: false,
+ });
+ return (
+ data?.find((acceptance) => acceptance.document === 'analyst_agreement') ??
+ null
+ );
+}
diff --git a/platforms/market/src/features/legal/models/agreement-gate/index.ts b/platforms/market/src/features/legal/models/agreement-gate/index.ts
new file mode 100644
index 0000000..796c61c
--- /dev/null
+++ b/platforms/market/src/features/legal/models/agreement-gate/index.ts
@@ -0,0 +1,2 @@
+export type { AgreementGateModel, AgreementGateView } from './types';
+export { useAgreementGate } from './use-agreement-gate';
diff --git a/platforms/market/src/features/legal/models/agreement-gate/types.ts b/platforms/market/src/features/legal/models/agreement-gate/types.ts
new file mode 100644
index 0000000..37579d4
--- /dev/null
+++ b/platforms/market/src/features/legal/models/agreement-gate/types.ts
@@ -0,0 +1,17 @@
+import type { LegalDocumentModel } from '../legal-document';
+
+/** summary: what changed and the checkbox. full: the whole text, with the way back. */
+export type AgreementGateView = 'summary' | 'full';
+
+export type AgreementGateModel = {
+ isOpen: boolean;
+ agreement: LegalDocumentModel;
+ view: AgreementGateView;
+ showFullText: () => void;
+ showSummary: () => void;
+ isTicked: boolean;
+ setTicked: (ticked: boolean) => void;
+ canAccept: boolean;
+ isAccepting: boolean;
+ accept: () => void;
+};
diff --git a/platforms/market/src/features/legal/models/agreement-gate/use-agreement-gate.ts b/platforms/market/src/features/legal/models/agreement-gate/use-agreement-gate.ts
new file mode 100644
index 0000000..8ea7104
--- /dev/null
+++ b/platforms/market/src/features/legal/models/agreement-gate/use-agreement-gate.ts
@@ -0,0 +1,67 @@
+import { showToast } from '@lumina/island/molecules/toast';
+import { isHttpError } from '@lumina/libs/http';
+import { useMutation, useQueryClient } from '@tanstack/react-query';
+import { useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { showActionError } from '../../../../shared/utils';
+import { useAgreementRequired } from '../../../../stores/auth';
+import { acceptAgreement } from '../../actions/accept-agreement';
+import { LEGAL_ERROR_CODES } from '../../constants';
+import { legalKeys } from '../../repositories/legal';
+import { useLegalDocument } from '../legal-document';
+import type { AgreementGateModel, AgreementGateView } from './types';
+
+/**
+ * The blocking re-acceptance (J01-4): open while a newer major agreement is owed, learned from the
+ * session or from a 403 on any call. «پذیرش و ادامه» needs the box ticked. If a newer version came
+ * out while it was open, the text reads again and the box empties, so nobody accepts unread text.
+ */
+export function useAgreementGate(): AgreementGateModel {
+ const { t } = useTranslation('legal');
+ const queryClient = useQueryClient();
+ const isOpen = useAgreementRequired();
+ const agreement = useLegalDocument('analyst_agreement', { enabled: isOpen });
+ const [view, setView] = useState('summary');
+ const [isTicked, setTicked] = useState(false);
+
+ const accept = useMutation({
+ mutationFn: (version: string) =>
+ acceptAgreement({ document: 'analyst_agreement', version }),
+ onSuccess: () => {
+ void queryClient.invalidateQueries({
+ queryKey: legalKeys.acceptances(),
+ });
+ setTicked(false);
+ setView('summary');
+ showToast({ tone: 'success', message: t('agreement.gate.accepted') });
+ },
+ onError: (error) => {
+ if (
+ isHttpError(error) &&
+ error.code === LEGAL_ERROR_CODES.versionOutdated
+ ) {
+ setTicked(false);
+ void agreement.reload();
+ }
+ showActionError(error, { t, failedMessage: t('agreement.gate.failed') });
+ },
+ });
+
+ const version = agreement.document?.version;
+
+ return {
+ isOpen,
+ agreement,
+ view,
+ showFullText: () => setView('full'),
+ showSummary: () => setView('summary'),
+ isTicked,
+ setTicked,
+ canAccept: isTicked && version !== undefined,
+ isAccepting: accept.isPending,
+ accept: () => {
+ if (isTicked && version !== undefined) accept.mutate(version);
+ },
+ };
+}
diff --git a/platforms/market/src/features/legal/models/legal-document/index.ts b/platforms/market/src/features/legal/models/legal-document/index.ts
new file mode 100644
index 0000000..e459dfa
--- /dev/null
+++ b/platforms/market/src/features/legal/models/legal-document/index.ts
@@ -0,0 +1,2 @@
+export type { LegalDocumentModel } from './types';
+export { useLegalDocument } from './use-legal-document';
diff --git a/platforms/market/src/features/legal/models/legal-document/types.ts b/platforms/market/src/features/legal/models/legal-document/types.ts
new file mode 100644
index 0000000..d60cfa2
--- /dev/null
+++ b/platforms/market/src/features/legal/models/legal-document/types.ts
@@ -0,0 +1,10 @@
+import type { LegalDocumentPayload } from '../../repositories/legal';
+
+export type LegalDocumentModel = {
+ document: LegalDocumentPayload | null;
+ isLoading: boolean;
+ isError: boolean;
+ isReloading: boolean;
+ /** Reads the document again; resolves with the newest version it got. */
+ reload: () => Promise<{ data?: LegalDocumentPayload }>;
+};
diff --git a/platforms/market/src/features/legal/models/legal-document/use-legal-document.ts b/platforms/market/src/features/legal/models/legal-document/use-legal-document.ts
new file mode 100644
index 0000000..ca3a92e
--- /dev/null
+++ b/platforms/market/src/features/legal/models/legal-document/use-legal-document.ts
@@ -0,0 +1,28 @@
+import { useQuery } from '@tanstack/react-query';
+
+import type { LegalDocumentKey } from '../../entities/legal-document';
+import { legalKeys, legalRepository } from '../../repositories/legal';
+import type { LegalDocumentModel } from './types';
+
+/**
+ * A legal document's latest version, read in the browser (0070). Its failure stays with the part
+ * that shows it, which offers `reload`, so a form around it keeps working.
+ */
+export function useLegalDocument(
+ key: LegalDocumentKey,
+ { enabled = true }: { enabled?: boolean } = {},
+): LegalDocumentModel {
+ const query = useQuery({
+ queryKey: legalKeys.document(key),
+ queryFn: ({ signal }) => legalRepository.getDocument({ key }, { signal }),
+ enabled,
+ throwOnError: false,
+ });
+ return {
+ document: query.data ?? null,
+ isLoading: query.isPending && enabled,
+ isError: query.isError,
+ isReloading: query.isRefetching,
+ reload: () => query.refetch(),
+ };
+}
diff --git a/platforms/market/src/features/legal/repositories/legal/constants.ts b/platforms/market/src/features/legal/repositories/legal/constants.ts
new file mode 100644
index 0000000..1860213
--- /dev/null
+++ b/platforms/market/src/features/legal/repositories/legal/constants.ts
@@ -0,0 +1,14 @@
+import type { LegalDocumentKey } from '../../entities/legal-document';
+
+export const LEGAL_ENDPOINTS = {
+ document: (key: LegalDocumentKey) => `/legal/${key}`,
+ acceptances: '/me/legal-acceptances',
+ accept: '/me/agreements',
+} as const;
+
+export const legalKeys = {
+ all: ['legal'] as const,
+ document: (key: LegalDocumentKey) =>
+ [...legalKeys.all, 'document', key] as const,
+ acceptances: () => [...legalKeys.all, 'acceptances'] as const,
+};
diff --git a/platforms/market/src/features/legal/repositories/legal/index.ts b/platforms/market/src/features/legal/repositories/legal/index.ts
new file mode 100644
index 0000000..373940e
--- /dev/null
+++ b/platforms/market/src/features/legal/repositories/legal/index.ts
@@ -0,0 +1,9 @@
+export { LEGAL_ENDPOINTS, legalKeys } from './constants';
+export { legalRepository } from './legal';
+export type {
+ AcceptDocumentArgs,
+ AcceptedDocumentPayload,
+ GetDocumentArgs,
+ LegalAcceptancePayload,
+ LegalDocumentPayload,
+} from './types';
diff --git a/platforms/market/src/features/legal/repositories/legal/legal.ts b/platforms/market/src/features/legal/repositories/legal/legal.ts
new file mode 100644
index 0000000..9b393f2
--- /dev/null
+++ b/platforms/market/src/features/legal/repositories/legal/legal.ts
@@ -0,0 +1,52 @@
+import { legalHttp } from '../../http';
+import { LEGAL_ENDPOINTS } from './constants';
+import {
+ toAcceptDocumentDto,
+ toAcceptedDocumentPayload,
+ toLegalAcceptancesPayload,
+ toLegalDocumentPayload,
+} from './mappers';
+import type {
+ AcceptDocumentArgs,
+ AcceptDocumentResponseDto,
+ AcceptedDocumentPayload,
+ GetDocumentArgs,
+ LegalAcceptancePayload,
+ LegalAcceptancesResponseDto,
+ LegalDocumentPayload,
+ LegalDocumentResponseDto,
+} from './types';
+
+/** The versioned legal documents (public) and the signed-in user's acceptances. */
+export const legalRepository = {
+ /** The latest version; the text changes without a deploy. */
+ async getDocument(
+ { key }: GetDocumentArgs,
+ { signal }: { signal?: AbortSignal } = {},
+ ): Promise {
+ const response = await legalHttp.get(
+ LEGAL_ENDPOINTS.document(key),
+ { signal },
+ );
+ return toLegalDocumentPayload(response);
+ },
+
+ async listAcceptances({ signal }: { signal?: AbortSignal } = {}): Promise<
+ LegalAcceptancePayload[]
+ > {
+ const response = await legalHttp.get(
+ LEGAL_ENDPOINTS.acceptances,
+ { signal },
+ );
+ return toLegalAcceptancesPayload(response);
+ },
+
+ /** 422 `agreement_version_outdated` unless the version is still the latest. */
+ async accept(args: AcceptDocumentArgs): Promise {
+ const response = await legalHttp.post(
+ LEGAL_ENDPOINTS.accept,
+ toAcceptDocumentDto(args),
+ );
+ return toAcceptedDocumentPayload(response);
+ },
+};
diff --git a/platforms/market/src/features/legal/repositories/legal/mappers.ts b/platforms/market/src/features/legal/repositories/legal/mappers.ts
new file mode 100644
index 0000000..2ebb973
--- /dev/null
+++ b/platforms/market/src/features/legal/repositories/legal/mappers.ts
@@ -0,0 +1,52 @@
+import type {
+ AcceptDocumentArgs,
+ AcceptDocumentDto,
+ AcceptDocumentResponseDto,
+ AcceptedDocumentPayload,
+ LegalAcceptancePayload,
+ LegalAcceptancesResponseDto,
+ LegalDocumentPayload,
+ LegalDocumentResponseDto,
+} from './types';
+
+export function toLegalDocumentPayload(
+ dto: LegalDocumentResponseDto,
+): LegalDocumentPayload {
+ return {
+ key: dto.key,
+ version: dto.version,
+ title: dto.title,
+ bodyMd: dto.bodyMd,
+ isMajor: dto.isMajor,
+ changeSummary: dto.changeSummary,
+ publishedAt: dto.publishedAt,
+ effectiveAt: dto.effectiveAt,
+ };
+}
+
+export function toLegalAcceptancesPayload(
+ dto: LegalAcceptancesResponseDto,
+): LegalAcceptancePayload[] {
+ return dto.items.map(({ document, version, acceptedAt }) => ({
+ document,
+ version,
+ acceptedAt,
+ }));
+}
+
+export function toAcceptDocumentDto(
+ args: AcceptDocumentArgs,
+): AcceptDocumentDto {
+ return { document: args.document, version: args.version };
+}
+
+export function toAcceptedDocumentPayload(
+ dto: AcceptDocumentResponseDto,
+): AcceptedDocumentPayload {
+ return {
+ document: dto.document,
+ version: dto.version,
+ acceptedAt: dto.acceptedAt,
+ agreementRequired: dto.agreementRequired,
+ };
+}
diff --git a/platforms/market/src/features/legal/repositories/legal/types.ts b/platforms/market/src/features/legal/repositories/legal/types.ts
new file mode 100644
index 0000000..3716223
--- /dev/null
+++ b/platforms/market/src/features/legal/repositories/legal/types.ts
@@ -0,0 +1,25 @@
+import type {
+ LegalAcceptanceEntity,
+ LegalDocumentEntity,
+ LegalDocumentKey,
+} from '../../entities/legal-document';
+
+export type GetDocumentArgs = { key: LegalDocumentKey };
+export type LegalDocumentResponseDto = LegalDocumentEntity;
+export type LegalDocumentPayload = LegalDocumentEntity;
+
+export type LegalAcceptancesResponseDto = { items: LegalAcceptanceEntity[] };
+export type LegalAcceptancePayload = LegalAcceptanceEntity;
+
+export type AcceptDocumentArgs = {
+ document: LegalDocumentKey;
+ version: string;
+};
+export type AcceptDocumentDto = AcceptDocumentArgs;
+export type AcceptDocumentResponseDto = LegalAcceptanceEntity & {
+ agreementRequired: boolean;
+};
+export type AcceptedDocumentPayload = LegalAcceptancePayload & {
+ /** True when an even newer major agreement is still owed. */
+ agreementRequired: boolean;
+};
diff --git a/platforms/market/src/features/legal/types.ts b/platforms/market/src/features/legal/types.ts
new file mode 100644
index 0000000..5fb320a
--- /dev/null
+++ b/platforms/market/src/features/legal/types.ts
@@ -0,0 +1,7 @@
+import type { LegalDocumentKey } from './entities/legal-document';
+
+declare module '@lumina/libs/event-emitter' {
+ interface EventMap {
+ 'legal.agreement-accepted': { document: LegalDocumentKey; version: string };
+ }
+}
diff --git a/platforms/market/src/features/legal/utils/parse-legal-markdown.test.ts b/platforms/market/src/features/legal/utils/parse-legal-markdown.test.ts
new file mode 100644
index 0000000..861ac41
--- /dev/null
+++ b/platforms/market/src/features/legal/utils/parse-legal-markdown.test.ts
@@ -0,0 +1,74 @@
+import { describe, expect, it } from 'vitest';
+
+import { parseLegalMarkdown } from './parse-legal-markdown';
+
+const plain = (text: string) => [{ text, bold: false }];
+
+describe('parseLegalMarkdown', () => {
+ it('reads ## and ### as a section and a subsection', () => {
+ expect(parseLegalMarkdown('## قوانین پلتفرم\n\n### حساب')).toEqual([
+ { kind: 'section', inlines: plain('قوانین پلتفرم') },
+ { kind: 'subsection', inlines: plain('حساب') },
+ ]);
+ });
+
+ it('joins the lines of a paragraph and splits on a blank line', () => {
+ expect(parseLegalMarkdown('یک\nدو\n\nسه')).toEqual([
+ { kind: 'paragraph', inlines: plain('یک دو') },
+ { kind: 'paragraph', inlines: plain('سه') },
+ ]);
+ });
+
+ it('reads an ordered list, whatever its numbers', () => {
+ expect(parseLegalMarkdown('1. یک\n2. دو')).toEqual([
+ { kind: 'list', items: [plain('یک'), plain('دو')] },
+ ]);
+ });
+
+ it('keeps a number in a paragraph as text unless every line is an item', () => {
+ expect(parseLegalMarkdown('1. یک\nادامه')).toEqual([
+ { kind: 'paragraph', inlines: plain('1. یک ادامه') },
+ ]);
+ });
+
+ it('reads a quote across lines', () => {
+ expect(parseLegalMarkdown('> پیشنویس\n> است')).toEqual([
+ { kind: 'quote', inlines: plain('پیشنویس است') },
+ ]);
+ });
+
+ it('marks **bold** inside any block', () => {
+ expect(parseLegalMarkdown('پیش **میان** پس')).toEqual([
+ {
+ kind: 'paragraph',
+ inlines: [
+ { text: 'پیش ', bold: false },
+ { text: 'میان', bold: true },
+ { text: ' پس', bold: false },
+ ],
+ },
+ ]);
+ expect(parseLegalMarkdown('1. **بازگشت** وجه')).toEqual([
+ {
+ kind: 'list',
+ items: [
+ [
+ { text: 'بازگشت', bold: true },
+ { text: ' وجه', bold: false },
+ ],
+ ],
+ },
+ ]);
+ });
+
+ it('leaves markup it does not know as plain text', () => {
+ expect(parseLegalMarkdown('')).toEqual([
+ { kind: 'paragraph', inlines: plain('') },
+ ]);
+ });
+
+ it('answers nothing for empty text and handles Windows line ends', () => {
+ expect(parseLegalMarkdown(' \n\n ')).toEqual([]);
+ expect(parseLegalMarkdown('## الف\r\n\r\nب')).toHaveLength(2);
+ });
+});
diff --git a/platforms/market/src/features/legal/utils/parse-legal-markdown.ts b/platforms/market/src/features/legal/utils/parse-legal-markdown.ts
new file mode 100644
index 0000000..3a8105d
--- /dev/null
+++ b/platforms/market/src/features/legal/utils/parse-legal-markdown.ts
@@ -0,0 +1,60 @@
+/** A stretch of text, bold or not. */
+export type LegalInline = { text: string; bold: boolean };
+
+export type LegalBlock =
+ | { kind: 'section'; inlines: LegalInline[] }
+ | { kind: 'subsection'; inlines: LegalInline[] }
+ | { kind: 'paragraph'; inlines: LegalInline[] }
+ | { kind: 'quote'; inlines: LegalInline[] }
+ | { kind: 'list'; items: LegalInline[][] };
+
+const ORDERED_ITEM = /^\d+\.\s+(.*)$/;
+
+function parseInlines(text: string): LegalInline[] {
+ return text
+ .split('**')
+ .map((part, index) => ({ text: part, bold: index % 2 === 1 }))
+ .filter((inline) => inline.text.length > 0);
+}
+
+/**
+ * The little markdown legal text uses: `##`, `###`, paragraphs, ordered lists, `>` quotes and
+ * `**bold**`. Anything else stays plain text, so the text renders as data and never as markup.
+ * Blocks are separated by a blank line; lines of one paragraph join with a space.
+ */
+export function parseLegalMarkdown(source: string): LegalBlock[] {
+ const blocks: LegalBlock[] = [];
+ for (const chunk of source.replace(/\r\n/g, '\n').split(/\n\s*\n/)) {
+ const lines = chunk
+ .split('\n')
+ .map((line) => line.trim())
+ .filter(Boolean);
+ const [first] = lines;
+ if (first === undefined) continue;
+
+ if (first.startsWith('### ')) {
+ blocks.push({
+ kind: 'subsection',
+ inlines: parseInlines(first.slice(4)),
+ });
+ } else if (first.startsWith('## ')) {
+ blocks.push({ kind: 'section', inlines: parseInlines(first.slice(3)) });
+ } else if (first.startsWith('>')) {
+ const text = lines.map((line) => line.replace(/^>\s?/, '')).join(' ');
+ blocks.push({ kind: 'quote', inlines: parseInlines(text) });
+ } else if (lines.every((line) => ORDERED_ITEM.test(line))) {
+ blocks.push({
+ kind: 'list',
+ items: lines.map((line) =>
+ parseInlines(line.replace(ORDERED_ITEM, '$1')),
+ ),
+ });
+ } else {
+ blocks.push({
+ kind: 'paragraph',
+ inlines: parseInlines(lines.join(' ')),
+ });
+ }
+ }
+ return blocks;
+}
diff --git a/platforms/market/src/features/notification/constants.ts b/platforms/market/src/features/notification/constants.ts
index 161b536..5e27e68 100644
--- a/platforms/market/src/features/notification/constants.ts
+++ b/platforms/market/src/features/notification/constants.ts
@@ -6,7 +6,7 @@ export const UNREAD_BADGE_CAP = 99;
/** A creator's filter chips over their one list (J07-5h, 0058), after «همه». */
export type NotificationCategory = 'predictions' | 'finance' | 'account';
-/** The chips in reading order: «همه · پیشبینیها · مالی · حساب». */
+/** The chips in reading order: «همه · سیگنالها · مالی · حساب». */
export const NOTIFICATION_CATEGORIES = [
'predictions',
'finance',
@@ -36,4 +36,5 @@ export const NOTIFICATION_CATEGORY: Partial<
account_reinstated: 'account',
capacity_request_result: 'account',
invite_code_deactivated: 'account',
+ tier_off_sale: 'account',
};
diff --git a/platforms/market/src/features/notification/entities/notification/types.ts b/platforms/market/src/features/notification/entities/notification/types.ts
index 90efa78..14a793a 100644
--- a/platforms/market/src/features/notification/entities/notification/types.ts
+++ b/platforms/market/src/features/notification/entities/notification/types.ts
@@ -16,6 +16,9 @@
* went, `invite_code_deactivated` that their invite code was turned off, and `prediction_corrected`
* 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).
+ * `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
* extra days (with the new expiry), `subscription_refunded` that money was paid back and the
* subscription ended.
@@ -29,6 +32,8 @@ export type NotificationType =
| 'subscription_expired'
| 'subscription_expired_suspended'
| 'subscription_extended'
+ | 'rules_updated'
+ | 'tier_off_sale'
| 'subscription_refunded'
| 'payment_pending_review'
| 'waitlist_capacity'
diff --git a/platforms/market/src/features/notification/models/notification-centre/types.ts b/platforms/market/src/features/notification/models/notification-centre/types.ts
index d2992e3..b6f684f 100644
--- a/platforms/market/src/features/notification/models/notification-centre/types.ts
+++ b/platforms/market/src/features/notification/models/notification-centre/types.ts
@@ -15,7 +15,7 @@ export type NotificationCentreModel = {
items: NotificationPayload[];
/** The items under the chosen chip; all of them for an investor, who has no chips. */
visibleItems: NotificationPayload[];
- /** A creator filters the one list with chips «همه · پیشبینیها · مالی · حساب» (0058). */
+ /** A creator filters the one list with chips «همه · سیگنالها · مالی · حساب» (0058). */
showsCategories: boolean;
category: NotificationFilter;
/** Filters in place: no URL change, so back still returns to where the bell was tapped. */
diff --git a/platforms/market/src/features/notification/models/notification-centre/use-notification-centre.ts b/platforms/market/src/features/notification/models/notification-centre/use-notification-centre.ts
index 0acc8de..2a41047 100644
--- a/platforms/market/src/features/notification/models/notification-centre/use-notification-centre.ts
+++ b/platforms/market/src/features/notification/models/notification-centre/use-notification-centre.ts
@@ -38,6 +38,7 @@ const IN_APP_PATHS: ReadonlySet = new Set([
ROUTES.dashboard.finance,
ROUTES.account.profile,
ROUTES.notifications,
+ ROUTES.rules.general,
]);
const CHANNEL_PATH = ROUTES.channel('');
const CHECKOUT_PATH = ROUTES.checkout('');
diff --git a/platforms/market/src/features/post/entities/post/types.ts b/platforms/market/src/features/post/entities/post/types.ts
index 5a39a02..85f917e 100644
--- a/platforms/market/src/features/post/entities/post/types.ts
+++ b/platforms/market/src/features/post/entities/post/types.ts
@@ -59,8 +59,11 @@ export type PredictionEntity = {
/** `gold`, `crypto`, `equities`, `forex` or `USDT`; older posts may carry another key. */
market: string;
direction: PredictionDirection;
- /** The market quote at publish, stamped by the API. */
+ /** The analyst's exact entry, or the middle of a range. */
entryPrice: number;
+ /** A range entry: both, low below high. */
+ entryLow?: number;
+ entryHigh?: number;
/** One to three, each further from the entry; the last one is final. */
targetPrices: number[];
stopLoss?: number;
diff --git a/platforms/market/src/features/post/repositories/post/mappers.ts b/platforms/market/src/features/post/repositories/post/mappers.ts
index 0c9c674..c4e7e6b 100644
--- a/platforms/market/src/features/post/repositories/post/mappers.ts
+++ b/platforms/market/src/features/post/repositories/post/mappers.ts
@@ -27,6 +27,8 @@ export function toPredictionPayload(
market: entity.market,
direction: entity.direction,
entryPrice: entity.entryPrice,
+ entryLow: entity.entryLow ?? null,
+ entryHigh: entity.entryHigh ?? null,
targetPrices: entity.targetPrices,
stopLoss: entity.stopLoss ?? null,
horizon: entity.horizon,
@@ -110,6 +112,9 @@ function toPredictionDto(args: PredictionArgs): PredictionDto {
symbol: args.symbol.trim().toUpperCase(),
market: args.market.trim(),
direction: args.direction,
+ entryPrice: args.entryPrice ?? undefined,
+ entryLow: args.entryLow ?? undefined,
+ entryHigh: args.entryHigh ?? undefined,
targetPrices: args.targetPrices,
stopLoss: args.stopLoss ?? undefined,
horizon: args.horizon.trim(),
diff --git a/platforms/market/src/features/post/repositories/post/types.ts b/platforms/market/src/features/post/repositories/post/types.ts
index 733e028..6c83dce 100644
--- a/platforms/market/src/features/post/repositories/post/types.ts
+++ b/platforms/market/src/features/post/repositories/post/types.ts
@@ -17,7 +17,11 @@ export type PredictionPayload = {
symbol: string;
market: string;
direction: PredictionDirection;
+ /** The exact entry, or the middle of a range. */
entryPrice: number;
+ /** A range entry: both, low below high; otherwise null. */
+ entryLow: number | null;
+ entryHigh: number | null;
/** Nearest first; the last one is the final target. */
targetPrices: number[];
stopLoss: number | null;
@@ -150,6 +154,10 @@ export type PredictionArgs = {
symbol: string;
market: string;
direction: PredictionDirection;
+ /** Exactly one form to publish: this, or `entryLow` with `entryHigh`. */
+ entryPrice?: number;
+ entryLow?: number;
+ entryHigh?: number;
/** One to three, each further from the entry than the one before. */
targetPrices: number[];
stopLoss?: number | null;
@@ -195,6 +203,9 @@ export type PredictionDto = {
symbol: string;
market: string;
direction: PredictionDirection;
+ entryPrice?: number;
+ entryLow?: number;
+ entryHigh?: number;
targetPrices: number[];
stopLoss?: number;
horizon: string;
diff --git a/platforms/market/src/features/prediction/actions/publish-prediction/actions.ts b/platforms/market/src/features/prediction/actions/publish-prediction/actions.ts
index 7ec58b5..9aa8b9b 100644
--- a/platforms/market/src/features/prediction/actions/publish-prediction/actions.ts
+++ b/platforms/market/src/features/prediction/actions/publish-prediction/actions.ts
@@ -22,8 +22,8 @@ export type PublishPredictionArgs = {
};
/**
- * Publishes a prediction as a post: the API stamps the entry at the market price now, and from
- * then on it can't be edited or deleted. Send the same `idempotencyKey` with an unchanged form, so
+ * Publishes a prediction as a post, with the entry and stop the analyst stated. From then on it
+ * can't be edited or deleted. Send the same `idempotencyKey` with an unchanged form, so
* a retry after a lost answer returns the first post instead of a second. It waits 10 seconds for
* the answer (J09-3). Emits `post.publish` and `prediction.publish`.
*/
diff --git a/platforms/market/src/features/prediction/entities/prediction-stats/types.ts b/platforms/market/src/features/prediction/entities/prediction-stats/types.ts
index f6d1e9e..cc8ac45 100644
--- a/platforms/market/src/features/prediction/entities/prediction-stats/types.ts
+++ b/platforms/market/src/features/prediction/entities/prediction-stats/types.ts
@@ -1,27 +1,29 @@
import type { PredictionOutcome } from '../../../post';
/**
- * content-service `getCreatorPredictionStats`: a creator's track record over their published
- * predictions. Below the threshold (10 closed and 30 days since the first prediction) the public
- * read answers `public: false` with every number 0 and no trend; the owner's track record always
- * carries the real numbers.
+ * `GET /creators/:id/prediction-stats`: a creator's track record from the last nightly evaluation.
+ * Below the threshold (10 closed and 30 days since the first signal), or before the first run, it
+ * answers `public: false` with every number 0 and no trend.
*/
export type PredictionStatsEntity = {
creatorId: string;
- /** The record may be shown; absent from the owner's track record. */
+ /** The record may be shown. */
public?: boolean;
- /** Published predictions, open and closed. */
+ /** Published signals, open and closed; voided ones are left out. */
totalPredictions: number;
activePredictions: number;
- /** Closed: wins + losses + breakeven. */
+ /** Closed: wins + losses + breakeven, as those three are named here. */
pastPredictions: number;
+ /** «رسیده به هدف». */
wins: number;
+ /** «خورده به حد ضرر». */
losses: number;
+ /** «پایان مهلت». The API's name stays, though most of these are not a breakeven. */
breakeven: number;
/** A percentage with two decimals (`62.86`); 0 before the first close. */
winRate: number;
- /** The mean ROI of closed predictions, a percentage with two decimals. */
+ /** The mean ROI of closed signals, the stake split across targets; two decimals. */
avgRoiPercent: number;
- /** The last 10 closed outcomes, oldest first. */
+ /** The last 10 closed outcomes by their return (not the buckets above), oldest first. */
accuracyTrend: PredictionOutcome[];
};
diff --git a/platforms/market/src/features/prediction/entities/signal-stats/index.ts b/platforms/market/src/features/prediction/entities/signal-stats/index.ts
new file mode 100644
index 0000000..69b9a84
--- /dev/null
+++ b/platforms/market/src/features/prediction/entities/signal-stats/index.ts
@@ -0,0 +1 @@
+export type { SignalStatsEntity } from './types';
diff --git a/platforms/market/src/features/prediction/entities/signal-stats/types.ts b/platforms/market/src/features/prediction/entities/signal-stats/types.ts
new file mode 100644
index 0000000..9093ad4
--- /dev/null
+++ b/platforms/market/src/features/prediction/entities/signal-stats/types.ts
@@ -0,0 +1,37 @@
+/**
+ * `GET /me/signal-stats`: the signed-in analyst's numbers from the last nightly evaluation, the
+ * same snapshot the channel and the cards read. `status: 'pending'` until the first run, with no
+ * `stats`. Voided signals count nowhere but `outcomes.voided`.
+ */
+export type SignalStatsEntity = {
+ status: 'pending' | 'ready';
+ stats?: {
+ /** target ÷ (target + stop + expired), a percentage with two decimals. */
+ winRate: number;
+ /** A percentage with the stake split equally across each signal's targets. */
+ avgRoi: number;
+ /** Closed and active. */
+ total: number;
+ active: number;
+ outcomes: {
+ target: number;
+ stop: number;
+ expired: number;
+ active: number;
+ voided: number;
+ };
+ /** Reward per unit of risk to the first target; null with no signal to read it from. */
+ rrWorstAvg: number | null;
+ rrBestAvg: number | null;
+ closedCount: number;
+ daysActive: number;
+ isPublic: boolean;
+ evaluatedAt: string | null;
+ };
+ progress: {
+ closed: number;
+ requiredClosed: number;
+ daysActive: number;
+ requiredDays: number;
+ };
+};
diff --git a/platforms/market/src/features/prediction/entities/track-record/index.ts b/platforms/market/src/features/prediction/entities/track-record/index.ts
deleted file mode 100644
index 027662e..0000000
--- a/platforms/market/src/features/prediction/entities/track-record/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export type { TrackRecordEntity } from './types';
diff --git a/platforms/market/src/features/prediction/entities/track-record/types.ts b/platforms/market/src/features/prediction/entities/track-record/types.ts
deleted file mode 100644
index afede87..0000000
--- a/platforms/market/src/features/prediction/entities/track-record/types.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import type { PredictionStatsEntity } from '../prediction-stats';
-
-/**
- * `GET /creators/me/track-record`: the signed-in creator's own record and how far it is from
- * going public (`closed >= required` and `daysActive >= requiredDays`, counted from the first
- * published prediction). `stats` is always filled for the owner.
- */
-export type TrackRecordEntity = {
- public: boolean;
- closed: number;
- required: number;
- daysActive: number;
- requiredDays: number;
- stats: PredictionStatsEntity;
-};
diff --git a/platforms/market/src/features/prediction/index.ts b/platforms/market/src/features/prediction/index.ts
index a36636a..2eb1302 100644
--- a/platforms/market/src/features/prediction/index.ts
+++ b/platforms/market/src/features/prediction/index.ts
@@ -51,8 +51,7 @@ export {
export type { PredictionListPageModel } from './models/prediction-list';
export { useSymbolPickerPart } from './models/symbol-picker';
export type { SymbolPickerPartModel } from './models/symbol-picker';
-export { useTrackRecordPart } from './models/track-record';
-export type { TrackRecordPartModel } from './models/track-record';
+export { useSignalStatsPart } from './models/signal-stats';
export {
MARKET_DATA_ENDPOINTS,
marketDataKeys,
@@ -77,5 +76,7 @@ export type {
OwnPredictionPayload,
OwnPredictionsPagePayload,
PredictionStatsPayload,
- TrackRecordPayload,
+ SignalNumbersPayload,
+ SignalProgressPayload,
+ SignalStatsPayload,
} from './repositories/prediction';
diff --git a/platforms/market/src/features/prediction/models/own-predictions/types.ts b/platforms/market/src/features/prediction/models/own-predictions/types.ts
index 1f30df6..9511195 100644
--- a/platforms/market/src/features/prediction/models/own-predictions/types.ts
+++ b/platforms/market/src/features/prediction/models/own-predictions/types.ts
@@ -4,7 +4,7 @@ import type { OwnPredictionPayload } from '../../repositories/prediction';
export type OwnPredictionSection = 'open' | 'closed';
/**
- * داشبورد › پیشبینیها as a whole (J10-3c): waiting for the first list, nothing published yet
+ * داشبورد › سیگنالها as a whole (J10-3c): waiting for the first list, nothing published yet
* (the API's `counts.all` is 0), or its sections.
*/
export type PredictionsTabPartModel = { status: 'loading' | 'empty' | 'ready' };
diff --git a/platforms/market/src/features/prediction/models/own-predictions/use-own-prediction-count.ts b/platforms/market/src/features/prediction/models/own-predictions/use-own-prediction-count.ts
index 606cbd0..3683991 100644
--- a/platforms/market/src/features/prediction/models/own-predictions/use-own-prediction-count.ts
+++ b/platforms/market/src/features/prediction/models/own-predictions/use-own-prediction-count.ts
@@ -4,7 +4,7 @@ import { ownSectionQueryOptions } from './queries';
import type { OwnPredictionSection } from './types';
/**
- * A section's total for its title, «پیشبینیهای باز (۳)», from the API's counts; `undefined`
+ * A section's total for its title, «سیگنالهای باز (۳)», from the API's counts; `undefined`
* while loading or failed, so the title stands without it over the section's error (J10-3e).
*/
export function useOwnPredictionCount(
diff --git a/platforms/market/src/features/prediction/models/own-predictions/use-own-predictions-section.ts b/platforms/market/src/features/prediction/models/own-predictions/use-own-predictions-section.ts
index 4225d7b..d925640 100644
--- a/platforms/market/src/features/prediction/models/own-predictions/use-own-predictions-section.ts
+++ b/platforms/market/src/features/prediction/models/own-predictions/use-own-predictions-section.ts
@@ -4,7 +4,7 @@ import { ownSectionQueryOptions } from './queries';
import type { OwnPredictionSection, OwnPredictionsSectionModel } from './types';
/**
- * A داشبورد › پیشبینیها section's cards (J10-3): every open prediction, newest first, or the two
+ * A داشبورد › سیگنالها section's cards (J10-3): every open prediction, newest first, or the two
* closed most recently. Loads and fails on its own.
*/
export function useOwnPredictionsSection(
diff --git a/platforms/market/src/features/prediction/models/prediction-cache/prediction-cache.ts b/platforms/market/src/features/prediction/models/prediction-cache/prediction-cache.ts
index 0a2f87f..41ca60b 100644
--- a/platforms/market/src/features/prediction/models/prediction-cache/prediction-cache.ts
+++ b/platforms/market/src/features/prediction/models/prediction-cache/prediction-cache.ts
@@ -9,8 +9,8 @@ type OwnList = InfiniteData;
/**
* A prediction closed (early, or found closed by the system): every cached copy shows it closed
- * in place, «همه پیشبینیها» included, where it stays until the list is read again. The tab's
- * lists, the track record and the public record are read again.
+ * in place, «همه سیگنالها» included, where it stays until the list is read again. The tab's
+ * lists, the analyst's numbers and the public record are read again.
*/
export function applyClosedPrediction(
queryClient: QueryClient,
@@ -42,17 +42,17 @@ export function applyClosedPrediction(
queryKey: [...predictionKeys.own(), 'preview'],
});
void queryClient.invalidateQueries({
- queryKey: predictionKeys.trackRecord(),
+ queryKey: predictionKeys.signalStats(),
});
void queryClient.invalidateQueries({
queryKey: predictionKeys.stats(post.creatorId),
});
}
-/** A new prediction: the creator's lists and track record are read again. */
+/** A new signal: the creator's lists and numbers are read again. */
export function refreshOwnPredictions(queryClient: QueryClient): void {
void queryClient.invalidateQueries({ queryKey: predictionKeys.own() });
void queryClient.invalidateQueries({
- queryKey: predictionKeys.trackRecord(),
+ queryKey: predictionKeys.signalStats(),
});
}
diff --git a/platforms/market/src/features/prediction/models/prediction-composer/publish-reason.test.ts b/platforms/market/src/features/prediction/models/prediction-composer/publish-reason.test.ts
new file mode 100644
index 0000000..facf667
--- /dev/null
+++ b/platforms/market/src/features/prediction/models/prediction-composer/publish-reason.test.ts
@@ -0,0 +1,53 @@
+import { describe, expect, it } from 'vitest';
+
+import { publishReason } from './publish-reason';
+
+const clear = {
+ invalid: [],
+ missing: [],
+ quoteUnavailable: false,
+ chart: null,
+};
+
+describe('publishReason', () => {
+ it('has nothing to say about a complete form', () => {
+ expect(publishReason(clear)).toBeUndefined();
+ });
+
+ it('lists what is empty', () => {
+ expect(publishReason({ ...clear, missing: ['حد ضرر'] })).toEqual({
+ kind: 'missing',
+ fields: ['حد ضرر'],
+ });
+ });
+
+ it('puts «اصلاح» before «کامل»', () => {
+ expect(
+ publishReason({ ...clear, invalid: ['هدف ۱'], missing: ['حد ضرر'] }),
+ ).toEqual({ kind: 'invalid', fields: ['هدف ۱'] });
+ });
+
+ it('puts the fields before the price and the upload', () => {
+ expect(
+ publishReason({
+ ...clear,
+ missing: ['ورود'],
+ quoteUnavailable: true,
+ chart: 'uploading',
+ })?.kind,
+ ).toBe('missing');
+ });
+
+ it('then the price, then the upload', () => {
+ expect(
+ publishReason({ ...clear, quoteUnavailable: true, chart: 'failed' })
+ ?.kind,
+ ).toBe('quote-unavailable');
+ expect(publishReason({ ...clear, chart: 'uploading' })?.kind).toBe(
+ 'chart-uploading',
+ );
+ expect(publishReason({ ...clear, chart: 'failed' })?.kind).toBe(
+ 'chart-failed',
+ );
+ });
+});
diff --git a/platforms/market/src/features/prediction/models/prediction-composer/publish-reason.ts b/platforms/market/src/features/prediction/models/prediction-composer/publish-reason.ts
new file mode 100644
index 0000000..5f47208
--- /dev/null
+++ b/platforms/market/src/features/prediction/models/prediction-composer/publish-reason.ts
@@ -0,0 +1,27 @@
+/** What stands between the form and «انتشار سیگنال», worst first. */
+export type PublishReasonInput = {
+ /** Field names that need fixing. */
+ invalid: string[];
+ /** Field names still empty. */
+ missing: string[];
+ quoteUnavailable: boolean;
+ chart: 'uploading' | 'failed' | null;
+};
+
+export type PublishReason =
+ | { kind: 'invalid' | 'missing'; fields: string[] }
+ | { kind: 'quote-unavailable' | 'chart-uploading' | 'chart-failed' };
+
+/** Why the CTA waits, or `undefined`: «اصلاح» beats «کامل», and both beat the price or an upload. */
+export function publishReason({
+ invalid,
+ missing,
+ quoteUnavailable,
+ chart,
+}: PublishReasonInput): PublishReason | undefined {
+ if (invalid.length > 0) return { kind: 'invalid', fields: invalid };
+ if (missing.length > 0) return { kind: 'missing', fields: missing };
+ if (quoteUnavailable) return { kind: 'quote-unavailable' };
+ if (chart === 'uploading') return { kind: 'chart-uploading' };
+ return chart === 'failed' ? { kind: 'chart-failed' } : undefined;
+}
diff --git a/platforms/market/src/features/prediction/models/prediction-composer/types.ts b/platforms/market/src/features/prediction/models/prediction-composer/types.ts
index ff1993b..18f71d5 100644
--- a/platforms/market/src/features/prediction/models/prediction-composer/types.ts
+++ b/platforms/market/src/features/prediction/models/prediction-composer/types.ts
@@ -1,6 +1,9 @@
import type { UseFormReturn } from 'react-hook-form';
-import type { PredictionComposerFormValues } from '../../../../shared/validations';
+import type {
+ EntryMode,
+ PredictionComposerFormValues,
+} from '../../../../shared/validations';
import type { PostAccessLevel, PostPayload } from '../../../post';
import type { PREDICTION_HORIZONS } from '../../constants';
import type { PredictionMarket } from '../../entities/market-data';
@@ -36,8 +39,8 @@ export type ChartImageModel = {
};
/**
- * The entry price field (J09-1, J09-2c): nothing until a symbol is picked, a skeleton line while
- * its price loads, the live price with who priced it, or unavailable with «تلاش مجدد».
+ * The live price under the entry (J09-1, J09-2c): nothing until a symbol is picked, a skeleton line
+ * while its price loads, the price with who priced it, or unavailable with «تلاش مجدد».
*/
export type ComposerQuote =
| { status: 'none' }
@@ -57,8 +60,12 @@ export type ComposerSummary = {
symbol: string;
market: PredictionMarket;
direction: PredictionDirection;
- /** The live price now; the API stamps its own at publish («≈»). */
+ entryMode: EntryMode;
+ /** The exact entry, or the middle of a range: what the card measures from. */
entryPrice: number;
+ /** A range entry's ends; `null` for an exact one. */
+ entryLow: number | null;
+ entryHigh: number | null;
targetPrices: number[];
stopLoss: number | null;
horizon: PredictionHorizon;
@@ -68,7 +75,7 @@ export type ComposerSummary = {
};
/**
- * idle → confirming (the «انتشار پیشبینی» sheet) → publishing → published (it stays publishing
+ * idle → confirming (the «انتشار سیگنال» sheet) → publishing → published (it stays publishing
* until `onDone`'s navigation takes the composer away), or back to idle with the failure shown.
*/
export type ComposerPhase = 'idle' | 'confirming' | 'publishing';
@@ -90,6 +97,11 @@ export type PredictionComposerPageModel = {
setMarket: (market: PredictionMarket) => void;
direction: PredictionDirection | '';
setDirection: (direction: PredictionDirection) => void;
+ /** «قیمت دقیق» or «بازه». */
+ entryMode: EntryMode;
+ setEntryMode: (mode: EntryMode) => void;
+ /** The analyst typed in the exact entry: it stops following the live quote. */
+ markEntryEdited: () => void;
horizon: PredictionHorizon | '';
setHorizon: (horizon: PredictionHorizon) => void;
accessLevel: PostAccessLevel;
@@ -116,7 +128,7 @@ export type PredictionComposerPageModel = {
/** The CTA waits frozen, saying why: what to fix, what is missing, the price, an upload. */
publishBlock: { frozen: boolean; reason?: string };
phase: ComposerPhase;
- /** «انتشار پیشبینی»: checks the form, then asks to confirm. */
+ /** «انتشار سیگنال»: checks the form, then asks to confirm. */
requestPublish: () => void;
/** The confirm step's summary while it is open. */
confirmSummary: ComposerSummary | null;
diff --git a/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.test.tsx b/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.test.tsx
new file mode 100644
index 0000000..971bf9a
--- /dev/null
+++ b/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.test.tsx
@@ -0,0 +1,264 @@
+import { HttpError } from '@lumina/libs/http';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+import { act, renderHook, waitFor } from '@testing-library/react';
+import type { ReactNode } from 'react';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { publishPrediction } from '../../actions/publish-prediction';
+import { usePredictionComposerPage } from './use-prediction-composer-page';
+
+const quotes = vi.hoisted(() => ({ price: 100 }));
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({
+ t: (key: string, values?: { fields?: string }) =>
+ values?.fields ? `${key} ${values.fields}` : key,
+ }),
+}));
+vi.mock('next/navigation', () => ({
+ useRouter: () => ({ push: vi.fn() }),
+}));
+vi.mock('../../../../app/navigation/hooks/use-leave-guard', () => ({
+ useLeaveGuard: vi.fn(),
+}));
+vi.mock('../../../profile', () => ({
+ profileKeys: { mine: () => ['profile'] },
+ profileRepository: { getMine: async () => ({ markets: [] }) },
+}));
+vi.mock('../../../post', () => ({ resetCachedChannel: vi.fn() }));
+vi.mock('../prediction-cache', () => ({ refreshOwnPredictions: vi.fn() }));
+vi.mock('../symbol-picker', () => ({
+ symbolsQueryOptions: (market: string) => ({
+ queryKey: ['symbols', market],
+ queryFn: async () => [
+ { symbol: 'BTCUSDT', source: 'Binance', market: 'crypto', quote: null },
+ ],
+ }),
+}));
+vi.mock('../../repositories/market-data', () => ({
+ QUOTE_REFRESH_MS: 15_000,
+ marketDataKeys: { quote: (symbol: string) => ['quote', symbol] },
+ marketDataRepository: {
+ getQuote: async (symbol: string) => ({
+ symbol,
+ price: quotes.price,
+ at: '2026-01-01T10:00:00Z',
+ source: 'mock',
+ }),
+ },
+}));
+vi.mock('../../actions/publish-prediction', () => ({
+ publishPrediction: vi.fn(),
+}));
+vi.mock('./use-chart-image', () => ({
+ useChartImage: () => ({
+ image: null,
+ error: null,
+ add: vi.fn(),
+ remove: vi.fn(),
+ retry: vi.fn(),
+ abort: vi.fn(),
+ }),
+}));
+
+const onDone = vi.fn();
+
+function setup() {
+ const queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false } },
+ });
+ const wrapper = ({ children }: { children: ReactNode }) => (
+ {children}
+ );
+ const hook = renderHook(
+ () =>
+ usePredictionComposerPage({
+ creatorId: 'c1',
+ onDone,
+ onLeave: vi.fn(),
+ }),
+ { wrapper },
+ );
+ return { ...hook, queryClient };
+}
+
+type Hook = ReturnType['result'];
+
+async function pickSymbol(result: Hook) {
+ act(() => result.current.setMarket('crypto'));
+ act(() =>
+ result.current.selectSymbol({
+ symbol: 'BTCUSDT',
+ } as Parameters[0]),
+ );
+ await waitFor(() => expect(result.current.quote.status).toBe('ready'));
+ await waitFor(() =>
+ expect(result.current.form.getValues('entryPrice')).not.toBe(''),
+ );
+}
+
+function fill(result: Hook) {
+ act(() => {
+ result.current.setDirection('long');
+ result.current.setHorizon('1w');
+ result.current.form.setValue('targets.0.value', '120');
+ result.current.form.setValue('stopLoss', '90');
+ });
+}
+
+beforeEach(() => {
+ quotes.price = 100;
+ vi.mocked(publishPrediction).mockReset();
+});
+
+describe('usePredictionComposerPage entry', () => {
+ it('prefills the exact entry from the live quote', async () => {
+ const { result } = setup();
+ await pickSymbol(result);
+ expect(result.current.form.getValues('entryPrice')).toBe('100');
+ });
+
+ it('follows the quote until the analyst edits it', async () => {
+ const { result, queryClient } = setup();
+ await pickSymbol(result);
+
+ quotes.price = 105;
+ await act(() =>
+ queryClient.refetchQueries({ queryKey: ['quote', 'BTCUSDT'] }),
+ );
+ await waitFor(() =>
+ expect(result.current.form.getValues('entryPrice')).toBe('105'),
+ );
+
+ act(() => {
+ result.current.markEntryEdited();
+ result.current.form.setValue('entryPrice', '101');
+ });
+ quotes.price = 110;
+ await act(() =>
+ queryClient.refetchQueries({ queryKey: ['quote', 'BTCUSDT'] }),
+ );
+ await waitFor(() => {
+ const { quote } = result.current;
+ expect(quote.status === 'ready' && quote.price).toBe(110);
+ });
+ expect(result.current.form.getValues('entryPrice')).toBe('101');
+ });
+});
+
+describe('usePredictionComposerPage publish block', () => {
+ it('lists the stop and the entry as missing', async () => {
+ const { result } = setup();
+ act(() => result.current.setEntryMode('range'));
+ expect(result.current.publishBlock.reason).toContain('composer.missing');
+ expect(result.current.publishBlock.reason).toContain(
+ 'composer.fields.entry',
+ );
+ expect(result.current.publishBlock.reason).toContain(
+ 'composer.fields.stop',
+ );
+ });
+
+ it('asks to fix a level on a direction change, ahead of what is missing', async () => {
+ const { result } = setup();
+ await pickSymbol(result);
+ fill(result);
+ act(() => result.current.form.setValue('horizon', ''));
+ await waitFor(() =>
+ expect(result.current.publishBlock.reason).toContain('composer.missing'),
+ );
+ act(() => result.current.setDirection('short'));
+ await waitFor(() =>
+ expect(result.current.publishBlock.reason).toContain('composer.invalid'),
+ );
+ });
+
+ it('is clear on a complete form', async () => {
+ const { result } = setup();
+ await pickSymbol(result);
+ fill(result);
+ await waitFor(() => expect(result.current.publishBlock.frozen).toBe(false));
+ expect(result.current.preview.status).toBe('ready');
+ });
+});
+
+describe('usePredictionComposerPage publishing', () => {
+ async function confirm(result: Hook) {
+ await waitFor(() => expect(result.current.publishBlock.frozen).toBe(false));
+ await act(async () => result.current.requestPublish());
+ await waitFor(() => expect(result.current.phase).toBe('confirming'));
+ }
+
+ it('sends the exact entry it showed, even when the quote moved since', async () => {
+ vi.mocked(publishPrediction).mockResolvedValue({ id: 'p1' } as never);
+ const { result, queryClient } = setup();
+ await pickSymbol(result);
+ fill(result);
+ await confirm(result);
+
+ quotes.price = 105;
+ await act(() =>
+ queryClient.refetchQueries({ queryKey: ['quote', 'BTCUSDT'] }),
+ );
+ expect(result.current.confirmSummary?.entryPrice).toBe(100);
+
+ await act(async () => result.current.publish());
+ const [args] = vi.mocked(publishPrediction).mock.calls[0];
+ expect(args.prediction).toMatchObject({
+ entryPrice: 100,
+ stopLoss: 90,
+ targetPrices: [120],
+ });
+ expect(args.prediction.entryLow).toBeUndefined();
+ });
+
+ it('sends a range as its two ends, with the middle in the summary', async () => {
+ vi.mocked(publishPrediction).mockResolvedValue({ id: 'p1' } as never);
+ const { result } = setup();
+ await pickSymbol(result);
+ fill(result);
+ act(() => {
+ result.current.setEntryMode('range');
+ result.current.form.setValue('entryLow', '98');
+ result.current.form.setValue('entryHigh', '102');
+ });
+ await confirm(result);
+ expect(result.current.confirmSummary).toMatchObject({
+ entryPrice: 100,
+ entryLow: 98,
+ entryHigh: 102,
+ });
+
+ await act(async () => result.current.publish());
+ const [args] = vi.mocked(publishPrediction).mock.calls[0];
+ expect(args.prediction).toMatchObject({ entryLow: 98, entryHigh: 102 });
+ expect(args.prediction.entryPrice).toBeUndefined();
+ });
+
+ it.each([
+ ['entry', 'entry_required', 'entryPrice', 'validation.entry-required'],
+ ['stopLoss', 'stop_required', 'stopLoss', 'validation.stop-required'],
+ ] as const)(
+ 'puts a refused %s back on its field',
+ async (field, code, name, message) => {
+ vi.mocked(publishPrediction).mockRejectedValue(
+ new HttpError({
+ message: 'refused',
+ code: 'PREDICTION_INVALID',
+ status: 422,
+ details: { errors: [{ field, code }] },
+ method: 'POST',
+ url: '/posts',
+ }),
+ );
+ const { result } = setup();
+ await pickSymbol(result);
+ fill(result);
+ await confirm(result);
+ await act(async () => result.current.publish());
+ expect(result.current.form.getFieldState(name).error?.message).toContain(
+ message,
+ );
+ },
+ );
+});
diff --git a/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.ts b/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.ts
index 9d2c6c9..5a7f4c9 100644
--- a/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.ts
+++ b/platforms/market/src/features/prediction/models/prediction-composer/use-prediction-composer-page.ts
@@ -1,7 +1,7 @@
import { valibotResolver } from '@hookform/resolvers/valibot';
import { showToast } from '@lumina/island/molecules/toast';
import { isHttpError } from '@lumina/libs/http';
-import { list, number } from '@lumina/tools/format';
+import { list, number, price } from '@lumina/tools/format';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { useRouter } from 'next/navigation';
import {
@@ -17,13 +17,24 @@ import { useTranslation } from 'react-i18next';
import { useLeaveGuard } from '../../../../app/navigation/hooks/use-leave-guard';
import {
+ ENTRY_RANGE_ORDER_MESSAGE,
+ ENTRY_REQUIRED_MESSAGE,
+ entryFieldsOf,
+ entryIssue,
+ entryLevels,
levelPrice,
PREDICTION_FORM_LIMITS,
predictionComposerSchema,
+ STOP_REQUIRED_MESSAGE,
stopIssue,
+ stopSideMessage,
targetIssues,
+ targetSideMessage,
+} from '../../../../shared/validations';
+import type {
+ EntryMode,
+ PredictionComposerFormValues,
} from '../../../../shared/validations';
-import type { PredictionComposerFormValues } from '../../../../shared/validations';
import { resetCachedChannel } from '../../../post';
import { profileKeys, profileRepository } from '../../../profile';
import { publishPrediction } from '../../actions/publish-prediction';
@@ -40,11 +51,11 @@ import {
PREDICTION_ERROR_CODES,
predictionErrorCode,
predictionFieldIssues,
- quoteOfError,
} from '../../repositories/prediction';
import type { PredictionFieldIssue } from '../../repositories/prediction';
import { refreshOwnPredictions } from '../prediction-cache';
import { symbolsQueryOptions } from '../symbol-picker';
+import { publishReason } from './publish-reason';
import type {
ComposerPhase,
ComposerQuote,
@@ -64,6 +75,10 @@ const DEFAULT_VALUES: PredictionComposerFormValues = {
market: '',
symbol: '',
direction: '',
+ entryMode: 'exact',
+ entryPrice: '',
+ entryLow: '',
+ entryHigh: '',
targets: [{ value: '' }],
stopLoss: '',
horizon: '',
@@ -83,8 +98,8 @@ function toFieldError(
{ field, code }: PredictionFieldIssue,
direction: string,
targetCount: number,
+ mode: EntryMode,
): { name: FormPath | 'root.chart'; message: string } {
- const side = direction === 'short' ? 'short' : 'long';
const target = /^targetPrices\.(\d+)$/.exec(field);
if (target) {
return {
@@ -92,15 +107,21 @@ function toFieldError(
message:
code === 'targets_order'
? 'predictions:validation.targets-order'
- : `predictions:validation.target-side.${side}`,
+ : targetSideMessage(direction, mode),
};
}
switch (code) {
- case 'stop_wrong_side':
+ case 'entry_required':
return {
- name: 'stopLoss',
- message: `predictions:validation.stop-side.${side}`,
+ name: entryFieldsOf(mode)[0],
+ message: ENTRY_REQUIRED_MESSAGE,
};
+ case 'entry_range_order':
+ return { name: 'entryLow', message: ENTRY_RANGE_ORDER_MESSAGE };
+ case 'stop_required':
+ return { name: 'stopLoss', message: STOP_REQUIRED_MESSAGE };
+ case 'stop_wrong_side':
+ return { name: 'stopLoss', message: stopSideMessage(direction, mode) };
case 'targets_too_many':
return {
name: `targets.${Math.max(0, targetCount - 1)}.value`,
@@ -119,13 +140,13 @@ function toFieldError(
}
/**
- * «پیشبینی جدید» (J09-1…J09-3): access, market, symbol with its live price, direction, up to
- * three targets, an optional stop, the horizon, a note and one chart image, then a confirm step.
- * The entry is the market price at publish, which the API stamps; the form shows the live one,
- * read every 15 seconds, and checks the levels against it on blur, on a direction change and on
- * every new price. The CTA stays frozen and says why until the form can publish. A publish sends
- * one idempotency key per unchanged form, so a retry never publishes twice. Nothing is kept as a
- * draft: leaving with something typed asks first.
+ * «سیگنال جدید» (J09-1…J09-3): access, market, symbol with its live price, direction, the entry, up
+ * to three targets, the required stop, the horizon, a note and one chart image, then a confirm
+ * step. The entry is one exact price, prefilled from the live quote (read every 15 seconds) and
+ * following it until the analyst edits it, or a range. The levels are checked against it on blur, on
+ * a direction change and on every new price. The CTA stays frozen and says why until the form can
+ * publish. A publish sends one idempotency key per unchanged form, so a retry never publishes twice.
+ * Nothing is kept as a draft: leaving with something typed asks first.
*/
export function usePredictionComposerPage({
creatorId,
@@ -140,7 +161,7 @@ export function usePredictionComposerPage({
const [isConfirmingLeave, setIsConfirmingLeave] = useState(false);
// A link elsewhere in the app the creator followed with something typed: asked first.
const [leaveTo, setLeaveTo] = useState(null);
- // What the confirm step opened with, should the price drop out while it is open.
+ // What the confirm step shows and sends: a live quote moving the entry mustn't change it.
const [confirmed, setConfirmed] = useState(null);
// When the API last said there was no price at publish: a newer price clears it.
const [noPriceSince, setNoPriceSince] = useState(null);
@@ -152,16 +173,11 @@ export function usePredictionComposerPage({
}, []);
// The key goes with the body it was made for; any change makes a new one.
const attempt = useRef<{ key: string; body: string } | null>(null);
- // The levels are checked against the price the form shows.
- const entryRef = useRef(null);
+ // The analyst typed in the exact entry: the live quote no longer fills it.
+ const entryEdited = useRef(false);
const form = useForm({
- resolver: (values, context, options) =>
- valibotResolver(predictionComposerSchema(entryRef.current))(
- values,
- context,
- options,
- ),
+ resolver: valibotResolver(predictionComposerSchema()),
mode: 'onTouched',
defaultValues: DEFAULT_VALUES,
});
@@ -171,6 +187,10 @@ export function usePredictionComposerPage({
marketValue,
symbol,
directionValue,
+ entryMode,
+ entryPriceText,
+ entryLow,
+ entryHigh,
targets,
stopLoss,
horizonValue,
@@ -182,6 +202,10 @@ export function usePredictionComposerPage({
'market',
'symbol',
'direction',
+ 'entryMode',
+ 'entryPrice',
+ 'entryLow',
+ 'entryHigh',
'targets',
'stopLoss',
'horizon',
@@ -244,20 +268,42 @@ export function usePredictionComposerPage({
// The market's real source; the quote's own says `mock` in development.
source: symbolRow?.source ?? quoteData.source,
};
- const entryPrice = quote.status === 'ready' ? quote.price : null;
+ const livePrice = quote.status === 'ready' ? quote.price : null;
+ const entryValues = {
+ entryMode,
+ entryPrice: entryPriceText,
+ entryLow,
+ entryHigh,
+ };
+ const entry = entryLevels(entryValues);
- // A new price or direction checks every typed level again; without a price the checks pause.
+ // Until the analyst edits it, the exact entry follows the live quote of the picked symbol.
+ const fillEntry = useEffectEvent(() => {
+ if (!entryEdited.current && livePrice !== null) {
+ form.setValue('entryPrice', price(livePrice));
+ }
+ });
+ useEffect(() => fillEntry(), [livePrice, symbol]);
+
+ // A new price, entry or direction checks every typed level again.
const recheck = () => {
- entryRef.current = entryPrice;
const values = form.getValues();
const names: FormPath[] = values.targets.flatMap((target, index) =>
target.value.trim() ? [`targets.${index}.value` as const] : [],
);
if (values.stopLoss.trim()) names.push('stopLoss');
+ names.push(
+ ...entryFieldsOf(values.entryMode).filter((field) =>
+ values[field].trim(),
+ ),
+ );
if (names.length > 0) void form.trigger(names);
};
const recheckLevels = useEffectEvent(recheck);
- useEffect(() => recheckLevels(), [entryPrice, direction]);
+ useEffect(
+ () => recheckLevels(),
+ [livePrice, direction, entryMode, entry?.low, entry?.high],
+ );
const { errors } = form.formState;
const targetLabel = (index: number) =>
@@ -267,49 +313,66 @@ export function usePredictionComposerPage({
!market && t('composer.fields.market'),
!symbol && t('composer.fields.symbol'),
!direction && t('composer.fields.direction'),
+ entryFieldsOf(entryMode).some(
+ (field) => entryIssue(entryValues, field) === 'required',
+ ) && t('composer.fields.entry'),
...targets.map(
(target, index) => !target.value.trim() && targetLabel(index),
),
+ !stopLoss.trim() && t('composer.fields.stop'),
!horizon && t('composer.fields.horizon'),
].filter((label): label is string => typeof label === 'string');
const invalid = [
errors.market && t('composer.fields.market'),
errors.symbol && t('composer.fields.symbol'),
+ entryFieldsOf(entryMode).some(
+ // Empty says «کامل», not «اصلاح», even with its error showing.
+ (field) => errors[field] && entryValues[field].trim(),
+ ) && t('composer.fields.entry'),
...targets.map(
(_target, index) => errors.targets?.[index]?.value && targetLabel(index),
),
- errors.stopLoss && t('composer.fields.stop'),
+ errors.stopLoss && stopLoss.trim() && t('composer.fields.stop'),
errors.horizon && t('composer.fields.horizon'),
errors.note && t('composer.fields.note'),
errors.root?.chart && t('composer.fields.chart'),
].filter((label): label is string => typeof label === 'string');
- const reason = invalid.length
- ? t('composer.invalid', { fields: list(invalid) })
- : missing.length
- ? t('composer.missing', { fields: list(missing) })
- : quote.status === 'unavailable'
- ? t('composer.quote-unavailable')
- : chart.image?.status === 'uploading'
- ? t('content:composer.uploading-reason')
- : chart.image?.status === 'failed'
- ? t('content:composer.images.failed', { n: number(1) })
- : undefined;
+ const block = publishReason({
+ invalid,
+ missing,
+ quoteUnavailable: quote.status === 'unavailable',
+ chart:
+ chart.image?.status === 'uploading' || chart.image?.status === 'failed'
+ ? chart.image.status
+ : null,
+ });
+ const reason = !block
+ ? undefined
+ : block.kind === 'invalid'
+ ? t('composer.invalid', { fields: list(block.fields) })
+ : block.kind === 'missing'
+ ? t('composer.missing', { fields: list(block.fields) })
+ : block.kind === 'quote-unavailable'
+ ? t('composer.quote-unavailable')
+ : block.kind === 'chart-uploading'
+ ? t('content:composer.uploading-reason')
+ : t('content:composer.images.failed', { n: number(1) });
const levelsBroken =
- targetIssues(direction, targets, entryPrice).some(Boolean) ||
- stopIssue(direction, stopLoss, entryPrice) !== null;
+ targetIssues(direction, targets, entry).some(Boolean) ||
+ stopIssue(direction, stopLoss, entry) !== null;
const summary: ComposerSummary | null =
- missing.length === 0 &&
- entryPrice !== null &&
- market &&
- direction &&
- horizon
+ missing.length === 0 && entry !== null && market && direction && horizon
? {
symbol,
market,
direction,
- entryPrice,
+ entryMode,
+ // A range's distances and returns read its middle, as the API stores it.
+ entryPrice: (entry.low + entry.high) / 2,
+ entryLow: entryMode === 'range' ? entry.low : null,
+ entryHigh: entryMode === 'range' ? entry.high : null,
targetPrices: targets.flatMap(
(target) => levelPrice(target.value) ?? [],
),
@@ -325,16 +388,12 @@ export function usePredictionComposerPage({
const failPublish = (error: unknown) => {
const code = predictionErrorCode(error);
if (code === PREDICTION_ERROR_CODES.invalid) {
- // The levels were checked against a newer price: the form shows it.
- const checked = quoteOfError(error);
- if (checked) {
- queryClient.setQueryData(marketDataKeys.quote(checked.symbol), checked);
- }
predictionFieldIssues(error).forEach((issue, index) => {
const { name, message } = toFieldError(
issue,
form.getValues('direction'),
form.getValues('targets').length,
+ form.getValues('entryMode'),
);
form.setError(
name,
@@ -362,7 +421,7 @@ export function usePredictionComposerPage({
};
const publish = async () => {
- const sent = summary ?? confirmed;
+ const sent = confirmed;
if (phase !== 'confirming' || !sent) return;
const args: PublishPredictionArgs = {
accessLevel: sent.accessLevel,
@@ -372,6 +431,12 @@ export function usePredictionComposerPage({
symbol: sent.symbol,
market: sent.market,
direction: sent.direction,
+ ...(sent.entryMode === 'range'
+ ? {
+ entryLow: sent.entryLow ?? undefined,
+ entryHigh: sent.entryHigh ?? undefined,
+ }
+ : { entryPrice: sent.entryPrice }),
targetPrices: sent.targetPrices,
stopLoss: sent.stopLoss,
horizon: sent.horizon,
@@ -404,6 +469,8 @@ export function usePredictionComposerPage({
return (
values.market !== '' ||
values.direction !== '' ||
+ values.entryLow.trim() !== '' ||
+ values.entryHigh.trim() !== '' ||
values.targets.some((target) => target.value.trim() !== '') ||
values.stopLoss.trim() !== '' ||
values.horizon !== '' ||
@@ -431,6 +498,13 @@ export function usePredictionComposerPage({
// `requestLeave`. A publish in flight navigates by itself.
useLeaveGuard(phase !== 'publishing' && hasSomethingToLose(), requestLink);
+ // Another symbol's price can't stay as the entry; the new quote fills it.
+ const clearEntry = () => {
+ entryEdited.current = false;
+ form.setValue('entryPrice', '');
+ form.clearErrors('entryPrice');
+ };
+
return {
form,
markets,
@@ -440,11 +514,20 @@ export function usePredictionComposerPage({
form.setValue('market', next, { shouldDirty: true });
// Another market's symbol can't stay: it goes, with its price.
form.setValue('symbol', '', { shouldDirty: true });
+ clearEntry();
form.clearErrors(['market', 'symbol']);
},
direction,
setDirection: (next) =>
form.setValue('direction', next, { shouldDirty: true }),
+ entryMode,
+ setEntryMode: (next) => {
+ form.setValue('entryMode', next, { shouldDirty: true });
+ form.clearErrors(['entryPrice', 'entryLow', 'entryHigh']);
+ },
+ markEntryEdited: () => {
+ entryEdited.current = true;
+ },
horizon,
setHorizon: (next) => {
form.setValue('horizon', next, { shouldDirty: true });
@@ -463,6 +546,7 @@ export function usePredictionComposerPage({
) {
queryClient.setQueryData(marketDataKeys.quote(row.symbol), row.quote);
}
+ if (row.symbol !== symbol) clearEntry();
form.setValue('symbol', row.symbol, { shouldDirty: true });
form.clearErrors('symbol');
},
@@ -502,7 +586,7 @@ export function usePredictionComposerPage({
setPhase('confirming');
})();
},
- confirmSummary: phase === 'idle' ? null : (summary ?? confirmed),
+ confirmSummary: phase === 'idle' ? null : confirmed,
publish: () => void publish(),
cancelConfirm: () => {
if (phase === 'confirming') setPhase('idle');
diff --git a/platforms/market/src/features/prediction/models/prediction-list/constants.ts b/platforms/market/src/features/prediction/models/prediction-list/constants.ts
index 56e0559..a44c006 100644
--- a/platforms/market/src/features/prediction/models/prediction-list/constants.ts
+++ b/platforms/market/src/features/prediction/models/prediction-list/constants.ts
@@ -1,2 +1,2 @@
-/** The «همه پیشبینیها» chip in the URL: `?status=closed`; «باز» has none. */
+/** The «همه سیگنالها» chip in the URL: `?status=closed`; «باز» has none. */
export const PREDICTION_STATUS_PARAM = 'status';
diff --git a/platforms/market/src/features/prediction/models/prediction-list/types.ts b/platforms/market/src/features/prediction/models/prediction-list/types.ts
index 5250662..10cc769 100644
--- a/platforms/market/src/features/prediction/models/prediction-list/types.ts
+++ b/platforms/market/src/features/prediction/models/prediction-list/types.ts
@@ -5,7 +5,7 @@ import type {
OwnPredictionPayload,
} from '../../repositories/prediction';
-/** «همه پیشبینیها» (J10-3f, J10-3g). */
+/** «همه سیگنالها» (J10-3f, J10-3g). */
export type PredictionListPageModel = {
/** The chip in the URL (`?status=`), «باز» by default. */
status: OwnPredictionsStatus;
diff --git a/platforms/market/src/features/prediction/models/prediction-list/use-prediction-list-page.ts b/platforms/market/src/features/prediction/models/prediction-list/use-prediction-list-page.ts
index c7a802b..54a35b5 100644
--- a/platforms/market/src/features/prediction/models/prediction-list/use-prediction-list-page.ts
+++ b/platforms/market/src/features/prediction/models/prediction-list/use-prediction-list-page.ts
@@ -19,7 +19,7 @@ function toStatus(value: string | null): OwnPredictionsStatus {
}
/**
- * «همه پیشبینیها» (J10-3f, J10-3g): «باز» · «بستهشده» · «همه» with the API's totals, the chip in
+ * «همه سیگنالها» (J10-3f, J10-3g): «باز» · «بستهشده» · «همه» with the API's totals, the chip in
* the URL so back and a reload keep it, 20 a page by cursor. open and all list the newest
* published first, closed the newest closed first. A card closed here stays in place, closed.
*/
diff --git a/platforms/market/src/features/prediction/models/signal-stats/index.ts b/platforms/market/src/features/prediction/models/signal-stats/index.ts
new file mode 100644
index 0000000..ae0c99e
--- /dev/null
+++ b/platforms/market/src/features/prediction/models/signal-stats/index.ts
@@ -0,0 +1 @@
+export { useSignalStatsPart } from './use-signal-stats-part';
diff --git a/platforms/market/src/features/prediction/models/signal-stats/use-signal-stats-part.ts b/platforms/market/src/features/prediction/models/signal-stats/use-signal-stats-part.ts
new file mode 100644
index 0000000..0a0c0c3
--- /dev/null
+++ b/platforms/market/src/features/prediction/models/signal-stats/use-signal-stats-part.ts
@@ -0,0 +1,19 @@
+import { useSuspenseQuery } from '@tanstack/react-query';
+
+import {
+ predictionKeys,
+ predictionRepository,
+} from '../../repositories/prediction';
+import type { SignalStatsPayload } from '../../repositories/prediction';
+
+/**
+ * «عملکرد سیگنالها», shared by داشبورد's سیگنالها and نمای کلی so they read one cached answer:
+ * `pending` before the first nightly evaluation, when no client shows a number.
+ */
+export function useSignalStatsPart(): SignalStatsPayload {
+ const { data } = useSuspenseQuery({
+ queryKey: predictionKeys.signalStats(),
+ queryFn: ({ signal }) => predictionRepository.getSignalStats({ signal }),
+ });
+ return data;
+}
diff --git a/platforms/market/src/features/prediction/models/track-record/index.ts b/platforms/market/src/features/prediction/models/track-record/index.ts
deleted file mode 100644
index ca0479e..0000000
--- a/platforms/market/src/features/prediction/models/track-record/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { useTrackRecordPart } from './use-track-record-part';
-export type { TrackRecordPartModel } from './types';
diff --git a/platforms/market/src/features/prediction/models/track-record/types.ts b/platforms/market/src/features/prediction/models/track-record/types.ts
deleted file mode 100644
index 8be856d..0000000
--- a/platforms/market/src/features/prediction/models/track-record/types.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import type { PredictionStatsPayload } from '../../repositories/prediction';
-
-/** «کارنامه شما» once public, else «کارنامه عمومی» with its progress (J10-3, J10-3b). */
-export type TrackRecordPartModel =
- | { kind: 'public'; stats: PredictionStatsPayload }
- | {
- kind: 'progress';
- closed: number;
- required: number;
- /** Days left to a month of activity; `null` once that part is met. */
- daysLeft: number | null;
- };
diff --git a/platforms/market/src/features/prediction/models/track-record/use-track-record-part.ts b/platforms/market/src/features/prediction/models/track-record/use-track-record-part.ts
deleted file mode 100644
index 2c7969b..0000000
--- a/platforms/market/src/features/prediction/models/track-record/use-track-record-part.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { useSuspenseQuery } from '@tanstack/react-query';
-
-import {
- predictionKeys,
- predictionRepository,
-} from '../../repositories/prediction';
-import type { TrackRecordPartModel } from './types';
-
-/**
- * داشبورد › پیشبینیها › the record (J10-3): the creator's own numbers once the record is public
- * (10 closed, a month since the first prediction, as the API decides); before that, how far it is
- * from public, since the channel shows no record yet.
- */
-export function useTrackRecordPart(): TrackRecordPartModel {
- const { data } = useSuspenseQuery({
- queryKey: predictionKeys.trackRecord(),
- queryFn: ({ signal }) => predictionRepository.getTrackRecord({ signal }),
- });
-
- if (data.isPublic) return { kind: 'public', stats: data.stats };
- const daysLeft = data.requiredDays - data.daysActive;
- return {
- kind: 'progress',
- closed: data.closed,
- required: data.required,
- daysLeft: daysLeft > 0 ? daysLeft : null,
- };
-}
diff --git a/platforms/market/src/features/prediction/repositories/prediction/constants.ts b/platforms/market/src/features/prediction/repositories/prediction/constants.ts
index b1c0662..ec9dd7c 100644
--- a/platforms/market/src/features/prediction/repositories/prediction/constants.ts
+++ b/platforms/market/src/features/prediction/repositories/prediction/constants.ts
@@ -7,13 +7,13 @@ export const PREDICTION_ENDPOINTS = {
closeEarly: (postId: string) => `${post(postId)}/close-early`,
stats: (creatorId: string) =>
`/creators/${encodeURIComponent(creatorId)}/prediction-stats`,
- trackRecord: '/creators/me/track-record',
+ signalStats: '/me/signal-stats',
own: '/posts/me/predictions',
} as const;
/** The codes the API marks prediction failures with; branch on these, never on the message. */
export const PREDICTION_ERROR_CODES = {
- /** 422 on publish: `details.errors` lists `{ field, code }`, with `details.quote` for levels. */
+ /** 422 on publish: `details.errors` lists `{ field, code }`. */
invalid: 'PREDICTION_INVALID',
/** 503 on a price read or an early close, 409 on publish: no fresh price for the symbol. */
quoteUnavailable: 'QUOTE_UNAVAILABLE',
@@ -35,15 +35,18 @@ export const PREDICTION_FIELD_CODES = [
'horizon_invalid',
'note_too_long',
'chart_too_many',
+ 'entry_required',
+ 'entry_range_order',
+ 'stop_required',
'target_wrong_side',
'targets_order',
'stop_wrong_side',
] as const;
-/** The «همه پیشبینیها» page size. */
+/** The «همه سیگنالها» page size. */
export const OWN_PREDICTIONS_PAGE_LIMIT = 20;
-/** The tab's «پیشبینیهای باز» reads every open one in one go: the API's largest page. */
+/** The tab's «سیگنالهای باز» reads every open one in one go: the API's largest page. */
export const OWN_OPEN_PREVIEW_LIMIT = 50;
/** The tab's «بستهشدههای اخیر». */
@@ -53,14 +56,14 @@ export const predictionKeys = {
all: ['prediction'] as const,
stats: (creatorId: string) =>
[...predictionKeys.all, 'stats', creatorId] as const,
- /** The signed-in creator's own track record and its progress to public. */
- trackRecord: () => [...predictionKeys.all, 'track-record'] as const,
+ /** The signed-in analyst's numbers from the last nightly evaluation. */
+ signalStats: () => [...predictionKeys.all, 'signal-stats'] as const,
/** Every list of the creator's own predictions, for invalidation. */
own: () => [...predictionKeys.all, 'own'] as const,
/** A first page the داشبورد tab shows. */
ownPreview: (status: OwnPredictionsStatus, limit: number) =>
[...predictionKeys.own(), 'preview', status, limit] as const,
- /** «همه پیشبینیها», page after page. */
+ /** «همه سیگنالها», page after page. */
ownList: (status: OwnPredictionsStatus) =>
[...predictionKeys.own(), 'list', status] as const,
/** The price an early close would record now. */
diff --git a/platforms/market/src/features/prediction/repositories/prediction/errors.ts b/platforms/market/src/features/prediction/repositories/prediction/errors.ts
index a855bf6..7759d77 100644
--- a/platforms/market/src/features/prediction/repositories/prediction/errors.ts
+++ b/platforms/market/src/features/prediction/repositories/prediction/errors.ts
@@ -1,9 +1,6 @@
import { isHttpError } from '@lumina/libs/http';
import type { PostEntity } from '../../../post';
-import type { QuoteEntity } from '../../entities/market-data';
-import { toQuotePayload } from '../market-data';
-import type { QuotePayload } from '../market-data';
import { PREDICTION_ERROR_CODES, PREDICTION_FIELD_CODES } from './constants';
import { toOwnPredictionPayload } from './mappers';
import type {
@@ -48,18 +45,6 @@ export function predictionFieldIssues(error: unknown): PredictionFieldIssue[] {
);
}
-/** The price a 422 checked the levels against, to show it in place of the old one. */
-export function quoteOfError(error: unknown): QuotePayload | null {
- const quote = detailsOf(error)?.quote;
- return isRecord(quote) &&
- typeof quote.symbol === 'string' &&
- typeof quote.price === 'number' &&
- typeof quote.at === 'string' &&
- typeof quote.source === 'string'
- ? toQuotePayload(quote as QuoteEntity)
- : null;
-}
-
/** The closed post a 409 `PREDICTION_ALREADY_CLOSED` carries, to show it as it is now. */
export function closedPostOfError(error: unknown): OwnPredictionPayload | null {
const post = detailsOf(error)?.post;
diff --git a/platforms/market/src/features/prediction/repositories/prediction/index.ts b/platforms/market/src/features/prediction/repositories/prediction/index.ts
index bc4cb02..268526e 100644
--- a/platforms/market/src/features/prediction/repositories/prediction/index.ts
+++ b/platforms/market/src/features/prediction/repositories/prediction/index.ts
@@ -10,7 +10,6 @@ export {
closedPostOfError,
predictionErrorCode,
predictionFieldIssues,
- quoteOfError,
} from './errors';
export { predictionRepository } from './prediction';
export type {
@@ -23,5 +22,7 @@ export type {
PredictionFieldCode,
PredictionFieldIssue,
PredictionStatsPayload,
- TrackRecordPayload,
+ SignalNumbersPayload,
+ SignalProgressPayload,
+ SignalStatsPayload,
} from './types';
diff --git a/platforms/market/src/features/prediction/repositories/prediction/mappers.ts b/platforms/market/src/features/prediction/repositories/prediction/mappers.ts
index 4f539a1..bd64193 100644
--- a/platforms/market/src/features/prediction/repositories/prediction/mappers.ts
+++ b/platforms/market/src/features/prediction/repositories/prediction/mappers.ts
@@ -8,8 +8,9 @@ import type {
OwnPredictionsPageResponseDto,
PredictionStatsPayload,
PredictionStatsResponseDto,
- TrackRecordPayload,
- TrackRecordResponseDto,
+ SignalProgressPayload,
+ SignalStatsPayload,
+ SignalStatsResponseDto,
} from './types';
export function toPredictionStatsPayload(
@@ -31,16 +32,42 @@ export function toPredictionStatsPayload(
};
}
-export function toTrackRecordPayload(
- dto: TrackRecordResponseDto,
-): TrackRecordPayload {
+/**
+ * How far from public: `closed` stops at what is required, so it never reads «۱۲ از ۱۰»;
+ * `daysLeft` is `null` once the month of activity is met.
+ */
+export function toSignalProgressPayload(
+ progress: SignalStatsResponseDto['progress'],
+ isPublic: boolean,
+): SignalProgressPayload {
+ const daysLeft = progress.requiredDays - progress.daysActive;
return {
- isPublic: dto.public,
- closed: dto.closed,
- required: dto.required,
- daysActive: dto.daysActive,
- requiredDays: dto.requiredDays,
- stats: toPredictionStatsPayload(dto.stats, dto.public),
+ isPublic,
+ closed: Math.min(progress.closed, progress.requiredClosed),
+ required: progress.requiredClosed,
+ daysLeft: daysLeft > 0 ? daysLeft : null,
+ };
+}
+
+export function toSignalStatsPayload(
+ dto: SignalStatsResponseDto,
+): SignalStatsPayload {
+ const { stats, progress } = dto;
+ if (dto.status !== 'ready' || !stats) return { status: 'pending' };
+ return {
+ status: 'ready',
+ stats: {
+ winRate: stats.winRate,
+ avgRoi: stats.avgRoi,
+ total: stats.total,
+ active: stats.active,
+ outcomes: stats.outcomes,
+ riskReward:
+ stats.rrWorstAvg != null && stats.rrBestAvg != null
+ ? { worst: stats.rrWorstAvg, best: stats.rrBestAvg }
+ : null,
+ },
+ progress: toSignalProgressPayload(progress, stats.isPublic),
};
}
diff --git a/platforms/market/src/features/prediction/repositories/prediction/prediction.ts b/platforms/market/src/features/prediction/repositories/prediction/prediction.ts
index 573e9bd..302420f 100644
--- a/platforms/market/src/features/prediction/repositories/prediction/prediction.ts
+++ b/platforms/market/src/features/prediction/repositories/prediction/prediction.ts
@@ -6,7 +6,7 @@ import {
toCloseQuotePayload,
toOwnPredictionsPagePayload,
toPredictionStatsPayload,
- toTrackRecordPayload,
+ toSignalStatsPayload,
} from './mappers';
import type {
ClosePredictionResponseDto,
@@ -17,14 +17,14 @@ import type {
OwnPredictionsPageResponseDto,
PredictionStatsPayload,
PredictionStatsResponseDto,
- TrackRecordPayload,
- TrackRecordResponseDto,
+ SignalStatsPayload,
+ SignalStatsResponseDto,
} from './types';
/**
* Prediction tracking. The prediction itself lives on its post (`PredictionPayload` in the post
* feature), published through the post feature with an idempotency key; this closes it early,
- * reads the creator's own lists and track record, and the public record.
+ * reads the creator's own lists and numbers, and the public record.
*/
export const predictionRepository = {
/**
@@ -66,15 +66,15 @@ export const predictionRepository = {
return toPredictionStatsPayload(response);
},
- /** The signed-in creator's own record, always with its numbers, and its progress to public. */
- async getTrackRecord({
+ /** The signed-in analyst's numbers from the last nightly evaluation, or `pending` before it. */
+ async getSignalStats({
signal,
- }: { signal?: AbortSignal } = {}): Promise {
- const response = await predictionHttp.get(
- PREDICTION_ENDPOINTS.trackRecord,
+ }: { signal?: AbortSignal } = {}): Promise {
+ const response = await predictionHttp.get(
+ PREDICTION_ENDPOINTS.signalStats,
{ signal },
);
- return toTrackRecordPayload(response);
+ return toSignalStatsPayload(response);
},
/** A page of the creator's own published predictions, with the totals per status. */
diff --git a/platforms/market/src/features/prediction/repositories/prediction/signal-stats-mappers.test.ts b/platforms/market/src/features/prediction/repositories/prediction/signal-stats-mappers.test.ts
new file mode 100644
index 0000000..8371eee
--- /dev/null
+++ b/platforms/market/src/features/prediction/repositories/prediction/signal-stats-mappers.test.ts
@@ -0,0 +1,97 @@
+import { describe, expect, it } from 'vitest';
+
+import { toSignalProgressPayload, toSignalStatsPayload } from './mappers';
+import type { SignalStatsResponseDto } from './types';
+
+const progress = {
+ closed: 4,
+ requiredClosed: 10,
+ daysActive: 12,
+ requiredDays: 30,
+};
+const stats = {
+ winRate: 60,
+ avgRoi: -1.5,
+ total: 12,
+ active: 2,
+ outcomes: { target: 6, stop: 3, expired: 1, active: 2, voided: 0 },
+ rrWorstAvg: 1.4,
+ rrBestAvg: 3,
+ closedCount: 10,
+ daysActive: 12,
+ isPublic: false,
+ evaluatedAt: '2026-11-01T22:30:00.000Z',
+};
+
+describe('toSignalProgressPayload', () => {
+ it('counts the days left to a month of activity', () => {
+ expect(toSignalProgressPayload(progress, false)).toEqual({
+ isPublic: false,
+ closed: 4,
+ required: 10,
+ daysLeft: 18,
+ });
+ });
+
+ it.each([30, 45])('has no days left at %d days', (daysActive) => {
+ expect(
+ toSignalProgressPayload({ ...progress, daysActive }, false).daysLeft,
+ ).toBeNull();
+ });
+
+ it('stops at what is required, so it never reads 12 of 10', () => {
+ expect(
+ toSignalProgressPayload({ ...progress, closed: 12 }, false).closed,
+ ).toBe(10);
+ });
+});
+
+describe('toSignalStatsPayload', () => {
+ it('is pending with no numbers before the first evaluation', () => {
+ expect(toSignalStatsPayload({ status: 'pending', progress })).toEqual({
+ status: 'pending',
+ });
+ });
+
+ it('is pending when ready arrives with no stats, never zeros', () => {
+ expect(
+ toSignalStatsPayload({
+ status: 'ready',
+ progress,
+ } as SignalStatsResponseDto),
+ ).toEqual({
+ status: 'pending',
+ });
+ });
+
+ it('maps the numbers and the record being public', () => {
+ const answer = toSignalStatsPayload({
+ status: 'ready',
+ stats: { ...stats, isPublic: true },
+ progress,
+ });
+ expect(answer).toMatchObject({
+ status: 'ready',
+ stats: {
+ winRate: 60,
+ avgRoi: -1.5,
+ total: 12,
+ active: 2,
+ riskReward: { worst: 1.4, best: 3 },
+ },
+ progress: { isPublic: true },
+ });
+ });
+
+ it.each([
+ [{ rrWorstAvg: null, rrBestAvg: null }],
+ [{ rrWorstAvg: 1.4, rrBestAvg: null }],
+ ])('has no risk to reward for %j', (over) => {
+ const answer = toSignalStatsPayload({
+ status: 'ready',
+ stats: { ...stats, ...over },
+ progress,
+ });
+ expect(answer.status === 'ready' && answer.stats.riskReward).toBeNull();
+ });
+});
diff --git a/platforms/market/src/features/prediction/repositories/prediction/types.ts b/platforms/market/src/features/prediction/repositories/prediction/types.ts
index bed3f9f..03034a7 100644
--- a/platforms/market/src/features/prediction/repositories/prediction/types.ts
+++ b/platforms/market/src/features/prediction/repositories/prediction/types.ts
@@ -11,7 +11,7 @@ import type {
OwnPredictionsStatus,
} from '../../entities/own-predictions';
import type { PredictionStatsEntity } from '../../entities/prediction-stats';
-import type { TrackRecordEntity } from '../../entities/track-record';
+import type { SignalStatsEntity } from '../../entities/signal-stats';
import type {
PREDICTION_ERROR_CODES,
PREDICTION_FIELD_CODES,
@@ -23,8 +23,9 @@ export type PredictionErrorCode =
export type PredictionFieldCode = (typeof PREDICTION_FIELD_CODES)[number];
/**
- * One field a 422 `PREDICTION_INVALID` refused, with the API's path: `market`, `symbol`,
- * `targetPrices` or `targetPrices.`, `stopLoss`, `horizon`, `caption` (the note), `media`.
+ * One field a 422 `PREDICTION_INVALID` refused, with the API's path: `market`, `symbol`, `entry`,
+ * `entryLow`, `targetPrices` or `targetPrices.`, `stopLoss`, `horizon`, `caption` (the note),
+ * `media`.
*/
export type PredictionFieldIssue = { field: string; code: PredictionFieldCode };
@@ -59,31 +60,63 @@ export type PredictionStatsPayload = {
isPublic: boolean;
/** A percentage: `62.86`. */
winRate: number;
- /** A percentage over closed predictions. */
+ /** A percentage over closed signals, the stake split across each one's targets. */
avgRoiPercent: number;
/** Published, open and closed. */
totalPredictions: number;
activePredictions: number;
- /** The API's `pastPredictions`: wins + losses + breakeven. */
+ /** The API's `pastPredictions`: target + stop + expired. */
closedPredictions: number;
+ /** Closed at «هدف»; an early or admin close counts here by a profit at close. */
wins: number;
+ /** Closed at «حد ضرر»; an early or admin close counts here by a loss at close. */
losses: number;
+ /** «پایان مهلت», not a breakeven; an early or admin close at no gain or loss counts here. */
breakeven: number;
- /** The last 10 closed outcomes, oldest first. */
+ /** The last 10 closed outcomes by their return, oldest first. */
accuracyTrend: PredictionOutcome[];
};
export type PredictionStatsResponseDto = PredictionStatsEntity;
-/** The owner's record and how far it is from going public (J10-3, J10-3b). */
-export type TrackRecordPayload = {
+/** How far the analyst's record is from going public. */
+export type SignalProgressPayload = {
isPublic: boolean;
+ /** Closed signals so far, never more than `required`. */
closed: number;
required: number;
- daysActive: number;
- requiredDays: number;
- stats: PredictionStatsPayload;
+ /** Days left to a month of activity; `null` once that part is met. */
+ daysLeft: number | null;
};
-export type TrackRecordResponseDto = TrackRecordEntity;
+
+/** The numbers every page shows the same: the channel, نمای کلی and سیگنالها. */
+export type SignalNumbersPayload = {
+ /** A percentage: `62.86`. */
+ winRate: number;
+ /** A signed percentage. */
+ avgRoi: number;
+ /** Closed and active. */
+ total: number;
+ active: number;
+ outcomes: {
+ target: number;
+ stop: number;
+ expired: number;
+ active: number;
+ voided: number;
+ };
+ /** Averages of reward per unit of risk, lower then higher; `null` with no signal to read. */
+ riskReward: { worst: number; best: number } | null;
+};
+
+/** `pending` before the first nightly evaluation: no number exists to show, not even a zero. */
+export type SignalStatsPayload =
+ | { status: 'pending' }
+ | {
+ status: 'ready';
+ stats: SignalNumbersPayload;
+ progress: SignalProgressPayload;
+ };
+export type SignalStatsResponseDto = SignalStatsEntity;
export type ListOwnPredictionsArgs = {
/** `open` by default. */
diff --git a/platforms/market/src/features/pricing/constants.ts b/platforms/market/src/features/pricing/constants.ts
index a6892d8..df9534b 100644
--- a/platforms/market/src/features/pricing/constants.ts
+++ b/platforms/market/src/features/pricing/constants.ts
@@ -6,9 +6,6 @@ export const PRICING_EVENTS = {
saved: 'pricing.saved',
} 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 ۷.۱). */
export const PRICE_ROUND_STEP_TOMAN = 1_000;
diff --git a/platforms/market/src/features/pricing/entities/pricing-tier/types.ts b/platforms/market/src/features/pricing/entities/pricing-tier/types.ts
index 46d05f3..6e636ab 100644
--- a/platforms/market/src/features/pricing/entities/pricing-tier/types.ts
+++ b/platforms/market/src/features/pricing/entities/pricing-tier/types.ts
@@ -32,6 +32,10 @@ export type PricingTierEntity = {
perMonthEquivalentFa: string | null;
floorTomanPerMonth: number;
floorHelperFa: string;
+ promoFloorHintFa: string;
+ /** Below the price floor: hidden from buyers until a valid price is saved. */
+ offSale: boolean;
+ offSaleBannerFa: string | null;
priceFieldLabelFa: string;
suggestedPriceToman: number | null;
suggestionHintFa: string | null;
diff --git a/platforms/market/src/features/pricing/index.ts b/platforms/market/src/features/pricing/index.ts
index 3b62385..0bd9fd8 100644
--- a/platforms/market/src/features/pricing/index.ts
+++ b/platforms/market/src/features/pricing/index.ts
@@ -1,11 +1,7 @@
import './types';
export { savePricing } from './actions/save-pricing';
-export {
- PRICE_ROUND_STEP_TOMAN,
- PRICING_EVENTS,
- PROMO_FLOOR_TOMAN_PER_MONTH,
-} from './constants';
+export { PRICE_ROUND_STEP_TOMAN, PRICING_EVENTS } from './constants';
export { usePricingPage } from './models/pricing';
export type {
PricingFieldMessage,
diff --git a/platforms/market/src/features/pricing/models/pricing-card/types.ts b/platforms/market/src/features/pricing/models/pricing-card/types.ts
index 5b6a6cb..3d006a8 100644
--- a/platforms/market/src/features/pricing/models/pricing-card/types.ts
+++ b/platforms/market/src/features/pricing/models/pricing-card/types.ts
@@ -6,6 +6,8 @@ import type {
/** A priced, offered plan as the «قیمت طرحها» card lists it. */
export type PricingPlanRow = {
billingPeriod: BillingPeriod;
+ /** Below the price floor: hidden from buyers until a valid price is saved. */
+ offSale: boolean;
/** The standing period total. */
priceToman: number;
perMonthToman: number;
@@ -23,6 +25,8 @@ export type PricingCardPartModel = {
/** Nothing priced yet: one line and «تعیین قیمتها» (۲.۴). */
isEmpty: boolean;
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 (۲.۳). */
lockedUntil: string | null;
verification: VerificationStatus;
diff --git a/platforms/market/src/features/pricing/models/pricing-card/use-pricing-card-part.ts b/platforms/market/src/features/pricing/models/pricing-card/use-pricing-card-part.ts
index d1fa71d..03fcecc 100644
--- a/platforms/market/src/features/pricing/models/pricing-card/use-pricing-card-part.ts
+++ b/platforms/market/src/features/pricing/models/pricing-card/use-pricing-card-part.ts
@@ -7,7 +7,7 @@ import type { PricingCardPartModel, PricingPlanRow } from './types';
/**
* طرحهای اشتراک › «قیمت طرحها» (Creator Dashboard ۲.۱–۲.۵): each offered, priced plan with its
* 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.
*/
export function usePricingCardPart(): PricingCardPartModel {
@@ -23,6 +23,7 @@ export function usePricingCardPart(): PricingCardPartModel {
return [
{
billingPeriod: tier.billingPeriod,
+ offSale: tier.offSale,
priceToman: tier.priceToman,
perMonthToman:
tier.perMonthToman ?? Math.round(tier.priceToman / months),
@@ -43,6 +44,9 @@ export function usePricingCardPart(): PricingCardPartModel {
return {
isEmpty: data.firstTimeSetup || plans.length === 0,
plans,
+ offSale: plans
+ .filter((plan) => plan.offSale)
+ .map((plan) => plan.billingPeriod),
lockedUntil: data.cooldown.locked ? data.cooldown.editableAt : null,
verification: data.verification.status,
};
diff --git a/platforms/market/src/features/pricing/models/pricing/pricing-rules.test.ts b/platforms/market/src/features/pricing/models/pricing/pricing-rules.test.ts
new file mode 100644
index 0000000..88eb785
--- /dev/null
+++ b/platforms/market/src/features/pricing/models/pricing/pricing-rules.test.ts
@@ -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 = {}) => ({
+ enabled: price !== '',
+ priceToman: price,
+ promotion: {
+ enabled: false,
+ percent: '',
+ startsAt: null,
+ endsAt: null,
+ indefinite: true,
+ },
+ ...over,
+});
+const values = (
+ over: Partial = {},
+): 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',
+ });
+ });
+});
diff --git a/platforms/market/src/features/pricing/models/pricing/pricing-rules.ts b/platforms/market/src/features/pricing/models/pricing/pricing-rules.ts
index 8d7465d..0c938be 100644
--- a/platforms/market/src/features/pricing/models/pricing/pricing-rules.ts
+++ b/platforms/market/src/features/pricing/models/pricing/pricing-rules.ts
@@ -4,10 +4,7 @@ import {
} from '../../../../shared/constants';
import type { BillingPeriod } from '../../../../shared/constants';
import { toPriceNumber } from '../../../../shared/utils';
-import {
- PRICE_ROUND_STEP_TOMAN,
- PROMO_FLOOR_TOMAN_PER_MONTH,
-} from '../../constants';
+import { PRICE_ROUND_STEP_TOMAN } from '../../constants';
import type {
PricingFieldName,
SavePricingArgs,
@@ -15,7 +12,8 @@ import type {
import type { PricingFormValues, PricingIssue } from './types';
// 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. */
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]);
}
+/** 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. */
export function promotionalTotal(total: number, percent: number): number {
const raw = (total * (100 - percent)) / 100;
@@ -51,7 +57,7 @@ export type PromotionStartContext = {
export function checkPricingDraft(
values: PricingFormValues,
- floors: Record,
+ floorPerMonth: number,
starts?: PromotionStartContext,
): Partial> {
const issues: Partial> = {};
@@ -68,10 +74,12 @@ export function checkPricingDraft(
add(`tiers.${period}.priceToman`, { code: 'required' });
continue;
}
- if (perMonth(total, period) < floors[period]) {
+ if (total < floorTotal(floorPerMonth, period)) {
add(`tiers.${period}.priceToman`, {
code: 'below-floor',
- floor: floors[period],
+ floor: floorPerMonth,
+ floorTotal: floorTotal(floorPerMonth, period),
+ period,
});
}
}
@@ -103,15 +111,12 @@ export function checkPricingDraft(
} else {
const total = toToman(values.tiers[period].priceToman);
if (total !== null) {
- const promoPerMonth = perMonth(
- promotionalTotal(total, percent),
- period,
- );
- if (promoPerMonth < PROMO_FLOOR_TOMAN_PER_MONTH) {
+ const promoTotal = promotionalTotal(total, percent);
+ if (promoTotal < floorTotal(floorPerMonth, period)) {
add(`tiers.${period}.promotion.percent`, {
code: 'promo-floor',
- amount: promoPerMonth,
- floor: PROMO_FLOOR_TOMAN_PER_MONTH,
+ amount: perMonth(promoTotal, period),
+ floor: floorPerMonth,
});
}
}
diff --git a/platforms/market/src/features/pricing/models/pricing/types.ts b/platforms/market/src/features/pricing/models/pricing/types.ts
index 288ca42..0e0069c 100644
--- a/platforms/market/src/features/pricing/models/pricing/types.ts
+++ b/platforms/market/src/features/pricing/models/pricing/types.ts
@@ -31,7 +31,12 @@ export type PricingFormValues = {
/** A broken rule, with what its message needs. */
export type PricingIssue =
| { code: 'required' }
- | { code: 'below-floor'; floor: number }
+ | {
+ code: 'below-floor';
+ floor: number;
+ floorTotal: number;
+ period: BillingPeriod;
+ }
| {
code: 'per-month-increase';
amount: number;
@@ -81,7 +86,13 @@ export type PricingTierView = {
priceMessage: PricingFieldMessage | null;
/** The per-month equivalent of a valid total. */
perMonthToman: number | null;
+ /** The least this period's total may be, after any discount. */
+ floorTotalToman: 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 (۲.۲). */
disableNoteCount: number | null;
promotion: PricingPromotionView;
@@ -102,6 +113,8 @@ export type PricingPageModel = {
prePurchase: boolean;
/** Standing prices and periods frozen until this date; promotions stay live (۶.۲). */
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[];
setEnabled: (period: BillingPeriod, enabled: boolean) => void;
setPrice: (period: BillingPeriod, text: string) => void;
diff --git a/platforms/market/src/features/pricing/models/pricing/use-pricing-page.ts b/platforms/market/src/features/pricing/models/pricing/use-pricing-page.ts
index 3f01ad0..a508f45 100644
--- a/platforms/market/src/features/pricing/models/pricing/use-pricing-page.ts
+++ b/platforms/market/src/features/pricing/models/pricing/use-pricing-page.ts
@@ -27,6 +27,7 @@ import type {
} from '../../repositories/pricing';
import {
checkPricingDraft,
+ floorTotal,
perMonth,
pricingFieldId,
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
* 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
- * 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.
*/
export function usePricingPage(): PricingPageModel {
@@ -121,16 +123,12 @@ export function usePricingPage(): PricingPageModel {
});
const locked = payload.cooldown.locked;
- const floors = useMemo(
- () =>
- Object.fromEntries(
- payload.tiers.map((tier) => [
- tier.billingPeriod,
- tier.floorTomanPerMonth,
- ]),
- ) as Record,
- [payload.tiers],
- );
+ const floorPerMonth = payload.floorTomanPerMonth;
+ const isPriceLocked = (period: BillingPeriod) =>
+ locked &&
+ !payload.tiers.some(
+ (tier) => tier.billingPeriod === period && tier.offSale,
+ );
const savedStarts = useMemo(
() =>
Object.fromEntries(
@@ -143,11 +141,11 @@ export function usePricingPage(): PricingPageModel {
);
const issues = useMemo(
() =>
- checkPricingDraft(values, floors, {
+ checkPricingDraft(values, floorPerMonth, {
saved: savedStarts,
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)
@@ -195,7 +193,10 @@ export function usePricingPage(): PricingPageModel {
? messageOf(priceField, current.priceToman !== '')
: null,
perMonthToman: total === null ? null : perMonth(total, period),
- floorTomanPerMonth: tier.floorTomanPerMonth,
+ floorTotalToman: floorTotal(floorPerMonth, period),
+ floorTomanPerMonth: floorPerMonth,
+ offSale: tier.offSale,
+ locked: locked && !tier.offSale,
disableNoteCount:
!current.enabled && tier.enabled && tier.activeSubscribers > 0
? tier.activeSubscribers
@@ -301,6 +302,8 @@ export function usePricingPage(): PricingPageModel {
const saved = toFormValues(fresh);
for (const tier of fresh.tiers) {
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`, {
defaultValue: saved.tiers[period].enabled,
});
@@ -377,19 +380,20 @@ export function usePricingPage(): PricingPageModel {
verification: payload.verification.status,
prePurchase: payload.cooldown.prePurchase,
lockedUntil: locked ? payload.cooldown.editableAt : null,
+ hasOffSale: payload.tiers.some((tier) => tier.offSale),
tiers,
setEnabled: (period, enabled) => {
- if (locked || period === 'monthly') return;
+ if (isPriceLocked(period) || period === 'monthly') return;
update(`tiers.${period}.enabled`, enabled);
},
setPrice: (period, text) => {
- if (locked) return;
+ if (isPriceLocked(period)) return;
update(`tiers.${period}.priceToman`, toAmountText(text));
},
blurPrice: (period) => {
if (period !== 'monthly' || !payload.firstTimeSetup) return;
const monthly = toToman(form.getValues('tiers.monthly.priceToman'));
- if (monthly !== null && monthly >= floors.monthly)
+ if (monthly !== null && monthly >= floorPerMonth)
fillSuggestions(monthly);
},
setPromotionEnabled: (period, enabled) => {
diff --git a/platforms/market/src/features/pricing/repositories/pricing/mappers.ts b/platforms/market/src/features/pricing/repositories/pricing/mappers.ts
index eac2bdd..734d37c 100644
--- a/platforms/market/src/features/pricing/repositories/pricing/mappers.ts
+++ b/platforms/market/src/features/pricing/repositories/pricing/mappers.ts
@@ -24,7 +24,7 @@ function toPricingTierPayload(dto: PricingTierEntity): PricingTierPayload {
enabled: dto.enabled,
priceToman: dto.priceToman,
perMonthToman: dto.perMonthToman,
- floorTomanPerMonth: dto.floorTomanPerMonth,
+ offSale: dto.offSale,
suggestedPriceToman: dto.suggestedPriceToman,
prefillSuggestion: dto.prefillSuggestion,
activeSubscribers: dto.activeSubscribers,
@@ -46,6 +46,7 @@ export function toPricingFormPayload(
): PricingFormPayload {
return {
firstTimeSetup: dto.firstTimeSetup,
+ floorTomanPerMonth: dto.floorTomanPerMonth,
verification: {
status: dto.verification.status,
canBeSubscribedTo: dto.verification.canBeSubscribedTo,
diff --git a/platforms/market/src/features/pricing/repositories/pricing/types.ts b/platforms/market/src/features/pricing/repositories/pricing/types.ts
index 31d6ca8..a43a0bb 100644
--- a/platforms/market/src/features/pricing/repositories/pricing/types.ts
+++ b/platforms/market/src/features/pricing/repositories/pricing/types.ts
@@ -22,6 +22,8 @@ export type PricingFormResponseDto = {
monthlyMandatoryNoteFa: string;
existingSubscribersNoteFa: string;
firstTimeSetup: boolean;
+ /** «کف قیمت»: the least any tier may finally cost per month, after any discount. */
+ floorTomanPerMonth: number;
verification: {
status: VerificationStatus;
canBeSubscribedTo: boolean;
@@ -66,8 +68,8 @@ export type PricingTierPayload = {
enabled: boolean;
priceToman: number | null;
perMonthToman: number | null;
- /** The lowest allowed price per month for this period. */
- floorTomanPerMonth: number;
+ /** Below the price floor: hidden from buyers, and editable through the 7-day lock. */
+ offSale: boolean;
/** Monthly × duration minus the period's discount, from the saved (or previewed) monthly price. */
suggestedPriceToman: number | null;
prefillSuggestion: boolean;
@@ -79,6 +81,8 @@ export type PricingTierPayload = {
export type PricingFormPayload = {
/** Nothing has been priced yet; the longer periods carry the suggestions as prices. */
firstTimeSetup: boolean;
+ /** «کف قیمت»: the least any tier may finally cost per month, after any discount. */
+ floorTomanPerMonth: number;
verification: {
status: VerificationStatus;
canBeSubscribedTo: boolean;
diff --git a/platforms/market/src/features/subscription/models/renewal/use-renewal-sheet.ts b/platforms/market/src/features/subscription/models/renewal/use-renewal-sheet.ts
index 8a04614..b700bf5 100644
--- a/platforms/market/src/features/subscription/models/renewal/use-renewal-sheet.ts
+++ b/platforms/market/src/features/subscription/models/renewal/use-renewal-sheet.ts
@@ -4,6 +4,7 @@ import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ROUTES } from '../../../../app/navigation/navigation';
+import { CHECKOUT_ERROR_CODES, checkoutErrorCode } from '../../../checkout';
import { isConnectionError, showActionError } from '../../../../shared/utils';
import { startRenewal } from '../../actions/start-renewal';
import {
@@ -22,7 +23,8 @@ import type {
* 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
* 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({
subscriptionId,
@@ -55,6 +57,9 @@ export function useRenewalSheet({
}, []);
const reload = () => {
+ void queryClient.invalidateQueries({
+ queryKey: subscriptionKeys.preview(subscriptionId),
+ });
void queryClient.invalidateQueries({
queryKey: subscriptionKeys.detail(subscriptionId),
});
@@ -89,6 +94,11 @@ export function useRenewalSheet({
} catch (error) {
setPhase('idle');
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, {
t,
failedMessage:
diff --git a/platforms/market/src/index.ts b/platforms/market/src/index.ts
index 81ab5d0..68614ed 100644
--- a/platforms/market/src/index.ts
+++ b/platforms/market/src/index.ts
@@ -246,7 +246,6 @@ export {
PRICING_EVENTS,
pricingKeys,
pricingRepository,
- PROMO_FLOOR_TOMAN_PER_MONTH,
savePricing,
usePricingCardPart,
usePricingPage,
@@ -435,3 +434,28 @@ export {
useViewerStatus,
} from './stores/auth';
export type { AuthState, Session, ViewerStatus } from './stores/auth';
+export {
+ acceptAgreement,
+ LEGAL_ERROR_CODES,
+ LEGAL_EVENTS,
+ legalKeys,
+ legalRepository,
+ parseLegalMarkdown,
+ useAgreementAcceptance,
+ useAgreementGate,
+ useLegalDocument,
+} from './features/legal';
+export type {
+ AcceptDocumentArgs,
+ AcceptedDocumentPayload,
+ AgreementGateModel,
+ AgreementGateView,
+ LegalAcceptanceEntity,
+ LegalAcceptancePayload,
+ LegalBlock,
+ LegalDocumentEntity,
+ LegalDocumentKey,
+ LegalDocumentModel,
+ LegalDocumentPayload,
+ LegalInline,
+} from './features/legal';
diff --git a/platforms/market/src/shared/labels/content-labels.tsx b/platforms/market/src/shared/labels/content-labels.tsx
index ef9d758..3a7faed 100644
--- a/platforms/market/src/shared/labels/content-labels.tsx
+++ b/platforms/market/src/shared/labels/content-labels.tsx
@@ -79,10 +79,14 @@ export function predictionCardLabels(t: ContentT): PredictionCardLabels {
toFinalTarget: t('prediction.to-final-target'),
toStop: t('prediction.to-stop'),
riskReward: t('prediction.risk-reward'),
+ riskRewardRange: (worst, best) =>
+ t('prediction.risk-reward-range', { worst, best }),
levels: {
stop: t('prediction.levels.stop'),
entry: t('prediction.levels.entry'),
base: t('prediction.levels.base'),
+ range: t('prediction.levels.range'),
+ entryRange: t('prediction.levels.entry-range'),
target,
finalTarget: t('prediction.levels.final-target'),
close: t('prediction.levels.close'),
@@ -171,6 +175,11 @@ export function creatorStatsLabels(t: ContentT): CreatorStatsLabels {
loss: t('stats.outcomes.loss'),
breakeven: t('stats.outcomes.breakeven'),
},
+ splitOutcomes: {
+ win: t('stats.split-outcomes.win'),
+ loss: t('stats.split-outcomes.loss'),
+ breakeven: t('stats.split-outcomes.breakeven'),
+ },
splitLegend: (count, outcome) => (
<>
{count} {outcome}
diff --git a/platforms/market/src/shared/labels/creator-stats-labels.test.ts b/platforms/market/src/shared/labels/creator-stats-labels.test.ts
new file mode 100644
index 0000000..0e2730d
--- /dev/null
+++ b/platforms/market/src/shared/labels/creator-stats-labels.test.ts
@@ -0,0 +1,20 @@
+import { describe, expect, it } from 'vitest';
+
+import content from '../locales/fa/content.json';
+
+// `wins`, `losses` and `breakeven` now hold «هدف», «حد ضرر» and «پایان مهلت»: the channel's split
+// must say so, while the curve still reads each signal's return.
+describe('channel stats copy', () => {
+ it('names the split by how signals ended', () => {
+ expect(content.stats['split-outcomes']).toEqual({
+ win: 'رسیده به هدف',
+ loss: 'خورده به حد ضرر',
+ breakeven: 'پایان مهلت',
+ });
+ expect(content.stats['split-sentence']).not.toContain('سربهسر');
+ });
+
+ it('keeps the curve on the return at close', () => {
+ expect(content.stats.outcomes.breakeven).toBe('سربهسر');
+ });
+});
diff --git a/platforms/market/src/shared/locales/fa/account.json b/platforms/market/src/shared/locales/fa/account.json
index db5ac17..baec24f 100644
--- a/platforms/market/src/shared/locales/fa/account.json
+++ b/platforms/market/src/shared/locales/fa/account.json
@@ -21,7 +21,9 @@
"install-mobile": "دسترسی سریع از صفحه اصلی گوشی",
"install-desktop": "دسترسی سریع، بدون نوار مرورگر",
"support": "پشتیبانی",
- "terms": "قوانین لومینا"
+ "terms": "قوانین و مقررات لومینا",
+ "agreement": "توافقنامه تحلیلگر",
+ "agreement-record": "نسخه {{version}} · پذیرفتهشده در {{date}}"
},
"sign-out": "خروج از حساب",
"version": "لومینا · نسخه 1٫0 بتا"
@@ -97,10 +99,10 @@
"description": "کانالهایی که مشترک هستید"
},
"newPredictions": {
- "label": "پیشبینیهای تازه"
+ "label": "سیگنالهای تازه"
},
"predictionClosed": {
- "label": "بسته شدن پیشبینیها",
+ "label": "بسته شدن سیگنالها",
"description": "رسیدن به هدف، حد ضرر یا پایان افق"
},
"followedAnalysts": {
@@ -110,7 +112,7 @@
},
"sms": {
"newPredictions": {
- "label": "پیشبینیهای تازه"
+ "label": "سیگنالهای تازه"
},
"subscriptionReminder": {
"label": "یادآوری پایان اشتراک",
@@ -131,7 +133,7 @@
"label": "مشترک تازه"
},
"predictionClosed": {
- "label": "بسته شدن خودکار پیشبینیها",
+ "label": "بسته شدن خودکار سیگنالها",
"description": "رسیدن به هدف، حد ضرر یا پایان افق"
},
"capacityRequestResult": {
@@ -179,7 +181,7 @@
"body": "از این به بعد از آیکون لومینا روی دسکتاپ وارد شوید."
}
},
- "notifications": "دریافت اعلان پستها و پیشبینیها",
+ "notifications": "دریافت اعلان پستها و سیگنالها",
"no-browser-bar": "بدون نوار مرورگر",
"action": "نصب اپلیکیشن",
"ios": {
diff --git a/platforms/market/src/shared/locales/fa/auth.json b/platforms/market/src/shared/locales/fa/auth.json
index 85160ec..97163cd 100644
--- a/platforms/market/src/shared/locales/fa/auth.json
+++ b/platforms/market/src/shared/locales/fa/auth.json
@@ -1,4 +1,5 @@
{
+ "rules-caption": "ورود یا ثبتنام به معنی پذیرش قوانین و مقررات لومینا است.",
"header": {
"brand": "لومینا",
"home": "صفحه اصلی لومینا",
@@ -93,7 +94,7 @@
"investor": "سرمایهگذار",
"investor-description": "تحلیلگران را با کارنامهشان مقایسه میکنم و در کانالشان مشترک میشوم.",
"creator": "تحلیلگر",
- "creator-description": "تحلیل و پیشبینی منتشر میکنم و از اشتراک کانالم درآمد دارم.",
+ "creator-description": "تحلیل و سیگنال منتشر میکنم و از اشتراک کانالم درآمد دارم.",
"note": "نوع حساب پس از ثبتنام قابل تغییر نیست.",
"submit": "ادامه"
},
@@ -115,7 +116,6 @@
"title": "اطلاعات حساب",
"description": "نام شما فقط در اطلاعات کاربری دیده میشود؛ دیگران شما را با نام کاربری میشناسند.",
"submit": "ساخت حساب",
- "terms-before": "با ساخت حساب، ",
"failed": "حساب ساخته نشد",
"network-title": "خطا در ثبت اطلاعات.",
"success": "حساب شما ساخته شد."
@@ -129,15 +129,10 @@
"private-title": "اطلاعات هویتی",
"private-description": "محرمانه است و فقط برای تأیید هویت بررسی میشود.",
"submit": "ثبت و ادامه",
- "terms-before": "با ثبت اطلاعات، ",
"failed": "اطلاعات ثبت نشد",
"success": "اطلاعات شما دریافت شد. پس از تأیید، حساب شما فعال میشود.",
"username-placeholder": "ali_trader"
},
- "terms-link": "قوانین لومینا",
- "terms-after": " را میپذیرید.",
- "rules-title": "قوانین لومینا",
- "rules-close": "متوجه شدم",
"fields": {
"first-name": "نام",
"first-name-placeholder": "مثال: علی",
@@ -242,7 +237,7 @@
"title": "پیشنمایش پروفایل",
"live": "پیشنمایش زنده — سرمایهگذاران این را میبینند",
"channel": "کانال در لومینا",
- "note": "آمار و کارنامه پیشبینیها پس از اولین پیشبینیهای شما در همین صفحه نمایش داده میشود.",
+ "note": "آمار و کارنامه سیگنالها پس از اولین سیگنالهای شما در همین صفحه نمایش داده میشود.",
"close": "بستن پیشنمایش"
},
"done": {
diff --git a/platforms/market/src/shared/locales/fa/channel.json b/platforms/market/src/shared/locales/fa/channel.json
index 377155c..1baff73 100644
--- a/platforms/market/src/shared/locales/fa/channel.json
+++ b/platforms/market/src/shared/locales/fa/channel.json
@@ -1,7 +1,7 @@
{
"meta": {
"title": "@{{username}}",
- "description": "کانال @{{username}} در لومینا: پستها و پیشبینیهای ثبتشده، با کارنامهای که پیش از اشتراک میبینید.",
+ "description": "کانال @{{username}} در لومینا: پستها و سیگنالهای ثبتشده، با کارنامهای که پیش از اشتراک میبینید.",
"post-title": "پست @{{username}}",
"post-missing-title": "پست پیدا نشد",
"unavailable-title": "کانال در دسترس نیست"
@@ -33,7 +33,7 @@
"subscribe": "اشتراک",
"subscribed": "مشترک هستید",
"follow": "دنبال کردن",
- "unfollow": "دنبال نکردن",
+ "following": "دنبال میکنید",
"unfollow-frozen": "تا زمانی که اشتراک این کانال فعال است، امکان لغو دنبالکردن وجود ندارد.",
"pending": "پرداخت در حال بررسی",
"pending-description": "پرداخت شما در حال بررسی است. پس از تأیید، اشتراک شما فعال میشود. اگر پرداخت انجام شده و اشتراک فعال نشد، با پشتیبانی در ارتباط باشید.",
@@ -88,8 +88,8 @@
}
},
"stats": {
- "loading": "در حال بارگذاری عملکرد پیشبینیها…",
- "error-title": "عملکرد پیشبینیها بارگذاری نشد",
+ "loading": "در حال بارگذاری عملکرد سیگنالها…",
+ "error-title": "عملکرد سیگنالها بارگذاری نشد",
"error-description": "بقیه کانال در دسترس است. این بخش را دوباره بارگذاری کنید."
},
"feed": {
@@ -100,13 +100,13 @@
"no-subscribers": "این پست تا پیوستن نخستین مشترک، برای همه قفل میماند.",
"empty": {
"title": "این کانال هنوز پستی منتشر نکرده است",
- "description": "با دنبال کردن، از پستها و پیشبینیهای تازه باخبر میشوید."
+ "description": "با دنبال کردن، از پستها و سیگنالهای تازه باخبر میشوید."
},
"own-empty": {
"title": "هنوز پستی منتشر نکردهاید",
- "description": "اولین پست یا پیشبینی خود را منتشر کنید تا دنبالکنندگان آن را ببینند.",
+ "description": "اولین پست یا سیگنال خود را منتشر کنید تا دنبالکنندگان آن را ببینند.",
"post": "پست جدید",
- "prediction": "پیشبینی جدید"
+ "prediction": "سیگنال جدید"
}
},
"post": {
@@ -142,7 +142,7 @@
"subtitle": "کد شما ساخته شد: {{code}}"
},
"prediction": {
- "title": "اولین پیشبینی را منتشر کنید",
+ "title": "اولین سیگنال را منتشر کنید",
"subtitle": "کارنامه عمومی شما از همینجا شروع میشود."
},
"cta": "تعیین قیمتها",
diff --git a/platforms/market/src/shared/locales/fa/common.json b/platforms/market/src/shared/locales/fa/common.json
index 9140b4c..8bee224 100644
--- a/platforms/market/src/shared/locales/fa/common.json
+++ b/platforms/market/src/shared/locales/fa/common.json
@@ -1,7 +1,7 @@
{
"app": {
"name": "لومینا",
- "description": "پیشبینیهای ساختاریافته و ثبتشدهی تحلیلگران مالی ایرانی، با کارنامهای که پیش از اشتراک میبینید."
+ "description": "سیگنالهای ساختاریافته و ثبتشدهی تحلیلگران مالی ایرانی، با کارنامهای که پیش از اشتراک میبینید."
},
"toaster": "اعلانها",
"toast-close": "بستن اعلان",
@@ -67,7 +67,7 @@
"publish": {
"menu": "انتشار",
"post": "پست جدید",
- "prediction": "پیشبینی جدید",
+ "prediction": "سیگنال جدید",
"close": "بستن",
"pending": {
"title": "در انتظار تأیید",
diff --git a/platforms/market/src/shared/locales/fa/content.json b/platforms/market/src/shared/locales/fa/content.json
index 0a67c74..2cdb40e 100644
--- a/platforms/market/src/shared/locales/fa/content.json
+++ b/platforms/market/src/shared/locales/fa/content.json
@@ -38,7 +38,7 @@
"cancel": "انصراف",
"deleted": "پست حذف شد.",
"failed": "خطا در حذف پست.",
- "prediction-locked": "پیشبینی پس از انتشار قابل حذف نیست."
+ "prediction-locked": "سیگنال پس از انتشار قابل حذف نیست."
},
"access-via": "دسترسی از طریق اشتراک {{period}}",
"access-ended": "اشتراک شما پایان یافت. این پست تا بارگذاری بعدی باز میماند."
@@ -73,7 +73,9 @@
"target-n": "هدف {{n}}",
"final-target": "هدف نهایی",
"close": "بستهشدن",
- "horizon": "افق"
+ "horizon": "افق",
+ "range": "بازه",
+ "entry-range": "ورود (بازه)"
},
"ladder": {
"level": "سطح",
@@ -86,7 +88,7 @@
"not-triggered": "فعال نشد"
},
"range": {
- "label": "محدوده پیشبینی: {{values}}",
+ "label": "محدوده سیگنال: {{values}}",
"stop": "حد ضرر {{price}}",
"entry": "ورود {{price}}",
"target": "هدف {{price}}",
@@ -101,7 +103,7 @@
"close-prediction": "بستن زودهنگام",
"pending-close": {
"title": "در انتظار تأیید بستهشدن",
- "frozen": "این پیشبینی بهزودی بهصورت خودکار بسته میشود.",
+ "frozen": "این سیگنال بهزودی بهصورت خودکار بسته میشود.",
"target": "هدف نهایی زده شد",
"target-n": "هدف {{n}} زده شد",
"stop": "حد ضرر فعال شد",
@@ -123,30 +125,36 @@
"note": "پس از انتشار، غیرقابل ویرایش و حذف"
},
"locked": {
- "title": "پیشبینی پریمیوم",
+ "title": "سیگنال پریمیوم",
"description": "دارایی، جهت، ورود، اهداف و حد ضرر پنهان است.",
"hidden": "پنهان",
"content": "محتوای پریمیوم"
- }
+ },
+ "risk-reward-range": "{{worst}} تا {{best}}"
},
"stats": {
- "title": "عملکرد پیشبینیها",
+ "title": "عملکرد سیگنالها",
"view-record": "مشاهده کارنامه کامل",
"win-rate": "نرخ موفقیت",
- "closed-count": "از {{n}} پیشبینی بستهشده",
+ "closed-count": "از {{n}} سیگنال بستهشده",
"outcomes": {
"win": "موفق",
"loss": "ناموفق",
"breakeven": "سربهسر"
},
- "split-sentence": "{{win}} موفق، {{breakeven}} سربهسر، {{loss}} ناموفق",
+ "split-outcomes": {
+ "win": "رسیده به هدف",
+ "loss": "خورده به حد ضرر",
+ "breakeven": "پایان مهلت"
+ },
+ "split-sentence": "{{win}} رسیده به هدف، {{breakeven}} پایان مهلت، {{loss}} خورده به حد ضرر",
"avg-roi": "بازدهی میانگین",
- "total": "کل پیشبینیها",
- "active": "پیشبینیهای فعال",
+ "total": "کل سیگنالها",
+ "active": "سیگنالهای فعال",
"trend-title": "روند دقت",
- "trend-window": "{{n}} پیشبینی اخیر",
+ "trend-window": "{{n}} سیگنال اخیر",
"tally": "{{wins}} از {{total}} موفق",
- "curve-label": "منحنی نتیجه {{n}} پیشبینی اخیر، از قدیمیترین به جدیدترین: {{outcomes}}. هر موفق یک پله بالا، هر ناموفق یک پله پایین.",
+ "curve-label": "منحنی نتیجه {{n}} سیگنال اخیر، از قدیمیترین به جدیدترین: {{outcomes}}. هر موفق یک پله بالا، هر ناموفق یک پله پایین.",
"newest-point": "{{outcome}} (جدیدترین)",
"older": "قدیمیتر",
"newest": "جدیدترین",
@@ -222,7 +230,7 @@
"retry": "تلاش مجدد",
"not-editable": {
"title": "این پست قابل ویرایش نیست",
- "description": "پیشبینیها پس از انتشار ثابت میمانند و پستها فقط تا ۱۵ دقیقه پس از انتشار ویرایش میشوند.",
+ "description": "سیگنالها پس از انتشار ثابت میمانند و پستها فقط تا ۱۵ دقیقه پس از انتشار ویرایش میشوند.",
"back": "بازگشت به کانال"
}
},
diff --git a/platforms/market/src/shared/locales/fa/dashboard.json b/platforms/market/src/shared/locales/fa/dashboard.json
index a160e69..eddd3d7 100644
--- a/platforms/market/src/shared/locales/fa/dashboard.json
+++ b/platforms/market/src/shared/locales/fa/dashboard.json
@@ -10,7 +10,7 @@
"label": "تحلیلگرانی که دنبال میکنید",
"loading": "در حال بارگذاری دنبالشدهها…",
"error": "خطا در بارگذاری لیست. دوباره تلاش کنید.",
- "unfollow": "دنبال نکردن @{{username}}",
+ "unfollow": "دنبال میکنید @{{username}}",
"unavailable": "در دسترس نیست",
"suspended": "کانال این تحلیلگر موقتاً در دسترس نیست.",
"more": "نمایش تحلیلگران بیشتر",
@@ -58,6 +58,7 @@
"error": "دورههای اشتراک بارگذاری نشد. دوباره تلاش کنید.",
"current": "شما تا {{date}} اشتراک فعال دارید.",
"tiers": "دوره اشتراک",
+ "none-on-sale": "این کانال در حال حاضر طرحی برای فروش ندارد. پس از اصلاح قیمتها میتوانید اشتراک را تمدید کنید.",
"from": "تمدید از:",
"start": "شروع از:",
"today": "امروز — {{date}}",
@@ -135,7 +136,7 @@
},
"creator-tabs": {
"plans": "طرحهای اشتراک",
- "predictions": "پیشبینیها",
+ "predictions": "سیگنالها",
"finance": "مالی"
},
"plans": {
diff --git a/platforms/market/src/shared/locales/fa/errors.json b/platforms/market/src/shared/locales/fa/errors.json
index a346662..55e5488 100644
--- a/platforms/market/src/shared/locales/fa/errors.json
+++ b/platforms/market/src/shared/locales/fa/errors.json
@@ -102,6 +102,7 @@
"code-invalid": "کد دعوت واردشده معتبر نیست.",
"already-active": "اشتراک شما در این کانال همین حالا فعال است.",
"payment-pending": "پرداخت دیگری برای این کانال در حال بررسی است؛ تا روشن شدن نتیجه آن، پرداخت تازهای شروع نمیشود.",
- "unavailable": "این کانال در حال حاضر در دسترس نیست."
+ "unavailable": "این کانال در حال حاضر در دسترس نیست.",
+ "tier-unavailable": "این طرح در حال حاضر در فروش نیست. طرح دیگری را انتخاب کنید."
}
}
diff --git a/platforms/market/src/shared/locales/fa/home.json b/platforms/market/src/shared/locales/fa/home.json
index 93a081c..1813417 100644
--- a/platforms/market/src/shared/locales/fa/home.json
+++ b/platforms/market/src/shared/locales/fa/home.json
@@ -29,7 +29,7 @@
"verified": "تأییدشده",
"markets": "بازارهای تخصصی",
"win-rate": "نرخ موفقیت",
- "predictions": "پیشبینی",
+ "predictions": "سیگنال",
"avg-roi": "میانگین بازده",
"no-record": "کارنامه عمومی هنوز فعال نشده است.",
"followers": "{{followers}} دنبالکننده",
diff --git a/platforms/market/src/shared/locales/fa/landing.json b/platforms/market/src/shared/locales/fa/landing.json
index d5e6c88..0fb5579 100644
--- a/platforms/market/src/shared/locales/fa/landing.json
+++ b/platforms/market/src/shared/locales/fa/landing.json
@@ -16,13 +16,13 @@
},
"sample": "نمونه",
"hero": {
- "kicker": "تحلیلگران احرازشده، پیشبینیهای ثبتشده",
+ "kicker": "تحلیلگران احرازشده، سیگنالهای ثبتشده",
"title": "تحلیل بازار، با کارنامهای که پاک نمیشود",
- "lead": "در لومینا تحلیلگران طلا، فارکس، کریپتو و بورس پیشبینیهایشان را با قیمت ورود، هدف و افق زمانی ثبت میکنند و نتیجهی هر پیشبینی در کارنامهشان میماند. پیش از اشتراک، کارنامه را ببینید.",
+ "lead": "در لومینا تحلیلگران طلا، فارکس، کریپتو و بورس سیگنالهایشان را با قیمت ورود، هدف و افق زمانی ثبت میکنند و نتیجهی هر سیگنال در کارنامهشان میماند. پیش از اشتراک، کارنامه را ببینید.",
"register": "ثبتنام رایگان",
"how": "چطور کار میکند",
"note": "ثبتنام با شماره موبایل. دنبال کردن تحلیلگران رایگان است.",
- "image-alt": "کانال یک تحلیلگر در لومینا: کارنامهی پیشبینیها و یک پیشبینی موفق طلا که ثبتشده و غیرقابل ویرایش است.",
+ "image-alt": "کانال یک تحلیلگر در لومینا: کارنامهی سیگنالها و یک سیگنال موفق طلا که ثبتشده و غیرقابل ویرایش است.",
"image-caption": "تصویر نمونه از لومینا؛ نام و عددها ساختگی است."
},
"trust": {
@@ -33,7 +33,7 @@
"description": "هویت هر تحلیلگر بررسی میشود"
},
"immutable": {
- "title": "پیشبینی ثبتشده",
+ "title": "سیگنال ثبتشده",
"description": "بدون ویرایش و حذف"
},
"gateway": {
@@ -49,29 +49,29 @@
"markets": {
"kicker": "بازارها",
"title": "بازار شما، تحلیلگر شما",
- "lead": "تحلیلگران لومینا در چند بازار فعالاند و هر پیشبینی بازار و نماد مشخصی دارد.",
+ "lead": "تحلیلگران لومینا در چند بازار فعالاند و هر سیگنال بازار و نماد مشخصی دارد.",
"tabs": "بازارها",
"symbols": "نمونهی نمادها",
"panels": {
"gold": {
- "description": "پیشبینی برای انس جهانی، طلای ۱۸ عیار و سکه؛ هر کدام با قیمت ورود، هدف، حد ضرر و افق زمانی.",
+ "description": "سیگنال برای انس جهانی، طلای ۱۸ عیار و سکه؛ هر کدام با قیمت ورود، هدف، حد ضرر و افق زمانی.",
"symbols": ["XAUUSD", "طلای ۱۸ عیار", "سکه امامی"],
- "caption": "نمونهی یک پیشبینی موفق طلا؛ دادهها ساختگی است."
+ "caption": "نمونهی یک سیگنال موفق طلا؛ دادهها ساختگی است."
},
"forex": {
- "description": "جفتارزهای اصلی بازار جهانی؛ هر پیشبینی جهت خرید یا فروش و سطحهای قیمتی مشخص دارد.",
+ "description": "جفتارزهای اصلی بازار جهانی؛ هر سیگنال جهت خرید یا فروش و سطحهای قیمتی مشخص دارد.",
"symbols": ["EURUSD", "GBPUSD", "USDJPY"],
- "caption": "نمونهی یک پیشبینی سربهسر فارکس؛ دادهها ساختگی است."
+ "caption": "نمونهی یک سیگنال سربهسر فارکس؛ دادهها ساختگی است."
},
"crypto": {
- "description": "بیتکوین، اتریوم و رمزارزهای پرمعامله؛ در پیشبینیهای باز، فاصله تا هدف و تا حد ضرر همیشه پیداست.",
+ "description": "بیتکوین، اتریوم و رمزارزهای پرمعامله؛ در سیگنالهای باز، فاصله تا هدف و تا حد ضرر همیشه پیداست.",
"symbols": ["BTCUSDT", "ETHUSDT", "SOLUSDT"],
- "caption": "نمونهی یک پیشبینی باز کریپتو؛ دادهها ساختگی است."
+ "caption": "نمونهی یک سیگنال باز کریپتو؛ دادهها ساختگی است."
},
"equities": {
- "description": "شاخص کل و سهمهای بورس تهران؛ نتیجهی هر پیشبینی، سود یا زیان، در کارنامه میماند.",
+ "description": "شاخص کل و سهمهای بورس تهران؛ نتیجهی هر سیگنال، سود یا زیان، در کارنامه میماند.",
"symbols": ["شاخص کل", "فولاد", "شستا"],
- "caption": "نمونهی یک پیشبینی موفق بورس؛ دادهها ساختگی است."
+ "caption": "نمونهی یک سیگنال موفق بورس؛ دادهها ساختگی است."
}
}
},
@@ -88,7 +88,7 @@
"verified": "تأییدشده",
"markets": "بازارهای تخصصی",
"win-rate": "نرخ موفقیت",
- "predictions": "پیشبینی",
+ "predictions": "سیگنال",
"avg-roi": "میانگین بازده",
"followers": "{{followers}} دنبالکننده",
"view": "مشاهده کانال"
@@ -97,11 +97,11 @@
"record": {
"kicker": "کارنامه",
"title": "کارنامهای که میشود بررسی کرد",
- "lead": "درصد موفقیت، میانگین بازده و روند دقت هر تحلیلگر از پیشبینیهای ثبتشدهاش حساب میشود؛ ناموفقها هم.",
+ "lead": "درصد موفقیت، میانگین بازده و روند دقت هر تحلیلگر از سیگنالهای ثبتشدهاش حساب میشود؛ ناموفقها هم.",
"facts": {
"immutable": {
"title": "غیرقابل ویرایش و حذف",
- "description": "هر پیشبینی با زمان ثبتش منتشر میشود و پس از انتشار قابل ویرایش یا حذف نیست."
+ "description": "هر سیگنال با زمان ثبتش منتشر میشود و پس از انتشار قابل ویرایش یا حذف نیست."
},
"outcome": {
"title": "نتیجه از روی بازده",
@@ -109,15 +109,15 @@
},
"public": {
"title": "نتیجه برای همه پیداست",
- "description": "نتیجهی پیشبینیهای ویژه هم برای همه دیده میشود؛ فقط جزئیاتشان مخصوص مشترکان است."
+ "description": "نتیجهی سیگنالهای ویژه هم برای همه دیده میشود؛ فقط جزئیاتشان مخصوص مشترکان است."
},
"threshold": {
"title": "کارنامهی معنادار",
- "description": "کارنامه پس از یک ماه فعالیت و ثبت تعداد کافی پیشبینی بستهشده نمایش داده میشود تا عددهایش معنادار باشند."
+ "description": "کارنامه پس از یک ماه فعالیت و ثبت تعداد کافی سیگنال بستهشده نمایش داده میشود تا عددهایش معنادار باشند."
}
},
"caption": "نمونهی کارنامهی یک تحلیلگر، با دادههای ساختگی.",
- "caption-wide": "نمونهی کارنامهی یک تحلیلگر و یکی از پیشبینیهای ناموفقش، با دادههای ساختگی."
+ "caption-wide": "نمونهی کارنامهی یک تحلیلگر و یکی از سیگنالهای ناموفقش، با دادههای ساختگی."
},
"how": {
"kicker": "چطور کار میکند",
@@ -129,18 +129,18 @@
},
"judge": {
"title": "تحلیلگران را بسنجید",
- "description": "کانال تحلیلگران را ببینید، رایگان دنبالشان کنید و کارنامهی پیشبینیهایشان را بررسی کنید."
+ "description": "کانال تحلیلگران را ببینید، رایگان دنبالشان کنید و کارنامهی سیگنالهایشان را بررسی کنید."
},
"subscribe": {
"title": "مشترک شوید",
- "description": "برای پستها و پیشبینیهای ویژه، دورهای از ماهانه تا سالانه را انتخاب کنید و با درگاه بانکی بپردازید. دسترسی بلافاصله باز میشود."
+ "description": "برای پستها و سیگنالهای ویژه، دورهای از ماهانه تا سالانه را انتخاب کنید و با درگاه بانکی بپردازید. دسترسی بلافاصله باز میشود."
}
}
},
"plans": {
"kicker": "اشتراک",
"title": "رایگان دنبال کنید؛ برای تحلیلهای ویژه مشترک شوید",
- "lead": "پستهای رایگان هر تحلیلگر برای همه باز است. پستها و پیشبینیهای ویژه مخصوص مشترکان کانال اوست.",
+ "lead": "پستهای رایگان هر تحلیلگر برای همه باز است. پستها و سیگنالهای ویژه مخصوص مشترکان کانال اوست.",
"facts": {
"periods": {
"title": "دورههای اشتراک",
@@ -181,18 +181,18 @@
},
"record": {
"title": "کارنامهای که با شما میماند",
- "description": "هر پیشبینی ثبتشده به کارنامهتان اضافه میشود؛ اعتباری که با بسته شدن یک کانال در پیامرسانها از بین نمیرود."
+ "description": "هر سیگنال ثبتشده به کارنامهتان اضافه میشود؛ اعتباری که با بسته شدن یک کانال در پیامرسانها از بین نمیرود."
},
"dashboard": {
"title": "داشبورد کسبوکار",
- "description": "مشترکان فعال، درآمد، تراکنشها و خلاصهی عملکرد پیشبینیها در یک نگاه."
+ "description": "مشترکان فعال، درآمد، تراکنشها و خلاصهی عملکرد سیگنالها در یک نگاه."
}
},
"apply": "درخواست عضویت تحلیلگر",
"apply-note": "حساب تحلیلگر پس از احراز هویت و تأیید تیم لومینا فعال میشود.",
"sample": {
"name": "سارا مرادی",
- "bio": "تحلیل تکنیکال طلا و ارز، با پیشبینیهای هفتگی.",
+ "bio": "تحلیل تکنیکال طلا و ارز، با سیگنالهای هفتگی.",
"prices": "قیمت طرحها",
"currency": "تومان"
},
@@ -203,23 +203,23 @@
"items": {
"follow-cost": {
"question": "دنبال کردن تحلیلگران هزینه دارد؟",
- "answer": "نه. دنبال کردن رایگان است و پستهای رایگان هر تحلیلگر را میبینید. برای پستها و پیشبینیهای ویژه باید در کانال او مشترک شوید."
+ "answer": "نه. دنبال کردن رایگان است و پستهای رایگان هر تحلیلگر را میبینید. برای پستها و سیگنالهای ویژه باید در کانال او مشترک شوید."
},
"invite-code": {
"question": "برای اشتراک به کد دعوت نیاز دارم؟",
"answer": "بله. ثبتنام و دنبال کردن آزاد است، اما در دورهی آزمایشی ظرفیت هر کانال محدود است و اشتراک با کد دعوت همان تحلیلگر انجام میشود. کد را از خود تحلیلگر میگیرید؛ اگر با لینک دعوت او وارد شوید، کد خودش در صفحهی خرید اشتراک ثبت میشود."
},
"outcome": {
- "question": "نتیجهی پیشبینیها چطور مشخص میشود؟",
- "answer": "هر پیشبینی با دارایی، جهت، قیمت ورود، هدف، حد ضرر و افق زمانی ثبت میشود. لومینا آن را خودش میبندد: وقتی قیمت به هدف نهایی یا حد ضرر برسد یا افق تمام شود، با قیمتی که از یک منبع مشخص ثبت میشود. تحلیلگر فقط میتواند زودتر ببندد، آن هم با قیمت لحظهای بازار؛ قیمت بستهشدن را هیچکس دستی وارد نمیکند. بازده از قیمت ورود تا قیمت بستهشدن حساب میشود: مثبت یعنی موفق، صفر یعنی سربهسر و منفی یعنی ناموفق. نتیجه نهایی است و در کارنامه میماند."
+ "question": "نتیجهی سیگنالها چطور مشخص میشود؟",
+ "answer": "هر سیگنال با دارایی، جهت، قیمت ورود، هدف، حد ضرر و افق زمانی ثبت میشود. لومینا آن را خودش میبندد: وقتی قیمت به هدف نهایی یا حد ضرر برسد یا افق تمام شود، با قیمتی که از یک منبع مشخص ثبت میشود. تحلیلگر فقط میتواند زودتر ببندد، آن هم با قیمت لحظهای بازار؛ قیمت بستهشدن را هیچکس دستی وارد نمیکند. بازده از قیمت ورود تا قیمت بستهشدن حساب میشود: مثبت یعنی موفق، صفر یعنی سربهسر و منفی یعنی ناموفق. نتیجه نهایی است و در کارنامه میماند."
},
"delete-loss": {
- "question": "تحلیلگر میتواند پیشبینی ناموفق را پاک کند؟",
- "answer": "نه. پیشبینی پس از انتشار نه ویرایش میشود و نه حذف، و نتیجهی بستهشدنش هم نهایی است."
+ "question": "تحلیلگر میتواند سیگنال ناموفق را پاک کند؟",
+ "answer": "نه. سیگنال پس از انتشار نه ویرایش میشود و نه حذف، و نتیجهی بستهشدنش هم نهایی است."
},
"hidden-record": {
"question": "چرا کارنامهی بعضی تحلیلگران را نمیبینم؟",
- "answer": "کارنامه پس از یک ماه فعالیت و ثبت تعداد کافی پیشبینی بستهشده نمایش داده میشود تا عددهایش معنادار باشند. تحلیلگر هم میتواند نمایش کارنامهاش را خاموش کند."
+ "answer": "کارنامه پس از یک ماه فعالیت و ثبت تعداد کافی سیگنال بستهشده نمایش داده میشود تا عددهایش معنادار باشند. تحلیلگر هم میتواند نمایش کارنامهاش را خاموش کند."
},
"payment": {
"question": "پرداخت چطور انجام میشود؟",
diff --git a/platforms/market/src/shared/locales/fa/legal.json b/platforms/market/src/shared/locales/fa/legal.json
new file mode 100644
index 0000000..223be07
--- /dev/null
+++ b/platforms/market/src/shared/locales/fa/legal.json
@@ -0,0 +1,40 @@
+{
+ "document": {
+ "loading": "در حال بارگذاری متن…",
+ "footer": "نسخه {{version}} · آخرین بهروزرسانی: {{date}}",
+ "failed": "متن بارگذاری نشد"
+ },
+ "dialog": {
+ "close": "متوجه شدم",
+ "rules-title": "قوانین و مقررات لومینا",
+ "agreement-title": "توافقنامه تحلیلگر"
+ },
+ "subscription": {
+ "hours": "زمان پاسخگویی: {{hours}}"
+ },
+ "agreement": {
+ "record": "نسخه {{version}} · پذیرفتهشده در {{date}}، ساعت {{time}}",
+ "kyc": {
+ "title": "توافقنامه تحلیلگر",
+ "text": "پیش از وارد کردن اطلاعات هویتی، توافقنامه تحلیلگر را بخوانید و بپذیرید.",
+ "read": "خواندن متن",
+ "checkbox": "توافقنامه تحلیلگر را خواندهام و میپذیرم.",
+ "frozen": "برای ادامه، توافقنامه تحلیلگر را بپذیرید.",
+ "changed": "توافقنامه تحلیلگر بهروزرسانی شد. نسخهٔ جدید را بخوانید و بپذیرید.",
+ "failed": "متن توافقنامه بارگذاری نشد."
+ },
+ "gate": {
+ "title": "توافقنامه تحلیلگر بهروزرسانی شد",
+ "body": "برای ادامه کار با لومینا، نسخهٔ جدید توافقنامه را بخوانید و بپذیرید. تا پیش از پذیرش، انتشار و دسترسی به داشبورد ممکن نیست.",
+ "changes": "تغییرات مهم نسخه {{version}}",
+ "read": "خواندن متن کامل",
+ "back": "بازگشت به خلاصه تغییرات",
+ "checkbox": "نسخهٔ جدید توافقنامه تحلیلگر را خواندهام و میپذیرم.",
+ "accept": "پذیرش و ادامه",
+ "frozen": "ابتدا توافقنامه را بپذیرید.",
+ "sign-out": "خروج از حساب",
+ "accepted": "توافقنامه پذیرفته شد.",
+ "failed": "پذیرش ثبت نشد"
+ }
+ }
+}
diff --git a/platforms/market/src/shared/locales/fa/notifications.json b/platforms/market/src/shared/locales/fa/notifications.json
index 1413a82..382b0cc 100644
--- a/platforms/market/src/shared/locales/fa/notifications.json
+++ b/platforms/market/src/shared/locales/fa/notifications.json
@@ -4,7 +4,7 @@
"loading": "در حال بارگذاری اعلانها…",
"error": "خطا در بارگذاری اعلانها. دوباره تلاش کنید.",
"empty": "اعلانی وجود ندارد.",
- "empty-analyst": "نتیجه پیشبینیها، مشترکان جدید، واریزها و خبرهای حساب شما اینجا میآید.",
+ "empty-analyst": "نتیجه سیگنالها، مشترکان جدید، واریزها و خبرهای حساب شما اینجا میآید.",
"empty-category": "در این دسته اعلانی نیست.",
"bell": "اعلانها",
"bell-unread": "اعلانها، {{count}} خواندهنشده",
@@ -24,7 +24,7 @@
"categories": {
"label": "دسته اعلانها",
"all": "همه",
- "predictions": "پیشبینیها",
+ "predictions": "سیگنالها",
"finance": "مالی",
"account": "حساب"
}
diff --git a/platforms/market/src/shared/locales/fa/predictions.json b/platforms/market/src/shared/locales/fa/predictions.json
index cbe6b03..e94c743 100644
--- a/platforms/market/src/shared/locales/fa/predictions.json
+++ b/platforms/market/src/shared/locales/fa/predictions.json
@@ -1,9 +1,9 @@
{
"composer": {
- "title": "پیشبینی جدید",
- "loading": "در حال آمادهسازی پیشبینی جدید…",
+ "title": "سیگنال جدید",
+ "loading": "در حال آمادهسازی سیگنال جدید…",
"cancel": "انصراف",
- "access": "سطح دسترسی پیشبینی",
+ "access": "سطح دسترسی سیگنال",
"free": "رایگان",
"premium": "پریمیوم",
"premium-hint": "نتیجه برای همه نمایش داده میشود؛ نماد، جهت و سطوح فقط برای مشترکان باز است.",
@@ -20,19 +20,23 @@
"symbol-value": "{{symbol}} · {{name}}",
"symbol-hint": "ابتدا بازار را انتخاب کنید.",
"direction": "جهت",
- "entry": "قیمت ورود",
- "entry-note": "قیمت لحظهای · منبع: {{source}} · {{time}}",
+ "entry": "ورود",
+ "entry-exact": "قیمت دقیق",
+ "entry-range": "بازه",
+ "entry-price": "قیمت ورود",
+ "entry-from": "از",
+ "entry-to": "تا",
+ "entry-hint": "قیمت لحظهای: {{price}} · منبع: {{source}} · {{time}}",
"entry-pending": "قیمت لحظهای پس از انتخاب نماد نمایش داده میشود.",
"entry-loading": "در حال دریافت قیمت لحظهای…",
- "entry-stamp": "قیمت ورود در لحظهی انتشار ثبت میشود.",
"quote-unavailable": "قیمت لحظهای در دسترس نیست. چند دقیقه بعد دوباره تلاش کنید.",
"retry": "تلاش مجدد",
"target": "هدف {{n}}",
"remove-target": "حذف هدف {{n}}",
"add-target": "افزودن هدف",
"targets-max": "حداکثر سه هدف میتوانید تعیین کنید.",
- "stop": "حد ضرر (اختیاری)",
- "stop-hint": "بدون حد ضرر، پیشبینی فقط با رسیدن به هدف نهایی یا پایان افق بسته میشود.",
+ "stop": "حد ضرر",
+ "stop-hint": "بدون حد ضرر، سیگنال منتشر نمیشود.",
"horizon": "افق زمانی",
"horizons": {
"1w": "۱ هفته",
@@ -43,19 +47,20 @@
},
"horizon-end": "پایان افق: {{date}}",
"note": "توضیح (اختیاری)",
- "note-placeholder": "دلیل این پیشبینی را بنویسید؛ برای مشترکان نمایش داده میشود.",
+ "note-placeholder": "دلیل این سیگنال را بنویسید؛ برای مشترکان نمایش داده میشود.",
"chart": "تصویر نمودار (اختیاری)",
"chart-list": "تصویر نمودار",
"preview": "پیشنمایش",
"preview-incomplete": "پیشنمایش پس از تکمیل فرم",
"preview-errors": "پیشنمایش پس از رفع خطاها",
- "publish": "انتشار پیشبینی",
+ "publish": "انتشار سیگنال",
"missing": "برای انتشار، این موارد را کامل کنید: {{fields}}.",
"invalid": "برای انتشار، این موارد را اصلاح کنید: {{fields}}.",
"fields": {
"market": "بازار",
"symbol": "نماد",
"direction": "جهت",
+ "entry": "ورود",
"target": "هدف {{n}}",
"stop": "حد ضرر",
"horizon": "افق زمانی",
@@ -63,24 +68,23 @@
"chart": "تصویر نمودار"
},
"publish-failed": "انتشار انجام نشد. اطلاعات شما حفظ شده است؛ دوباره تلاش کنید.",
- "published": "پیشبینی منتشر شد.",
+ "published": "سیگنال منتشر شد.",
"confirm": {
- "title": "انتشار پیشبینی",
- "prediction": "پیشبینی",
+ "title": "انتشار سیگنال",
+ "prediction": "سیگنال",
"entry": "قیمت ورود",
- "entry-value": "≈ {{price}}",
- "entry-note": "قیمت لحظهی انتشار",
"target": "هدف",
"target-n": "هدف {{n}}",
"stop": "حد ضرر",
"horizon-end": "پایان افق",
"access": "دسترسی",
- "warning": "پس از انتشار، این پیشبینی قابل ویرایش یا حذف نیست. قیمت ورود همان قیمت لحظهی انتشار است و نتیجه را لومینا ثبت میکند.",
+ "warning": "پس از انتشار، این سیگنال قابل ویرایش یا حذف نیست و نتیجه را لومینا با قیمت منبع ثبت میکند.",
"submit": "انتشار",
- "back": "ادامه ویرایش"
+ "back": "ادامه ویرایش",
+ "entry-exact": "قیمت دقیق"
},
"leave": {
- "title": "پیشبینی شما ذخیره نشده است. آیا میخواهید خارج شوید؟",
+ "title": "سیگنال شما ذخیره نشده است. آیا میخواهید خارج شوید؟",
"confirm": "خروج",
"cancel": "ادامه ویرایش"
}
@@ -112,12 +116,23 @@
"note-long": "توضیح حداکثر ۵۰۰ کاراکتر است.",
"symbol": "فقط نمادهای این فهرست قابل پیگیریاند.",
"horizon": "یکی از افقهای زمانی فهرست را انتخاب کنید.",
- "chart": "فقط یک تصویر نمودار میتوانید اضافه کنید."
+ "chart": "فقط یک تصویر نمودار میتوانید اضافه کنید.",
+ "entry-required": "قیمت ورود یا بازه ورود را وارد کنید.",
+ "entry-range-order": "ابتدای بازه باید کمتر از انتهای آن باشد.",
+ "stop-required": "حد ضرر را وارد کنید؛ بدون آن سیگنال منتشر نمیشود.",
+ "target-side-range": {
+ "long": "برای خرید، هدف باید بالاتر از سقف بازه ورود باشد.",
+ "short": "برای فروش، هدف باید پایینتر از کف بازه ورود باشد."
+ },
+ "stop-side-range": {
+ "long": "برای خرید، حد ضرر باید پایینتر از کف بازه ورود باشد.",
+ "short": "برای فروش، حد ضرر باید بالاتر از سقف بازه ورود باشد."
+ }
},
"close": {
"title": "بستن زودهنگام",
- "description": "پیشبینی با قیمت لحظهای بازار بسته میشود. این قیمت را لومینا ثبت میکند و قابل تغییر نیست.",
- "prediction": "پیشبینی",
+ "description": "سیگنال با قیمت لحظهای بازار بسته میشود. این قیمت را لومینا ثبت میکند و قابل تغییر نیست.",
+ "prediction": "سیگنال",
"entry": "ورود",
"target": "هدف",
"stop": "حد ضرر",
@@ -130,45 +145,78 @@
"submit": "بستن با این قیمت",
"cancel": "انصراف",
"unavailable": "قیمت لحظهای در دسترس نیست. چند دقیقه بعد دوباره تلاش کنید.",
- "already-closed": "این پیشبینی پیشتر بهطور خودکار بسته شده است.",
+ "already-closed": "این سیگنال پیشتر بهطور خودکار بسته شده است.",
"dismiss": "بستن",
- "closed": "پیشبینی بسته شد.",
- "failed": "پیشبینی {{symbol}} بسته نشد."
+ "closed": "سیگنال بسته شد.",
+ "failed": "سیگنال {{symbol}} بسته نشد."
},
"tab": {
- "meta-title": "پیشبینیها",
- "loading": "در حال بارگذاری پیشبینیها…",
- "record": {
- "title": "کارنامه شما",
- "loading": "در حال بارگذاری کارنامه…",
- "error": "کارنامه بارگذاری نشد.",
- "public-title": "کارنامه عمومی",
- "threshold": "کارنامه عمومی شما پس از {{required}} پیشبینی بستهشده و یک ماه فعالیت نمایش داده میشود.",
- "progress": "{{closed}} از {{required}} پیشبینی بستهشده",
- "days-left": "{{n}} روز تا یک ماه فعالیت"
- },
- "open": "پیشبینیهای باز",
+ "meta-title": "سیگنالها",
+ "loading": "در حال بارگذاری سیگنالها…",
+ "open": "سیگنالهای باز",
"recent-closed": "بستهشدههای اخیر",
- "all": "همه پیشبینیها",
- "empty": "هنوز پیشبینی منتشر نکردهاید",
- "new": "پیشبینی جدید"
+ "all": "همه سیگنالها",
+ "empty": "هنوز سیگنال منتشر نکردهاید",
+ "new": "سیگنال جدید"
+ },
+ "performance": {
+ "title": "عملکرد سیگنالها",
+ "loading": "در حال بارگذاری عملکرد سیگنالها…",
+ "error": "عملکرد سیگنالها بارگذاری نشد.",
+ "pending": {
+ "title": "ارزیابی عملکرد سیگنالها بهزودی فعال میشود.",
+ "description": "عددها پس از اولین ارزیابی شبانه نمایش داده میشوند."
+ },
+ "tiles": {
+ "win-rate": "نرخ موفقیت",
+ "avg-roi": "بازدهی میانگین",
+ "total": "کل سیگنالها",
+ "active": "سیگنالهای فعال"
+ },
+ "outcomes-title": "نتیجه سیگنالها",
+ "outcomes": {
+ "target": "رسیده به هدف",
+ "stop": "خورده به حد ضرر",
+ "expired": "پایان مهلت",
+ "active": "فعال",
+ "voided": "باطلشده"
+ },
+ "risk-reward": "ریسک به ریوارد (میانگین)",
+ "risk-reward-range": "{{worst}} تا {{best}}",
+ "progress": "{{closed}} از {{required}} سیگنال بستهشده تا نمایش عمومی",
+ "days-left": "{{n}} روز تا یک ماه فعالیت",
+ "public": "کارنامه عمومی شما فعال است",
+ "tips": {
+ "win-rate": "سیگنالهایی که با پایان مهلت بسته شدهاند، ناموفق حساب میشوند.",
+ "avg-roi": "بازدهی هر سیگنال با تقسیم مساوی سرمایه بین هدفها محاسبه میشود.",
+ "risk-reward": "بدترین و بهترین حالت: در سیگنالهای بازهای، ورود در دورترین و نزدیکترین نقطهٔ بازه به هدف.",
+ "expired": "در نرخ موفقیت، ناموفق حساب میشود.",
+ "voided": "در نرخ موفقیت و بازدهی حساب نمیشود."
+ },
+ "tip-labels": {
+ "win-rate": "توضیح نرخ موفقیت",
+ "avg-roi": "توضیح بازدهی میانگین",
+ "risk-reward": "توضیح ریسک به ریوارد",
+ "expired": "توضیح پایان مهلت",
+ "voided": "توضیح باطلشده"
+ }
},
"list": {
- "title": "پیشبینیها",
- "loading": "در حال بارگذاری پیشبینیها…",
- "error": "پیشبینیها بارگذاری نشد.",
- "filter": "فیلتر پیشبینیها",
+ "title": "سیگنالها",
+ "loading": "در حال بارگذاری سیگنالها…",
+ "error": "سیگنالها بارگذاری نشد.",
+ "filter": "فیلتر سیگنالها",
"filters": {
"open": "باز ({{n}})",
"closed": "بستهشده ({{n}})",
"all": "همه ({{n}})"
},
"empty": {
- "open": "پیشبینی بازی ندارید.",
- "closed": "هنوز پیشبینیای بسته نشده است.",
- "all": "هنوز پیشبینی منتشر نکردهاید"
+ "open": "سیگنال بازی ندارید.",
+ "closed": "هنوز سیگنالی بسته نشده است.",
+ "all": "هنوز سیگنال منتشر نکردهاید"
},
"more": "نمایش بیشتر",
- "more-failed": "پیشبینیهای بیشتر بارگذاری نشد."
+ "more-failed": "سیگنالهای بیشتر بارگذاری نشد."
}
}
diff --git a/platforms/market/src/shared/locales/fa/pricing.json b/platforms/market/src/shared/locales/fa/pricing.json
index f6a1f16..f464b95 100644
--- a/platforms/market/src/shared/locales/fa/pricing.json
+++ b/platforms/market/src/shared/locales/fa/pricing.json
@@ -18,6 +18,11 @@
"loading": "در حال بارگذاری قیمت طرحها…",
"error": "قیمت طرحها بارگذاری نشد. دوباره تلاش کنید."
},
+ "off-sale": {
+ "badge": "خارج از فروش",
+ "banner": "طرح {{tier}} شما از فروش خارج شد",
+ "action": "اصلاح قیمت"
+ },
"form": {
"label": "قیمتگذاری اشتراک",
"required-tag": "الزامی",
@@ -26,7 +31,13 @@
"price-label": "قیمت کل دوره",
"price-label-of": "قیمت کل دوره {{period}}",
"currency": "تومان",
- "floor": "حداقل قیمت این دوره {{floor}} تومان در ماه است.",
+ "floor": "حداقل {{total}} تومان ({{floor}} در ماه)، حتی بعد از تخفیف.",
+ "floor-monthly": "حداقل {{floor}} تومان در ماه، حتی بعد از تخفیف.",
+ "total-of": {
+ "quarterly": "سه ماه",
+ "semi_annual": "شش ماه",
+ "yearly": "یک سال"
+ },
"per-month": "معادل {{amount}} تومان در ماه",
"disable-note": "{{count}} مشترک فعال روی این دوره دارید. با غیرفعال کردن، اشتراک آنها تا پایان دوره ادامه مییابد و فقط این دوره برای کاربران جدید نمایش داده نمیشود.",
"existing-note": "تغییر قیمت روی مشترکان فعلی تأثیری ندارد. قیمت جدید از زمان تمدید اشتراک آنها اعمال میشود.",
@@ -44,9 +55,10 @@
"errors": {
"required": "وارد کردن قیمت برای دورههای فعال الزامی است.",
"below-floor": "قیمت این دوره نمیتواند کمتر از {{floor}} تومان در ماه باشد.",
+ "below-floor-long": "قیمت این دوره نمیتواند کمتر از {{floor}} تومان در ماه ({{total}} تومان برای {{period}}) باشد.",
"per-month-increase": "قیمت ماهانه این دوره ({{amount}} تومان) نباید بیشتر از دوره {{period}} ({{shorter}} تومان) باشد.",
"promo-percent": "درصد تخفیف باید بین ۱ تا ۹۹ باشد.",
- "promo-floor": "قیمت با تخفیف ({{amount}} تومان در ماه) نمیتواند کمتر از {{floor}} تومان در ماه باشد.",
+ "promo-floor": "قیمت با تخفیف ({{amount}} تومان در ماه) نمیتواند کمتر از کف {{floor}} تومان در ماه باشد.",
"promo-end-required": "تاریخ و ساعت پایان را انتخاب کنید، یا «بدون تاریخ پایان» را بزنید.",
"promo-start-past": "تاریخ و ساعت شروع نمیتواند در گذشته باشد.",
"promo-range": "تاریخ و ساعت پایان باید بعد از شروع باشد."
@@ -59,6 +71,7 @@
"intro": "با فعالکردن، درصد تخفیف و بازه زمانی آن را تعیین میکنید. قیمت پایه این دوره تغییر نمیکند.",
"percent": "درصد تخفیف",
"percent-sign": "٪",
+ "floor-hint": "قیمت با تخفیف نباید کمتر از {{floor}} تومان در ماه شود.",
"start": "تاریخ و ساعت شروع",
"end": "تاریخ و ساعت پایان",
"indefinite": "بدون تاریخ پایان",
diff --git a/platforms/market/src/shared/locales/fa/rules.json b/platforms/market/src/shared/locales/fa/rules.json
index 28661a8..7676a08 100644
--- a/platforms/market/src/shared/locales/fa/rules.json
+++ b/platforms/market/src/shared/locales/fa/rules.json
@@ -1,40 +1,14 @@
{
- "meta-title": "قوانین لومینا",
- "meta-description": "قوانین عمومی استفاده از لومینا: حساب کاربری، محتوای تحلیلگران، محتوای ممنوع، پیشبینیها، تعلیق حساب، حریم خصوصی و تغییر قوانین.",
- "title": "قوانین لومینا",
+ "meta-title": "قوانین و مقررات لومینا",
+ "meta-description": "قوانین و مقررات استفاده از لومینا: قوانین پلتفرم و حریم خصوصی.",
+ "title": "قوانین و مقررات لومینا",
"tabs": {
- "label": "قوانین لومینا",
- "general": "قوانین عمومی",
+ "label": "قوانین و مقررات لومینا",
+ "general": "قوانین و مقررات",
"subscription": "شرایط اشتراک"
},
- "s1": {
- "title": "1. حساب کاربری",
- "p1": "هر شماره موبایل فقط یک حساب دارد و ورود همیشه با کد پیامکی انجام میشود. اطلاعاتی که هنگام ثبتنام وارد میکنید باید واقعی و متعلق به خودتان باشد.",
- "p2": "کد ورود را به هیچکس، حتی پشتیبانی لومینا، ندهید."
- },
- "s2": {
- "title": "2. محتوای تحلیلگران",
- "p1": "تحلیلها و پیشبینیها نظر شخصی تحلیلگر است و توصیه قطعی خرید یا فروش نیست. تصمیم سرمایهگذاری و مسئولیت آن با خود شماست و لومینا سود یا درستی هیچ تحلیلی را تضمین نمیکند."
- },
- "s3": {
- "title": "3. محتوای ممنوع",
- "p1": "وعده سود تضمینی یا بدون ریسک؛ درخواست پرداخت یا اطلاعات بانکی بیرون از لومینا؛ تبلیغ کانالها و خدمات پولی دیگر؛ انتشار محتوای دیگران بدون اجازه؛ توهین، تهدید یا انتشار اطلاعات شخصی افراد؛ هر محتوای خلاف قوانین جمهوری اسلامی ایران."
- },
- "s4": {
- "title": "4. پیشبینیها و کارنامه",
- "p1": "پیشبینی پس از انتشار ویرایش نمیشود و فقط پیش از رسیدن به هدف یا حد ضرر میتوان آن را زودتر بست. نتیجه با قیمت منبع اعلامشده ثبت میشود و اگر قیمت نادرست ثبت شده باشد، ادمین نتیجه را با ذکر دلیل اصلاح میکند."
- },
- "s5": {
- "title": "5. تعلیق حساب",
- "p1": "اگر قوانین رعایت نشود، حساب تعلیق میشود و دلیل آن با پیامک و اعلان به شما گفته میشود. برای اعتراض با پشتیبانی تماس بگیرید. در دوره تعلیق، اشتراکهای فعال طبق «شرایط اشتراک» بررسی میشوند."
- },
- "s6": {
- "title": "6. حریم خصوصی",
- "p1": "دیگران شما را فقط با نام کاربری میبینند. شماره موبایل و نام شما فقط برای خودتان و پشتیبانی نمایش داده میشود. تصویر کارت ملی تحلیلگر فقط برای احراز هویت استفاده میشود و در هیچ صفحهای نمایش داده نمیشود."
- },
- "s7": {
- "title": "7. تغییر قوانین",
- "p1": "هر تغییر در این قوانین پیش از اجرا با اعلان به شما اطلاع داده میشود. ادامه استفاده از لومینا به معنی پذیرش قوانین تازه است."
- },
- "updated": "آخرین بهروزرسانی: 1 مهر 1405"
+ "agreement": {
+ "meta-title": "توافقنامه تحلیلگر",
+ "title": "توافقنامه تحلیلگر"
+ }
}
diff --git a/platforms/market/src/shared/locales/fa/terms.json b/platforms/market/src/shared/locales/fa/terms.json
index 7dccc23..e7c5687 100644
--- a/platforms/market/src/shared/locales/fa/terms.json
+++ b/platforms/market/src/shared/locales/fa/terms.json
@@ -1,54 +1,4 @@
{
"meta-title": "شرایط اشتراک",
- "meta-description": "شرایط خرید، تمدید و بازگشت وجه اشتراک کانال تحلیلگران در لومینا.",
- "title": "شرایط اشتراک",
- "s1": {
- "title": "1. اشتراک چیست؟",
- "p1": "با خرید اشتراک، به محتوای ویژه (پریمیوم) کانال یک تحلیلگر برای مدت انتخابشده دسترسی پیدا میکنید. دسترسی شما بلافاصله پس از تأیید پرداخت فعال میشود و تا پایان دوره ادامه دارد.",
- "p2": "اشتراک بهصورت خودکار تمدید نمیشود. پیش از پایان دوره به شما اطلاع داده میشود تا در صورت تمایل، اشتراک خود را تمدید کنید."
- },
- "s2": {
- "title": "2. بازگشت وجه",
- "p1": "اشتراکها بهدلیل ماهیت دیجیتال و دسترسی فوری به محتوا، بهطور کلی قابل بازگشت نیستند.",
- "p2": "در موارد استثنایی میتوانید از طریق پشتیبانی لومینا درخواست بررسی دهید. هر درخواست بهصورت جداگانه بررسی میشود.",
- "p3": "در صورت تأیید بازگشت وجه، مبلغ از طریق انتقال بانکی به شماره شبایی که به پشتیبانی اعلام میکنید واریز میشود. مسئولیت صحت شماره شبای اعلامشده بر عهده شماست. بازگشت وجه بهصورت اعتبار داخل پلتفرم انجام نمیشود."
- },
- "s3": {
- "title": "3. در صورت غیرفعال شدن کانال تحلیلگر",
- "p1": "اگر دسترسی به کانال یک تحلیلگر در طول دوره اشتراک شما متوقف شود، بلافاصله از طریق پیامک و اعلان در پلتفرم به شما اطلاع داده میشود و دو گزینه خواهید داشت:",
- "refund-lead": "درخواست بازگشت وجه:",
- "refund": "با پیام به پشتیبانی لومینا، مبلغ دوره استفادهنشده بهصورت نسبی محاسبه و به حساب شما واریز میشود.",
- "wait-lead": "انتظار برای بازگشت کانال:",
- "wait": "اگر کانال پیش از پایان اشتراک شما دوباره فعال شود، مدتزمان توقف به اشتراک شما اضافه میشود و تاریخ انقضای جدید به شما اعلام خواهد شد.",
- "p2": "اگر هیچ اقدامی نکنید، گزینه دوم بهطور خودکار اعمال میشود.",
- "p3": "با دریافت بازگشت وجه، اشتراک شما پایان مییابد و مدت توقف به آن اضافه نمیشود.",
- "p4": "اگر اشتراک شما در دوره توقف به پایان برسد، حق درخواست بازگشت وجه مدت استفادهنشده برای شما محفوظ میماند."
- },
- "s4": {
- "title": "4. تغییر قیمت",
- "p1": "قیمتی که هنگام خرید پرداخت کردهاید تا پایان دوره اشتراک شما ثابت میماند. تغییر قیمت توسط تحلیلگر روی اشتراک فعلی شما تأثیری ندارد.",
- "p2": "در زمان تمدید، قیمت جاری آن کانال اعمال میشود و پیش از پرداخت به شما نمایش داده خواهد شد."
- },
- "s5": {
- "title": "5. تخفیفها",
- "p1": "تخفیفهای دورهای هنگام خرید اشتراک جدید، تمدید اشتراک فعلی، و خرید مجدد پس از پایان دوره قابل استفاده هستند.",
- "p2": "تخفیف روی اشتراکی که پیشتر خریداری کردهاید اعمال نمیشود، اما میتوانید در زمان تمدید یا خرید مجدد از آن بهرهمند شوید.",
- "p3": "پایان یافتن یک تخفیف روی اشتراکی که با قیمت تخفیفخورده خریداری شده تأثیری ندارد؛ شما تا پایان دوره از همان قیمت بهرهمند میشوید."
- },
- "s6": {
- "title": "6. محتوا و مسئولیت",
- "p1": "محتوای منتشرشده در کانالها، شامل تحلیلها، پیشبینیها و دیدگاهها، توسط تحلیلگران تولید میشود و مسئولیت آن بهعهده خود آنهاست.",
- "p2": "لومینا بستری برای انتشار و اعتبارسنجی عملکرد تحلیلگران فراهم میکند و هیچیک از محتوای منتشرشده را تأیید، تضمین یا بهعنوان توصیه سرمایهگذاری ارائه نمیدهد.",
- "p3": "تصمیمات سرمایهگذاری شما بر عهده خودتان است."
- },
- "s7": {
- "title": "7. مشکلات پرداخت",
- "p1": "اگر مبلغی از حساب شما کسر شده اما پرداخت ناموفق اعلام شده است، این مبلغ حداکثر ظرف 72 ساعت بهطور خودکار توسط بانک به حساب شما بازمیگردد.",
- "p2": "اگر پرداخت موفق بوده اما اشتراک شما فعال نشده است، شماره پیگیری را از بخش تراکنشها برای پشتیبانی ارسال کنید تا دسترسی شما فعال شود."
- },
- "s8": {
- "title": "8. ارتباط با پشتیبانی",
- "p1": "برای هرگونه پرسش یا مشکل، از طریق پیامرسان بله یا تلگرام با پشتیبانی لومینا در ارتباط باشید.",
- "hours": "زمان پاسخگویی: {{hours}}"
- }
+ "meta-description": "شرایط خرید، تمدید و بازگشت وجه اشتراک کانال تحلیلگران در لومینا."
}
diff --git a/platforms/market/src/shared/locales/resources.ts b/platforms/market/src/shared/locales/resources.ts
index d3b3b55..d093a62 100644
--- a/platforms/market/src/shared/locales/resources.ts
+++ b/platforms/market/src/shared/locales/resources.ts
@@ -7,6 +7,7 @@ import faDashboard from './fa/dashboard.json';
import faErrors from './fa/errors.json';
import faFinance from './fa/finance.json';
import faHome from './fa/home.json';
+import faLegal from './fa/legal.json';
import faNotifications from './fa/notifications.json';
import faPayment from './fa/payment.json';
import faPredictions from './fa/predictions.json';
@@ -35,6 +36,7 @@ export const resources = {
finance: faFinance,
account: faAccount,
predictions: faPredictions,
+ legal: faLegal,
},
} as const;
diff --git a/platforms/market/src/shared/locales/server-resources.ts b/platforms/market/src/shared/locales/server-resources.ts
index 6f85dc2..72d639b 100644
--- a/platforms/market/src/shared/locales/server-resources.ts
+++ b/platforms/market/src/shared/locales/server-resources.ts
@@ -5,9 +5,9 @@ import faRules from './fa/rules.json';
import faTerms from './fa/terms.json';
/**
- * Namespaces that only server components read: the prerendered landing, the subscription terms
- * and «قوانین لومینا» (the registration sheet gets those rules rendered on the server). They stay
- * out of every client bundle; each app's server bootstrap adds them to its i18n instance.
+ * Namespaces that only server components read: the prerendered landing, and the metadata, title and
+ * tabs of the rules pages (their text comes from the API). They stay out of every client bundle;
+ * each app's server bootstrap adds them to its i18n instance.
*/
export const SERVER_RESOURCES = {
fa: {
diff --git a/platforms/market/src/shared/validations/index.ts b/platforms/market/src/shared/validations/index.ts
index 55219a2..ebf3445 100644
--- a/platforms/market/src/shared/validations/index.ts
+++ b/platforms/market/src/shared/validations/index.ts
@@ -27,14 +27,27 @@ export {
export { payoutAccountSchema } from './finance-validations';
export { checkoutSchema } from './payment-validations';
export {
+ ENTRY_RANGE_ORDER_MESSAGE,
+ ENTRY_REQUIRED_MESSAGE,
+ entryFieldsOf,
+ entryIssue,
+ entryLevels,
levelPrice,
PREDICTION_FORM_LIMITS,
predictionComposerSchema,
+ STOP_REQUIRED_MESSAGE,
stopIssue,
+ stopSideMessage,
targetIssues,
+ targetSideMessage,
} from './prediction-validations';
export type {
LevelIssue,
+ EntryField,
+ EntryIssue,
+ EntryLevels,
+ EntryMode,
+ EntryValues,
PredictionComposerFormValues,
} from './prediction-validations';
export {
diff --git a/platforms/market/src/shared/validations/prediction-validations.test.ts b/platforms/market/src/shared/validations/prediction-validations.test.ts
new file mode 100644
index 0000000..ea365bb
--- /dev/null
+++ b/platforms/market/src/shared/validations/prediction-validations.test.ts
@@ -0,0 +1,251 @@
+import * as v from 'valibot';
+import { describe, expect, it } from 'vitest';
+
+import {
+ entryIssue,
+ entryLevels,
+ predictionComposerSchema,
+ stopIssue,
+ targetIssues,
+} from './prediction-validations';
+import type { PredictionComposerFormValues } from './prediction-validations';
+
+const exact = { low: 100, high: 100 };
+const range = { low: 98, high: 102 };
+const targets = (...values: string[]) => values.map((value) => ({ value }));
+
+const form = (
+ over: Partial = {},
+): PredictionComposerFormValues => ({
+ accessLevel: 'free',
+ market: 'crypto',
+ symbol: 'BTCUSDT',
+ direction: 'long',
+ entryMode: 'exact',
+ entryPrice: '100',
+ entryLow: '',
+ entryHigh: '',
+ targets: targets('110'),
+ stopLoss: '90',
+ horizon: '1w',
+ note: '',
+ ...over,
+});
+
+/** Each failing field's message, by its path. */
+function messages(values: PredictionComposerFormValues) {
+ const result = v.safeParse(predictionComposerSchema(), values);
+ return Object.fromEntries(
+ (result.issues ?? []).map((issue) => [
+ v.getDotPath(issue),
+ issue.message.replace('predictions:validation.', ''),
+ ]),
+ );
+}
+
+describe('entryIssue', () => {
+ const values = (over = {}) => ({
+ entryMode: 'range' as const,
+ entryPrice: '',
+ entryLow: '98',
+ entryHigh: '102',
+ ...over,
+ });
+
+ it('asks for the fields of the chosen form only', () => {
+ expect(entryIssue(values(), 'entryPrice')).toBeNull();
+ expect(entryIssue(values({ entryMode: 'exact' }), 'entryLow')).toBeNull();
+ expect(entryIssue(values({ entryMode: 'exact' }), 'entryPrice')).toBe(
+ 'required',
+ );
+ });
+
+ it.each([
+ ['empty', { entryLow: '' }, 'required'],
+ ['not a price', { entryLow: 'x' }, 'format'],
+ ['zero', { entryLow: '0' }, 'format'],
+ ['above the end', { entryLow: '103' }, 'order'],
+ ['equal to the end', { entryLow: '102' }, 'order'],
+ ])('reads the start of a range: %s', (_name, over, issue) => {
+ expect(entryIssue(values(over), 'entryLow')).toBe(issue);
+ });
+
+ it('takes Persian digits and separators', () => {
+ expect(
+ entryIssue(
+ values({ entryLow: '۶۷٬۵۰۰', entryHigh: '۶۸٬۵۰۰' }),
+ 'entryLow',
+ ),
+ ).toBeNull();
+ });
+});
+
+describe('entryLevels', () => {
+ it('gives an exact entry as both ends', () => {
+ expect(
+ entryLevels({
+ entryMode: 'exact',
+ entryPrice: '100',
+ entryLow: '',
+ entryHigh: '',
+ }),
+ ).toEqual(exact);
+ });
+
+ it('gives a range', () => {
+ expect(
+ entryLevels({
+ entryMode: 'range',
+ entryPrice: '100',
+ entryLow: '98',
+ entryHigh: '102',
+ }),
+ ).toEqual(range);
+ });
+
+ it.each([
+ ['half a range', { entryLow: '98', entryHigh: '' }],
+ ['a range running down', { entryLow: '102', entryHigh: '98' }],
+ ])('is null for %s', (_name, over) => {
+ expect(
+ entryLevels({ entryMode: 'range', entryPrice: '100', ...over }),
+ ).toBeNull();
+ });
+});
+
+describe('targetIssues', () => {
+ it('needs a long target above an exact entry, a short one below', () => {
+ expect(targetIssues('long', targets('101'), exact)).toEqual([null]);
+ expect(targetIssues('long', targets('100'), exact)).toEqual(['side']);
+ expect(targetIssues('short', targets('99'), exact)).toEqual([null]);
+ expect(targetIssues('short', targets('100'), exact)).toEqual(['side']);
+ });
+
+ it('needs a long target above the top of a range', () => {
+ expect(targetIssues('long', targets('103'), range)).toEqual([null]);
+ expect(targetIssues('long', targets('102'), range)).toEqual(['side']);
+ expect(targetIssues('long', targets('100'), range)).toEqual(['side']);
+ });
+
+ it('needs a short target below the bottom of a range', () => {
+ expect(targetIssues('short', targets('97'), range)).toEqual([null]);
+ expect(targetIssues('short', targets('98'), range)).toEqual(['side']);
+ expect(targetIssues('short', targets('100'), range)).toEqual(['side']);
+ });
+
+ it('needs each target further than the one before', () => {
+ expect(targetIssues('long', targets('110', '110'), exact)).toEqual([
+ null,
+ 'order',
+ ]);
+ expect(targetIssues('short', targets('90', '95'), exact)).toEqual([
+ null,
+ 'order',
+ ]);
+ });
+
+ it('checks only the format without an entry or a direction', () => {
+ expect(targetIssues('long', targets('50', 'x', ''), null)).toEqual([
+ null,
+ 'format',
+ null,
+ ]);
+ expect(targetIssues('', targets('50'), exact)).toEqual([null]);
+ });
+});
+
+describe('stopIssue', () => {
+ it('requires a stop', () => {
+ expect(stopIssue('long', '', exact)).toBe('required');
+ expect(stopIssue('', ' ', null)).toBe('required');
+ });
+
+ it('needs a long stop under the entry, a short one over it', () => {
+ expect(stopIssue('long', '99', exact)).toBeNull();
+ expect(stopIssue('long', '100', exact)).toBe('side');
+ expect(stopIssue('short', '101', exact)).toBeNull();
+ expect(stopIssue('short', '100', exact)).toBe('side');
+ });
+
+ it('needs a long stop under the bottom of a range, a short one over the top', () => {
+ expect(stopIssue('long', '97', range)).toBeNull();
+ expect(stopIssue('long', '99', range)).toBe('side');
+ expect(stopIssue('short', '103', range)).toBeNull();
+ expect(stopIssue('short', '101', range)).toBe('side');
+ });
+
+ it('reports a bad price before anything else', () => {
+ expect(stopIssue('long', 'x', exact)).toBe('format');
+ });
+});
+
+describe('predictionComposerSchema', () => {
+ it('passes a whole form', () => {
+ expect(messages(form())).toEqual({});
+ });
+
+ it('passes a whole range', () => {
+ expect(
+ messages(form({ entryMode: 'range', entryLow: '98', entryHigh: '102' })),
+ ).toEqual({});
+ });
+
+ it('says so when the entry and the stop are empty', () => {
+ expect(messages(form({ entryPrice: '', stopLoss: '' }))).toEqual({
+ entryPrice: 'entry-required',
+ stopLoss: 'stop-required',
+ });
+ });
+
+ it('asks for both ends of a range', () => {
+ expect(messages(form({ entryMode: 'range' }))).toEqual({
+ entryLow: 'entry-required',
+ entryHigh: 'entry-required',
+ });
+ });
+
+ it('says a range runs upward', () => {
+ expect(
+ messages(form({ entryMode: 'range', entryLow: '102', entryHigh: '98' })),
+ ).toEqual({ entryLow: 'entry-range-order' });
+ });
+
+ it.each([
+ ['long', '95', '105', 'target-side.long', 'stop-side.long'],
+ ['short', '105', '95', 'target-side.short', 'stop-side.short'],
+ ])(
+ 'words a %s exact entry against «قیمت ورود»',
+ (direction, target, stopLoss, targetKey, stopKey) => {
+ expect(
+ messages(form({ direction, targets: targets(target), stopLoss })),
+ ).toEqual({ 'targets.0.value': targetKey, stopLoss: stopKey });
+ },
+ );
+
+ it.each([
+ ['long', '100', '100', 'target-side-range.long', 'stop-side-range.long'],
+ ['short', '100', '100', 'target-side-range.short', 'stop-side-range.short'],
+ ])(
+ 'words a %s range against its edge',
+ (direction, target, stopLoss, targetKey, stopKey) => {
+ expect(
+ messages(
+ form({
+ direction,
+ entryMode: 'range',
+ entryLow: '98',
+ entryHigh: '102',
+ targets: targets(target),
+ stopLoss,
+ }),
+ ),
+ ).toEqual({ 'targets.0.value': targetKey, stopLoss: stopKey });
+ },
+ );
+
+ it('keeps the order rule', () => {
+ expect(messages(form({ targets: targets('110', '105') }))).toEqual({
+ 'targets.1.value': 'targets-order',
+ });
+ });
+});
diff --git a/platforms/market/src/shared/validations/prediction-validations.ts b/platforms/market/src/shared/validations/prediction-validations.ts
index 5b98fdc..cffcd53 100644
--- a/platforms/market/src/shared/validations/prediction-validations.ts
+++ b/platforms/market/src/shared/validations/prediction-validations.ts
@@ -11,10 +11,22 @@ export const PREDICTION_FORM_LIMITS = {
} as const;
/**
- * Why a typed level can't stand: not a price, on the wrong side of the entry, or not further
- * than the target before it.
+ * Why a typed level can't stand: empty though required, not a price, on the wrong side of the
+ * entry, or not further than the target before it.
*/
-export type LevelIssue = 'format' | 'side' | 'order';
+export type LevelIssue = 'required' | 'format' | 'side' | 'order';
+
+/** Why a typed entry can't stand: empty, not a price, or a range that doesn't run upward. */
+export type EntryIssue = 'required' | 'format' | 'order';
+
+export type EntryMode = 'exact' | 'range';
+
+export type EntryField = 'entryPrice' | 'entryLow' | 'entryHigh';
+
+export type EntryValues = { entryMode: EntryMode } & Record;
+
+/** The entry the levels are checked against: an exact entry has `low` equal to `high`. */
+export type EntryLevels = { low: number; high: number };
type Direction = 'long' | 'short';
@@ -31,24 +43,53 @@ const isDirection = (direction: string): direction is Direction =>
const isBeyond = (direction: Direction, a: number, b: number) =>
direction === 'long' ? a > b : a < b;
+/** The fields the chosen form of entry uses. */
+export function entryFieldsOf(mode: EntryMode): EntryField[] {
+ return mode === 'range' ? ['entryLow', 'entryHigh'] : ['entryPrice'];
+}
+
+/** One entry field's issue; a field the chosen form doesn't use has none. */
+export function entryIssue(
+ values: EntryValues,
+ field: EntryField,
+): EntryIssue | null {
+ if (!entryFieldsOf(values.entryMode).includes(field)) return null;
+ const text = values[field];
+ if (text.trim() === '') return 'required';
+ const price = levelPrice(text);
+ if (price === null) return 'format';
+ if (field !== 'entryLow') return null;
+ const high = levelPrice(values.entryHigh);
+ return high !== null && price >= high ? 'order' : null;
+}
+
+/** The typed entry once it can stand, or `null`: the level checks wait for it. */
+export function entryLevels(values: EntryValues): EntryLevels | null {
+ const fields = entryFieldsOf(values.entryMode);
+ if (fields.some((field) => entryIssue(values, field) !== null)) return null;
+ const prices = fields.map((field) => levelPrice(values[field]) as number);
+ return { low: prices[0], high: prices[prices.length - 1] };
+}
+
/**
- * Each typed target against the live entry price (J09-2), as the API checks it at publish: past
- * the entry in the predicted direction, and further than the one before. A target equal to the
- * entry, or to the one before, breaks the rule. Without a direction or a price (loading, or
- * unavailable) only the format is checked: the level checks pause and every value stays.
+ * Each typed target against the entry (J09-2), as the API checks it at publish: past the entry in
+ * the predicted direction, and further than the one before. With a range the whole range counts, so
+ * a long target must clear its top and a short one its bottom. A target equal to the entry, or to
+ * the one before, breaks the rule. Without a direction or an entry only the format is checked.
*/
export function targetIssues(
direction: string,
targets: readonly { value: string }[],
- entryPrice: number | null,
+ entry: EntryLevels | null,
): (LevelIssue | null)[] {
const prices = targets.map((target) => levelPrice(target.value));
return prices.map((price, index) => {
if (price === null) {
return targets[index].value.trim() === '' ? null : 'format';
}
- if (!isDirection(direction) || entryPrice === null) return null;
- if (!isBeyond(direction, price, entryPrice)) return 'side';
+ if (!isDirection(direction) || entry === null) return null;
+ const edge = direction === 'long' ? entry.high : entry.low;
+ if (!isBeyond(direction, price, edge)) return 'side';
const previous = index > 0 ? prices[index - 1] : null;
return previous != null && !isBeyond(direction, price, previous)
? 'order'
@@ -56,16 +97,20 @@ export function targetIssues(
});
}
-/** The stop loss against the live entry price: on the other side of it, never equal. */
+/**
+ * The stop loss, required, against the entry: on the other side of it, never equal. With a range
+ * the whole range counts, so a long stop must be under its bottom and a short one over its top.
+ */
export function stopIssue(
direction: string,
stopLoss: string,
- entryPrice: number | null,
+ entry: EntryLevels | null,
): LevelIssue | null {
const stop = levelPrice(stopLoss);
- if (stop === null) return stopLoss.trim() === '' ? null : 'format';
- if (!isDirection(direction) || entryPrice === null) return null;
- return isBeyond(direction, entryPrice, stop) ? null : 'side';
+ if (stop === null) return stopLoss.trim() === '' ? 'required' : 'format';
+ if (!isDirection(direction) || entry === null) return null;
+ const edge = direction === 'long' ? entry.low : entry.high;
+ return isBeyond(direction, edge, stop) ? null : 'side';
}
const PRICE_INVALID = 'content:validation.price-invalid';
@@ -73,93 +118,117 @@ const PRICE_INVALID = 'content:validation.price-invalid';
const sideOf = (direction: string): Direction =>
direction === 'short' ? 'short' : 'long';
-/** A target's message for its issue, in the predicted direction's words. */
-function targetMessage(issue: LevelIssue | null, direction: string): string {
- if (issue === 'format') return PRICE_INVALID;
- if (issue === 'order') return 'predictions:validation.targets-order';
- return `predictions:validation.target-side.${sideOf(direction)}`;
+/** «… قیمت ورود» for an exact entry, «… سقف/کف بازه ورود» for a range. */
+export function targetSideMessage(direction: string, mode: EntryMode): string {
+ const key = mode === 'range' ? 'target-side-range' : 'target-side';
+ return `predictions:validation.${key}.${sideOf(direction)}`;
}
-type TargetsInput = { direction: string; targets: { value: string }[] };
+export function stopSideMessage(direction: string, mode: EntryMode): string {
+ const key = mode === 'range' ? 'stop-side-range' : 'stop-side';
+ return `predictions:validation.${key}.${sideOf(direction)}`;
+}
+
+export const ENTRY_REQUIRED_MESSAGE = 'predictions:validation.entry-required';
+export const ENTRY_RANGE_ORDER_MESSAGE =
+ 'predictions:validation.entry-range-order';
+export const STOP_REQUIRED_MESSAGE = 'predictions:validation.stop-required';
+
+const ENTRY_MESSAGES: Record = {
+ required: ENTRY_REQUIRED_MESSAGE,
+ format: PRICE_INVALID,
+ order: ENTRY_RANGE_ORDER_MESSAGE,
+};
+
+const composerFields = v.object({
+ accessLevel: v.picklist(['free', 'premium']),
+ market: v.string(),
+ symbol: v.string(),
+ direction: v.string(),
+ entryMode: v.picklist(['exact', 'range']),
+ entryPrice: v.string(),
+ entryLow: v.string(),
+ entryHigh: v.string(),
+ targets: v.array(v.object({ value: v.string() })),
+ stopLoss: v.string(),
+ horizon: v.string(),
+ note: v.pipe(
+ v.string(),
+ v.maxLength(
+ PREDICTION_FORM_LIMITS.noteMaxLength,
+ 'predictions:validation.note-long',
+ ),
+ ),
+});
+
+export type PredictionComposerFormValues = v.InferInput;
/** Target `index`'s check, read from the whole list so the order rule sees the one before. */
-const targetIsValid =
- (index: number, entryPrice: number | null) =>
- ({ direction, targets }: TargetsInput) =>
- index >= targets.length ||
- targetIssues(direction, targets, entryPrice)[index] === null;
+const targetIssueOf = (input: PredictionComposerFormValues, index: number) =>
+ index < input.targets.length
+ ? targetIssues(input.direction, input.targets, entryLevels(input))[index]
+ : null;
-const targetMessageOf =
- (index: number, entryPrice: number | null) =>
- ({ input }: { input: TargetsInput }) =>
- targetMessage(
- targetIssues(input.direction, input.targets, entryPrice)[index] ?? null,
- input.direction,
- );
+function targetCheck(index: number) {
+ return v.forward(
+ v.check(
+ (input: PredictionComposerFormValues) =>
+ targetIssueOf(input, index) === null,
+ ({ input }) => {
+ const issue = targetIssueOf(input, index);
+ if (issue === 'format') return PRICE_INVALID;
+ if (issue === 'order') return 'predictions:validation.targets-order';
+ return targetSideMessage(input.direction, input.entryMode);
+ },
+ ),
+ ['targets', index, 'value'],
+ );
+}
+
+function entryCheck(field: EntryField) {
+ return v.forward(
+ v.check(
+ (input: PredictionComposerFormValues) =>
+ entryIssue(input, field) === null,
+ ({ input }) => ENTRY_MESSAGES[entryIssue(input, field) ?? 'required'],
+ ),
+ [field],
+ );
+}
/**
- * The prediction composer (J09-1, J09-2), checked against the live entry price: pass the quote
- * the form shows, or `null` while there is none. Completeness (market, symbol, direction, each
- * target, horizon) isn't an error here: the CTA stays frozen and lists what is missing. Each
- * level's error sits on that level.
+ * The prediction composer (J09-1, J09-2), checked against the entry the analyst typed. The stop and
+ * one form of entry are required: empty, each says so on its own field. Other completeness (market,
+ * symbol, direction, each target, horizon) isn't an error here: the CTA stays frozen and lists what
+ * is missing. Each level's error sits on that level.
*/
-export function predictionComposerSchema(entryPrice: number | null) {
+export function predictionComposerSchema() {
return v.pipe(
- v.object({
- accessLevel: v.picklist(['free', 'premium']),
- market: v.string(),
- symbol: v.string(),
- direction: v.string(),
- targets: v.array(v.object({ value: v.string() })),
- stopLoss: v.string(),
- horizon: v.string(),
- note: v.pipe(
- v.string(),
- v.maxLength(
- PREDICTION_FORM_LIMITS.noteMaxLength,
- 'predictions:validation.note-long',
- ),
- ),
- }),
+ composerFields,
+ entryCheck('entryPrice'),
+ entryCheck('entryLow'),
+ entryCheck('entryHigh'),
+ targetCheck(0),
+ targetCheck(1),
+ targetCheck(2),
v.forward(
- v.partialCheck(
- [['direction'], ['targets']],
- targetIsValid(0, entryPrice),
- targetMessageOf(0, entryPrice),
- ),
- ['targets', 0, 'value'],
- ),
- v.forward(
- v.partialCheck(
- [['direction'], ['targets']],
- targetIsValid(1, entryPrice),
- targetMessageOf(1, entryPrice),
- ),
- ['targets', 1, 'value'],
- ),
- v.forward(
- v.partialCheck(
- [['direction'], ['targets']],
- targetIsValid(2, entryPrice),
- targetMessageOf(2, entryPrice),
- ),
- ['targets', 2, 'value'],
- ),
- v.forward(
- v.partialCheck(
- [['direction'], ['stopLoss']],
- ({ direction, stopLoss }) =>
- stopIssue(direction, stopLoss, entryPrice) === null,
- ({ input }) =>
- stopIssue(input.direction, input.stopLoss, entryPrice) === 'format'
+ v.check(
+ (input: PredictionComposerFormValues) =>
+ stopIssue(input.direction, input.stopLoss, entryLevels(input)) ===
+ null,
+ ({ input }) => {
+ const issue = stopIssue(
+ input.direction,
+ input.stopLoss,
+ entryLevels(input),
+ );
+ if (issue === 'required') return STOP_REQUIRED_MESSAGE;
+ return issue === 'format'
? PRICE_INVALID
- : `predictions:validation.stop-side.${sideOf(input.direction)}`,
+ : stopSideMessage(input.direction, input.entryMode);
+ },
),
['stopLoss'],
),
);
}
-
-export type PredictionComposerFormValues = v.InferInput<
- ReturnType
->;
diff --git a/platforms/market/src/stores/auth/auth-store.ts b/platforms/market/src/stores/auth/auth-store.ts
index e6f4c29..a5f278c 100644
--- a/platforms/market/src/stores/auth/auth-store.ts
+++ b/platforms/market/src/stores/auth/auth-store.ts
@@ -25,6 +25,10 @@ export const useAuthStore = create()(
set((state) => {
if (state.session) state.session.needsProfile = false;
}),
+ setAgreementRequired: (required) =>
+ set((state) => {
+ if (state.session) state.session.agreementRequired = required;
+ }),
clearSession: () =>
set((state) => {
state.status = 'guest';
@@ -38,3 +42,5 @@ export const useCurrentAccount = () =>
useAuthStore((state) => state.session?.account ?? null);
export const useNeedsProfile = () =>
useAuthStore((state) => state.session?.needsProfile ?? false);
+export const useAgreementRequired = () =>
+ useAuthStore((state) => state.session?.agreementRequired ?? false);
diff --git a/platforms/market/src/stores/auth/index.ts b/platforms/market/src/stores/auth/index.ts
index 8f30ff0..e1f8824 100644
--- a/platforms/market/src/stores/auth/index.ts
+++ b/platforms/market/src/stores/auth/index.ts
@@ -1,4 +1,5 @@
export {
+ useAgreementRequired,
useAuthStore,
useCurrentAccount,
useNeedsProfile,
diff --git a/platforms/market/src/stores/auth/types.ts b/platforms/market/src/stores/auth/types.ts
index e3cd174..569457e 100644
--- a/platforms/market/src/stores/auth/types.ts
+++ b/platforms/market/src/stores/auth/types.ts
@@ -10,6 +10,11 @@ export type Session = {
* step 5 sends them back to it. Always `false` for an investor.
*/
needsProfile: boolean;
+ /**
+ * An analyst who owes a newer major agreement: a blocking modal stays open until they accept it.
+ * Always `false` for an investor.
+ */
+ agreementRequired: boolean;
};
export type AuthState = {
@@ -20,5 +25,7 @@ export type AuthState = {
updateAccount: (account: AccountPayload) => void;
/** Step 5 is done: the creator may use the rest of the app. */
profileCompleted: () => void;
+ /** Set by the session's answer or a 403 `agreement_required`; cleared by accepting. */
+ setAgreementRequired: (required: boolean) => void;
clearSession: () => void;
};
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 3c20d56..1284a4d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -77,13 +77,13 @@ importers:
version: 23.2.1(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(supports-color@7.2.0)
'@nx/next':
specifier: 23.2.1
- version: 23.2.1(b4b6c8e9be4135ee1bb6ef9ffa4d4137)
+ version: 23.2.1(6543f1d197293d3d143c8135a664e776)
'@nx/oxlint':
specifier: 23.2.1
version: 23.2.1(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(@typescript-eslint/parser@8.71.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint-config-prettier@10.1.8(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0)))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(oxlint@1.86.0)(supports-color@7.2.0)(typescript@6.0.3)
'@nx/react':
specifier: 23.2.1
- version: 23.2.1(@babel/core@7.29.7(supports-color@7.2.0))(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(@zkochan/js-yaml@0.0.7)(debug@4.4.3(supports-color@7.2.0))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(react-dom@19.3.0(react@19.3.0))(react@19.3.0)(supports-color@7.2.0)(typescript@6.0.3)(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0))
+ version: 23.2.1(@babel/core@7.29.7(supports-color@7.2.0))(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(@zkochan/js-yaml@0.0.7)(debug@4.4.3(supports-color@7.2.0))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(react-dom@19.3.0(react@19.3.0))(react@19.3.0)(supports-color@7.2.0)(typescript@6.0.3)(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0))(vitest@5.0.5(@types/node@22.20.4)(jsdom@30.1.3)(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0)))
'@swc-node/register':
specifier: ~1.11.1
version: 1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3)
@@ -99,6 +99,15 @@ importers:
'@tailwindcss/postcss':
specifier: ^4.3.3
version: 4.3.3
+ '@testing-library/dom':
+ specifier: ^10.4.2
+ version: 10.4.2
+ '@testing-library/react':
+ specifier: ^16.3.3
+ version: 16.3.3(@testing-library/dom@10.4.2)(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
+ '@testing-library/user-event':
+ specifier: ^14.6.8
+ version: 14.6.8(@testing-library/dom@10.4.2)
'@types/node':
specifier: ^22.0.0
version: 22.20.4
@@ -114,6 +123,9 @@ importers:
jiti:
specifier: ^2.7.0
version: 2.7.0
+ jsdom:
+ specifier: ^30.1.3
+ version: 30.1.3
nx:
specifier: 23.2.1
version: 23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23))
@@ -141,6 +153,9 @@ importers:
typescript-eslint:
specifier: ^8.58.0
version: 8.71.0(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
+ vitest:
+ specifier: ^5.0.5
+ version: 5.0.5(@types/node@22.20.4)(jsdom@30.1.3)(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0))
apps/bear:
dependencies:
@@ -288,6 +303,14 @@ packages:
resolution: {integrity: sha512-U4+70Pc5ZS9osnCBCE5Jha/ciHM+Yp+CNMNC/7HvYbNRk1Ldd+f7qO65W5qfhu/TCv+/ozljlXXe9Nj8419DMA==}
engines: {node: '>=10'}
+ '@asamuzakjp/css-color@7.1.9':
+ resolution: {integrity: sha512-vZ6JQVq8Ivgz6b/IBlAf90wZviXdluY13cQOPO+nJHbmXwGrPl2GcpqUY7a55/8ZVdfONXpCFMpRijOBCHNlcQ==}
+ engines: {node: ^22.22.2 || ^24.15.0 || >=26.0.0}
+
+ '@asamuzakjp/dom-selector@10.0.5':
+ resolution: {integrity: sha512-EgmJ7oEaGQECTn3H3wmnQpEy4hKY66VvM7VQndwPIQob3p877BgbyOUE3EX0LgXQCciF2H8KMdR+RznqjMNOLw==}
+ engines: {node: ^22.22.2 || ^24.15.0 || >=26.0.0}
+
'@babel/code-frame@7.29.7':
resolution: {integrity: sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==}
engines: {node: '>=6.9.0'}
@@ -864,6 +887,10 @@ packages:
'@borewit/text-codec@0.2.2':
resolution: {integrity: sha512-DDaRehssg1aNrH4+2hnj1B7vnUGEjU6OIlyRdkMd0aUdIUvKXrJfXsy8LVtXAy7DRvYVluWbMspsRhz2lcW0mQ==}
+ '@bramus/specificity@2.4.3':
+ resolution: {integrity: sha512-0GEz8qJWokkUVYQYRukmkSHIFNoBH8QTreeHrAFbvz1XFYc3Y+puhMs8PQ5x8GNugiC2l5jvDBXKLbBIByeSBw==}
+ hasBin: true
+
'@clack/core@1.4.3':
resolution: {integrity: sha512-/kr3UWNtdJfxZtPgDqUOmG2pvwlmcLGheex5yiZKdwbzZJxhV+HMNR9QNmyY5cGwTNV6LrR7Jtp+KjhUAP1qBQ==}
engines: {node: '>= 20.12.0'}
@@ -872,6 +899,42 @@ packages:
resolution: {integrity: sha512-y7/yvZ2TPAnR9+jnc00klvNNLkJiXFFrQA/hlLCcxA9a2A4zQIOimyFQ9XfwYKiGD1fb5GY8vbKIIgO8d5Tb2A==}
engines: {node: '>= 20.12.0'}
+ '@csstools/color-helpers@6.1.2':
+ resolution: {integrity: sha512-grhRy3OKmniaAEKXMjua5z/EODX0MSqBGjunw8+j/3HQjOnahs2AGhvEOIYVUWcU6ScApbhLhVrQTX8XqrMrow==}
+ engines: {node: '>=20.19.0'}
+
+ '@csstools/css-calc@3.4.3':
+ resolution: {integrity: sha512-iex20d8CHVkyvg6B7UKV7uHnI2Bqo9g+EFfT9E0y+GvTvhZ/DwONJ+9aKb1dlqm0ZiGsL5RXjp0fCoJYnkeDjA==}
+ engines: {node: '>=20.19.0'}
+ peerDependencies:
+ '@csstools/css-parser-algorithms': ^4.0.2
+ '@csstools/css-tokenizer': ^4.0.2
+
+ '@csstools/css-color-parser@4.2.7':
+ resolution: {integrity: sha512-zgm9yjQz5iJB4VL8RyVwd71TWB8Q89FSxt/NzXoWqPSkEBOVtn9L6vAPtSc9hpKfB0Awo/AL2VKFHjYetBLFHQ==}
+ engines: {node: '>=20.19.0'}
+ peerDependencies:
+ '@csstools/css-parser-algorithms': ^4.0.2
+ '@csstools/css-tokenizer': ^4.0.2
+
+ '@csstools/css-parser-algorithms@4.0.2':
+ resolution: {integrity: sha512-40cSKyMvK+tq4qz6Awrlye2WGuOKt3FwPgtGg6KTfbHOWNw+Rk1rzbAtZnZ6IBhsY491HLRnDXwoyBAijmmILA==}
+ engines: {node: '>=20.19.0'}
+ peerDependencies:
+ '@csstools/css-tokenizer': ^4.0.2
+
+ '@csstools/css-syntax-patches-for-csstree@1.1.16':
+ resolution: {integrity: sha512-LsDbJPP/B8cPasUJyTA5S99F7C4G93ngW8hUluXz8CFeOaaRnBPtBiIlvgcPYU0HmHNz8CXg+1vwFrIB4F6Dgw==}
+ peerDependencies:
+ css-tree: ^3.2.1
+ peerDependenciesMeta:
+ css-tree:
+ optional: true
+
+ '@csstools/css-tokenizer@4.0.2':
+ resolution: {integrity: sha512-OoKoR0f76dCY666JlcbhmVTs2drYj1GUXZTYTcbUgJjh9Nv41aFfZ21bPQTERm5+L5cBDo466NltB2lplS5GBw==}
+ engines: {node: '>=20.19.0'}
+
'@emnapi/core@1.11.2':
resolution: {integrity: sha512-TC8MkTuZUtcTSiFeuC0ksCh9QIJ5+F21MvZ4Wn4ORfYaFJ/0dsiudv5tVkejgwZlwQ39jL9WWDe2lz8x0WglOA==}
@@ -931,6 +994,15 @@ packages:
resolution: {integrity: sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ '@exodus/bytes@1.16.0':
+ resolution: {integrity: sha512-IcpW84uEn3N7ETtNZMlxKhfl6Pec8rUNGOTBtWbK1FKhJxIFAptZyVrvVRVBimAJxJCgc3PxepxkdWWG4DVzfA==}
+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}
+ peerDependencies:
+ '@noble/hashes': ^1.8.0 || ^2.0.0
+ peerDependenciesMeta:
+ '@noble/hashes':
+ optional: true
+
'@hookform/resolvers@5.9.1':
resolution: {integrity: sha512-7b7vsbraJxKgjVSA1Nur9tLwj539WGJUBLA7QNvXnFoT2pM5Z7G+6rlukk4B2/QrTZy6huRtH6wKeESPKuIr6w==}
peerDependencies:
@@ -2156,6 +2228,31 @@ packages:
peerDependencies:
react: ^18 || ^19
+ '@testing-library/dom@10.4.2':
+ resolution: {integrity: sha512-yzr2S9HyAIdhz2/6qHgbs665Q7PKVcDF05vsOlHPxG1mo36gKVesdYVeDLnXgfjJ03CrKRk08knc6+E/9m8v2Q==}
+ engines: {node: '>=18'}
+
+ '@testing-library/react@16.3.3':
+ resolution: {integrity: sha512-Uo193NgQbPMz6lrrhtRQQFcMC6Re/ELLFbbuVL30WDlZxlpZf9/lMHTAVxPRLw1q1iu9OJmR1c2BLiENRstdBg==}
+ engines: {node: '>=18'}
+ peerDependencies:
+ '@testing-library/dom': ^10.0.0
+ '@types/react': ^18.0.0 || ^19.0.0
+ '@types/react-dom': ^18.0.0 || ^19.0.0
+ react: ^18.0.0 || ^19.0.0
+ react-dom: ^18.0.0 || ^19.0.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
+ '@testing-library/user-event@14.6.8':
+ resolution: {integrity: sha512-vgSSqnANMnkcYR/vUNDbwS7aM3OErRLNUG8vCVVlj4oc6cKffUrccX7UAS5AmJQQNZTSibi9z5GvvRZ0aYgUCQ==}
+ engines: {node: '>=12', npm: '>=6'}
+ peerDependencies:
+ '@testing-library/dom': '>=7.21.4'
+
'@tokenizer/inflate@0.4.1':
resolution: {integrity: sha512-2mAv+8pkG6GIZiF1kNg1jAjh27IDxEPKwdGul3snfztFerfPGI1LjDezZp3i7BElXompqEtPmoPx6c2wgtWsOA==}
engines: {node: '>=18'}
@@ -2169,6 +2266,15 @@ packages:
'@tybys/wasm-util@0.9.0':
resolution: {integrity: sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw==}
+ '@types/aria-query@5.0.4':
+ resolution: {integrity: sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==}
+
+ '@types/chai@5.2.3':
+ resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==}
+
+ '@types/deep-eql@4.0.2':
+ resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==}
+
'@types/esquery@1.5.4':
resolution: {integrity: sha512-yYO4Q8H+KJHKW1rEeSzHxcZi90durqYgWVfnh5K6ZADVBjBv2e1NEveYX5yT2bffgN7RqzH3k9930m+i2yBoMA==}
@@ -2254,6 +2360,20 @@ packages:
resolution: {integrity: sha512-8eQ9R218XORK+KLosnf4bu/QsUXvUyVwTbArg7/0NMB1Pu87OJKvj4nhFblkYE8gQV73mW1dx1ptlPCkwRGa7A==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
+ '@vitest/mocker@5.0.5':
+ resolution: {integrity: sha512-xLL3lkDegJZw+MGoGaCCsFayDZthGgpAtr3Vziyfc4p7xH89K7KRPcRBBh/kEYm0Aqkt5DtTmkYpBtRV/FrHZg==}
+ peerDependencies:
+ msw: ^2.4.9 || ^3.0.0
+ vite: ^6.0.0 || ^7.0.0 || ^8.0.0
+ peerDependenciesMeta:
+ msw:
+ optional: true
+ vite:
+ optional: true
+
+ '@vitest/spy@5.0.5':
+ resolution: {integrity: sha512-lwJRExuH417257Q5wv9QYugN9IMJkoxcrKrYxGPQkBzl7wlNpTUxD/5yNX4ESKVUIShKPgkGchYPFMWOOk0wzw==}
+
'@webassemblyjs/ast@1.14.1':
resolution: {integrity: sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ==}
@@ -2397,9 +2517,20 @@ packages:
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
engines: {node: '>=8'}
+ ansi-styles@5.2.0:
+ resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==}
+ engines: {node: '>=10'}
+
argparse@2.0.1:
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
+ aria-query@5.3.0:
+ resolution: {integrity: sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==}
+
+ assertion-error@2.0.1:
+ resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==}
+ engines: {node: '>=12'}
+
async@3.2.6:
resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==}
@@ -2482,6 +2613,9 @@ packages:
resolution: {integrity: sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==}
engines: {node: '>= 0.8'}
+ bidi-js@1.1.0:
+ resolution: {integrity: sha512-fX1Onk0tdVPC7obPWB5EbJ1z7NVhLq4m2xZLq2YXBkxzMXIGRpNMU88n0EPgWseKl12J7zXs7qrDxPK4sRs2fg==}
+
binary-version-check@6.1.0:
resolution: {integrity: sha512-REKdLKmuViV2WrtWXvNSiPX04KbIjfUV3Cy8batUeOg+FtmowavzJorfFhWq95cVJzINnL/44ixP26TrdJZACA==}
engines: {node: '>=18'}
@@ -2548,6 +2682,10 @@ packages:
caniuse-lite@1.0.30001814:
resolution: {integrity: sha512-/Uaf1lAzr59XcMpW0o96WoEfr+VXK2OX4U9AgFoiSHsVJ4HppnIFUjtYzsyDH2+tgANaQb2/oxYGwCPapN1FpA==}
+ chai@6.3.0:
+ resolution: {integrity: sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==}
+ engines: {node: '>=18'}
+
chalk@4.1.2:
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
engines: {node: '>=10'}
@@ -2680,6 +2818,10 @@ packages:
csstype@3.2.3:
resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
+ data-urls@8.0.0:
+ resolution: {integrity: sha512-JQUCCK+/CAGbGGx618PlFZMXH81Jtj7t73CHv9dd/zVWvxgGT2zLFRjnKb+Ng46GIwcy+f7f88qd4duqllK+WQ==}
+ engines: {node: ^22.14.0 || >=24.0.0}
+
debug@4.4.3:
resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==}
engines: {node: '>=6.0'}
@@ -2689,6 +2831,9 @@ packages:
supports-color:
optional: true
+ decimal.js@10.6.0:
+ resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==}
+
decompress-response@10.0.0:
resolution: {integrity: sha512-oj7KWToJuuxlPr7VV0vabvxEIiqNMo+q0NueIiL3XhtwC6FVOX7Hr1c0C4eD0bmf7Zr+S/dSf2xvkH3Ad6sU3Q==}
engines: {node: '>=20'}
@@ -2715,6 +2860,10 @@ packages:
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
engines: {node: '>=0.4.0'}
+ dequal@2.0.3:
+ resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==}
+ engines: {node: '>=6'}
+
detect-libc@2.1.2:
resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==}
engines: {node: '>=8'}
@@ -2724,6 +2873,9 @@ packages:
engines: {node: '>= 16.0.0'}
hasBin: true
+ dom-accessibility-api@0.5.16:
+ resolution: {integrity: sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==}
+
dom-serializer@2.0.0:
resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==}
@@ -2771,6 +2923,10 @@ packages:
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
engines: {node: '>=0.12'}
+ entities@8.1.0:
+ resolution: {integrity: sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==}
+ engines: {node: '>=20.19.0'}
+
error-ex@1.3.4:
resolution: {integrity: sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==}
@@ -2858,6 +3014,9 @@ packages:
resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==}
engines: {node: '>=4.0'}
+ estree-walker@3.0.3:
+ resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}
+
esutils@2.0.3:
resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}
engines: {node: '>=0.10.0'}
@@ -2880,6 +3039,10 @@ packages:
resolution: {integrity: sha512-9Be3ZoN4LmYR90tUoVu2te2BsbzHfhJyfEiAVfz7N5/zv+jduIfLrV2xdQXOHbaD6KgpGdO9PRPM1Y4Q9QkPkA==}
engines: {node: ^18.19.0 || >=20.5.0}
+ expect-type@1.4.0:
+ resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==}
+ engines: {node: '>=12.0.0'}
+
ext-list@2.2.2:
resolution: {integrity: sha512-u+SQgsubraE6zItfVA0tBuCBhfU9ogSRnsvygI7wht9TS510oLkBRXBsqopeUG/GBOIQyKZO9wjTqIu/sf5zFA==}
engines: {node: '>=0.10.0'}
@@ -3067,6 +3230,10 @@ packages:
resolution: {integrity: sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==}
engines: {node: '>=12'}
+ html-encoding-sniffer@7.0.0:
+ resolution: {integrity: sha512-UikN5yr7xsCDAq87Or5or0PAlD3HJJOKVzM05az588WnpDJ4Ux7a2A53Qi6gofGg2/EtvF/H4hCi/TXfCW4Y6w==}
+ engines: {node: ^22.13.0 || >=24.0.0}
+
html-parse-stringify@4.0.1:
resolution: {integrity: sha512-0zHsZJrK7S3K2aucXWL6ycoYJ/iNtIcFHC/nYQgFklPtrv5LpJctIiSCroWZWeuoXvuyFdzp6KzjJQ+OT5MfFw==}
@@ -3187,6 +3354,9 @@ packages:
resolution: {integrity: sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==}
engines: {node: '>=0.10.0'}
+ is-potential-custom-element-name@1.0.1:
+ resolution: {integrity: sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==}
+
is-stream@3.0.0:
resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
@@ -3233,6 +3403,15 @@ packages:
resolution: {integrity: sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==}
hasBin: true
+ jsdom@30.1.3:
+ resolution: {integrity: sha512-hQMUPvRgN7KxsfIytDQji7bimuJeRQa6Qo5+iuiZQk5CafeRxLIA10/cG5YCBFNpD9RO3oqIiN4CO1Y44kxqXg==}
+ engines: {node: ^22.22.2 || ^24.15.0 || >=26.0.0}
+ peerDependencies:
+ canvas: ^3.2.3
+ peerDependenciesMeta:
+ canvas:
+ optional: true
+
jsesc@3.1.0:
resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==}
engines: {node: '>=6'}
@@ -3452,12 +3631,23 @@ packages:
resolution: {integrity: sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
+ lru-cache@11.5.3:
+ resolution: {integrity: sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==}
+ engines: {node: 20 || >=22}
+
lru-cache@5.1.1:
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
+ lz-string@1.5.0:
+ resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==}
+ hasBin: true
+
magic-string@0.30.21:
resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
+ magic-string@1.4.5:
+ resolution: {integrity: sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==}
+
make-asynchronous@1.1.0:
resolution: {integrity: sha512-ayF7iT+44LXdxJLTrTd3TLQpFDDvPCBxXxbv+pMUSuHA5Q8zyAfwkRP6aHHwNVFBUFWtxAHqwNJxF8vMZLAbVg==}
engines: {node: '>=18'}
@@ -3648,6 +3838,10 @@ packages:
resolution: {integrity: sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==}
engines: {node: '>= 0.4'}
+ obug@3.0.0:
+ resolution: {integrity: sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==}
+ engines: {node: '>=12.20.0'}
+
once@1.4.0:
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
@@ -3723,6 +3917,9 @@ packages:
resolution: {integrity: sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==}
engines: {node: '>=18'}
+ parse5@8.0.1:
+ resolution: {integrity: sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==}
+
path-exists@4.0.0:
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
engines: {node: '>=8'}
@@ -3784,6 +3981,10 @@ packages:
engines: {node: '>=14'}
hasBin: true
+ pretty-format@27.5.1:
+ resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==}
+ engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
+
pretty-ms@9.3.1:
resolution: {integrity: sha512-HzMy3Geq23nVALD/M2LliU+F+M+gVNsvkQWWqeBZ8HDiCgzo6YPJ/Omrmtq24EFrIsk0a3EkQGEd7bDOo+IhGA==}
engines: {node: '>=18'}
@@ -3835,6 +4036,9 @@ packages:
typescript:
optional: true
+ react-is@17.0.2:
+ resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}
+
react@19.3.0:
resolution: {integrity: sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==}
engines: {node: '>=0.10.0'}
@@ -3918,6 +4122,10 @@ packages:
resolution: {integrity: sha512-42tBVwLWnaQvW5zc4HbZrTuWccECCZfBi92FDuwtqxasH+JbPB3/FOKb1m222K42R4WxuxzzMsTswfzgtSu64Q==}
engines: {node: '>=11.0.0'}
+ saxes@6.0.0:
+ resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==}
+ engines: {node: '>=v12.22.7'}
+
scheduler@0.28.0:
resolution: {integrity: sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==}
@@ -4052,6 +4260,9 @@ packages:
resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==}
engines: {node: '>= 12'}
+ std-env@4.3.0:
+ resolution: {integrity: sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==}
+
streamx@2.28.1:
resolution: {integrity: sha512-zEzXb0s5Cds7tqMH6rhZ05lcJydCWiQPEwiNngVqzsxCc962vLY4Uw+mW7od8kDH258k2Uz/JrOkdIAAhSh9VA==}
@@ -4159,10 +4370,25 @@ packages:
resolution: {integrity: sha512-75voc/9G4rDIJleOo4jPvN4/YC4GRZrY8yy1uU4lwrB3XEQbWve8zXoO5No4eFrGcTAMYyoY67p8jRQdtA1HbA==}
engines: {node: '>=12'}
+ tinybench@6.2.2:
+ resolution: {integrity: sha512-nIZ2N2dFpjBsg2hgitKu7mA+FvsIJuGJOwysRngmVRRmWgR/UyPjwJj8c/fT/dhm8EkHnF5EOogRf+0Z2qrimA==}
+ engines: {node: '>=20.0.0'}
+
+ tinyexec@1.3.1:
+ resolution: {integrity: sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==}
+ engines: {node: '>=18'}
+
tinyglobby@0.2.17:
resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==}
engines: {node: '>=12.0.0'}
+ tldts-core@7.4.20:
+ resolution: {integrity: sha512-C630TWXZCZmLq0F2bW4QqwnaaxCQ/svpAqvJwnC4JvgEM5ohhBnGsEzTLSOXcN+xjz+kEaHS5uoWIw2klnqd0A==}
+
+ tldts@7.4.19:
+ resolution: {integrity: sha512-48dH6aSpQnpbzDUc4vIQZ1VjB8tkK+e8c1yx05/SZK+rkssgjEOlxDd/yU8/a4vGYQ9vRgJr9dwMq9TJ0b3X2Q==}
+ hasBin: true
+
tmp@0.2.7:
resolution: {integrity: sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==}
engines: {node: '>=14.14'}
@@ -4171,6 +4397,14 @@ packages:
resolution: {integrity: sha512-dRXchy+C0IgK8WPC6xvCHFRIWYUbqqdEIKPaKo/AcTUNzwLTK6AH7RjdLWsEZcAN/TBdtfUw3PYEgPr5VPr6ww==}
engines: {node: '>=14.16'}
+ tough-cookie@6.0.2:
+ resolution: {integrity: sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==}
+ engines: {node: '>=16'}
+
+ tr46@7.0.0:
+ resolution: {integrity: sha512-BcDSDW+SIGWVOns1Zm6Yg91q9AEj7eaID0QDY9oIqJD1A8dscNwMcl9Sms2DeuWCNov1X0/oXanHGYQBSLwZsg==}
+ engines: {node: ^22.14.0 || >=24.0.0}
+
ts-api-utils@2.5.0:
resolution: {integrity: sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==}
engines: {node: '>=18.12'}
@@ -4214,6 +4448,10 @@ packages:
undici-types@6.21.0:
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
+ undici@8.12.3:
+ resolution: {integrity: sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==}
+ engines: {node: '>=22.19.0'}
+
unicode-canonical-property-names-ecmascript@2.0.1:
resolution: {integrity: sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg==}
engines: {node: '>=4'}
@@ -4309,6 +4547,51 @@ packages:
yaml:
optional: true
+ vitest@5.0.5:
+ resolution: {integrity: sha512-cPODOMF8YnkiiYtDdHo6n4wWmBrOBBbOIYH2d33M4l3CdNn72h+qMmO6uXffUN6A5AZFXNND/d+krS9mgkXRfg==}
+ engines: {node: ^22.12.0 || ^24.0.0 || >=26.0.0}
+ hasBin: true
+ peerDependencies:
+ '@edge-runtime/vm': '*'
+ '@opentelemetry/api': ^1.9.0
+ '@types/node': ^22.0.0 || >=24.0.0
+ '@vitest/browser-playwright': 5.0.5
+ '@vitest/browser-preview': 5.0.5
+ '@vitest/browser-webdriverio': ^5.0.0-beta.5 || >=5.0.0
+ '@vitest/coverage-istanbul': 5.0.5
+ '@vitest/coverage-v8': 5.0.5
+ '@vitest/ui': 5.0.5
+ happy-dom: '*'
+ jsdom: '*'
+ vite: ^6.4.0 || ^7.0.0 || ^8.0.0
+ peerDependenciesMeta:
+ '@edge-runtime/vm':
+ optional: true
+ '@opentelemetry/api':
+ optional: true
+ '@types/node':
+ optional: true
+ '@vitest/browser-playwright':
+ optional: true
+ '@vitest/browser-preview':
+ optional: true
+ '@vitest/browser-webdriverio':
+ optional: true
+ '@vitest/coverage-istanbul':
+ optional: true
+ '@vitest/coverage-v8':
+ optional: true
+ '@vitest/ui':
+ optional: true
+ happy-dom:
+ optional: true
+ jsdom:
+ optional: true
+
+ w3c-xmlserializer@6.0.0:
+ resolution: {integrity: sha512-4Nsy8K5Tr6SPDH9jhKJOHf7ChDrc1zufZTVSF7x72hwuEXBqxqk9G6cK+K2NRUtB3iELRJqjXb4JPDMBjMTl2Q==}
+ engines: {node: ^22.22.2 || ^24.15.0 || >=26.0.0}
+
watchpack@2.5.2:
resolution: {integrity: sha512-6i/00NBjP4yGPs+caKSyRfpTF/8Torsu0MOW3mMzIbhgISFder8i7xbqgHlLMwJrdiN8ndBV3UA1/AfzPSr+jg==}
engines: {node: '>=10.13.0'}
@@ -4319,6 +4602,10 @@ packages:
web-worker@1.5.0:
resolution: {integrity: sha512-RiMReJrTAiA+mBjGONMnjVDP2u3p9R1vkcGz6gDIrOMT3oGuYwX2WRMYI9ipkphSuE5XKEhydbhNEJh4NY9mlw==}
+ webidl-conversions@8.0.1:
+ resolution: {integrity: sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==}
+ engines: {node: '>=20'}
+
webpack-merge@5.10.0:
resolution: {integrity: sha512-+4zXKdx7UnO+1jaN4l2lHVD+mFvnlZQP/6ljaJVb4SZiwIKeUnrT5l0gkT8z+n4hKpC+jpOv6O9R+gLtag7pSA==}
engines: {node: '>=10.0.0'}
@@ -4342,6 +4629,14 @@ packages:
engines: {node: '>=12'}
deprecated: Use @exodus/bytes instead for a more spec-conformant and faster implementation
+ whatwg-mimetype@5.0.0:
+ resolution: {integrity: sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==}
+ engines: {node: '>=20'}
+
+ whatwg-url@17.3.0:
+ resolution: {integrity: sha512-KwOAJrpf+GTgBvcBQJcP38sMF0DsQKdwtG+TxM2pW44P6E5k0hDbWrDmyuJDIF0Uef0aQq0ZoJs+5oI+k8ddhg==}
+ engines: {node: ^22.14.0 || >=24.0.0}
+
which@2.0.2:
resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}
engines: {node: '>= 8'}
@@ -4352,6 +4647,11 @@ packages:
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
hasBin: true
+ why-is-node-running@3.2.1:
+ resolution: {integrity: sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==}
+ engines: {node: '>=20.11'}
+ hasBin: true
+
wildcard@2.0.1:
resolution: {integrity: sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==}
@@ -4366,6 +4666,13 @@ packages:
wrappy@1.0.2:
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
+ xml-name-validator@5.0.0:
+ resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==}
+ engines: {node: '>=18'}
+
+ xmlchars@2.2.0:
+ resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==}
+
y18n@5.0.8:
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
engines: {node: '>=10'}
@@ -4424,6 +4731,21 @@ snapshots:
'@alloc/quick-lru@5.3.0': {}
+ '@asamuzakjp/css-color@7.1.9':
+ dependencies:
+ '@csstools/css-calc': 3.4.3(@csstools/css-parser-algorithms@4.0.2(@csstools/css-tokenizer@4.0.2))(@csstools/css-tokenizer@4.0.2)
+ '@csstools/css-color-parser': 4.2.7(@csstools/css-parser-algorithms@4.0.2(@csstools/css-tokenizer@4.0.2))(@csstools/css-tokenizer@4.0.2)
+ '@csstools/css-parser-algorithms': 4.0.2(@csstools/css-tokenizer@4.0.2)
+ '@csstools/css-tokenizer': 4.0.2
+ lru-cache: 11.5.3
+
+ '@asamuzakjp/dom-selector@10.0.5':
+ dependencies:
+ bidi-js: 1.1.0
+ css-tree: 3.2.1
+ is-potential-custom-element-name: 1.0.1
+ lru-cache: 11.5.3
+
'@babel/code-frame@7.29.7':
dependencies:
'@babel/helper-validator-identifier': 7.29.7
@@ -5240,6 +5562,10 @@ snapshots:
'@borewit/text-codec@0.2.2': {}
+ '@bramus/specificity@2.4.3':
+ dependencies:
+ css-tree: 3.2.1
+
'@clack/core@1.4.3':
dependencies:
fast-wrap-ansi: 0.2.0
@@ -5252,6 +5578,30 @@ snapshots:
fast-wrap-ansi: 0.2.0
sisteransi: 1.0.5
+ '@csstools/color-helpers@6.1.2': {}
+
+ '@csstools/css-calc@3.4.3(@csstools/css-parser-algorithms@4.0.2(@csstools/css-tokenizer@4.0.2))(@csstools/css-tokenizer@4.0.2)':
+ dependencies:
+ '@csstools/css-parser-algorithms': 4.0.2(@csstools/css-tokenizer@4.0.2)
+ '@csstools/css-tokenizer': 4.0.2
+
+ '@csstools/css-color-parser@4.2.7(@csstools/css-parser-algorithms@4.0.2(@csstools/css-tokenizer@4.0.2))(@csstools/css-tokenizer@4.0.2)':
+ dependencies:
+ '@csstools/color-helpers': 6.1.2
+ '@csstools/css-calc': 3.4.3(@csstools/css-parser-algorithms@4.0.2(@csstools/css-tokenizer@4.0.2))(@csstools/css-tokenizer@4.0.2)
+ '@csstools/css-parser-algorithms': 4.0.2(@csstools/css-tokenizer@4.0.2)
+ '@csstools/css-tokenizer': 4.0.2
+
+ '@csstools/css-parser-algorithms@4.0.2(@csstools/css-tokenizer@4.0.2)':
+ dependencies:
+ '@csstools/css-tokenizer': 4.0.2
+
+ '@csstools/css-syntax-patches-for-csstree@1.1.16(css-tree@3.2.1)':
+ optionalDependencies:
+ css-tree: 3.2.1
+
+ '@csstools/css-tokenizer@4.0.2': {}
+
'@emnapi/core@1.11.2':
dependencies:
'@emnapi/wasi-threads': 1.2.2
@@ -5332,6 +5682,8 @@ snapshots:
'@eslint/core': 0.17.0
levn: 0.4.1
+ '@exodus/bytes@1.16.0': {}
+
'@hookform/resolvers@5.9.1(ajv@8.20.0)(react-hook-form@7.89.0(@types/react@19.3.0)(react@19.3.0))(valibot@1.5.0(typescript@6.0.3))':
dependencies:
'@standard-schema/utils': 0.3.0
@@ -5697,14 +6049,14 @@ snapshots:
- nx
- supports-color
- '@nx/next@23.2.1(b4b6c8e9be4135ee1bb6ef9ffa4d4137)':
+ '@nx/next@23.2.1(6543f1d197293d3d143c8135a664e776)':
dependencies:
'@babel/plugin-proposal-decorators': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)
'@nx/devkit': 23.2.1(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))
'@nx/eslint': 23.2.1(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(@zkochan/js-yaml@0.0.7)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(supports-color@7.2.0)
'@nx/js': 23.2.1(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(supports-color@7.2.0)
- '@nx/react': 23.2.1(@babel/core@7.29.7(supports-color@7.2.0))(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(@zkochan/js-yaml@0.0.7)(debug@4.4.3(supports-color@7.2.0))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(react-dom@19.3.0(react@19.3.0))(react@19.3.0)(supports-color@7.2.0)(typescript@6.0.3)(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0))
- '@nx/web': 23.2.1(5edbad283f4527d1fc6a7dbafd6db7ef)
+ '@nx/react': 23.2.1(@babel/core@7.29.7(supports-color@7.2.0))(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(@zkochan/js-yaml@0.0.7)(debug@4.4.3(supports-color@7.2.0))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(react-dom@19.3.0(react@19.3.0))(react@19.3.0)(supports-color@7.2.0)(typescript@6.0.3)(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0))(vitest@5.0.5(@types/node@22.20.4)(jsdom@30.1.3)(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0)))
+ '@nx/web': 23.2.1(e12d0c8ff9aba933cba5d8df0ac4a5f2)
'@phenomnomnominal/tsquery': 6.2.0(typescript@6.0.3)
copy-webpack-plugin: 14.0.0(webpack@5.111.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(csso@5.0.5)(lightningcss@1.33.0)(postcss@8.5.28)(sharp@0.35.5(@types/node@22.20.4))(svgo@4.1.0))
ignore: 7.0.11
@@ -5790,13 +6142,13 @@ snapshots:
- typescript
- verdaccio
- '@nx/react@23.2.1(@babel/core@7.29.7(supports-color@7.2.0))(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(@zkochan/js-yaml@0.0.7)(debug@4.4.3(supports-color@7.2.0))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(react-dom@19.3.0(react@19.3.0))(react@19.3.0)(supports-color@7.2.0)(typescript@6.0.3)(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0))':
+ '@nx/react@23.2.1(@babel/core@7.29.7(supports-color@7.2.0))(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(@zkochan/js-yaml@0.0.7)(debug@4.4.3(supports-color@7.2.0))(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(react-dom@19.3.0(react@19.3.0))(react@19.3.0)(supports-color@7.2.0)(typescript@6.0.3)(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0))(vitest@5.0.5(@types/node@22.20.4)(jsdom@30.1.3)(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0)))':
dependencies:
'@babel/preset-react': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)
'@nx/devkit': 23.2.1(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))
'@nx/eslint': 23.2.1(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(@zkochan/js-yaml@0.0.7)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(supports-color@7.2.0)
'@nx/js': 23.2.1(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(supports-color@7.2.0)
- '@nx/web': 23.2.1(5edbad283f4527d1fc6a7dbafd6db7ef)
+ '@nx/web': 23.2.1(e12d0c8ff9aba933cba5d8df0ac4a5f2)
'@phenomnomnominal/tsquery': 6.2.0(typescript@6.0.3)
minimatch: 10.2.5
react: 19.3.0
@@ -5804,7 +6156,7 @@ snapshots:
semver: 7.8.5
tslib: 2.8.1
optionalDependencies:
- '@nx/vite': 23.2.1(b2f4a7406abd7b921160f0153ba59543)
+ '@nx/vite': 23.2.1(e652bccf01757e31a1c09f8180659a70)
transitivePeerDependencies:
- '@babel/core'
- '@babel/traverse'
@@ -5825,11 +6177,11 @@ snapshots:
- vite
- vitest
- '@nx/vite@23.2.1(b2f4a7406abd7b921160f0153ba59543)':
+ '@nx/vite@23.2.1(e652bccf01757e31a1c09f8180659a70)':
dependencies:
'@nx/devkit': 23.2.1(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))
'@nx/js': 23.2.1(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(supports-color@7.2.0)
- '@nx/vitest': 23.2.1(b2f4a7406abd7b921160f0153ba59543)
+ '@nx/vitest': 23.2.1(e652bccf01757e31a1c09f8180659a70)
'@phenomnomnominal/tsquery': 6.2.0(typescript@6.0.3)
ajv: 8.20.0
picomatch: 4.0.4
@@ -5850,7 +6202,7 @@ snapshots:
- vitest
optional: true
- '@nx/vitest@23.2.1(b2f4a7406abd7b921160f0153ba59543)':
+ '@nx/vitest@23.2.1(e652bccf01757e31a1c09f8180659a70)':
dependencies:
'@nx/devkit': 23.2.1(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))
'@nx/js': 23.2.1(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(supports-color@7.2.0)
@@ -5860,6 +6212,7 @@ snapshots:
optionalDependencies:
'@nx/eslint': 23.2.1(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(@zkochan/js-yaml@0.0.7)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(supports-color@7.2.0)
vite: 8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0)
+ vitest: 5.0.5(@types/node@22.20.4)(jsdom@30.1.3)(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0))
transitivePeerDependencies:
- '@babel/traverse'
- '@swc-node/register'
@@ -5871,7 +6224,7 @@ snapshots:
- verdaccio
optional: true
- '@nx/web@23.2.1(5edbad283f4527d1fc6a7dbafd6db7ef)':
+ '@nx/web@23.2.1(e12d0c8ff9aba933cba5d8df0ac4a5f2)':
dependencies:
'@nx/devkit': 23.2.1(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))
'@nx/js': 23.2.1(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(supports-color@7.2.0)
@@ -5881,7 +6234,7 @@ snapshots:
tslib: 2.8.1
optionalDependencies:
'@nx/eslint': 23.2.1(@babel/traverse@7.29.8(supports-color@7.2.0))(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/cli@0.8.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(supports-color@7.2.0))(@swc/core@1.15.47(@swc/helpers@0.5.23))(@zkochan/js-yaml@0.0.7)(eslint@9.39.5(jiti@2.7.0)(supports-color@7.2.0))(nx@23.2.1(@swc-node/register@1.11.1(@swc/core@1.15.47(@swc/helpers@0.5.23))(@swc/types@0.1.28)(supports-color@7.2.0)(typescript@6.0.3))(@swc/core@1.15.47(@swc/helpers@0.5.23)))(supports-color@7.2.0)
- '@nx/vite': 23.2.1(b2f4a7406abd7b921160f0153ba59543)
+ '@nx/vite': 23.2.1(e652bccf01757e31a1c09f8180659a70)
transitivePeerDependencies:
- '@babel/traverse'
- '@swc-node/register'
@@ -5906,8 +6259,7 @@ snapshots:
- '@swc-node/register'
- '@swc/core'
- '@oxc-project/types@0.152.0':
- optional: true
+ '@oxc-project/types@0.152.0': {}
'@oxc-resolver/binding-android-arm-eabi@11.24.2':
optional: true
@@ -6078,8 +6430,7 @@ snapshots:
'@rolldown/binding-win32-x64-msvc@1.2.12':
optional: true
- '@rolldown/pluginutils@1.0.1':
- optional: true
+ '@rolldown/pluginutils@1.0.1': {}
'@sec-ant/readable-stream@0.4.1': {}
@@ -6277,6 +6628,31 @@ snapshots:
'@tanstack/query-core': 5.104.1
react: 19.3.0
+ '@testing-library/dom@10.4.2':
+ dependencies:
+ '@babel/code-frame': 7.29.7
+ '@babel/runtime': 7.29.7
+ '@types/aria-query': 5.0.4
+ aria-query: 5.3.0
+ dom-accessibility-api: 0.5.16
+ lz-string: 1.5.0
+ picocolors: 1.1.1
+ pretty-format: 27.5.1
+
+ '@testing-library/react@16.3.3(@testing-library/dom@10.4.2)(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)':
+ dependencies:
+ '@babel/runtime': 7.29.7
+ '@testing-library/dom': 10.4.2
+ react: 19.3.0
+ react-dom: 19.3.0(react@19.3.0)
+ optionalDependencies:
+ '@types/react': 19.3.0
+ '@types/react-dom': 19.3.0(@types/react@19.3.0)
+
+ '@testing-library/user-event@14.6.8(@testing-library/dom@10.4.2)':
+ dependencies:
+ '@testing-library/dom': 10.4.2
+
'@tokenizer/inflate@0.4.1(supports-color@7.2.0)':
dependencies:
debug: 4.4.3(supports-color@7.2.0)
@@ -6295,6 +6671,15 @@ snapshots:
dependencies:
tslib: 2.8.1
+ '@types/aria-query@5.0.4': {}
+
+ '@types/chai@5.2.3':
+ dependencies:
+ '@types/deep-eql': 4.0.2
+ assertion-error: 2.0.1
+
+ '@types/deep-eql@4.0.2': {}
+
'@types/esquery@1.5.4':
dependencies:
'@types/estree': 1.0.9
@@ -6410,6 +6795,17 @@ snapshots:
'@typescript-eslint/types': 8.71.0
eslint-visitor-keys: 5.0.1
+ '@vitest/mocker@5.0.5(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0))':
+ dependencies:
+ '@jridgewell/trace-mapping': 0.3.31
+ '@vitest/spy': 5.0.5
+ estree-walker: 3.0.3
+ magic-string: 1.4.5
+ optionalDependencies:
+ vite: 8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0)
+
+ '@vitest/spy@5.0.5': {}
+
'@webassemblyjs/ast@1.14.1':
dependencies:
'@webassemblyjs/helper-numbers': 1.13.2
@@ -6632,8 +7028,16 @@ snapshots:
dependencies:
color-convert: 2.0.1
+ ansi-styles@5.2.0: {}
+
argparse@2.0.1: {}
+ aria-query@5.3.0:
+ dependencies:
+ dequal: 2.0.3
+
+ assertion-error@2.0.1: {}
+
async@3.2.6: {}
asynckit@0.4.0: {}
@@ -6718,6 +7122,10 @@ snapshots:
dependencies:
safe-buffer: 5.1.2
+ bidi-js@1.1.0:
+ dependencies:
+ require-from-string: 2.0.2
+
binary-version-check@6.1.0:
dependencies:
binary-version: 7.1.0
@@ -6797,6 +7205,8 @@ snapshots:
caniuse-lite@1.0.30001814: {}
+ chai@6.3.0: {}
+
chalk@4.1.2:
dependencies:
ansi-styles: 4.3.0
@@ -6922,6 +7332,13 @@ snapshots:
csstype@3.2.3: {}
+ data-urls@8.0.0:
+ dependencies:
+ whatwg-mimetype: 5.0.0
+ whatwg-url: 17.3.0
+ transitivePeerDependencies:
+ - '@noble/hashes'
+
debug@4.4.3(supports-color@7.2.0):
dependencies:
ms: 2.1.3
@@ -6935,6 +7352,8 @@ snapshots:
supports-color: 8.1.1
optional: true
+ decimal.js@10.6.0: {}
+
decompress-response@10.0.0:
dependencies:
mimic-response: 4.0.0
@@ -6956,12 +7375,16 @@ snapshots:
delayed-stream@1.0.0: {}
+ dequal@2.0.3: {}
+
detect-libc@2.1.2: {}
detect-port@2.1.0:
dependencies:
address: 2.0.3
+ dom-accessibility-api@0.5.16: {}
+
dom-serializer@2.0.0:
dependencies:
domelementtype: 2.3.0
@@ -7009,6 +7432,8 @@ snapshots:
entities@4.5.0: {}
+ entities@8.1.0: {}
+
error-ex@1.3.4:
dependencies:
is-arrayish: 0.2.1
@@ -7115,6 +7540,10 @@ snapshots:
estraverse@5.3.0: {}
+ estree-walker@3.0.3:
+ dependencies:
+ '@types/estree': 1.0.9
+
esutils@2.0.3: {}
eventemitter3@4.0.7: {}
@@ -7154,6 +7583,8 @@ snapshots:
strip-final-newline: 4.0.0
yoctocolors: 2.2.0
+ expect-type@1.4.0: {}
+
ext-list@2.2.2:
dependencies:
mime-db: 1.54.0
@@ -7330,6 +7761,12 @@ snapshots:
dependencies:
whatwg-encoding: 2.0.0
+ html-encoding-sniffer@7.0.0:
+ dependencies:
+ '@exodus/bytes': 1.16.0
+ transitivePeerDependencies:
+ - '@noble/hashes'
+
html-parse-stringify@4.0.1: {}
http-cache-semantics@4.2.0: {}
@@ -7438,6 +7875,8 @@ snapshots:
dependencies:
isobject: 3.0.1
+ is-potential-custom-element-name@1.0.1: {}
+
is-stream@3.0.0: {}
is-stream@4.0.1: {}
@@ -7470,6 +7909,31 @@ snapshots:
dependencies:
argparse: 2.0.1
+ jsdom@30.1.3:
+ dependencies:
+ '@asamuzakjp/css-color': 7.1.9
+ '@asamuzakjp/dom-selector': 10.0.5
+ '@bramus/specificity': 2.4.3
+ '@csstools/css-syntax-patches-for-csstree': 1.1.16(css-tree@3.2.1)
+ '@exodus/bytes': 1.16.0
+ css-tree: 3.2.1
+ data-urls: 8.0.0
+ decimal.js: 10.6.0
+ html-encoding-sniffer: 7.0.0
+ is-potential-custom-element-name: 1.0.1
+ lru-cache: 11.5.3
+ parse5: 8.0.1
+ saxes: 6.0.0
+ tough-cookie: 6.0.2
+ undici: 8.12.3
+ w3c-xmlserializer: 6.0.0
+ webidl-conversions: 8.0.1
+ whatwg-mimetype: 5.0.0
+ whatwg-url: 17.3.0
+ xml-name-validator: 5.0.0
+ transitivePeerDependencies:
+ - '@noble/hashes'
+
jsesc@3.1.0: {}
json-buffer@3.0.1: {}
@@ -7605,7 +8069,6 @@ snapshots:
lightningcss-linux-x64-musl: 1.33.0
lightningcss-win32-arm64-msvc: 1.33.0
lightningcss-win32-x64-msvc: 1.33.0
- optional: true
lines-and-columns@1.2.4: {}
@@ -7626,14 +8089,22 @@ snapshots:
lowercase-keys@3.0.0: {}
+ lru-cache@11.5.3: {}
+
lru-cache@5.1.1:
dependencies:
yallist: 3.1.1
+ lz-string@1.5.0: {}
+
magic-string@0.30.21:
dependencies:
'@jridgewell/sourcemap-codec': 1.6.0
+ magic-string@1.4.5:
+ dependencies:
+ '@jridgewell/sourcemap-codec': 1.6.0
+
make-asynchronous@1.1.0:
dependencies:
p-event: 6.0.1
@@ -7914,6 +8385,8 @@ snapshots:
object-inspect@1.13.4: {}
+ obug@3.0.0: {}
+
once@1.4.0:
dependencies:
wrappy: 1.0.2
@@ -8029,6 +8502,10 @@ snapshots:
parse-ms@4.0.0: {}
+ parse5@8.0.1:
+ dependencies:
+ entities: 8.1.0
+
path-exists@4.0.0: {}
path-key@3.1.1: {}
@@ -8045,8 +8522,7 @@ snapshots:
picomatch@4.0.4: {}
- picomatch@4.0.7:
- optional: true
+ picomatch@4.0.7: {}
pirates@4.0.7: {}
@@ -8077,6 +8553,12 @@ snapshots:
prettier@3.6.2: {}
+ pretty-format@27.5.1:
+ dependencies:
+ ansi-regex: 5.0.1
+ ansi-styles: 5.2.0
+ react-is: 17.0.2
+
pretty-ms@9.3.1:
dependencies:
parse-ms: 4.0.0
@@ -8114,6 +8596,8 @@ snapshots:
react-dom: 19.3.0(react@19.3.0)
typescript: 6.0.3
+ react-is@17.0.2: {}
+
react@19.3.0: {}
readable-stream@3.6.2:
@@ -8191,7 +8675,6 @@ snapshots:
'@rolldown/binding-openharmony-arm64': 1.2.12
'@rolldown/binding-win32-arm64-msvc': 1.2.12
'@rolldown/binding-win32-x64-msvc': 1.2.12
- optional: true
run-applescript@7.0.0: {}
@@ -8203,6 +8686,10 @@ snapshots:
sax@1.6.1: {}
+ saxes@6.0.0:
+ dependencies:
+ xmlchars: 2.2.0
+
scheduler@0.28.0: {}
schema-utils@4.5.0:
@@ -8347,6 +8834,8 @@ snapshots:
source-map@0.7.6: {}
+ std-env@4.3.0: {}
+
streamx@2.28.1:
dependencies:
events-universal: 1.0.1
@@ -8473,11 +8962,21 @@ snapshots:
dependencies:
convert-hrtime: 5.0.0
+ tinybench@6.2.2: {}
+
+ tinyexec@1.3.1: {}
+
tinyglobby@0.2.17:
dependencies:
fdir: 6.5.0(picomatch@4.0.4)
picomatch: 4.0.4
+ tldts-core@7.4.20: {}
+
+ tldts@7.4.19:
+ dependencies:
+ tldts-core: 7.4.20
+
tmp@0.2.7: {}
token-types@6.1.2:
@@ -8486,6 +8985,14 @@ snapshots:
'@tokenizer/token': 0.3.0
ieee754: 1.2.1
+ tough-cookie@6.0.2:
+ dependencies:
+ tldts: 7.4.19
+
+ tr46@7.0.0:
+ dependencies:
+ punycode: 2.3.1
+
ts-api-utils@2.5.0(typescript@6.0.3):
dependencies:
typescript: 6.0.3
@@ -8526,6 +9033,8 @@ snapshots:
undici-types@6.21.0: {}
+ undici@8.12.3: {}
+
unicode-canonical-property-names-ecmascript@2.0.1: {}
unicode-match-property-ecmascript@2.0.0:
@@ -8578,7 +9087,32 @@ snapshots:
jiti: 2.7.0
terser: 5.51.2
yaml: 2.9.0
- optional: true
+
+ vitest@5.0.5(@types/node@22.20.4)(jsdom@30.1.3)(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0)):
+ dependencies:
+ '@types/chai': 5.2.3
+ '@vitest/mocker': 5.0.5(vite@8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0))
+ chai: 6.3.0
+ es-module-lexer: 2.3.2
+ expect-type: 1.4.0
+ magic-string: 1.4.5
+ obug: 3.0.0
+ picomatch: 4.0.7
+ std-env: 4.3.0
+ tinybench: 6.2.2
+ tinyexec: 1.3.1
+ tinyglobby: 0.2.17
+ vite: 8.3.2(@types/node@22.20.4)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.0)
+ why-is-node-running: 3.2.1
+ optionalDependencies:
+ '@types/node': 22.20.4
+ jsdom: 30.1.3
+ transitivePeerDependencies:
+ - msw
+
+ w3c-xmlserializer@6.0.0:
+ dependencies:
+ xml-name-validator: 5.0.0
watchpack@2.5.2:
dependencies:
@@ -8590,6 +9124,8 @@ snapshots:
web-worker@1.5.0: {}
+ webidl-conversions@8.0.1: {}
+
webpack-merge@5.10.0:
dependencies:
clone-deep: 4.0.1
@@ -8639,6 +9175,16 @@ snapshots:
dependencies:
iconv-lite: 0.6.3
+ whatwg-mimetype@5.0.0: {}
+
+ whatwg-url@17.3.0:
+ dependencies:
+ '@exodus/bytes': 1.16.0
+ tr46: 7.0.0
+ webidl-conversions: 8.0.1
+ transitivePeerDependencies:
+ - '@noble/hashes'
+
which@2.0.2:
dependencies:
isexe: 2.0.0
@@ -8647,6 +9193,8 @@ snapshots:
dependencies:
isexe: 2.0.0
+ why-is-node-running@3.2.1: {}
+
wildcard@2.0.1: {}
word-wrap@1.2.5: {}
@@ -8659,6 +9207,10 @@ snapshots:
wrappy@1.0.2: {}
+ xml-name-validator@5.0.0: {}
+
+ xmlchars@2.2.0: {}
+
y18n@5.0.8: {}
yallist@3.1.1: {}
diff --git a/tools/vitest-setup.ts b/tools/vitest-setup.ts
new file mode 100644
index 0000000..cbf7c53
--- /dev/null
+++ b/tools/vitest-setup.ts
@@ -0,0 +1,18 @@
+import { cleanup } from '@testing-library/react';
+import { afterEach } from 'vitest';
+
+afterEach(cleanup);
+
+// jsdom has `` without its modal methods.
+if (typeof HTMLDialogElement !== 'undefined') {
+ HTMLDialogElement.prototype.showModal ??= function showModal(
+ this: HTMLDialogElement,
+ ) {
+ this.open = true;
+ };
+ HTMLDialogElement.prototype.close ??= function close(
+ this: HTMLDialogElement,
+ ) {
+ this.open = false;
+ };
+}
diff --git a/vitest.config.ts b/vitest.config.ts
new file mode 100644
index 0000000..6131e51
--- /dev/null
+++ b/vitest.config.ts
@@ -0,0 +1,13 @@
+import { defineConfig } from 'vitest/config';
+
+// Component and unit tests of every project; each project's `test` script runs its own folder.
+export default defineConfig({
+ oxc: { jsx: { runtime: 'automatic' } },
+ resolve: { conditions: ['@lumina/source'] },
+ test: {
+ environment: 'jsdom',
+ include: ['src/**/*.test.{ts,tsx}'],
+ setupFiles: [`${import.meta.dirname}/tools/vitest-setup.ts`],
+ restoreMocks: true,
+ },
+});