feat(signals): add exact or range entry and required stop-loss to the composer
The composer asks for the entry as «قیمت دقیق», prefilled from the live quote until edited, or «بازه», plus a required stop-loss, and checks the levels against that entry on blur, on a direction change and on every quote refresh. The confirm step sends what it showed. The signal card shows a range with «بازه» and «ورود (بازه)», measures from its middle, and shows «ریسک به ریوارد» as lower to higher ratio. Every UI string now says «سیگنال» in place of «پیشبینی». Code identifiers and routes stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
01c838e869
commit
cac4f8e229
|
|
@ -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).
|
* only. From a page, the `@modal` slot opens it as a dialog over that page instead (0023).
|
||||||
*/
|
*/
|
||||||
export default function ComposePredictionPage() {
|
export default function ComposePredictionPage() {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {
|
||||||
} from '@lumina/market/app/screens/(flow)/compose/prediction/organisms/prediction-composer';
|
} 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
|
* 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
|
* 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.
|
* who may publish, why not for one who may not, or the no-access state for anyone else.
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { i18n } from '../../../../i18n';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The creator's داشبورد on desktop (Creator Dashboard ۵.۱): the 640 column under the header, with
|
* 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
|
* route with its own loading, so the heading and the tabs stay while one loads. Locked until
|
||||||
* registration step 5 is done (0016).
|
* registration step 5 is done (0016).
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { PredictionsTabSkeleton } from '@lumina/market/app/screens/(main)/dashbo
|
||||||
|
|
||||||
import { i18n } from '../../../../../i18n';
|
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() {
|
export default function Loading() {
|
||||||
return (
|
return (
|
||||||
<PredictionsTabSkeleton label={i18n.t('predictions:tab.loading')} delayed />
|
<PredictionsTabSkeleton label={i18n.t('predictions:tab.loading')} delayed />
|
||||||
|
|
|
||||||
|
|
@ -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.
|
* browser only. Each block loads and fails on its own; the tabs stay.
|
||||||
*/
|
*/
|
||||||
export default function PredictionsPage() {
|
export default function PredictionsPage() {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { PredictionListSkeleton } from '@lumina/market/app/screens/(main)/dashbo
|
||||||
|
|
||||||
import { i18n } from '../../../../../i18n';
|
import { i18n } from '../../../../../i18n';
|
||||||
|
|
||||||
/** «همه پیشبینیها» before it arrives, under its real title. */
|
/** «همه سیگنالها» before it arrives, under its real title. */
|
||||||
export default function Loading() {
|
export default function Loading() {
|
||||||
return (
|
return (
|
||||||
<FlexBox tag="main" justifyContent="justify-center" className="px-8 py-10">
|
<FlexBox tag="main" justifyContent="justify-center" className="px-8 py-10">
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ export const metadata: Metadata = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* «همه پیشبینیها» on desktop (J10-3f): the same list in the 640 column, «بازگشت» over its title
|
* «همه سیگنالها» 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.
|
* back to the سیگنالها tab. The creator's own, in the browser only.
|
||||||
*/
|
*/
|
||||||
export default function PredictionListPage() {
|
export default function PredictionListPage() {
|
||||||
const skeleton = (
|
const skeleton = (
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export const metadata: Metadata = {
|
||||||
robots: { index: false },
|
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() {
|
export default function ComposePredictionPage() {
|
||||||
return (
|
return (
|
||||||
<AuthGuard
|
<AuthGuard
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { i18n } from '../../../../i18n';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The creator's داشبورد on mobile (Creator Dashboard ۱.۱, 0034): the tab bar «داشبورد», the three
|
* 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).
|
* bar and the tabs stay while one loads. Locked until registration step 5 is done (0016).
|
||||||
*/
|
*/
|
||||||
export default function CreatorDashboardLayout({
|
export default function CreatorDashboardLayout({
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { PredictionsTabSkeleton } from '@lumina/market/app/screens/(main)/dashbo
|
||||||
|
|
||||||
import { i18n } from '../../../../../i18n';
|
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() {
|
export default function Loading() {
|
||||||
return (
|
return (
|
||||||
<PredictionsTabSkeleton label={i18n.t('predictions:tab.loading')} delayed />
|
<PredictionsTabSkeleton label={i18n.t('predictions:tab.loading')} delayed />
|
||||||
|
|
|
||||||
|
|
@ -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.
|
* browser only. Each block loads and fails on its own; the tabs stay.
|
||||||
*/
|
*/
|
||||||
export default function PredictionsPage() {
|
export default function PredictionsPage() {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { PredictionListSkeleton } from '@lumina/market/app/screens/(main)/dashbo
|
||||||
|
|
||||||
import { i18n } from '../../../../../i18n';
|
import { i18n } from '../../../../../i18n';
|
||||||
|
|
||||||
/** «همه پیشبینیها» before it arrives, under its real bar. */
|
/** «همه سیگنالها» before it arrives, under its real bar. */
|
||||||
export default function Loading() {
|
export default function Loading() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ export const metadata: Metadata = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* «همه پیشبینیها» on mobile (J10-3f, J10-3g): a page pushed from the پیشبینیها tab, back ·
|
* «همه سیگنالها» 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;
|
* «سیگنالها» · support, with the nav kept on داشبورد. The creator's own, in the browser only;
|
||||||
* opened on its own, back goes to the tab.
|
* opened on its own, back goes to the tab.
|
||||||
*/
|
*/
|
||||||
export default function PredictionListPage() {
|
export default function PredictionListPage() {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import { QuoteHealth } from './components/QuoteHealth';
|
||||||
import { QuoteHealthSkeleton } from './components/QuoteHealthSkeleton';
|
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
|
* (نیاز به تأیید 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
|
* remounts the rows behind the table skeleton. The detail opens beside the table and the dialogs
|
||||||
* over it.
|
* over it.
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import { OutcomeValue } from './OutcomeValue';
|
||||||
import { PredictionCardView } from './PredictionCardView';
|
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
|
* 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 same source with a reason (the analyst's correction notice carries it), the outcome following
|
||||||
* the typed price, and «لغو اصلاح» back.
|
* the typed price, and «لغو اصلاح» back.
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import { useRetained } from '../use-retained';
|
||||||
import { DialogSubject } from './DialogSubject';
|
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.
|
* are internal: they change nothing on the card, the track record or the outcome.
|
||||||
*/
|
*/
|
||||||
export function FlagDialog({ actions }: ActionsProps) {
|
export function FlagDialog({ actions }: ActionsProps) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import type { PredictionPayload } from '@lumina/garden-roof/features/predictions
|
||||||
import { Button } from '@lumina/island/atoms/button';
|
import { Button } from '@lumina/island/atoms/button';
|
||||||
import { useTranslation } from 'react-i18next';
|
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({
|
export function OpenRowButton({
|
||||||
prediction,
|
prediction,
|
||||||
href,
|
href,
|
||||||
|
|
|
||||||
|
|
@ -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
|
* 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
|
* 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
|
* analyst's correction notice carries the reason. The win-rate change shows when the track record
|
||||||
* is known (opened from the detail).
|
* is known (opened from the detail).
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import type { PageModelProps } from '../types';
|
||||||
import { PredictionDetail } from './PredictionDetail';
|
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.
|
* on its own: a failed read errors inside the panel and leaves the queue as it was.
|
||||||
*/
|
*/
|
||||||
export function PredictionSheet({ model }: PageModelProps) {
|
export function PredictionSheet({ model }: PageModelProps) {
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,14 @@ export function predictionCardLabels(
|
||||||
toFinalTarget: t('card.to-final-target'),
|
toFinalTarget: t('card.to-final-target'),
|
||||||
toStop: t('card.to-stop'),
|
toStop: t('card.to-stop'),
|
||||||
riskReward: t('card.risk-reward'),
|
riskReward: t('card.risk-reward'),
|
||||||
|
riskRewardRange: (worst, best) =>
|
||||||
|
t('card.risk-reward-range', { worst, best }),
|
||||||
levels: {
|
levels: {
|
||||||
stop: t('card.levels.stop'),
|
stop: t('card.levels.stop'),
|
||||||
entry: t('card.levels.entry'),
|
entry: t('card.levels.entry'),
|
||||||
base: t('card.levels.base'),
|
base: t('card.levels.base'),
|
||||||
|
range: t('card.levels.range'),
|
||||||
|
entryRange: t('card.levels.entry-range'),
|
||||||
target,
|
target,
|
||||||
finalTarget: t('card.levels.final-target'),
|
finalTarget: t('card.levels.final-target'),
|
||||||
close: t('card.levels.close'),
|
close: t('card.levels.close'),
|
||||||
|
|
|
||||||
|
|
@ -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).
|
* queues in the browser once the admin is known (0062).
|
||||||
*/
|
*/
|
||||||
export default function PredictionsPage() {
|
export default function PredictionsPage() {
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,16 @@
|
||||||
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.
|
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 |
|
| 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) |
|
| 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) |
|
| 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 |
|
| ↳ 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 |
|
| ↳ 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 |
|
| ↳ 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 |
|
| 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
|
## 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)).
|
- 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`).
|
- 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`).
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
| loading.tsx | `dashboard/predictions/all/loading.tsx`: the real top bar (bull) or page title (bear) over `PredictionListSkeleton`, `delayed` |
|
| loading.tsx | `dashboard/predictions/all/loading.tsx`: the real top bar (bull) or page title (bear) over `PredictionListSkeleton`, `delayed` |
|
||||||
| First flush | none |
|
| First flush | none |
|
||||||
| Canonical | none: `noindex` |
|
| Canonical | none: `noindex` |
|
||||||
| H1 | bull: none, the bar's «همه پیشبینیها» is a `<span>`; bear: «همه پیشبینیها» in `DesktopPageTitle` |
|
| H1 | bull: none, the bar's «همه سیگنالها» is a `<span>`; bear: «همه سیگنالها» in `DesktopPageTitle` |
|
||||||
| JSON-LD | none |
|
| JSON-LD | none |
|
||||||
| Scripts | none beyond the layout's |
|
| Scripts | none beyond the layout's |
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,11 @@ In bull's document order. Everything sits in `AuthGuard role="creator"`, whose f
|
||||||
|
|
||||||
| Section | Data | HTML | JS | Index | Notes |
|
| 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) |
|
| 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 `<Suspense>` |
|
| ↳ TrackRecord | viewer | skeleton | hydrate | no | the record or its progress to public; own `PartBoundary` and `<Suspense>` |
|
||||||
| ↳ PredictionSection «باز» | viewer | skeleton | hydrate | no | every open prediction as `OwnPredictionCard`; not drawn when empty; loads and fails on its own |
|
| ↳ 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 |
|
| ↳↳ 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 `<a href>` to `/dashboard/predictions/all` |
|
| ↳ PredictionSection «بستهشدههای اخیر» | viewer | skeleton | hydrate | no | the two closed most recently; then «همه سیگنالها», an `<a href>` to `/dashboard/predictions/all` |
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
| MobileTopBar (bull) | config | first flush | hydrate | no | `isTab`: the brand and «داشبورد» centred, in a `<span>`; support entry; the connection bar under it (0040) |
|
| MobileTopBar (bull) | config | first flush | hydrate | no | `isTab`: the brand and «داشبورد» centred, in a `<span>`; 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 |
|
| ↳ 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 |
|
||||||
| «داشبورد» `<h1>` (bear) | config | first flush | none | no | at the top of the 640 column |
|
| «داشبورد» `<h1>` (bear) | config | first flush | none | no | at the top of the 640 column |
|
||||||
| DashboardTabs | config | first flush | hydrate | no | `role="creator"`: island `TabLinks`, an `<a href>` per tab «طرحهای اشتراک» · «پیشبینیها» · «مالی» (0034); the active tab comes from `usePathname`, so the server HTML already marks it |
|
| DashboardTabs | config | first flush | hydrate | no | `role="creator"`: island `TabLinks`, an `<a href>` per tab «طرحهای اشتراک» · «سیگنالها» · «مالی» (0034); the active tab comes from `usePathname`, so the server HTML already marks it |
|
||||||
|
|
||||||
Scripts: none beyond the root layout's.
|
Scripts: none beyond the root layout's.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
| ↳ Brand link (bear) | viewer | first flush | hydrate | no | `useHomeHref`: `/feed` while the viewer is unknown (so in the server HTML), `/` for a guest, `homeRoute` for a member |
|
| ↳ Brand link (bear) | viewer | first flush | hydrate | no | `useHomeHref`: `/feed` while the viewer is unknown (so in the server HTML), `/` for a guest, `homeRoute` for a member |
|
||||||
| ↳ Nav: خانه or کانال, داشبورد (bear) | viewer | none | hydrate | no | members only; `HeaderNavLink` is `next/link` |
|
| ↳ Nav: خانه or کانال, داشبورد (bear) | viewer | none | hydrate | no | members only; `HeaderNavLink` is `next/link` |
|
||||||
| ↳ SearchField (bear) | viewer | none | hydrate | no | investors only, not on `/search`; Enter calls `router.push('/search?q=…')` |
|
| ↳ SearchField (bear) | viewer | none | hydrate | no | investors only, not on `/search`; Enter calls `router.push('/search?q=…')` |
|
||||||
| ↳ PublishMenu (bear) | viewer | none | hydrate | no | creators only; «پست جدید» and «پیشبینی جدید» open the `@modal` intercepts (0023) |
|
| ↳ PublishMenu (bear) | viewer | none | hydrate | no | creators only; «پست جدید» and «سیگنال جدید» open the `@modal` intercepts (0023) |
|
||||||
| ↳ SupportEntry (bear) | config | first flush | hydrate | no | the icon trigger; its `SupportDialog` popover renders only while open |
|
| ↳ SupportEntry (bear) | config | first flush | hydrate | no | the icon trigger; its `SupportDialog` popover renders only while open |
|
||||||
| ↳ NotificationBell (bear) | viewer | none | hydrate | no | members only; the unread count is a browser `useQuery` |
|
| ↳ NotificationBell (bear) | viewer | none | hydrate | no | members only; the unread count is a browser `useQuery` |
|
||||||
| ↳ NotificationPanel (bear) | query | none | interaction | no | the bell's side panel: `next/dynamic` with `ssr: false`, mounted on the bell's first click |
|
| ↳ NotificationPanel (bear) | query | none | interaction | no | the bell's side panel: `next/dynamic` with `ssr: false`, mounted on the bell's first click |
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ In bull's document order.
|
||||||
| ↳ Title or login link (bull) | viewer | skeleton | hydrate | no | |
|
| ↳ Title or login link (bull) | viewer | skeleton | hydrate | no | |
|
||||||
| DesktopPageTitle (bear) | config | first flush | hydrate | no | «بازگشت» and the H1 |
|
| DesktopPageTitle (bear) | config | first flush | hydrate | no | «بازگشت» and the H1 |
|
||||||
| NotificationCentre | viewer, query | skeleton | hydrate | no | `AuthGuard`, then `<Suspense>` and `PartBoundary name="notification-centre"`; `useSuspenseQuery` of the inbox; opening clears the bell (0058); bear: `framed` |
|
| NotificationCentre | viewer, query | skeleton | hydrate | no | `AuthGuard`, then `<Suspense>` and `PartBoundary name="notification-centre"`; `useSuspenseQuery` of the inbox; opening clears the bell (0058); bear: `framed` |
|
||||||
| ↳ FilterChips | viewer | skeleton | hydrate | no | creators only: «همه · پیشبینیها · مالی · حساب», filtered in place (0058) |
|
| ↳ FilterChips | viewer | skeleton | hydrate | no | creators only: «همه · سیگنالها · مالی · حساب», filtered in place (0058) |
|
||||||
| ↳ NotificationItem list | query | skeleton | hydrate | no | each row leads to its target; a row stays unread until tapped |
|
| ↳ NotificationItem list | query | skeleton | hydrate | no | each row leads to its target; a row stays unread until tapped |
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import { actionMenuVariants } from './variants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A short list of destinations or actions anchored to its trigger, such as «انتشار» → «پست جدید»
|
* A short list of destinations or actions anchored to its trigger, such as «انتشار» → «پست جدید»
|
||||||
* / «پیشبینی جدید», a post's share → «کپی لینک», or the desktop account menu with its identity
|
* / «سیگنال جدید», a post's share → «کپی لینک», or the desktop account menu with its identity
|
||||||
* `header`, links and a danger «خروج از حساب» after a separator. Put it in a positioned container
|
* `header`, links and a danger «خروج از حساب» after a separator. Put it in a positioned container
|
||||||
* that holds only the trigger and the menu, and give the trigger `aria-haspopup="menu"`. It takes focus when
|
* that holds only the trigger and the menu, and give the trigger `aria-haspopup="menu"`. It takes focus when
|
||||||
* it opens; ↑ ↓ move, and the trigger keeps its own press. Escape or a choice closes it and puts
|
* it opens; ↑ ↓ move, and the trigger keeps its own press. Escape or a choice closes it and puts
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ export type AnalystCardLabels = {
|
||||||
verified: string;
|
verified: string;
|
||||||
/** The market list's accessible name: «بازارهای تخصصی». */
|
/** The market list's accessible name: «بازارهای تخصصی». */
|
||||||
markets: string;
|
markets: string;
|
||||||
/** The stat tiles: «نرخ موفقیت», «پیشبینی», «میانگین بازده». */
|
/** The stat tiles: «نرخ موفقیت», «سیگنال», «میانگین بازده». */
|
||||||
winRate: ReactNode;
|
winRate: ReactNode;
|
||||||
predictions: ReactNode;
|
predictions: ReactNode;
|
||||||
avgRoi: ReactNode;
|
avgRoi: ReactNode;
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,13 @@ export type CreatorStatsData = {
|
||||||
* formatted (`1٬234`, `62٫9٪`), so the translation only places them.
|
* formatted (`1٬234`, `62٫9٪`), so the translation only places them.
|
||||||
*/
|
*/
|
||||||
export type CreatorStatsLabels = {
|
export type CreatorStatsLabels = {
|
||||||
/** «عملکرد پیشبینیها». */
|
/** «عملکرد سیگنالها». */
|
||||||
title: ReactNode;
|
title: ReactNode;
|
||||||
/** «مشاهده کارنامه کامل». */
|
/** «مشاهده کارنامه کامل». */
|
||||||
viewRecord: ReactNode;
|
viewRecord: ReactNode;
|
||||||
/** «نرخ موفقیت». */
|
/** «نرخ موفقیت». */
|
||||||
winRate: 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;
|
closedCount: (count: string) => ReactNode;
|
||||||
/** Each outcome in words, for the legend, the key, the tooltips and the curve's sentence: «موفق», «ناموفق», «سربهسر». */
|
/** Each outcome in words, for the legend, the key, the tooltips and the curve's sentence: «موفق», «ناموفق», «سربهسر». */
|
||||||
outcomes: Record<TrendOutcome, string>;
|
outcomes: Record<TrendOutcome, string>;
|
||||||
|
|
@ -48,19 +48,19 @@ export type CreatorStatsLabels = {
|
||||||
splitSentence: (counts: Record<TrendOutcome, string>) => string;
|
splitSentence: (counts: Record<TrendOutcome, string>) => string;
|
||||||
/** «بازدهی میانگین». */
|
/** «بازدهی میانگین». */
|
||||||
avgRoi: ReactNode;
|
avgRoi: ReactNode;
|
||||||
/** «کل پیشبینیها». */
|
/** «کل سیگنالها». */
|
||||||
total: ReactNode;
|
total: ReactNode;
|
||||||
/** «پیشبینیهای فعال». */
|
/** «سیگنالهای فعال». */
|
||||||
active: ReactNode;
|
active: ReactNode;
|
||||||
/** «روند دقت». */
|
/** «روند دقت». */
|
||||||
trendTitle: ReactNode;
|
trendTitle: ReactNode;
|
||||||
/** Beside the trend title: `(count) => \`${count} پیشبینی اخیر\``. */
|
/** Beside the trend title: `(count) => \`${count} سیگنال اخیر\``. */
|
||||||
trendWindow: (count: string) => ReactNode;
|
trendWindow: (count: string) => ReactNode;
|
||||||
/** `(wins, total) => \`${wins} از ${total} موفق\`` → «۷ از ۱۰ موفق». */
|
/** `(wins, total) => \`${wins} از ${total} موفق\`` → «۷ از ۱۰ موفق». */
|
||||||
tally: (wins: string, total: string) => ReactNode;
|
tally: (wins: string, total: string) => ReactNode;
|
||||||
/**
|
/**
|
||||||
* The curve's one image label, every outcome in order plus how to read it:
|
* 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;
|
curveLabel: (count: string, outcomes: string[]) => string;
|
||||||
/** The newest point's tooltip: `(outcome) => \`${outcome} (جدیدترین)\``. */
|
/** The newest point's tooltip: `(outcome) => \`${outcome} (جدیدترین)\``. */
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,11 @@ export type PostCardOwner = {
|
||||||
onDelete?: () => void;
|
onDelete?: () => void;
|
||||||
/** «مشاهده به عنوان کاربر», on premium posts only. */
|
/** «مشاهده به عنوان کاربر», on premium posts only. */
|
||||||
onPreview?: () => void;
|
onPreview?: () => void;
|
||||||
/** The embedded open prediction's «بستن پیشبینی». */
|
/** The embedded open prediction's «بستن سیگنال». */
|
||||||
onClosePrediction?: () => void;
|
onClosePrediction?: () => void;
|
||||||
/**
|
/**
|
||||||
* The embedded open prediction's close waiting for ops (J09-5): PredictionCard's `pendingClose`
|
* The embedded open prediction's close waiting for ops (J09-5): PredictionCard's `pendingClose`
|
||||||
* detail, which freezes «بستن پیشبینی».
|
* detail, which freezes «بستن سیگنال».
|
||||||
*/
|
*/
|
||||||
pendingClose?: ReactNode;
|
pendingClose?: ReactNode;
|
||||||
/** 15 minutes after publishing: the edit icon stays, frozen, and explains itself. */
|
/** 15 minutes after publishing: the edit icon stays, frozen, and explains itself. */
|
||||||
|
|
|
||||||
|
|
@ -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(
|
||||||
|
<PredictionCard
|
||||||
|
prediction={prediction}
|
||||||
|
variant={variant}
|
||||||
|
publishedAt="2026-01-01T00:00:00Z"
|
||||||
|
now="2026-01-02T00:00:00Z"
|
||||||
|
labels={labels}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -37,7 +37,12 @@ export function OpenKpis({ prediction, math, labels }: PredictionPartProps) {
|
||||||
)}
|
)}
|
||||||
{riskReward != null && (
|
{riskReward != null && (
|
||||||
<Kpi label={labels.riskReward} color="primary">
|
<Kpi label={labels.riskReward} color="primary">
|
||||||
{ratio(1, riskReward)}
|
{riskReward.worst === riskReward.best
|
||||||
|
? ratio(1, riskReward.worst)
|
||||||
|
: labels.riskRewardRange(
|
||||||
|
ratio(1, riskReward.worst),
|
||||||
|
ratio(1, riskReward.best),
|
||||||
|
)}
|
||||||
</Kpi>
|
</Kpi>
|
||||||
)}
|
)}
|
||||||
</GridBox>
|
</GridBox>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { Element } from '../../../primitives/element';
|
||||||
import { cn } from '../../../tools/cn';
|
import { cn } from '../../../tools/cn';
|
||||||
import { CLOSE_SORT_NUDGE, EMPTY_VALUE, TREND_COLORS } from '../constants';
|
import { CLOSE_SORT_NUDGE, EMPTY_VALUE, TREND_COLORS } from '../constants';
|
||||||
import type { LadderRow, PredictionPartProps } from '../types';
|
import type { LadderRow, PredictionPartProps } from '../types';
|
||||||
import { trendOf } from '../utils';
|
import { entryText, isRangeEntry, trendOf } from '../utils';
|
||||||
import { ladderCellVariants, ladderHeadVariants } from '../variants';
|
import { ladderCellVariants, ladderHeadVariants } from '../variants';
|
||||||
import { LevelGlyph } from './LevelGlyph';
|
import { LevelGlyph } from './LevelGlyph';
|
||||||
|
|
||||||
|
|
@ -24,6 +24,7 @@ export function PredictionLadder({
|
||||||
const { closed, closeFav, risk, hits, targetsFav, stopHit } = math;
|
const { closed, closeFav, risk, hits, targetsFav, stopHit } = math;
|
||||||
const { levels, ladder } = labels;
|
const { levels, ladder } = labels;
|
||||||
const many = targetPrices.length > 1;
|
const many = targetPrices.length > 1;
|
||||||
|
const isRange = isRangeEntry(prediction);
|
||||||
|
|
||||||
const rows: LadderRow[] = targetPrices.map((target, index) => ({
|
const rows: LadderRow[] = targetPrices.map((target, index) => ({
|
||||||
key: `t${index}`,
|
key: `t${index}`,
|
||||||
|
|
@ -44,9 +45,10 @@ export function PredictionLadder({
|
||||||
order: 0,
|
order: 0,
|
||||||
change: null,
|
change: null,
|
||||||
glyph: <LevelGlyph kind="entry" />,
|
glyph: <LevelGlyph kind="entry" />,
|
||||||
label: levels.entry,
|
label: isRange ? levels.entryRange : levels.entry,
|
||||||
price: entryPrice,
|
price: entryPrice,
|
||||||
state: levels.base,
|
priceText: isRange ? entryText(prediction) : undefined,
|
||||||
|
state: isRange ? levels.range : levels.base,
|
||||||
});
|
});
|
||||||
if (stopLoss != null && risk != null) {
|
if (stopLoss != null && risk != null) {
|
||||||
rows.push({
|
rows.push({
|
||||||
|
|
@ -145,7 +147,7 @@ export function PredictionLadder({
|
||||||
variant="body-sm"
|
variant="body-sm"
|
||||||
className={cn(cell, 'text-end font-bold')}
|
className={cn(cell, 'text-end font-bold')}
|
||||||
>
|
>
|
||||||
{price(row.price)}
|
{row.priceText ?? price(row.price)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
tag="td"
|
tag="td"
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,15 @@ import { GridBox } from '../../../atoms/grid-box';
|
||||||
import { Typography } from '../../../atoms/typography';
|
import { Typography } from '../../../atoms/typography';
|
||||||
import { TREND_COLORS } from '../constants';
|
import { TREND_COLORS } from '../constants';
|
||||||
import type { PredictionPartProps } from '../types';
|
import type { PredictionPartProps } from '../types';
|
||||||
import { hasLongPrice, trendOf } from '../utils';
|
import { entryText, hasLongPrice, isRangeEntry, trendOf } from '../utils';
|
||||||
import { levelsVariants } from '../variants';
|
import { levelsVariants } from '../variants';
|
||||||
import { LevelGlyph } from './LevelGlyph';
|
import { LevelGlyph } from './LevelGlyph';
|
||||||
import { LevelTile } from './LevelTile';
|
import { LevelTile } from './LevelTile';
|
||||||
|
|
||||||
/** Compact: the exact prices on sunken tiles, stop loss → entry → targets, each with its % from entry. */
|
/**
|
||||||
|
* Compact: the exact prices on sunken tiles, stop loss → entry → targets, each with its % from entry.
|
||||||
|
* A range entry shows both ends, marked «بازه» instead of «مبنا», on wider tiles.
|
||||||
|
*/
|
||||||
export function PredictionLevels({
|
export function PredictionLevels({
|
||||||
prediction,
|
prediction,
|
||||||
math,
|
math,
|
||||||
|
|
@ -17,8 +20,9 @@ export function PredictionLevels({
|
||||||
}: PredictionPartProps) {
|
}: PredictionPartProps) {
|
||||||
const { entryPrice, targetPrices, stopLoss } = prediction;
|
const { entryPrice, targetPrices, stopLoss } = prediction;
|
||||||
const many = targetPrices.length > 1;
|
const many = targetPrices.length > 1;
|
||||||
|
const isRange = isRangeEntry(prediction);
|
||||||
|
|
||||||
const value = (level: number, change: number | null) => (
|
const value = (level: string, change: number | null) => (
|
||||||
<>
|
<>
|
||||||
<Typography
|
<Typography
|
||||||
tag="span"
|
tag="span"
|
||||||
|
|
@ -26,11 +30,11 @@ export function PredictionLevels({
|
||||||
variant="body-sm"
|
variant="body-sm"
|
||||||
className="truncate text-end font-bold"
|
className="truncate text-end font-bold"
|
||||||
>
|
>
|
||||||
{price(level)}
|
{level}
|
||||||
</Typography>
|
</Typography>
|
||||||
{change == null ? (
|
{change == null ? (
|
||||||
<Typography tag="span" variant="micro" color="tertiary">
|
<Typography tag="span" variant="micro" color="tertiary">
|
||||||
{labels.levels.base}
|
{isRange ? labels.levels.range : labels.levels.base}
|
||||||
</Typography>
|
</Typography>
|
||||||
) : (
|
) : (
|
||||||
<Typography
|
<Typography
|
||||||
|
|
@ -52,6 +56,7 @@ export function PredictionLevels({
|
||||||
gap="gap-2"
|
gap="gap-2"
|
||||||
className={levelsVariants({
|
className={levelsVariants({
|
||||||
wide: hasLongPrice([entryPrice, stopLoss, ...targetPrices]),
|
wide: hasLongPrice([entryPrice, stopLoss, ...targetPrices]),
|
||||||
|
range: isRange,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{stopLoss != null && (
|
{stopLoss != null && (
|
||||||
|
|
@ -59,14 +64,14 @@ export function PredictionLevels({
|
||||||
glyph={<LevelGlyph kind="stop" />}
|
glyph={<LevelGlyph kind="stop" />}
|
||||||
label={labels.levels.stop}
|
label={labels.levels.stop}
|
||||||
>
|
>
|
||||||
{value(stopLoss, math.risk)}
|
{value(price(stopLoss), math.risk)}
|
||||||
</LevelTile>
|
</LevelTile>
|
||||||
)}
|
)}
|
||||||
<LevelTile
|
<LevelTile
|
||||||
glyph={<LevelGlyph kind="entry" />}
|
glyph={<LevelGlyph kind="entry" />}
|
||||||
label={labels.levels.entry}
|
label={labels.levels.entry}
|
||||||
>
|
>
|
||||||
{value(entryPrice, null)}
|
{value(entryText(prediction), null)}
|
||||||
</LevelTile>
|
</LevelTile>
|
||||||
{targetPrices.map((target, index) => (
|
{targetPrices.map((target, index) => (
|
||||||
<LevelTile
|
<LevelTile
|
||||||
|
|
@ -80,7 +85,7 @@ export function PredictionLevels({
|
||||||
}
|
}
|
||||||
label={labels.levels.target(many ? number(index + 1) : undefined)}
|
label={labels.levels.target(many ? number(index + 1) : undefined)}
|
||||||
>
|
>
|
||||||
{value(target, math.targetsFav[index])}
|
{value(price(target), math.targetsFav[index])}
|
||||||
</LevelTile>
|
</LevelTile>
|
||||||
))}
|
))}
|
||||||
</GridBox>
|
</GridBox>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { Typography } from '../../../atoms/typography';
|
||||||
import { Element } from '../../../primitives/element';
|
import { Element } from '../../../primitives/element';
|
||||||
import { OUTCOME_TRENDS } from '../constants';
|
import { OUTCOME_TRENDS } from '../constants';
|
||||||
import type { PredictionRangeProps } from '../types';
|
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 { markerVariants, rangeBandVariants, rangeVariants } from '../variants';
|
||||||
import { ClosePin } from './ClosePin';
|
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
|
* 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,
|
* 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
|
* 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({
|
export function PredictionRange({
|
||||||
prediction,
|
prediction,
|
||||||
|
|
@ -22,8 +22,7 @@ export function PredictionRange({
|
||||||
labels,
|
labels,
|
||||||
expanded,
|
expanded,
|
||||||
}: PredictionRangeProps) {
|
}: PredictionRangeProps) {
|
||||||
const { entryPrice, targetPrices, stopLoss, closedPrice, outcome } =
|
const { targetPrices, stopLoss, closedPrice, outcome } = prediction;
|
||||||
prediction;
|
|
||||||
const { position, risk, reward, closed, closeFav, targetsFav, hits } = math;
|
const { position, risk, reward, closed, closeFav, targetsFav, hits } = math;
|
||||||
const hasStop = risk != null;
|
const hasStop = risk != null;
|
||||||
const entry = position(0);
|
const entry = position(0);
|
||||||
|
|
@ -38,7 +37,7 @@ export function PredictionRange({
|
||||||
|
|
||||||
const label = labels.rangeLabel({
|
const label = labels.rangeLabel({
|
||||||
stop: hasStop ? price(stopLoss) : undefined,
|
stop: hasStop ? price(stopLoss) : undefined,
|
||||||
entry: price(entryPrice),
|
entry: entryText(prediction),
|
||||||
targets: targetPrices.map(price),
|
targets: targetPrices.map(price),
|
||||||
close: closed ? price(closedPrice) : undefined,
|
close: closed ? price(closedPrice) : undefined,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
export { PredictionCard } from './PredictionCard';
|
export { PredictionCard } from './PredictionCard';
|
||||||
|
export { entryText, isRangeEntry } from './utils';
|
||||||
export type {
|
export type {
|
||||||
PredictionCardLabels,
|
PredictionCardLabels,
|
||||||
PredictionCardProps,
|
PredictionCardProps,
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,11 @@ export type PredictionData = {
|
||||||
/** The market's label from the translations: «کریپتو», «طلا», «بورس». */
|
/** The market's label from the translations: «کریپتو», «طلا», «بورس». */
|
||||||
market?: ReactNode;
|
market?: ReactNode;
|
||||||
direction: PredictionDirection;
|
direction: PredictionDirection;
|
||||||
|
/** The exact entry, or the middle of a range: every distance and return reads this. */
|
||||||
entryPrice: number;
|
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. */
|
/** One or more, nearest first; designed for up to three. The last one is the final target. */
|
||||||
targetPrices: number[];
|
targetPrices: number[];
|
||||||
/** Optional: without it there is no stop marker, risk zone, level or «تا حد ضرر». */
|
/** Optional: without it there is no stop marker, risk zone, level or «تا حد ضرر». */
|
||||||
|
|
@ -90,6 +94,8 @@ export type PredictionCardLabels = {
|
||||||
toStop: ReactNode;
|
toStop: ReactNode;
|
||||||
/** «ریسک به ریوارد», against the first target. */
|
/** «ریسک به ریوارد», against the first target. */
|
||||||
riskReward: ReactNode;
|
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. */
|
/** The names of the price levels, in the levels grid, the ladder and the range axis. */
|
||||||
levels: {
|
levels: {
|
||||||
/** «حد ضرر». */
|
/** «حد ضرر». */
|
||||||
|
|
@ -98,6 +104,10 @@ export type PredictionCardLabels = {
|
||||||
entry: ReactNode;
|
entry: ReactNode;
|
||||||
/** Entry's reference mark in place of a % change: «مبنا». */
|
/** Entry's reference mark in place of a % change: «مبنا». */
|
||||||
base: ReactNode;
|
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}</> : 'هدف')`. */
|
/** A target, numbered only when there are several: `(n) => (n ? <>هدف {n}</> : 'هدف')`. */
|
||||||
target: (n?: string) => ReactNode;
|
target: (n?: string) => ReactNode;
|
||||||
/** «هدف نهایی», the range axis's end when there are several targets. */
|
/** «هدف نهایی», the range axis's end when there are several targets. */
|
||||||
|
|
@ -122,7 +132,7 @@ export type PredictionCardLabels = {
|
||||||
notTriggered: ReactNode;
|
notTriggered: ReactNode;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* The range bar's `aria-label`: «محدوده پیشبینی: حد ضرر ۹۵٬۰۰۰، ورود ۱۰۰٬۰۰۰، هدف ۱ ۱۱۰٬۰۰۰،
|
* The range bar's `aria-label`: «محدوده سیگنال: حد ضرر ۹۵٬۰۰۰، ورود ۱۰۰٬۰۰۰، هدف ۱ ۱۱۰٬۰۰۰،
|
||||||
* بستهشدن ۱۰۸٬۰۰۰».
|
* بستهشدن ۱۰۸٬۰۰۰».
|
||||||
*/
|
*/
|
||||||
rangeLabel: (values: PredictionRangeValues) => string;
|
rangeLabel: (values: PredictionRangeValues) => string;
|
||||||
|
|
@ -141,7 +151,7 @@ export type PredictionCardLabels = {
|
||||||
/** The owner's pending-close row title, in bold: «در انتظار تأیید بستهشدن» (J09-5). */
|
/** The owner's pending-close row title, in bold: «در انتظار تأیید بستهشدن» (J09-5). */
|
||||||
pendingClose?: ReactNode;
|
pendingClose?: ReactNode;
|
||||||
/**
|
/**
|
||||||
* Why «بستن زودهنگام» is frozen while a close waits for ops: «این پیشبینی بهزودی بهصورت خودکار
|
* Why «بستن زودهنگام» is frozen while a close waits for ops: «این سیگنال بهزودی بهصورت خودکار
|
||||||
* بسته میشود.» (J10-3f).
|
* بسته میشود.» (J10-3f).
|
||||||
*/
|
*/
|
||||||
closeFrozen?: ReactNode;
|
closeFrozen?: ReactNode;
|
||||||
|
|
@ -171,7 +181,7 @@ export type PredictionCardLabels = {
|
||||||
};
|
};
|
||||||
/** A premium card for a viewer without access. */
|
/** A premium card for a viewer without access. */
|
||||||
locked: {
|
locked: {
|
||||||
/** «پیشبینی پریمیوم». */
|
/** «سیگنال پریمیوم». */
|
||||||
title: ReactNode;
|
title: ReactNode;
|
||||||
/** «دارایی، جهت، ورود، اهداف و حد ضرر پنهان است.» */
|
/** «دارایی، جهت، ورود، اهداف و حد ضرر پنهان است.» */
|
||||||
description: 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. */
|
/** Every number the card shows, computed once from the prediction. */
|
||||||
export type PredictionMath = {
|
export type PredictionMath = {
|
||||||
targetsFav: number[];
|
targetsFav: number[];
|
||||||
|
|
@ -242,8 +254,8 @@ export type PredictionMath = {
|
||||||
risk: number | null;
|
risk: number | null;
|
||||||
/** The final target's favourable %. */
|
/** The final target's favourable %. */
|
||||||
reward: number | null;
|
reward: number | null;
|
||||||
/** x in «۱ : x», against the first target. */
|
/** Rewards per unit of risk to the first target: one answer for an exact entry, or a range's two ends. */
|
||||||
riskReward: number | null;
|
riskReward: RiskReward | null;
|
||||||
/** Closed with a close price: the range draws a fill and a pin. */
|
/** Closed with a close price: the range draws a fill and a pin. */
|
||||||
closed: boolean;
|
closed: boolean;
|
||||||
closeFav: number | null;
|
closeFav: number | null;
|
||||||
|
|
@ -358,6 +370,8 @@ export type LadderRow = {
|
||||||
glyph: ReactNode;
|
glyph: ReactNode;
|
||||||
label: ReactNode;
|
label: ReactNode;
|
||||||
price: number;
|
price: number;
|
||||||
|
/** In place of `price`: a range entry's two ends. */
|
||||||
|
priceText?: string;
|
||||||
state: ReactNode;
|
state: ReactNode;
|
||||||
/** A target the close reached. */
|
/** A target the close reached. */
|
||||||
hit?: boolean;
|
hit?: boolean;
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -13,6 +13,7 @@ import type {
|
||||||
PredictionOutcome,
|
PredictionOutcome,
|
||||||
PredictionStatus,
|
PredictionStatus,
|
||||||
PredictionTrend,
|
PredictionTrend,
|
||||||
|
RiskReward,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
export function toTime(value: DateInput): number {
|
export function toTime(value: DateInput): number {
|
||||||
|
|
@ -48,6 +49,46 @@ export function resolveStatus(
|
||||||
: 'open';
|
: 'open';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The entry is a range, not one price. */
|
||||||
|
export function isRangeEntry(
|
||||||
|
prediction: Pick<PredictionData, 'entryLow' | 'entryHigh'>,
|
||||||
|
): 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<PredictionData, 'entryPrice' | 'entryLow' | 'entryHigh'>,
|
||||||
|
): 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
|
* 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.
|
* 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 targetsFav = targetPrices.map(fav);
|
||||||
const risk = stopLoss != null ? fav(stopLoss) : null;
|
const risk = stopLoss != null ? fav(stopLoss) : null;
|
||||||
const reward = targetsFav.at(-1) ?? 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];
|
const points = [0, ...targetsFav];
|
||||||
if (risk != null) points.push(risk);
|
if (risk != null) points.push(risk);
|
||||||
|
|
@ -91,7 +126,8 @@ export function predictionMath(prediction: PredictionData): PredictionMath {
|
||||||
targetsFav,
|
targetsFav,
|
||||||
risk,
|
risk,
|
||||||
reward,
|
reward,
|
||||||
riskReward,
|
// Against the first target: the one most likely to be reached.
|
||||||
|
riskReward: riskRewardOf(prediction),
|
||||||
closed: closeFav != null,
|
closed: closeFav != null,
|
||||||
closeFav,
|
closeFav,
|
||||||
roi,
|
roi,
|
||||||
|
|
|
||||||
|
|
@ -121,8 +121,13 @@ export const levelsVariants = cva('m-0', {
|
||||||
true: 'grid-cols-[repeat(auto-fit,minmax(6rem,1fr))]',
|
true: 'grid-cols-[repeat(auto-fit,minmax(6rem,1fr))]',
|
||||||
false: 'grid-cols-[repeat(auto-fit,minmax(4.5rem,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(
|
export const ladderHeadVariants = cva(
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ export type PartBoundaryProps = {
|
||||||
/** The part, for the error report: «creator-stats», «feed». Never personal data. */
|
/** The part, for the error report: «creator-stats», «feed». Never personal data. */
|
||||||
name: string;
|
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.
|
* است…» (S3); without it the fallback says what every part says.
|
||||||
*/
|
*/
|
||||||
title?: string;
|
title?: string;
|
||||||
|
|
|
||||||
|
|
@ -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
|
* «ثبت اصلاح» (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
|
* proposed). Either way investors see «علت: اصلاح توسط ادمین» (J09-5d) and the analyst's track
|
||||||
* record follows the outcome. Emits `prediction.overridden`.
|
* record follows the outcome. Emits `prediction.overridden`.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import {
|
||||||
} from '../../repositories/predictions';
|
} from '../../repositories/predictions';
|
||||||
import type { PredictionDetailPartModel } from './types';
|
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 {
|
export function usePredictionDetailPart(id: string): PredictionDetailPartModel {
|
||||||
const { data } = useSuspenseQuery({
|
const { data } = useSuspenseQuery({
|
||||||
queryKey: predictionKeys.detail(id),
|
queryKey: predictionKeys.detail(id),
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import type { PredictionsPageModel } from './types';
|
||||||
import { usePredictionActions } from './use-prediction-actions';
|
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
|
* 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
|
* keeps them. Closing never happens without ops: a detected close waits in نیاز به تأیید while the
|
||||||
* card stays «فعال».
|
* card stays «فعال».
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
"analysts": "مدیریت تحلیلگران",
|
"analysts": "مدیریت تحلیلگران",
|
||||||
"codes": "کدهای دعوت",
|
"codes": "کدهای دعوت",
|
||||||
"subs": "اشتراکها",
|
"subs": "اشتراکها",
|
||||||
"preds": "پیشبینیها",
|
"preds": "سیگنالها",
|
||||||
"payouts": "تسویه تحلیلگران",
|
"payouts": "تسویه تحلیلگران",
|
||||||
"featured": "تحلیلگران منتخب",
|
"featured": "تحلیلگران منتخب",
|
||||||
"soon": "بهزودی",
|
"soon": "بهزودی",
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@
|
||||||
"verified": "تأییدشده",
|
"verified": "تأییدشده",
|
||||||
"markets": "بازارهای تخصصی",
|
"markets": "بازارهای تخصصی",
|
||||||
"win-rate": "نرخ موفقیت",
|
"win-rate": "نرخ موفقیت",
|
||||||
"predictions": "پیشبینی",
|
"predictions": "سیگنال",
|
||||||
"avg-roi": "میانگین بازده",
|
"avg-roi": "میانگین بازده",
|
||||||
"no-record": "کارنامه عمومی هنوز فعال نشده است.",
|
"no-record": "کارنامه عمومی هنوز فعال نشده است.",
|
||||||
"followers": "{{followers}} دنبالکننده",
|
"followers": "{{followers}} دنبالکننده",
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
"labels": {
|
"labels": {
|
||||||
"active_analysts": "تحلیلگران فعال",
|
"active_analysts": "تحلیلگران فعال",
|
||||||
"avg_paid_subscribers": "میانگین مشترک پرداختی هر تحلیلگر",
|
"avg_paid_subscribers": "میانگین مشترک پرداختی هر تحلیلگر",
|
||||||
"publishing_analysts": "تحلیلگرانی که پیشبینی منتشر کردهاند",
|
"publishing_analysts": "تحلیلگرانی که سیگنال منتشر کردهاند",
|
||||||
"paid_subscribers": "کل مشترکان پرداختی"
|
"paid_subscribers": "کل مشترکان پرداختی"
|
||||||
},
|
},
|
||||||
"value": "{{value}} / {{target}}",
|
"value": "{{value}} / {{target}}",
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
"payment_result": "پرداخت موفق",
|
"payment_result": "پرداخت موفق",
|
||||||
"kyc_submitted": "ارسال مدارک احراز هویت",
|
"kyc_submitted": "ارسال مدارک احراز هویت",
|
||||||
"verification_approved": "تأیید احراز هویت",
|
"verification_approved": "تأیید احراز هویت",
|
||||||
"first_prediction_published": "اولین پیشبینی منتشرشده"
|
"first_prediction_published": "اولین سیگنال منتشرشده"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"timeline": {
|
"timeline": {
|
||||||
|
|
@ -82,7 +82,7 @@
|
||||||
"columns": {
|
"columns": {
|
||||||
"analyst": "تحلیلگر",
|
"analyst": "تحلیلگر",
|
||||||
"paid": "مشترک پرداختی",
|
"paid": "مشترک پرداختی",
|
||||||
"predictions": "پیشبینی منتشرشده",
|
"predictions": "سیگنال منتشرشده",
|
||||||
"capacity": "ظرفیت کد",
|
"capacity": "ظرفیت کد",
|
||||||
"completion": "نرخ تکمیل پرداخت"
|
"completion": "نرخ تکمیل پرداخت"
|
||||||
},
|
},
|
||||||
|
|
@ -103,7 +103,7 @@
|
||||||
"onboarding": {
|
"onboarding": {
|
||||||
"label": "زمان آمادهسازی تحلیلگر",
|
"label": "زمان آمادهسازی تحلیلگر",
|
||||||
"value": "{{days}} روز",
|
"value": "{{days}} روز",
|
||||||
"hint": "میانه، از ثبتنام تا اولین پیشبینی منتشرشده"
|
"hint": "میانه، از ثبتنام تا اولین سیگنال منتشرشده"
|
||||||
},
|
},
|
||||||
"churn": {
|
"churn": {
|
||||||
"label": "ریزش ماه اول",
|
"label": "ریزش ماه اول",
|
||||||
|
|
@ -114,8 +114,8 @@
|
||||||
"hint": "{{completed}} پرداخت موفق از {{started}} ورود به درگاه"
|
"hint": "{{completed}} پرداخت موفق از {{started}} ورود به درگاه"
|
||||||
},
|
},
|
||||||
"pace": {
|
"pace": {
|
||||||
"label": "پیشبینی هر تحلیلگر در ماه",
|
"label": "سیگنال هر تحلیلگر در ماه",
|
||||||
"hint": "{{predictions}} پیشبینی در {{days}} روز، {{analysts}} تحلیلگر فعال"
|
"hint": "{{predictions}} سیگنال در {{days}} روز، {{analysts}} تحلیلگر فعال"
|
||||||
},
|
},
|
||||||
"views": {
|
"views": {
|
||||||
"label": "بازدید کارنامه",
|
"label": "بازدید کارنامه",
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"page": {
|
"page": {
|
||||||
"title": "پیشبینیها",
|
"title": "سیگنالها",
|
||||||
"meta-title": "پیشبینیها",
|
"meta-title": "سیگنالها",
|
||||||
"subtitle": "بستن خودکار تا تأیید ادمین منتشر نمیشود؛ پیشبینی تا آن زمان «فعال» میماند.",
|
"subtitle": "بستن خودکار تا تأیید ادمین منتشر نمیشود؛ سیگنال تا آن زمان «فعال» میماند.",
|
||||||
"loading": "در حال بارگذاری پیشبینیها…"
|
"loading": "در حال بارگذاری سیگنالها…"
|
||||||
},
|
},
|
||||||
"health": {
|
"health": {
|
||||||
"title": "وضعیت منابع قیمت",
|
"title": "وضعیت منابع قیمت",
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
"fresh": "بهروز",
|
"fresh": "بهروز",
|
||||||
"stale": "{{minutes}} دقیقه بدون قیمت",
|
"stale": "{{minutes}} دقیقه بدون قیمت",
|
||||||
"stale-no-price": "بدون قیمت",
|
"stale-no-price": "بدون قیمت",
|
||||||
"banner": "پیشنهاد بستن پیشبینیهای {{markets}} تا رسیدن قیمت تازه منتظر میماند و در این صف نمایش داده نمیشود. این پیشبینیها تا آن زمان باز میمانند.",
|
"banner": "پیشنهاد بستن سیگنالهای {{markets}} تا رسیدن قیمت تازه منتظر میماند و در این صف نمایش داده نمیشود. این سیگنالها تا آن زمان باز میمانند.",
|
||||||
"loading": "در حال بررسی منابع قیمت…",
|
"loading": "در حال بررسی منابع قیمت…",
|
||||||
"error": "وضعیت منابع قیمت بارگذاری نشد."
|
"error": "وضعیت منابع قیمت بارگذاری نشد."
|
||||||
},
|
},
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
"other": "سایر"
|
"other": "سایر"
|
||||||
},
|
},
|
||||||
"queues": {
|
"queues": {
|
||||||
"label": "صفهای پیشبینی",
|
"label": "صفهای سیگنال",
|
||||||
"tabs": {
|
"tabs": {
|
||||||
"needs_review": "نیاز به تأیید",
|
"needs_review": "نیاز به تأیید",
|
||||||
"open": "باز",
|
"open": "باز",
|
||||||
|
|
@ -57,8 +57,8 @@
|
||||||
"flagged": "پرچمخورده"
|
"flagged": "پرچمخورده"
|
||||||
},
|
},
|
||||||
"count": "{{count}} پیشنهاد در انتظار تأیید",
|
"count": "{{count}} پیشنهاد در انتظار تأیید",
|
||||||
"loading": "در حال بارگذاری پیشبینیها…",
|
"loading": "در حال بارگذاری سیگنالها…",
|
||||||
"error": "فهرست پیشبینیها بارگذاری نشد.",
|
"error": "فهرست سیگنالها بارگذاری نشد.",
|
||||||
"columns": {
|
"columns": {
|
||||||
"symbol": "نماد",
|
"symbol": "نماد",
|
||||||
"analyst": "تحلیلگر",
|
"analyst": "تحلیلگر",
|
||||||
|
|
@ -82,16 +82,16 @@
|
||||||
"flag": "پرچمگذاری",
|
"flag": "پرچمگذاری",
|
||||||
"open": "جزئیات"
|
"open": "جزئیات"
|
||||||
},
|
},
|
||||||
"open-row": "جزئیات پیشبینی {{symbol}} از {{name}}",
|
"open-row": "جزئیات سیگنال {{symbol}} از {{name}}",
|
||||||
"pending": "پیشنهاد بستن در انتظار تأیید",
|
"pending": "پیشنهاد بستن در انتظار تأیید",
|
||||||
"held": "در انتظار قیمت {{source}}",
|
"held": "در انتظار قیمت {{source}}",
|
||||||
"review": "بررسی و بستن",
|
"review": "بررسی و بستن",
|
||||||
"close-admin": "بستن با قیمت ادمین",
|
"close-admin": "بستن با قیمت ادمین",
|
||||||
"flag": "پرچمگذاری",
|
"flag": "پرچمگذاری",
|
||||||
"flag-row": "پرچمگذاری پیشبینی {{symbol}} از {{name}}",
|
"flag-row": "پرچمگذاری سیگنال {{symbol}} از {{name}}",
|
||||||
"unflag": "برداشتن پرچم",
|
"unflag": "برداشتن پرچم",
|
||||||
"order": {
|
"order": {
|
||||||
"needs_review": "ترتیب: قدیمیترین رویداد اول. پیشبینی تا تأیید ادمین باز میماند.",
|
"needs_review": "ترتیب: قدیمیترین رویداد اول. سیگنال تا تأیید ادمین باز میماند.",
|
||||||
"open": "جدیدترین انتشار اول",
|
"open": "جدیدترین انتشار اول",
|
||||||
"closed": "ترتیب: جدیدترین بستهشدن اول.",
|
"closed": "ترتیب: جدیدترین بستهشدن اول.",
|
||||||
"flagged": "ترتیب: جدیدترین پرچم اول."
|
"flagged": "ترتیب: جدیدترین پرچم اول."
|
||||||
|
|
@ -104,24 +104,24 @@
|
||||||
"description": "بستنهای خودکار تازه پیش از انتشار اینجا منتظر تأیید میمانند."
|
"description": "بستنهای خودکار تازه پیش از انتشار اینجا منتظر تأیید میمانند."
|
||||||
},
|
},
|
||||||
"open": {
|
"open": {
|
||||||
"title": "پیشبینی بازی نیست",
|
"title": "سیگنال بازی نیست",
|
||||||
"description": "پیشبینیهای منتشرشده تا بسته شدن اینجا نمایش داده میشوند."
|
"description": "سیگنالهای منتشرشده تا بسته شدن اینجا نمایش داده میشوند."
|
||||||
},
|
},
|
||||||
"closed": {
|
"closed": {
|
||||||
"title": "هنوز پیشبینیای بسته نشده است",
|
"title": "هنوز سیگنالی بسته نشده است",
|
||||||
"description": "پیشبینیهای بستهشده با نتیجهشان اینجا نمایش داده میشوند."
|
"description": "سیگنالهای بستهشده با نتیجهشان اینجا نمایش داده میشوند."
|
||||||
},
|
},
|
||||||
"flagged": {
|
"flagged": {
|
||||||
"title": "پیشبینی پرچمخوردهای نیست",
|
"title": "سیگنال پرچمخوردهای نیست",
|
||||||
"description": "پیشبینیهایی که پرچم بخورند اینجا نمایش داده میشوند."
|
"description": "سیگنالهایی که پرچم بخورند اینجا نمایش داده میشوند."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"detail": {
|
"detail": {
|
||||||
"title": "جزئیات پیشبینی",
|
"title": "جزئیات سیگنال",
|
||||||
"channel": "کانال",
|
"channel": "کانال",
|
||||||
"loading": "در حال بارگذاری پیشبینی…",
|
"loading": "در حال بارگذاری سیگنال…",
|
||||||
"error": "پیشبینی بارگذاری نشد.",
|
"error": "سیگنال بارگذاری نشد.",
|
||||||
"review": "بررسی و بستن",
|
"review": "بررسی و بستن",
|
||||||
"override": "اصلاح نتیجه",
|
"override": "اصلاح نتیجه",
|
||||||
"close-admin": "بستن با قیمت ادمین",
|
"close-admin": "بستن با قیمت ادمین",
|
||||||
|
|
@ -148,7 +148,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"title": "تأیید بستن پیشبینی",
|
"title": "تأیید بستن سیگنال",
|
||||||
"fields": {
|
"fields": {
|
||||||
"event": "رویداد",
|
"event": "رویداد",
|
||||||
"proposed": "قیمت پیشنهادی",
|
"proposed": "قیمت پیشنهادی",
|
||||||
|
|
@ -162,8 +162,8 @@
|
||||||
"reject": "رد پیشنهاد",
|
"reject": "رد پیشنهاد",
|
||||||
"lock": "پس از تأیید، نتیجه روی کارت و در کارنامه تحلیلگر ثبت میشود و فقط با «اصلاح نتیجه» تغییر میکند.",
|
"lock": "پس از تأیید، نتیجه روی کارت و در کارنامه تحلیلگر ثبت میشود و فقط با «اصلاح نتیجه» تغییر میکند.",
|
||||||
"confirm": "تأیید و بستن",
|
"confirm": "تأیید و بستن",
|
||||||
"done": "پیشبینی بسته شد.",
|
"done": "سیگنال بسته شد.",
|
||||||
"failed": "بستن پیشبینی انجام نشد"
|
"failed": "بستن سیگنال انجام نشد"
|
||||||
},
|
},
|
||||||
"correct": {
|
"correct": {
|
||||||
"price": "قیمت اصلاحشده",
|
"price": "قیمت اصلاحشده",
|
||||||
|
|
@ -173,18 +173,18 @@
|
||||||
"price-required": "قیمت اصلاحشده را بنویسید.",
|
"price-required": "قیمت اصلاحشده را بنویسید.",
|
||||||
"price-invalid": "قیمت را بهصورت یک عدد مثبت بنویسید.",
|
"price-invalid": "قیمت را بهصورت یک عدد مثبت بنویسید.",
|
||||||
"price-same": "قیمت اصلاحشده با قیمت ثبتشده یکی است؛ برای همین قیمت «لغو اصلاح» را بزنید.",
|
"price-same": "قیمت اصلاحشده با قیمت ثبتشده یکی است؛ برای همین قیمت «لغو اصلاح» را بزنید.",
|
||||||
"done": "پیشبینی با قیمت اصلاحشده بسته شد."
|
"done": "سیگنال با قیمت اصلاحشده بسته شد."
|
||||||
},
|
},
|
||||||
"reject": {
|
"reject": {
|
||||||
"title": "رد پیشنهاد بستن",
|
"title": "رد پیشنهاد بستن",
|
||||||
"banner": "پیشبینی باز میماند و بررسی قیمت ادامه پیدا میکند. قیمت ثبتشده حذف نمیشود و در گزارش ممیزی میماند.",
|
"banner": "سیگنال باز میماند و بررسی قیمت ادامه پیدا میکند. قیمت ثبتشده حذف نمیشود و در گزارش ممیزی میماند.",
|
||||||
"empty": "ابتدا دلیل رد پیشنهاد را بنویسید.",
|
"empty": "ابتدا دلیل رد پیشنهاد را بنویسید.",
|
||||||
"confirm": "رد پیشنهاد",
|
"confirm": "رد پیشنهاد",
|
||||||
"done": "پیشنهاد بستن رد شد.",
|
"done": "پیشنهاد بستن رد شد.",
|
||||||
"failed": "رد پیشنهاد انجام نشد"
|
"failed": "رد پیشنهاد انجام نشد"
|
||||||
},
|
},
|
||||||
"override": {
|
"override": {
|
||||||
"title": "اصلاح نتیجه پیشبینی",
|
"title": "اصلاح نتیجه سیگنال",
|
||||||
"compare": "فعلی ← پس از اصلاح",
|
"compare": "فعلی ← پس از اصلاح",
|
||||||
"fields": {
|
"fields": {
|
||||||
"closed-price": "قیمت بستهشدن",
|
"closed-price": "قیمت بستهشدن",
|
||||||
|
|
@ -194,7 +194,7 @@
|
||||||
"price": "قیمت بستهشدن جدید",
|
"price": "قیمت بستهشدن جدید",
|
||||||
"source-fixed": "منبع ثابت است: {{source}}",
|
"source-fixed": "منبع ثابت است: {{source}}",
|
||||||
"source-fixed-horizon": "منبع ثابت است: {{source}}، قیمت پایان افق ({{time}})",
|
"source-fixed-horizon": "منبع ثابت است: {{source}}، قیمت پایان افق ({{time}})",
|
||||||
"impact": "سرمایهگذاران روی کارت این پیشبینی میبینند: «علت: اصلاح توسط ادمین».",
|
"impact": "سرمایهگذاران روی کارت این سیگنال میبینند: «علت: اصلاح توسط ادمین».",
|
||||||
"impact-record": "کارنامه {{name}} تغییر میکند: نرخ موفقیت {{before}} ← {{after}}.",
|
"impact-record": "کارنامه {{name}} تغییر میکند: نرخ موفقیت {{before}} ← {{after}}.",
|
||||||
"confirm": "ثبت اصلاح",
|
"confirm": "ثبت اصلاح",
|
||||||
"price-required": "قیمت بستهشدن را بنویسید.",
|
"price-required": "قیمت بستهشدن را بنویسید.",
|
||||||
|
|
@ -204,22 +204,22 @@
|
||||||
"failed": "اصلاح نتیجه انجام نشد"
|
"failed": "اصلاح نتیجه انجام نشد"
|
||||||
},
|
},
|
||||||
"close-admin": {
|
"close-admin": {
|
||||||
"title": "بستن پیشبینی با قیمت ادمین",
|
"title": "بستن سیگنال با قیمت ادمین",
|
||||||
"compare": "پس از بستن",
|
"compare": "پس از بستن",
|
||||||
"fields": {
|
"fields": {
|
||||||
"entry": "قیمت ورود"
|
"entry": "قیمت ورود"
|
||||||
},
|
},
|
||||||
"price": "قیمت بستهشدن",
|
"price": "قیمت بستهشدن",
|
||||||
"hint": "زمان بستهشدن همین لحظه ثبت میشود.",
|
"hint": "زمان بستهشدن همین لحظه ثبت میشود.",
|
||||||
"impact": "پیشبینی با این قیمت بسته میشود و دوباره باز نمیشود. سرمایهگذاران روی کارت میبینند: «علت: اصلاح توسط ادمین» و تحلیلگر و دنبالکنندگان اعلان بستهشدن میگیرند.",
|
"impact": "سیگنال با این قیمت بسته میشود و دوباره باز نمیشود. سرمایهگذاران روی کارت میبینند: «علت: اصلاح توسط ادمین» و تحلیلگر و دنبالکنندگان اعلان بستهشدن میگیرند.",
|
||||||
"impact-pending": "پیشنهاد بستن در انتظار این پیشبینی هم کنار گذاشته میشود.",
|
"impact-pending": "پیشنهاد بستن در انتظار این سیگنال هم کنار گذاشته میشود.",
|
||||||
"confirm": "بستن پیشبینی",
|
"confirm": "بستن سیگنال",
|
||||||
"done": "پیشبینی با قیمت ادمین بسته شد.",
|
"done": "سیگنال با قیمت ادمین بسته شد.",
|
||||||
"failed": "بستن پیشبینی انجام نشد"
|
"failed": "بستن سیگنال انجام نشد"
|
||||||
},
|
},
|
||||||
"flag": {
|
"flag": {
|
||||||
"title": "پرچمگذاری پیشبینی",
|
"title": "پرچمگذاری سیگنال",
|
||||||
"banner": "پرچمها داخلیاند: روی کارت، کارنامه و نتیجهٔ این پیشبینی اثری ندارند و فقط ادمینها آنها را میبینند.",
|
"banner": "پرچمها داخلیاند: روی کارت، کارنامه و نتیجهٔ این سیگنال اثری ندارند و فقط ادمینها آنها را میبینند.",
|
||||||
"reason": "دلیل",
|
"reason": "دلیل",
|
||||||
"reason-label": "دلیل پرچم",
|
"reason-label": "دلیل پرچم",
|
||||||
"note": "توضیح",
|
"note": "توضیح",
|
||||||
|
|
@ -236,7 +236,7 @@
|
||||||
"done": "پرچم برداشته شد.",
|
"done": "پرچم برداشته شد.",
|
||||||
"failed": "برداشتن پرچم انجام نشد"
|
"failed": "برداشتن پرچم انجام نشد"
|
||||||
},
|
},
|
||||||
"conflict": "این پیشبینی پیشتر بسته یا بررسی شده است؛ اطلاعات بهروز شد.",
|
"conflict": "این سیگنال پیشتر بسته یا بررسی شده است؛ اطلاعات بهروز شد.",
|
||||||
"card": {
|
"card": {
|
||||||
"status": {
|
"status": {
|
||||||
"open": "فعال",
|
"open": "فعال",
|
||||||
|
|
@ -263,7 +263,9 @@
|
||||||
"target-n": "هدف {{n}}",
|
"target-n": "هدف {{n}}",
|
||||||
"final-target": "هدف نهایی",
|
"final-target": "هدف نهایی",
|
||||||
"close": "بستهشدن",
|
"close": "بستهشدن",
|
||||||
"horizon": "افق"
|
"horizon": "افق",
|
||||||
|
"range": "بازه",
|
||||||
|
"entry-range": "ورود (بازه)"
|
||||||
},
|
},
|
||||||
"ladder": {
|
"ladder": {
|
||||||
"level": "سطح",
|
"level": "سطح",
|
||||||
|
|
@ -276,7 +278,7 @@
|
||||||
"not-triggered": "فعال نشد"
|
"not-triggered": "فعال نشد"
|
||||||
},
|
},
|
||||||
"range": {
|
"range": {
|
||||||
"label": "محدوده پیشبینی: {{values}}",
|
"label": "محدوده سیگنال: {{values}}",
|
||||||
"stop": "حد ضرر {{price}}",
|
"stop": "حد ضرر {{price}}",
|
||||||
"entry": "ورود {{price}}",
|
"entry": "ورود {{price}}",
|
||||||
"target": "هدف {{price}}",
|
"target": "هدف {{price}}",
|
||||||
|
|
@ -299,10 +301,11 @@
|
||||||
"price-source": "منبع قیمت:"
|
"price-source": "منبع قیمت:"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"title": "پیشبینی پریمیوم",
|
"title": "سیگنال پریمیوم",
|
||||||
"description": "دارایی، جهت، ورود، اهداف و حد ضرر پنهان است.",
|
"description": "دارایی، جهت، ورود، اهداف و حد ضرر پنهان است.",
|
||||||
"hidden": "پنهان",
|
"hidden": "پنهان",
|
||||||
"content": "محتوای پریمیوم"
|
"content": "محتوای پریمیوم"
|
||||||
}
|
},
|
||||||
|
"risk-reward-range": "{{worst}} تا {{best}}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ export type PartBoundaryProps = {
|
||||||
/** The part, for the error report: «creator-stats», «feed». Never personal data. */
|
/** The part, for the error report: «creator-stats», «feed». Never personal data. */
|
||||||
name: string;
|
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.
|
* است…» (S3); without it the fallback says what every part says.
|
||||||
*/
|
*/
|
||||||
title?: string;
|
title?: string;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ const isBlocked = (standing: string): standing is BlockedStanding =>
|
||||||
standing === 'pending' || standing === 'rejected' || standing === 'suspended';
|
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
|
* 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
|
* 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
|
* nav; a press on the scrim closes it, and the FAB turns into an icon-only ✕ «بستن» (J08-1b). A
|
||||||
|
|
|
||||||
|
|
@ -57,10 +57,10 @@ export const ROUTES = {
|
||||||
subscriptions: '/dashboard/subscriptions',
|
subscriptions: '/dashboard/subscriptions',
|
||||||
transactions: '/dashboard/transactions',
|
transactions: '/dashboard/transactions',
|
||||||
following: '/dashboard/following',
|
following: '/dashboard/following',
|
||||||
/** The creator's داشبورد: «طرحهای اشتراک» (the default tab), «پیشبینیها» and «مالی». */
|
/** The creator's داشبورد: «طرحهای اشتراک» (the default tab), «سیگنالها» and «مالی». */
|
||||||
plans: '/dashboard/plans',
|
plans: '/dashboard/plans',
|
||||||
predictions: '/dashboard/predictions',
|
predictions: '/dashboard/predictions',
|
||||||
/** «همه پیشبینیها», pushed from the «پیشبینیها» tab; `?status=closed|all`. */
|
/** «همه سیگنالها», pushed from the «سیگنالها» tab; `?status=closed|all`. */
|
||||||
predictionsAll: '/dashboard/predictions/all',
|
predictionsAll: '/dashboard/predictions/all',
|
||||||
finance: '/dashboard/finance',
|
finance: '/dashboard/finance',
|
||||||
/** C7, pushed from the «قیمت طرحها» card. */
|
/** C7, pushed from the «قیمت طرحها» card. */
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import { ComposerLockedRedirect } from '../../../organisms/composer-locked';
|
||||||
import { PredictionComposerDialogSkeleton } from './PredictionComposerDialogSkeleton';
|
import { PredictionComposerDialogSkeleton } from './PredictionComposerDialogSkeleton';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* «پیشبینی جدید» over the current page on desktop (J09-1-D, 0023), for the route that intercepts
|
* «سیگنال جدید» over the current page on desktop (J09-1-D, 0023), for the route that intercepts
|
||||||
* /compose/prediction. The app wraps it in AuthGuard with `PredictionComposerDialogSkeleton`, so
|
* /compose/prediction. The app wraps it in AuthGuard with `PredictionComposerDialogSkeleton`, so
|
||||||
* it renders once the browser knows a signed-in viewer. Only a creator who may publish gets the
|
* it renders once the browser knows a signed-in viewer. Only a creator who may publish gets the
|
||||||
* composer; another creator goes to their own channel, which says why not (J09-1e, 0060), and
|
* composer; another creator goes to their own channel, which says why not (J09-1e, 0060), and
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import { ROUTES } from '../../../../../../navigation/navigation';
|
||||||
import { ComposerDialogPlaceholder } from './components/ComposerDialogPlaceholder';
|
import { ComposerDialogPlaceholder } from './components/ComposerDialogPlaceholder';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The «پیشبینی جدید» dialog until the browser knows the viewer: the same 960px frame with the
|
* The «سیگنال جدید» dialog until the browser knows the viewer: the same 960px frame with the
|
||||||
* form skeleton in its body, AuthGuard's fallback on the intercepted route. «انصراف» still closes
|
* form skeleton in its body, AuthGuard's fallback on the intercepted route. «انصراف» still closes
|
||||||
* it.
|
* it.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import { ConfirmPublish } from './ConfirmPublish';
|
||||||
import { LeaveConfirm } from './LeaveConfirm';
|
import { LeaveConfirm } from './LeaveConfirm';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* «پیشبینی جدید» in the 960px dialog over the current page (J09-1-D, 0023). Escape, the scrim and
|
* «سیگنال جدید» in the 960px dialog over the current page (J09-1-D, 0023). Escape, the scrim and
|
||||||
* «انصراف» close an empty one and ask first about one with something to lose; the confirm step
|
* «انصراف» close an empty one and ask first about one with something to lose; the confirm step
|
||||||
* and the question open over it. Published, it closes onto the creator's channel, the new
|
* and the question open over it. Published, it closes onto the creator's channel, the new
|
||||||
* prediction on top, with the toast.
|
* prediction on top, with the toast.
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ import { SymbolField } from './SymbolField';
|
||||||
import { TargetsField } from './TargetsField';
|
import { TargetsField } from './TargetsField';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Every field of «پیشبینی جدید» in the boards' order (J09-1): access with the premium note, market,
|
* Every field of «سیگنال جدید» in the boards' order (J09-1): access with the premium note, market,
|
||||||
* symbol and direction (side by side on desktop), the locked entry, targets, stop, horizon with
|
* symbol and direction (side by side on desktop), the entry, targets, stop, horizon with
|
||||||
* its end, the note and the chart. A failed publish says so above them (J09-3d); while publishing,
|
* its end, the note and the chart. A failed publish says so above them (J09-3d); while publishing,
|
||||||
* everything holds still.
|
* everything holds still.
|
||||||
*/
|
*/
|
||||||
|
|
@ -69,7 +69,7 @@ export function ComposerFields({ model, layout }: ComposerPartProps) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FlexBox direction="flex-col" gap="gap-5">
|
<FlexBox direction="flex-col" gap="gap-5">
|
||||||
{/* «انتشار پیشبینی» is the retry, with the same key while nothing changes. */}
|
{/* «انتشار سیگنال» is the retry, with the same key while nothing changes. */}
|
||||||
{model.publishError && (
|
{model.publishError && (
|
||||||
<Banner tone="danger" title={model.publishError} />
|
<Banner tone="danger" title={model.publishError} />
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
|
||||||
import type { ComposerFrameProps } from '../types';
|
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.
|
* «انصراف» at the end of its header row, and the workspace edge to edge under the hairline.
|
||||||
* While publishing, Escape, the scrim and «انصراف» do nothing.
|
* While publishing, Escape, the scrim and «انصراف» do nothing.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ import { LeaveConfirm } from './LeaveConfirm';
|
||||||
import { PublishButton } from './PublishButton';
|
import { PublishButton } from './PublishButton';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* «پیشبینی جدید» on its own page. Mobile (J09-1-M): back · title · support, the ghost «انصراف»
|
* «سیگنال جدید» 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
|
* 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
|
* 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
|
* 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.
|
* prediction on top (J09-3c); left, it goes back.
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ export function ComposerPreview({ model }: Pick<ComposerPartProps, 'model'>) {
|
||||||
market: t(`common:markets.${summary.market}`),
|
market: t(`common:markets.${summary.market}`),
|
||||||
direction: summary.direction,
|
direction: summary.direction,
|
||||||
entryPrice: summary.entryPrice,
|
entryPrice: summary.entryPrice,
|
||||||
|
entryLow: summary.entryLow,
|
||||||
|
entryHigh: summary.entryHigh,
|
||||||
targetPrices: summary.targetPrices,
|
targetPrices: summary.targetPrices,
|
||||||
stopLoss: summary.stopLoss,
|
stopLoss: summary.stopLoss,
|
||||||
horizon: summary.horizon,
|
horizon: summary.horizon,
|
||||||
|
|
|
||||||
|
|
@ -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
|
* 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
|
* 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) {
|
export function ComposerWorkspace({ model }: ComposerWorkspaceProps) {
|
||||||
const { t } = useTranslation('predictions');
|
const { t } = useTranslation('predictions');
|
||||||
|
|
|
||||||
|
|
@ -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(
|
||||||
|
<ConfirmPublish
|
||||||
|
layout="desktop"
|
||||||
|
model={
|
||||||
|
{
|
||||||
|
confirmSummary,
|
||||||
|
phase: 'confirming',
|
||||||
|
publish: vi.fn(),
|
||||||
|
cancelConfirm: vi.fn(),
|
||||||
|
} as unknown as PredictionComposerPageModel
|
||||||
|
}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -8,14 +8,15 @@ import { DetailRow } from '@lumina/island/molecules/detail-row';
|
||||||
import { KeyValue } from '@lumina/island/molecules/key-value';
|
import { KeyValue } from '@lumina/island/molecules/key-value';
|
||||||
import { Modal } from '@lumina/island/molecules/modal';
|
import { Modal } from '@lumina/island/molecules/modal';
|
||||||
import { Sheet } from '@lumina/island/molecules/sheet';
|
import { Sheet } from '@lumina/island/molecules/sheet';
|
||||||
|
import { entryText } from '@lumina/island/organisms/prediction-card';
|
||||||
import { date, number, price } from '@lumina/tools/format';
|
import { date, number, price } from '@lumina/tools/format';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import type { ComposerPartProps } from '../types';
|
import type { ComposerPartProps } from '../types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* «انتشار پیشبینی» (J09-3, J09-3b): what goes live, row by row (a field left empty has none), the
|
* «انتشار سیگنال» (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
|
* 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
|
* deleted afterwards. While it publishes «انتشار» spins, «ادامه ویرایش» freezes and nothing
|
||||||
* dismisses it. A bottom sheet on mobile, a 420px modal on desktop.
|
* dismisses it. A bottom sheet on mobile, a 420px modal on desktop.
|
||||||
*/
|
*/
|
||||||
|
|
@ -45,14 +46,16 @@ export function ConfirmPublish({ model, layout }: ComposerPartProps) {
|
||||||
</DetailRow>
|
</DetailRow>
|
||||||
<DetailRow label={t('composer.confirm.entry')} strong>
|
<DetailRow label={t('composer.confirm.entry')} strong>
|
||||||
<Typography tag="bdi" dir="ltr" variant="inherit" color="inherit">
|
<Typography tag="bdi" dir="ltr" variant="inherit" color="inherit">
|
||||||
{t('composer.confirm.entry-value', {
|
{entryText(summary)}
|
||||||
price: price(summary.entryPrice),
|
|
||||||
})}
|
|
||||||
</Typography>
|
</Typography>
|
||||||
|
{summary.entryMode === 'exact' && (
|
||||||
|
<>
|
||||||
<Separator />
|
<Separator />
|
||||||
<Typography tag="span" variant="caption" color="secondary">
|
<Typography tag="span" variant="caption" color="secondary">
|
||||||
{t('composer.confirm.entry-note')}
|
{t('composer.confirm.entry-exact')}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</DetailRow>
|
</DetailRow>
|
||||||
{summary.targetPrices.map((target, index) => (
|
{summary.targetPrices.map((target, index) => (
|
||||||
<DetailRow
|
<DetailRow
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
|
import userEvent from '@testing-library/user-event';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
import { describe, expect, it, vi } from 'vitest';
|
||||||
|
|
||||||
|
import type { PredictionComposerPageModel } from '../../../../../../../../features/prediction';
|
||||||
|
import type { PredictionComposerFormValues } from '../../../../../../../../shared/validations';
|
||||||
|
import { EntryField } from './EntryField';
|
||||||
|
|
||||||
|
vi.mock('react-i18next', () => ({
|
||||||
|
useTranslation: () => ({
|
||||||
|
t: (key: string, values?: object) =>
|
||||||
|
values ? `${key} ${JSON.stringify(values)}` : key,
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
function Harness({ over }: { over: Partial<PredictionComposerPageModel> }) {
|
||||||
|
const form = useForm<PredictionComposerFormValues>({
|
||||||
|
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 <EntryField model={{ ...model, form }} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
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(<Harness over={{ quote: ready, markEntryEdited }} />);
|
||||||
|
const input = screen.getByLabelText<HTMLInputElement>(
|
||||||
|
'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(<Harness over={{ quote: ready, setEntryMode }} />);
|
||||||
|
await userEvent.click(
|
||||||
|
screen.getByRole('radio', { name: 'composer.entry-range' }),
|
||||||
|
);
|
||||||
|
expect(setEntryMode).toHaveBeenCalledWith('range');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows «از» and «تا» for a range', () => {
|
||||||
|
render(<Harness over={{ quote: ready, entryMode: 'range' }} />);
|
||||||
|
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(
|
||||||
|
<Harness
|
||||||
|
over={{
|
||||||
|
quote: { status: 'unavailable', isRetrying: false },
|
||||||
|
retryQuote,
|
||||||
|
}}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
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(<Harness over={{ symbol: '', quote: { status: 'none' } }} />);
|
||||||
|
expect(screen.getByText('composer.entry-pending')).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -1,64 +1,100 @@
|
||||||
import { Button } from '@lumina/island/atoms/button';
|
import { Button } from '@lumina/island/atoms/button';
|
||||||
import { FlexBox } from '@lumina/island/atoms/flex-box';
|
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 { Skeleton, SkeletonRegion } from '@lumina/island/atoms/skeleton';
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
import { Typography } from '@lumina/island/atoms/typography';
|
||||||
|
import { SegmentedChoice } from '@lumina/island/molecules/segmented-choice';
|
||||||
import { TextInput } from '@lumina/island/molecules/text-input';
|
import { TextInput } from '@lumina/island/molecules/text-input';
|
||||||
import { price, time } from '@lumina/tools/format';
|
import { price, time } from '@lumina/tools/format';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import type { EntryMode } from '../../../../../../../../shared/validations';
|
||||||
|
import { translateMessage } from '../../../../../../../../shared/utils';
|
||||||
import type { ComposerPartProps } from '../types';
|
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
|
* «ورود» (J09-1, J09-2c): «قیمت دقیق», prefilled from the live quote and editable, or «بازه» with
|
||||||
* the live price with its source and time, «—» before a symbol, a skeleton line while the price
|
* «از» and «تا». Under it, the live price with its source and time, a skeleton line while it loads,
|
||||||
* loads, or that there is no price now with «تلاش مجدد».
|
* or that there is no price now with «تلاش مجدد». An exact entry waits for a symbol.
|
||||||
*/
|
*/
|
||||||
export function EntryField({ model }: Pick<ComposerPartProps, 'model'>) {
|
export function EntryField({ model }: Pick<ComposerPartProps, 'model'>) {
|
||||||
const { t } = useTranslation('predictions');
|
const { t } = useTranslation(['predictions', 'content']);
|
||||||
const { quote } = model;
|
const { form, quote, entryMode, phase, symbol } = model;
|
||||||
const stamp = (
|
const { errors } = form.formState;
|
||||||
<Typography tag="span" variant="caption" color="secondary">
|
const busy = phase === 'publishing';
|
||||||
{t('composer.entry-stamp')}
|
|
||||||
</Typography>
|
|
||||||
);
|
|
||||||
|
|
||||||
if (quote.status === 'loading') {
|
const input = (name: 'entryPrice' | 'entryLow' | 'entryHigh') =>
|
||||||
return (
|
({
|
||||||
<FlexBox direction="flex-col" gap="gap-2">
|
dir: 'ltr',
|
||||||
<Typography tag="span" variant="label">
|
inputMode: 'decimal',
|
||||||
{t('composer.entry')}
|
autoComplete: 'off',
|
||||||
</Typography>
|
frozen: busy,
|
||||||
<SkeletonRegion label={t('composer.entry-loading')}>
|
error: translateMessage(t, errors[name]?.message),
|
||||||
<Skeleton height={48} />
|
}) as const;
|
||||||
</SkeletonRegion>
|
|
||||||
{stamp}
|
|
||||||
</FlexBox>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FlexBox direction="flex-col" gap="gap-2">
|
<FlexBox direction="flex-col" gap="gap-2">
|
||||||
<TextInput
|
<FieldGroup label={t('composer.entry')}>
|
||||||
|
<SegmentedChoice<EntryMode>
|
||||||
label={t('composer.entry')}
|
label={t('composer.entry')}
|
||||||
locked
|
options={[
|
||||||
dir="ltr"
|
{ value: 'exact', label: t('composer.entry-exact') },
|
||||||
|
{ value: 'range', label: t('composer.entry-range') },
|
||||||
|
]}
|
||||||
|
value={entryMode}
|
||||||
|
onChange={model.setEntryMode}
|
||||||
|
tone="neutral"
|
||||||
|
block
|
||||||
|
disabled={busy}
|
||||||
|
/>
|
||||||
|
</FieldGroup>
|
||||||
|
{entryMode === 'exact' ? (
|
||||||
|
<TextInput
|
||||||
|
label={t('composer.entry-price')}
|
||||||
placeholder="—"
|
placeholder="—"
|
||||||
value={quote.status === 'ready' ? price(quote.price) : ''}
|
{...input('entryPrice')}
|
||||||
lockedNote={
|
frozen={busy || symbol === ''}
|
||||||
quote.status === 'ready'
|
{...form.register('entryPrice', { onChange: model.markEntryEdited })}
|
||||||
? t('composer.entry-note', {
|
/>
|
||||||
|
) : (
|
||||||
|
<GridBox cols="grid-cols-2" gap="gap-3" alignItems="items-start">
|
||||||
|
<TextInput
|
||||||
|
label={t('composer.entry-from')}
|
||||||
|
{...input('entryLow')}
|
||||||
|
{...form.register('entryLow')}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={t('composer.entry-to')}
|
||||||
|
{...input('entryHigh')}
|
||||||
|
{...form.register('entryHigh')}
|
||||||
|
/>
|
||||||
|
</GridBox>
|
||||||
|
)}
|
||||||
|
{quote.status === 'loading' && (
|
||||||
|
<SkeletonRegion label={t('composer.entry-loading')}>
|
||||||
|
<Skeleton height={16} />
|
||||||
|
</SkeletonRegion>
|
||||||
|
)}
|
||||||
|
{quote.status === 'none' && (
|
||||||
|
<Typography tag="span" variant="caption" color="secondary">
|
||||||
|
{t('composer.entry-pending')}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
{quote.status === 'ready' && (
|
||||||
|
<Typography tag="span" variant="caption" color="secondary">
|
||||||
|
{t('composer.entry-hint', {
|
||||||
|
price: price(quote.price),
|
||||||
source: quote.source,
|
source: quote.source,
|
||||||
time: time(quote.at),
|
time: time(quote.at),
|
||||||
})
|
})}
|
||||||
: t('composer.entry-pending')
|
</Typography>
|
||||||
}
|
)}
|
||||||
error={
|
|
||||||
quote.status === 'unavailable'
|
|
||||||
? t('composer.quote-unavailable')
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
{quote.status === 'unavailable' && (
|
{quote.status === 'unavailable' && (
|
||||||
|
<>
|
||||||
|
<Typography tag="span" variant="caption" color="danger" role="alert">
|
||||||
|
{t('composer.quote-unavailable')}
|
||||||
|
</Typography>
|
||||||
<FlexBox>
|
<FlexBox>
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
|
|
@ -70,8 +106,8 @@ export function EntryField({ model }: Pick<ComposerPartProps, 'model'>) {
|
||||||
{t('composer.retry')}
|
{t('composer.retry')}
|
||||||
</Button>
|
</Button>
|
||||||
</FlexBox>
|
</FlexBox>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
{stamp}
|
|
||||||
</FlexBox>
|
</FlexBox>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
|
||||||
import type { ComposerPartProps } from '../types';
|
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).
|
* press checks the form, then asks to confirm (J09-3). Offline it freezes and says why (0043).
|
||||||
*/
|
*/
|
||||||
export function PublishButton({ model, layout }: ComposerPartProps) {
|
export function PublishButton({ model, layout }: ComposerPartProps) {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import type { DashboardTabsProps } from './types';
|
||||||
/**
|
/**
|
||||||
* The داشبورد's section row, full width, the current one underlined: the investor's «اشتراکها» ·
|
* The داشبورد's section row, full width, the current one underlined: the investor's «اشتراکها» ·
|
||||||
* «تراکنشها» · «دنبالشدهها» (U8 ۴.۱, ۶.۱; U8 ۵.۲), or the creator'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.
|
* loads; the current one comes from the URL, which the server render already knows.
|
||||||
*/
|
*/
|
||||||
export function DashboardTabs({
|
export function DashboardTabs({
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import type { PredictionListProps } from './types';
|
||||||
const FILTERS: readonly OwnPredictionsStatus[] = ['open', 'closed', 'all'];
|
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
|
* 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
|
* «نمایش بیشتر». The cards stay while another chip's list or the next page loads; a failed page
|
||||||
* says so in place of «نمایش بیشتر».
|
* says so in place of «نمایش بیشتر».
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||||
|
|
||||||
import type { PredictionListSkeletonProps } from './types';
|
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({
|
export function PredictionListSkeleton({
|
||||||
label,
|
label,
|
||||||
delayed,
|
delayed,
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ import { PredictionsTabSkeleton } from './PredictionsTabSkeleton';
|
||||||
import type { PredictionsTabProps } from './types';
|
import type { PredictionsTabProps } from './types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* داشبورد › پیشبینیها (J10-3), the creator's own, in the browser only: the record or its progress
|
* داشبورد › سیگنالها (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
|
* 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,
|
* «همه سیگنالها». 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.
|
* only the way to publish one (J10-3c). No edit or delete: a published prediction is final.
|
||||||
*/
|
*/
|
||||||
export function PredictionsTab({ layout }: PredictionsTabProps) {
|
export function PredictionsTab({ layout }: PredictionsTabProps) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
|
||||||
|
|
||||||
import type { PredictionsTabSkeletonProps } from './types';
|
import type { PredictionsTabSkeletonProps } from './types';
|
||||||
|
|
||||||
/** داشبورد › پیشبینیها before it arrives, block for block: the record, then two cards. */
|
/** داشبورد › سیگنالها before it arrives, block for block: the record, then two cards. */
|
||||||
export function PredictionsTabSkeleton({
|
export function PredictionsTabSkeleton({
|
||||||
label,
|
label,
|
||||||
delayed,
|
delayed,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import type { PredictionSectionProps } from '../types';
|
||||||
import { SectionCards } from './SectionCards';
|
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
|
* 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.
|
* nothing in it isn't drawn.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const FILTERS: readonly NotificationFilter[] = [
|
||||||
/**
|
/**
|
||||||
* اعلانها (U5 §۲, J07-5, J07-5h): every notification of the last 30 days, newest first, in one
|
* اعلانها (U5 §۲, J07-5, J07-5h): every notification of the last 30 days, newest first, in one
|
||||||
* list of rows whatever its type. Opening it clears the bell. A creator filters it with chips
|
* list of rows whatever its type. Opening it clears the bell. A creator filters it with chips
|
||||||
* «همه · پیشبینیها · مالی · حساب» in place (0058), which stay in both empty states: nothing at
|
* «همه · سیگنالها · مالی · حساب» in place (0058), which stay in both empty states: nothing at
|
||||||
* all says what will arrive here (J07-5k), and an empty chip offers «نمایش همه». An investor's
|
* all says what will arrive here (J07-5k), and an empty chip offers «نمایش همه». An investor's
|
||||||
* empty list is one calm line under a muted bell, with no action (۲.۳, J07-5e).
|
* empty list is one calm line under a muted bell, with no action (۲.۳, J07-5e).
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { Icon } from '@lumina/island/atoms/icon';
|
import { Icon } from '@lumina/island/atoms/icon';
|
||||||
import { Separator } from '@lumina/island/atoms/separator';
|
import { Separator } from '@lumina/island/atoms/separator';
|
||||||
import { Typography } from '@lumina/island/atoms/typography';
|
import { Typography } from '@lumina/island/atoms/typography';
|
||||||
|
import { entryText } from '@lumina/island/organisms/prediction-card';
|
||||||
import { DetailRow } from '@lumina/island/molecules/detail-row';
|
import { DetailRow } from '@lumina/island/molecules/detail-row';
|
||||||
import { KeyValue } from '@lumina/island/molecules/key-value';
|
import { KeyValue } from '@lumina/island/molecules/key-value';
|
||||||
import { price } from '@lumina/tools/format';
|
import { price } from '@lumina/tools/format';
|
||||||
|
|
@ -33,7 +34,7 @@ export function PredictionSummary({ post, children }: PredictionSummaryProps) {
|
||||||
</Typography>
|
</Typography>
|
||||||
</DetailRow>
|
</DetailRow>
|
||||||
<DetailRow label={t('close.entry')} strong ltr>
|
<DetailRow label={t('close.entry')} strong ltr>
|
||||||
{price(prediction.entryPrice)}
|
{entryText(prediction)}
|
||||||
</DetailRow>
|
</DetailRow>
|
||||||
{finalTarget != null && (
|
{finalTarget != null && (
|
||||||
<DetailRow label={t('close.target')} strong ltr>
|
<DetailRow label={t('close.target')} strong ltr>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ export const UNREAD_BADGE_CAP = 99;
|
||||||
/** A creator's filter chips over their one list (J07-5h, 0058), after «همه». */
|
/** A creator's filter chips over their one list (J07-5h, 0058), after «همه». */
|
||||||
export type NotificationCategory = 'predictions' | 'finance' | 'account';
|
export type NotificationCategory = 'predictions' | 'finance' | 'account';
|
||||||
|
|
||||||
/** The chips in reading order: «همه · پیشبینیها · مالی · حساب». */
|
/** The chips in reading order: «همه · سیگنالها · مالی · حساب». */
|
||||||
export const NOTIFICATION_CATEGORIES = [
|
export const NOTIFICATION_CATEGORIES = [
|
||||||
'predictions',
|
'predictions',
|
||||||
'finance',
|
'finance',
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ export type NotificationCentreModel = {
|
||||||
items: NotificationPayload[];
|
items: NotificationPayload[];
|
||||||
/** The items under the chosen chip; all of them for an investor, who has no chips. */
|
/** The items under the chosen chip; all of them for an investor, who has no chips. */
|
||||||
visibleItems: NotificationPayload[];
|
visibleItems: NotificationPayload[];
|
||||||
/** A creator filters the one list with chips «همه · پیشبینیها · مالی · حساب» (0058). */
|
/** A creator filters the one list with chips «همه · سیگنالها · مالی · حساب» (0058). */
|
||||||
showsCategories: boolean;
|
showsCategories: boolean;
|
||||||
category: NotificationFilter;
|
category: NotificationFilter;
|
||||||
/** Filters in place: no URL change, so back still returns to where the bell was tapped. */
|
/** Filters in place: no URL change, so back still returns to where the bell was tapped. */
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,11 @@ export type PredictionEntity = {
|
||||||
/** `gold`, `crypto`, `equities`, `forex` or `USDT`; older posts may carry another key. */
|
/** `gold`, `crypto`, `equities`, `forex` or `USDT`; older posts may carry another key. */
|
||||||
market: string;
|
market: string;
|
||||||
direction: PredictionDirection;
|
direction: PredictionDirection;
|
||||||
/** The market quote at publish, stamped by the API. */
|
/** The analyst's exact entry, or the middle of a range. */
|
||||||
entryPrice: number;
|
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. */
|
/** One to three, each further from the entry; the last one is final. */
|
||||||
targetPrices: number[];
|
targetPrices: number[];
|
||||||
stopLoss?: number;
|
stopLoss?: number;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ export function toPredictionPayload(
|
||||||
market: entity.market,
|
market: entity.market,
|
||||||
direction: entity.direction,
|
direction: entity.direction,
|
||||||
entryPrice: entity.entryPrice,
|
entryPrice: entity.entryPrice,
|
||||||
|
entryLow: entity.entryLow ?? null,
|
||||||
|
entryHigh: entity.entryHigh ?? null,
|
||||||
targetPrices: entity.targetPrices,
|
targetPrices: entity.targetPrices,
|
||||||
stopLoss: entity.stopLoss ?? null,
|
stopLoss: entity.stopLoss ?? null,
|
||||||
horizon: entity.horizon,
|
horizon: entity.horizon,
|
||||||
|
|
@ -110,6 +112,9 @@ function toPredictionDto(args: PredictionArgs): PredictionDto {
|
||||||
symbol: args.symbol.trim().toUpperCase(),
|
symbol: args.symbol.trim().toUpperCase(),
|
||||||
market: args.market.trim(),
|
market: args.market.trim(),
|
||||||
direction: args.direction,
|
direction: args.direction,
|
||||||
|
entryPrice: args.entryPrice ?? undefined,
|
||||||
|
entryLow: args.entryLow ?? undefined,
|
||||||
|
entryHigh: args.entryHigh ?? undefined,
|
||||||
targetPrices: args.targetPrices,
|
targetPrices: args.targetPrices,
|
||||||
stopLoss: args.stopLoss ?? undefined,
|
stopLoss: args.stopLoss ?? undefined,
|
||||||
horizon: args.horizon.trim(),
|
horizon: args.horizon.trim(),
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,11 @@ export type PredictionPayload = {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
market: string;
|
market: string;
|
||||||
direction: PredictionDirection;
|
direction: PredictionDirection;
|
||||||
|
/** The exact entry, or the middle of a range. */
|
||||||
entryPrice: number;
|
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. */
|
/** Nearest first; the last one is the final target. */
|
||||||
targetPrices: number[];
|
targetPrices: number[];
|
||||||
stopLoss: number | null;
|
stopLoss: number | null;
|
||||||
|
|
@ -150,6 +154,10 @@ export type PredictionArgs = {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
market: string;
|
market: string;
|
||||||
direction: PredictionDirection;
|
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. */
|
/** One to three, each further from the entry than the one before. */
|
||||||
targetPrices: number[];
|
targetPrices: number[];
|
||||||
stopLoss?: number | null;
|
stopLoss?: number | null;
|
||||||
|
|
@ -195,6 +203,9 @@ export type PredictionDto = {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
market: string;
|
market: string;
|
||||||
direction: PredictionDirection;
|
direction: PredictionDirection;
|
||||||
|
entryPrice?: number;
|
||||||
|
entryLow?: number;
|
||||||
|
entryHigh?: number;
|
||||||
targetPrices: number[];
|
targetPrices: number[];
|
||||||
stopLoss?: number;
|
stopLoss?: number;
|
||||||
horizon: string;
|
horizon: string;
|
||||||
|
|
|
||||||
|
|
@ -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
|
* Publishes a prediction as a post, with the entry and stop the analyst stated. From then on it
|
||||||
* then on it can't be edited or deleted. Send the same `idempotencyKey` with an unchanged form, so
|
* 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
|
* 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`.
|
* the answer (J09-3). Emits `post.publish` and `prediction.publish`.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import type { OwnPredictionPayload } from '../../repositories/prediction';
|
||||||
export type OwnPredictionSection = 'open' | 'closed';
|
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.
|
* (the API's `counts.all` is 0), or its sections.
|
||||||
*/
|
*/
|
||||||
export type PredictionsTabPartModel = { status: 'loading' | 'empty' | 'ready' };
|
export type PredictionsTabPartModel = { status: 'loading' | 'empty' | 'ready' };
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { ownSectionQueryOptions } from './queries';
|
||||||
import type { OwnPredictionSection } from './types';
|
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).
|
* while loading or failed, so the title stands without it over the section's error (J10-3e).
|
||||||
*/
|
*/
|
||||||
export function useOwnPredictionCount(
|
export function useOwnPredictionCount(
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { ownSectionQueryOptions } from './queries';
|
||||||
import type { OwnPredictionSection, OwnPredictionsSectionModel } from './types';
|
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.
|
* closed most recently. Loads and fails on its own.
|
||||||
*/
|
*/
|
||||||
export function useOwnPredictionsSection(
|
export function useOwnPredictionsSection(
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ type OwnList = InfiniteData<OwnPredictionsPagePayload, string | undefined>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A prediction closed (early, or found closed by the system): every cached copy shows it closed
|
* 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
|
* 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.
|
* lists, the track record and the public record are read again.
|
||||||
*/
|
*/
|
||||||
export function applyClosedPrediction(
|
export function applyClosedPrediction(
|
||||||
|
|
|
||||||
|
|
@ -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',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
import type { UseFormReturn } from 'react-hook-form';
|
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 { PostAccessLevel, PostPayload } from '../../../post';
|
||||||
import type { PREDICTION_HORIZONS } from '../../constants';
|
import type { PREDICTION_HORIZONS } from '../../constants';
|
||||||
import type { PredictionMarket } from '../../entities/market-data';
|
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
|
* The live price under the entry (J09-1, J09-2c): nothing until a symbol is picked, a skeleton line
|
||||||
* its price loads, the live price with who priced it, or unavailable with «تلاش مجدد».
|
* while its price loads, the price with who priced it, or unavailable with «تلاش مجدد».
|
||||||
*/
|
*/
|
||||||
export type ComposerQuote =
|
export type ComposerQuote =
|
||||||
| { status: 'none' }
|
| { status: 'none' }
|
||||||
|
|
@ -57,8 +60,12 @@ export type ComposerSummary = {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
market: PredictionMarket;
|
market: PredictionMarket;
|
||||||
direction: PredictionDirection;
|
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;
|
entryPrice: number;
|
||||||
|
/** A range entry's ends; `null` for an exact one. */
|
||||||
|
entryLow: number | null;
|
||||||
|
entryHigh: number | null;
|
||||||
targetPrices: number[];
|
targetPrices: number[];
|
||||||
stopLoss: number | null;
|
stopLoss: number | null;
|
||||||
horizon: PredictionHorizon;
|
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.
|
* until `onDone`'s navigation takes the composer away), or back to idle with the failure shown.
|
||||||
*/
|
*/
|
||||||
export type ComposerPhase = 'idle' | 'confirming' | 'publishing';
|
export type ComposerPhase = 'idle' | 'confirming' | 'publishing';
|
||||||
|
|
@ -90,6 +97,11 @@ export type PredictionComposerPageModel = {
|
||||||
setMarket: (market: PredictionMarket) => void;
|
setMarket: (market: PredictionMarket) => void;
|
||||||
direction: PredictionDirection | '';
|
direction: PredictionDirection | '';
|
||||||
setDirection: (direction: PredictionDirection) => void;
|
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 | '';
|
horizon: PredictionHorizon | '';
|
||||||
setHorizon: (horizon: PredictionHorizon) => void;
|
setHorizon: (horizon: PredictionHorizon) => void;
|
||||||
accessLevel: PostAccessLevel;
|
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. */
|
/** The CTA waits frozen, saying why: what to fix, what is missing, the price, an upload. */
|
||||||
publishBlock: { frozen: boolean; reason?: string };
|
publishBlock: { frozen: boolean; reason?: string };
|
||||||
phase: ComposerPhase;
|
phase: ComposerPhase;
|
||||||
/** «انتشار پیشبینی»: checks the form, then asks to confirm. */
|
/** «انتشار سیگنال»: checks the form, then asks to confirm. */
|
||||||
requestPublish: () => void;
|
requestPublish: () => void;
|
||||||
/** The confirm step's summary while it is open. */
|
/** The confirm step's summary while it is open. */
|
||||||
confirmSummary: ComposerSummary | null;
|
confirmSummary: ComposerSummary | null;
|
||||||
|
|
|
||||||
|
|
@ -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 }) => (
|
||||||
|
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||||
|
);
|
||||||
|
const hook = renderHook(
|
||||||
|
() =>
|
||||||
|
usePredictionComposerPage({
|
||||||
|
creatorId: 'c1',
|
||||||
|
onDone,
|
||||||
|
onLeave: vi.fn(),
|
||||||
|
}),
|
||||||
|
{ wrapper },
|
||||||
|
);
|
||||||
|
return { ...hook, queryClient };
|
||||||
|
}
|
||||||
|
|
||||||
|
type Hook = ReturnType<typeof setup>['result'];
|
||||||
|
|
||||||
|
async function pickSymbol(result: Hook) {
|
||||||
|
act(() => result.current.setMarket('crypto'));
|
||||||
|
act(() =>
|
||||||
|
result.current.selectSymbol({
|
||||||
|
symbol: 'BTCUSDT',
|
||||||
|
} as Parameters<typeof result.current.selectSymbol>[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,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { valibotResolver } from '@hookform/resolvers/valibot';
|
import { valibotResolver } from '@hookform/resolvers/valibot';
|
||||||
import { showToast } from '@lumina/island/molecules/toast';
|
import { showToast } from '@lumina/island/molecules/toast';
|
||||||
import { isHttpError } from '@lumina/libs/http';
|
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 { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import {
|
import {
|
||||||
|
|
@ -17,13 +17,24 @@ import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { useLeaveGuard } from '../../../../app/navigation/hooks/use-leave-guard';
|
import { useLeaveGuard } from '../../../../app/navigation/hooks/use-leave-guard';
|
||||||
import {
|
import {
|
||||||
|
ENTRY_RANGE_ORDER_MESSAGE,
|
||||||
|
ENTRY_REQUIRED_MESSAGE,
|
||||||
|
entryFieldsOf,
|
||||||
|
entryIssue,
|
||||||
|
entryLevels,
|
||||||
levelPrice,
|
levelPrice,
|
||||||
PREDICTION_FORM_LIMITS,
|
PREDICTION_FORM_LIMITS,
|
||||||
predictionComposerSchema,
|
predictionComposerSchema,
|
||||||
|
STOP_REQUIRED_MESSAGE,
|
||||||
stopIssue,
|
stopIssue,
|
||||||
|
stopSideMessage,
|
||||||
targetIssues,
|
targetIssues,
|
||||||
|
targetSideMessage,
|
||||||
|
} from '../../../../shared/validations';
|
||||||
|
import type {
|
||||||
|
EntryMode,
|
||||||
|
PredictionComposerFormValues,
|
||||||
} from '../../../../shared/validations';
|
} from '../../../../shared/validations';
|
||||||
import type { PredictionComposerFormValues } from '../../../../shared/validations';
|
|
||||||
import { resetCachedChannel } from '../../../post';
|
import { resetCachedChannel } from '../../../post';
|
||||||
import { profileKeys, profileRepository } from '../../../profile';
|
import { profileKeys, profileRepository } from '../../../profile';
|
||||||
import { publishPrediction } from '../../actions/publish-prediction';
|
import { publishPrediction } from '../../actions/publish-prediction';
|
||||||
|
|
@ -40,11 +51,11 @@ import {
|
||||||
PREDICTION_ERROR_CODES,
|
PREDICTION_ERROR_CODES,
|
||||||
predictionErrorCode,
|
predictionErrorCode,
|
||||||
predictionFieldIssues,
|
predictionFieldIssues,
|
||||||
quoteOfError,
|
|
||||||
} from '../../repositories/prediction';
|
} from '../../repositories/prediction';
|
||||||
import type { PredictionFieldIssue } from '../../repositories/prediction';
|
import type { PredictionFieldIssue } from '../../repositories/prediction';
|
||||||
import { refreshOwnPredictions } from '../prediction-cache';
|
import { refreshOwnPredictions } from '../prediction-cache';
|
||||||
import { symbolsQueryOptions } from '../symbol-picker';
|
import { symbolsQueryOptions } from '../symbol-picker';
|
||||||
|
import { publishReason } from './publish-reason';
|
||||||
import type {
|
import type {
|
||||||
ComposerPhase,
|
ComposerPhase,
|
||||||
ComposerQuote,
|
ComposerQuote,
|
||||||
|
|
@ -64,6 +75,10 @@ const DEFAULT_VALUES: PredictionComposerFormValues = {
|
||||||
market: '',
|
market: '',
|
||||||
symbol: '',
|
symbol: '',
|
||||||
direction: '',
|
direction: '',
|
||||||
|
entryMode: 'exact',
|
||||||
|
entryPrice: '',
|
||||||
|
entryLow: '',
|
||||||
|
entryHigh: '',
|
||||||
targets: [{ value: '' }],
|
targets: [{ value: '' }],
|
||||||
stopLoss: '',
|
stopLoss: '',
|
||||||
horizon: '',
|
horizon: '',
|
||||||
|
|
@ -83,8 +98,8 @@ function toFieldError(
|
||||||
{ field, code }: PredictionFieldIssue,
|
{ field, code }: PredictionFieldIssue,
|
||||||
direction: string,
|
direction: string,
|
||||||
targetCount: number,
|
targetCount: number,
|
||||||
|
mode: EntryMode,
|
||||||
): { name: FormPath | 'root.chart'; message: string } {
|
): { name: FormPath | 'root.chart'; message: string } {
|
||||||
const side = direction === 'short' ? 'short' : 'long';
|
|
||||||
const target = /^targetPrices\.(\d+)$/.exec(field);
|
const target = /^targetPrices\.(\d+)$/.exec(field);
|
||||||
if (target) {
|
if (target) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -92,15 +107,21 @@ function toFieldError(
|
||||||
message:
|
message:
|
||||||
code === 'targets_order'
|
code === 'targets_order'
|
||||||
? 'predictions:validation.targets-order'
|
? 'predictions:validation.targets-order'
|
||||||
: `predictions:validation.target-side.${side}`,
|
: targetSideMessage(direction, mode),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 'stop_wrong_side':
|
case 'entry_required':
|
||||||
return {
|
return {
|
||||||
name: 'stopLoss',
|
name: entryFieldsOf(mode)[0],
|
||||||
message: `predictions:validation.stop-side.${side}`,
|
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':
|
case 'targets_too_many':
|
||||||
return {
|
return {
|
||||||
name: `targets.${Math.max(0, targetCount - 1)}.value`,
|
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
|
* «سیگنال جدید» (J09-1…J09-3): access, market, symbol with its live price, direction, the entry, up
|
||||||
* three targets, an optional stop, the horizon, a note and one chart image, then a confirm step.
|
* to three targets, the required stop, the horizon, a note and one chart image, then a confirm
|
||||||
* The entry is the market price at publish, which the API stamps; the form shows the live one,
|
* step. The entry is one exact price, prefilled from the live quote (read every 15 seconds) and
|
||||||
* read every 15 seconds, and checks the levels against it on blur, on a direction change and on
|
* following it until the analyst edits it, or a range. The levels are checked against it on blur, on
|
||||||
* every new price. The CTA stays frozen and says why until the form can publish. A publish sends
|
* a direction change and on every new price. The CTA stays frozen and says why until the form can
|
||||||
* one idempotency key per unchanged form, so a retry never publishes twice. Nothing is kept as a
|
* publish. A publish sends one idempotency key per unchanged form, so a retry never publishes twice.
|
||||||
* draft: leaving with something typed asks first.
|
* Nothing is kept as a draft: leaving with something typed asks first.
|
||||||
*/
|
*/
|
||||||
export function usePredictionComposerPage({
|
export function usePredictionComposerPage({
|
||||||
creatorId,
|
creatorId,
|
||||||
|
|
@ -140,7 +161,7 @@ export function usePredictionComposerPage({
|
||||||
const [isConfirmingLeave, setIsConfirmingLeave] = useState(false);
|
const [isConfirmingLeave, setIsConfirmingLeave] = useState(false);
|
||||||
// A link elsewhere in the app the creator followed with something typed: asked first.
|
// A link elsewhere in the app the creator followed with something typed: asked first.
|
||||||
const [leaveTo, setLeaveTo] = useState<string | null>(null);
|
const [leaveTo, setLeaveTo] = useState<string | null>(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<ComposerSummary | null>(null);
|
const [confirmed, setConfirmed] = useState<ComposerSummary | null>(null);
|
||||||
// When the API last said there was no price at publish: a newer price clears it.
|
// When the API last said there was no price at publish: a newer price clears it.
|
||||||
const [noPriceSince, setNoPriceSince] = useState<number | null>(null);
|
const [noPriceSince, setNoPriceSince] = useState<number | null>(null);
|
||||||
|
|
@ -152,16 +173,11 @@ export function usePredictionComposerPage({
|
||||||
}, []);
|
}, []);
|
||||||
// The key goes with the body it was made for; any change makes a new one.
|
// 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);
|
const attempt = useRef<{ key: string; body: string } | null>(null);
|
||||||
// The levels are checked against the price the form shows.
|
// The analyst typed in the exact entry: the live quote no longer fills it.
|
||||||
const entryRef = useRef<number | null>(null);
|
const entryEdited = useRef(false);
|
||||||
|
|
||||||
const form = useForm<PredictionComposerFormValues>({
|
const form = useForm<PredictionComposerFormValues>({
|
||||||
resolver: (values, context, options) =>
|
resolver: valibotResolver(predictionComposerSchema()),
|
||||||
valibotResolver(predictionComposerSchema(entryRef.current))(
|
|
||||||
values,
|
|
||||||
context,
|
|
||||||
options,
|
|
||||||
),
|
|
||||||
mode: 'onTouched',
|
mode: 'onTouched',
|
||||||
defaultValues: DEFAULT_VALUES,
|
defaultValues: DEFAULT_VALUES,
|
||||||
});
|
});
|
||||||
|
|
@ -171,6 +187,10 @@ export function usePredictionComposerPage({
|
||||||
marketValue,
|
marketValue,
|
||||||
symbol,
|
symbol,
|
||||||
directionValue,
|
directionValue,
|
||||||
|
entryMode,
|
||||||
|
entryPriceText,
|
||||||
|
entryLow,
|
||||||
|
entryHigh,
|
||||||
targets,
|
targets,
|
||||||
stopLoss,
|
stopLoss,
|
||||||
horizonValue,
|
horizonValue,
|
||||||
|
|
@ -182,6 +202,10 @@ export function usePredictionComposerPage({
|
||||||
'market',
|
'market',
|
||||||
'symbol',
|
'symbol',
|
||||||
'direction',
|
'direction',
|
||||||
|
'entryMode',
|
||||||
|
'entryPrice',
|
||||||
|
'entryLow',
|
||||||
|
'entryHigh',
|
||||||
'targets',
|
'targets',
|
||||||
'stopLoss',
|
'stopLoss',
|
||||||
'horizon',
|
'horizon',
|
||||||
|
|
@ -244,20 +268,42 @@ export function usePredictionComposerPage({
|
||||||
// The market's real source; the quote's own says `mock` in development.
|
// The market's real source; the quote's own says `mock` in development.
|
||||||
source: symbolRow?.source ?? quoteData.source,
|
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 = () => {
|
const recheck = () => {
|
||||||
entryRef.current = entryPrice;
|
|
||||||
const values = form.getValues();
|
const values = form.getValues();
|
||||||
const names: FormPath[] = values.targets.flatMap((target, index) =>
|
const names: FormPath[] = values.targets.flatMap((target, index) =>
|
||||||
target.value.trim() ? [`targets.${index}.value` as const] : [],
|
target.value.trim() ? [`targets.${index}.value` as const] : [],
|
||||||
);
|
);
|
||||||
if (values.stopLoss.trim()) names.push('stopLoss');
|
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);
|
if (names.length > 0) void form.trigger(names);
|
||||||
};
|
};
|
||||||
const recheckLevels = useEffectEvent(recheck);
|
const recheckLevels = useEffectEvent(recheck);
|
||||||
useEffect(() => recheckLevels(), [entryPrice, direction]);
|
useEffect(
|
||||||
|
() => recheckLevels(),
|
||||||
|
[livePrice, direction, entryMode, entry?.low, entry?.high],
|
||||||
|
);
|
||||||
|
|
||||||
const { errors } = form.formState;
|
const { errors } = form.formState;
|
||||||
const targetLabel = (index: number) =>
|
const targetLabel = (index: number) =>
|
||||||
|
|
@ -267,49 +313,66 @@ export function usePredictionComposerPage({
|
||||||
!market && t('composer.fields.market'),
|
!market && t('composer.fields.market'),
|
||||||
!symbol && t('composer.fields.symbol'),
|
!symbol && t('composer.fields.symbol'),
|
||||||
!direction && t('composer.fields.direction'),
|
!direction && t('composer.fields.direction'),
|
||||||
|
entryFieldsOf(entryMode).some(
|
||||||
|
(field) => entryIssue(entryValues, field) === 'required',
|
||||||
|
) && t('composer.fields.entry'),
|
||||||
...targets.map(
|
...targets.map(
|
||||||
(target, index) => !target.value.trim() && targetLabel(index),
|
(target, index) => !target.value.trim() && targetLabel(index),
|
||||||
),
|
),
|
||||||
|
!stopLoss.trim() && t('composer.fields.stop'),
|
||||||
!horizon && t('composer.fields.horizon'),
|
!horizon && t('composer.fields.horizon'),
|
||||||
].filter((label): label is string => typeof label === 'string');
|
].filter((label): label is string => typeof label === 'string');
|
||||||
const invalid = [
|
const invalid = [
|
||||||
errors.market && t('composer.fields.market'),
|
errors.market && t('composer.fields.market'),
|
||||||
errors.symbol && t('composer.fields.symbol'),
|
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(
|
...targets.map(
|
||||||
(_target, index) => errors.targets?.[index]?.value && targetLabel(index),
|
(_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.horizon && t('composer.fields.horizon'),
|
||||||
errors.note && t('composer.fields.note'),
|
errors.note && t('composer.fields.note'),
|
||||||
errors.root?.chart && t('composer.fields.chart'),
|
errors.root?.chart && t('composer.fields.chart'),
|
||||||
].filter((label): label is string => typeof label === 'string');
|
].filter((label): label is string => typeof label === 'string');
|
||||||
|
|
||||||
const reason = invalid.length
|
const block = publishReason({
|
||||||
? t('composer.invalid', { fields: list(invalid) })
|
invalid,
|
||||||
: missing.length
|
missing,
|
||||||
? t('composer.missing', { fields: list(missing) })
|
quoteUnavailable: quote.status === 'unavailable',
|
||||||
: 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')
|
? t('composer.quote-unavailable')
|
||||||
: chart.image?.status === 'uploading'
|
: block.kind === 'chart-uploading'
|
||||||
? t('content:composer.uploading-reason')
|
? t('content:composer.uploading-reason')
|
||||||
: chart.image?.status === 'failed'
|
: t('content:composer.images.failed', { n: number(1) });
|
||||||
? t('content:composer.images.failed', { n: number(1) })
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const levelsBroken =
|
const levelsBroken =
|
||||||
targetIssues(direction, targets, entryPrice).some(Boolean) ||
|
targetIssues(direction, targets, entry).some(Boolean) ||
|
||||||
stopIssue(direction, stopLoss, entryPrice) !== null;
|
stopIssue(direction, stopLoss, entry) !== null;
|
||||||
const summary: ComposerSummary | null =
|
const summary: ComposerSummary | null =
|
||||||
missing.length === 0 &&
|
missing.length === 0 && entry !== null && market && direction && horizon
|
||||||
entryPrice !== null &&
|
|
||||||
market &&
|
|
||||||
direction &&
|
|
||||||
horizon
|
|
||||||
? {
|
? {
|
||||||
symbol,
|
symbol,
|
||||||
market,
|
market,
|
||||||
direction,
|
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(
|
targetPrices: targets.flatMap(
|
||||||
(target) => levelPrice(target.value) ?? [],
|
(target) => levelPrice(target.value) ?? [],
|
||||||
),
|
),
|
||||||
|
|
@ -325,16 +388,12 @@ export function usePredictionComposerPage({
|
||||||
const failPublish = (error: unknown) => {
|
const failPublish = (error: unknown) => {
|
||||||
const code = predictionErrorCode(error);
|
const code = predictionErrorCode(error);
|
||||||
if (code === PREDICTION_ERROR_CODES.invalid) {
|
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) => {
|
predictionFieldIssues(error).forEach((issue, index) => {
|
||||||
const { name, message } = toFieldError(
|
const { name, message } = toFieldError(
|
||||||
issue,
|
issue,
|
||||||
form.getValues('direction'),
|
form.getValues('direction'),
|
||||||
form.getValues('targets').length,
|
form.getValues('targets').length,
|
||||||
|
form.getValues('entryMode'),
|
||||||
);
|
);
|
||||||
form.setError(
|
form.setError(
|
||||||
name,
|
name,
|
||||||
|
|
@ -362,7 +421,7 @@ export function usePredictionComposerPage({
|
||||||
};
|
};
|
||||||
|
|
||||||
const publish = async () => {
|
const publish = async () => {
|
||||||
const sent = summary ?? confirmed;
|
const sent = confirmed;
|
||||||
if (phase !== 'confirming' || !sent) return;
|
if (phase !== 'confirming' || !sent) return;
|
||||||
const args: PublishPredictionArgs = {
|
const args: PublishPredictionArgs = {
|
||||||
accessLevel: sent.accessLevel,
|
accessLevel: sent.accessLevel,
|
||||||
|
|
@ -372,6 +431,12 @@ export function usePredictionComposerPage({
|
||||||
symbol: sent.symbol,
|
symbol: sent.symbol,
|
||||||
market: sent.market,
|
market: sent.market,
|
||||||
direction: sent.direction,
|
direction: sent.direction,
|
||||||
|
...(sent.entryMode === 'range'
|
||||||
|
? {
|
||||||
|
entryLow: sent.entryLow ?? undefined,
|
||||||
|
entryHigh: sent.entryHigh ?? undefined,
|
||||||
|
}
|
||||||
|
: { entryPrice: sent.entryPrice }),
|
||||||
targetPrices: sent.targetPrices,
|
targetPrices: sent.targetPrices,
|
||||||
stopLoss: sent.stopLoss,
|
stopLoss: sent.stopLoss,
|
||||||
horizon: sent.horizon,
|
horizon: sent.horizon,
|
||||||
|
|
@ -404,6 +469,8 @@ export function usePredictionComposerPage({
|
||||||
return (
|
return (
|
||||||
values.market !== '' ||
|
values.market !== '' ||
|
||||||
values.direction !== '' ||
|
values.direction !== '' ||
|
||||||
|
values.entryLow.trim() !== '' ||
|
||||||
|
values.entryHigh.trim() !== '' ||
|
||||||
values.targets.some((target) => target.value.trim() !== '') ||
|
values.targets.some((target) => target.value.trim() !== '') ||
|
||||||
values.stopLoss.trim() !== '' ||
|
values.stopLoss.trim() !== '' ||
|
||||||
values.horizon !== '' ||
|
values.horizon !== '' ||
|
||||||
|
|
@ -431,6 +498,13 @@ export function usePredictionComposerPage({
|
||||||
// `requestLeave`. A publish in flight navigates by itself.
|
// `requestLeave`. A publish in flight navigates by itself.
|
||||||
useLeaveGuard(phase !== 'publishing' && hasSomethingToLose(), requestLink);
|
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 {
|
return {
|
||||||
form,
|
form,
|
||||||
markets,
|
markets,
|
||||||
|
|
@ -440,11 +514,20 @@ export function usePredictionComposerPage({
|
||||||
form.setValue('market', next, { shouldDirty: true });
|
form.setValue('market', next, { shouldDirty: true });
|
||||||
// Another market's symbol can't stay: it goes, with its price.
|
// Another market's symbol can't stay: it goes, with its price.
|
||||||
form.setValue('symbol', '', { shouldDirty: true });
|
form.setValue('symbol', '', { shouldDirty: true });
|
||||||
|
clearEntry();
|
||||||
form.clearErrors(['market', 'symbol']);
|
form.clearErrors(['market', 'symbol']);
|
||||||
},
|
},
|
||||||
direction,
|
direction,
|
||||||
setDirection: (next) =>
|
setDirection: (next) =>
|
||||||
form.setValue('direction', next, { shouldDirty: true }),
|
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,
|
horizon,
|
||||||
setHorizon: (next) => {
|
setHorizon: (next) => {
|
||||||
form.setValue('horizon', next, { shouldDirty: true });
|
form.setValue('horizon', next, { shouldDirty: true });
|
||||||
|
|
@ -463,6 +546,7 @@ export function usePredictionComposerPage({
|
||||||
) {
|
) {
|
||||||
queryClient.setQueryData(marketDataKeys.quote(row.symbol), row.quote);
|
queryClient.setQueryData(marketDataKeys.quote(row.symbol), row.quote);
|
||||||
}
|
}
|
||||||
|
if (row.symbol !== symbol) clearEntry();
|
||||||
form.setValue('symbol', row.symbol, { shouldDirty: true });
|
form.setValue('symbol', row.symbol, { shouldDirty: true });
|
||||||
form.clearErrors('symbol');
|
form.clearErrors('symbol');
|
||||||
},
|
},
|
||||||
|
|
@ -502,7 +586,7 @@ export function usePredictionComposerPage({
|
||||||
setPhase('confirming');
|
setPhase('confirming');
|
||||||
})();
|
})();
|
||||||
},
|
},
|
||||||
confirmSummary: phase === 'idle' ? null : (summary ?? confirmed),
|
confirmSummary: phase === 'idle' ? null : confirmed,
|
||||||
publish: () => void publish(),
|
publish: () => void publish(),
|
||||||
cancelConfirm: () => {
|
cancelConfirm: () => {
|
||||||
if (phase === 'confirming') setPhase('idle');
|
if (phase === 'confirming') setPhase('idle');
|
||||||
|
|
|
||||||
|
|
@ -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';
|
export const PREDICTION_STATUS_PARAM = 'status';
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import type {
|
||||||
OwnPredictionPayload,
|
OwnPredictionPayload,
|
||||||
} from '../../repositories/prediction';
|
} from '../../repositories/prediction';
|
||||||
|
|
||||||
/** «همه پیشبینیها» (J10-3f, J10-3g). */
|
/** «همه سیگنالها» (J10-3f, J10-3g). */
|
||||||
export type PredictionListPageModel = {
|
export type PredictionListPageModel = {
|
||||||
/** The chip in the URL (`?status=`), «باز» by default. */
|
/** The chip in the URL (`?status=`), «باز» by default. */
|
||||||
status: OwnPredictionsStatus;
|
status: OwnPredictionsStatus;
|
||||||
|
|
|
||||||
|
|
@ -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
|
* 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.
|
* published first, closed the newest closed first. A card closed here stays in place, closed.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import {
|
||||||
import type { TrackRecordPartModel } from './types';
|
import type { TrackRecordPartModel } from './types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* داشبورد › پیشبینیها › the record (J10-3): the creator's own numbers once the record is public
|
* داشبورد › سیگنالها › 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
|
* (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.
|
* from public, since the channel shows no record yet.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ export const PREDICTION_ENDPOINTS = {
|
||||||
|
|
||||||
/** The codes the API marks prediction failures with; branch on these, never on the message. */
|
/** The codes the API marks prediction failures with; branch on these, never on the message. */
|
||||||
export const PREDICTION_ERROR_CODES = {
|
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',
|
invalid: 'PREDICTION_INVALID',
|
||||||
/** 503 on a price read or an early close, 409 on publish: no fresh price for the symbol. */
|
/** 503 on a price read or an early close, 409 on publish: no fresh price for the symbol. */
|
||||||
quoteUnavailable: 'QUOTE_UNAVAILABLE',
|
quoteUnavailable: 'QUOTE_UNAVAILABLE',
|
||||||
|
|
@ -35,15 +35,18 @@ export const PREDICTION_FIELD_CODES = [
|
||||||
'horizon_invalid',
|
'horizon_invalid',
|
||||||
'note_too_long',
|
'note_too_long',
|
||||||
'chart_too_many',
|
'chart_too_many',
|
||||||
|
'entry_required',
|
||||||
|
'entry_range_order',
|
||||||
|
'stop_required',
|
||||||
'target_wrong_side',
|
'target_wrong_side',
|
||||||
'targets_order',
|
'targets_order',
|
||||||
'stop_wrong_side',
|
'stop_wrong_side',
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
/** The «همه پیشبینیها» page size. */
|
/** The «همه سیگنالها» page size. */
|
||||||
export const OWN_PREDICTIONS_PAGE_LIMIT = 20;
|
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;
|
export const OWN_OPEN_PREVIEW_LIMIT = 50;
|
||||||
|
|
||||||
/** The tab's «بستهشدههای اخیر». */
|
/** The tab's «بستهشدههای اخیر». */
|
||||||
|
|
@ -60,7 +63,7 @@ export const predictionKeys = {
|
||||||
/** A first page the داشبورد tab shows. */
|
/** A first page the داشبورد tab shows. */
|
||||||
ownPreview: (status: OwnPredictionsStatus, limit: number) =>
|
ownPreview: (status: OwnPredictionsStatus, limit: number) =>
|
||||||
[...predictionKeys.own(), 'preview', status, limit] as const,
|
[...predictionKeys.own(), 'preview', status, limit] as const,
|
||||||
/** «همه پیشبینیها», page after page. */
|
/** «همه سیگنالها», page after page. */
|
||||||
ownList: (status: OwnPredictionsStatus) =>
|
ownList: (status: OwnPredictionsStatus) =>
|
||||||
[...predictionKeys.own(), 'list', status] as const,
|
[...predictionKeys.own(), 'list', status] as const,
|
||||||
/** The price an early close would record now. */
|
/** The price an early close would record now. */
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
import { isHttpError } from '@lumina/libs/http';
|
import { isHttpError } from '@lumina/libs/http';
|
||||||
|
|
||||||
import type { PostEntity } from '../../../post';
|
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 { PREDICTION_ERROR_CODES, PREDICTION_FIELD_CODES } from './constants';
|
||||||
import { toOwnPredictionPayload } from './mappers';
|
import { toOwnPredictionPayload } from './mappers';
|
||||||
import type {
|
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. */
|
/** The closed post a 409 `PREDICTION_ALREADY_CLOSED` carries, to show it as it is now. */
|
||||||
export function closedPostOfError(error: unknown): OwnPredictionPayload | null {
|
export function closedPostOfError(error: unknown): OwnPredictionPayload | null {
|
||||||
const post = detailsOf(error)?.post;
|
const post = detailsOf(error)?.post;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ export {
|
||||||
closedPostOfError,
|
closedPostOfError,
|
||||||
predictionErrorCode,
|
predictionErrorCode,
|
||||||
predictionFieldIssues,
|
predictionFieldIssues,
|
||||||
quoteOfError,
|
|
||||||
} from './errors';
|
} from './errors';
|
||||||
export { predictionRepository } from './prediction';
|
export { predictionRepository } from './prediction';
|
||||||
export type {
|
export type {
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,9 @@ export type PredictionErrorCode =
|
||||||
export type PredictionFieldCode = (typeof PREDICTION_FIELD_CODES)[number];
|
export type PredictionFieldCode = (typeof PREDICTION_FIELD_CODES)[number];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One field a 422 `PREDICTION_INVALID` refused, with the API's path: `market`, `symbol`,
|
* One field a 422 `PREDICTION_INVALID` refused, with the API's path: `market`, `symbol`, `entry`,
|
||||||
* `targetPrices` or `targetPrices.<i>`, `stopLoss`, `horizon`, `caption` (the note), `media`.
|
* `entryLow`, `targetPrices` or `targetPrices.<i>`, `stopLoss`, `horizon`, `caption` (the note),
|
||||||
|
* `media`.
|
||||||
*/
|
*/
|
||||||
export type PredictionFieldIssue = { field: string; code: PredictionFieldCode };
|
export type PredictionFieldIssue = { field: string; code: PredictionFieldCode };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,10 +79,14 @@ export function predictionCardLabels(t: ContentT): PredictionCardLabels {
|
||||||
toFinalTarget: t('prediction.to-final-target'),
|
toFinalTarget: t('prediction.to-final-target'),
|
||||||
toStop: t('prediction.to-stop'),
|
toStop: t('prediction.to-stop'),
|
||||||
riskReward: t('prediction.risk-reward'),
|
riskReward: t('prediction.risk-reward'),
|
||||||
|
riskRewardRange: (worst, best) =>
|
||||||
|
t('prediction.risk-reward-range', { worst, best }),
|
||||||
levels: {
|
levels: {
|
||||||
stop: t('prediction.levels.stop'),
|
stop: t('prediction.levels.stop'),
|
||||||
entry: t('prediction.levels.entry'),
|
entry: t('prediction.levels.entry'),
|
||||||
base: t('prediction.levels.base'),
|
base: t('prediction.levels.base'),
|
||||||
|
range: t('prediction.levels.range'),
|
||||||
|
entryRange: t('prediction.levels.entry-range'),
|
||||||
target,
|
target,
|
||||||
finalTarget: t('prediction.levels.final-target'),
|
finalTarget: t('prediction.levels.final-target'),
|
||||||
close: t('prediction.levels.close'),
|
close: t('prediction.levels.close'),
|
||||||
|
|
|
||||||
|
|
@ -99,10 +99,10 @@
|
||||||
"description": "کانالهایی که مشترک هستید"
|
"description": "کانالهایی که مشترک هستید"
|
||||||
},
|
},
|
||||||
"newPredictions": {
|
"newPredictions": {
|
||||||
"label": "پیشبینیهای تازه"
|
"label": "سیگنالهای تازه"
|
||||||
},
|
},
|
||||||
"predictionClosed": {
|
"predictionClosed": {
|
||||||
"label": "بسته شدن پیشبینیها",
|
"label": "بسته شدن سیگنالها",
|
||||||
"description": "رسیدن به هدف، حد ضرر یا پایان افق"
|
"description": "رسیدن به هدف، حد ضرر یا پایان افق"
|
||||||
},
|
},
|
||||||
"followedAnalysts": {
|
"followedAnalysts": {
|
||||||
|
|
@ -112,7 +112,7 @@
|
||||||
},
|
},
|
||||||
"sms": {
|
"sms": {
|
||||||
"newPredictions": {
|
"newPredictions": {
|
||||||
"label": "پیشبینیهای تازه"
|
"label": "سیگنالهای تازه"
|
||||||
},
|
},
|
||||||
"subscriptionReminder": {
|
"subscriptionReminder": {
|
||||||
"label": "یادآوری پایان اشتراک",
|
"label": "یادآوری پایان اشتراک",
|
||||||
|
|
@ -133,7 +133,7 @@
|
||||||
"label": "مشترک تازه"
|
"label": "مشترک تازه"
|
||||||
},
|
},
|
||||||
"predictionClosed": {
|
"predictionClosed": {
|
||||||
"label": "بسته شدن خودکار پیشبینیها",
|
"label": "بسته شدن خودکار سیگنالها",
|
||||||
"description": "رسیدن به هدف، حد ضرر یا پایان افق"
|
"description": "رسیدن به هدف، حد ضرر یا پایان افق"
|
||||||
},
|
},
|
||||||
"capacityRequestResult": {
|
"capacityRequestResult": {
|
||||||
|
|
@ -181,7 +181,7 @@
|
||||||
"body": "از این به بعد از آیکون لومینا روی دسکتاپ وارد شوید."
|
"body": "از این به بعد از آیکون لومینا روی دسکتاپ وارد شوید."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"notifications": "دریافت اعلان پستها و پیشبینیها",
|
"notifications": "دریافت اعلان پستها و سیگنالها",
|
||||||
"no-browser-bar": "بدون نوار مرورگر",
|
"no-browser-bar": "بدون نوار مرورگر",
|
||||||
"action": "نصب اپلیکیشن",
|
"action": "نصب اپلیکیشن",
|
||||||
"ios": {
|
"ios": {
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@
|
||||||
"investor": "سرمایهگذار",
|
"investor": "سرمایهگذار",
|
||||||
"investor-description": "تحلیلگران را با کارنامهشان مقایسه میکنم و در کانالشان مشترک میشوم.",
|
"investor-description": "تحلیلگران را با کارنامهشان مقایسه میکنم و در کانالشان مشترک میشوم.",
|
||||||
"creator": "تحلیلگر",
|
"creator": "تحلیلگر",
|
||||||
"creator-description": "تحلیل و پیشبینی منتشر میکنم و از اشتراک کانالم درآمد دارم.",
|
"creator-description": "تحلیل و سیگنال منتشر میکنم و از اشتراک کانالم درآمد دارم.",
|
||||||
"note": "نوع حساب پس از ثبتنام قابل تغییر نیست.",
|
"note": "نوع حساب پس از ثبتنام قابل تغییر نیست.",
|
||||||
"submit": "ادامه"
|
"submit": "ادامه"
|
||||||
},
|
},
|
||||||
|
|
@ -237,7 +237,7 @@
|
||||||
"title": "پیشنمایش پروفایل",
|
"title": "پیشنمایش پروفایل",
|
||||||
"live": "پیشنمایش زنده — سرمایهگذاران این را میبینند",
|
"live": "پیشنمایش زنده — سرمایهگذاران این را میبینند",
|
||||||
"channel": "کانال در لومینا",
|
"channel": "کانال در لومینا",
|
||||||
"note": "آمار و کارنامه پیشبینیها پس از اولین پیشبینیهای شما در همین صفحه نمایش داده میشود.",
|
"note": "آمار و کارنامه سیگنالها پس از اولین سیگنالهای شما در همین صفحه نمایش داده میشود.",
|
||||||
"close": "بستن پیشنمایش"
|
"close": "بستن پیشنمایش"
|
||||||
},
|
},
|
||||||
"done": {
|
"done": {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"meta": {
|
"meta": {
|
||||||
"title": "@{{username}}",
|
"title": "@{{username}}",
|
||||||
"description": "کانال @{{username}} در لومینا: پستها و پیشبینیهای ثبتشده، با کارنامهای که پیش از اشتراک میبینید.",
|
"description": "کانال @{{username}} در لومینا: پستها و سیگنالهای ثبتشده، با کارنامهای که پیش از اشتراک میبینید.",
|
||||||
"post-title": "پست @{{username}}",
|
"post-title": "پست @{{username}}",
|
||||||
"post-missing-title": "پست پیدا نشد",
|
"post-missing-title": "پست پیدا نشد",
|
||||||
"unavailable-title": "کانال در دسترس نیست"
|
"unavailable-title": "کانال در دسترس نیست"
|
||||||
|
|
@ -88,8 +88,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stats": {
|
"stats": {
|
||||||
"loading": "در حال بارگذاری عملکرد پیشبینیها…",
|
"loading": "در حال بارگذاری عملکرد سیگنالها…",
|
||||||
"error-title": "عملکرد پیشبینیها بارگذاری نشد",
|
"error-title": "عملکرد سیگنالها بارگذاری نشد",
|
||||||
"error-description": "بقیه کانال در دسترس است. این بخش را دوباره بارگذاری کنید."
|
"error-description": "بقیه کانال در دسترس است. این بخش را دوباره بارگذاری کنید."
|
||||||
},
|
},
|
||||||
"feed": {
|
"feed": {
|
||||||
|
|
@ -100,13 +100,13 @@
|
||||||
"no-subscribers": "این پست تا پیوستن نخستین مشترک، برای همه قفل میماند.",
|
"no-subscribers": "این پست تا پیوستن نخستین مشترک، برای همه قفل میماند.",
|
||||||
"empty": {
|
"empty": {
|
||||||
"title": "این کانال هنوز پستی منتشر نکرده است",
|
"title": "این کانال هنوز پستی منتشر نکرده است",
|
||||||
"description": "با دنبال کردن، از پستها و پیشبینیهای تازه باخبر میشوید."
|
"description": "با دنبال کردن، از پستها و سیگنالهای تازه باخبر میشوید."
|
||||||
},
|
},
|
||||||
"own-empty": {
|
"own-empty": {
|
||||||
"title": "هنوز پستی منتشر نکردهاید",
|
"title": "هنوز پستی منتشر نکردهاید",
|
||||||
"description": "اولین پست یا پیشبینی خود را منتشر کنید تا دنبالکنندگان آن را ببینند.",
|
"description": "اولین پست یا سیگنال خود را منتشر کنید تا دنبالکنندگان آن را ببینند.",
|
||||||
"post": "پست جدید",
|
"post": "پست جدید",
|
||||||
"prediction": "پیشبینی جدید"
|
"prediction": "سیگنال جدید"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"post": {
|
"post": {
|
||||||
|
|
@ -142,7 +142,7 @@
|
||||||
"subtitle": "کد شما ساخته شد: {{code}}"
|
"subtitle": "کد شما ساخته شد: {{code}}"
|
||||||
},
|
},
|
||||||
"prediction": {
|
"prediction": {
|
||||||
"title": "اولین پیشبینی را منتشر کنید",
|
"title": "اولین سیگنال را منتشر کنید",
|
||||||
"subtitle": "کارنامه عمومی شما از همینجا شروع میشود."
|
"subtitle": "کارنامه عمومی شما از همینجا شروع میشود."
|
||||||
},
|
},
|
||||||
"cta": "تعیین قیمتها",
|
"cta": "تعیین قیمتها",
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue