diff --git a/src/screens/CaseScreen.tsx b/src/screens/CaseScreen.tsx index ce9d323..f9f8762 100644 --- a/src/screens/CaseScreen.tsx +++ b/src/screens/CaseScreen.tsx @@ -240,9 +240,16 @@ export function CaseScreen() { (null); + const [busy, setBusy] = useState<'now' | 'custom' | null>(null); const [err, setErr] = useState(null); + const [asOf, setAsOf] = useState(''); + const [from, setFrom] = useState(''); + const [to, setTo] = useState(''); - async function run(asOf?: string) { - setBusy(asOf ? 'quiet' : 'now'); + // The window Ava will actually use, so the reviewer sees it before pressing Run. + const effectiveTo = to || asOf; + const dateErr = + from && effectiveTo && from > effectiveTo + ? 'The window must start before it ends.' + : to && asOf && to > asOf + ? '"Window to" cannot be after "data as of".' + : null; + + async function run(custom: boolean) { + setBusy(custom ? 'custom' : 'now'); setErr(null); try { - // The activity's one field is optional; omit it entirely for a live run - // so the workflow sees a genuinely empty submission. - const res = await client.startInstance( - WORKFLOW, - ACT.REVIEW, - asOf ? { review_as_of__review: asOf } : {}, - ); + // Every field on the activity is optional; send only the ones the + // reviewer set, so a plain run is a genuinely empty submission. + const data: Record = {}; + if (custom) { + if (asOf) data.review_as_of__review = asOf; + if (from) data.review_from__review = from; + if (to) data.review_to__review = to; + } + const res = await client.startInstance(WORKFLOW, ACT.REVIEW, data); if (res.instance_id) navigate(`/c/${res.instance_id}`); else navigate('/q/investigating'); } catch (e) { @@ -83,26 +99,76 @@ export function RunReviewScreen() { -
-
- -

- Scheduled daily at 06:00. This runs the same activity immediately. +

+ +

+ Latest data, last 6 weeks against the 8 weeks before. Scheduled daily at 06:00; this runs + the same activity immediately. +

+
+ + + +
+ + + +
+

Custom run

+

+ Replay a past morning, or point the review at a specific period. Leave a date blank to + use the default.

+
+ +
- -

- Runs the review against data as of this date — a period with no material change, - to show a no-findings outcome. -

+ + +

Ignore anything after this date. Try {shortDate(QUIET_MORNING_AS_OF)} for a quiet morning.

+
+ + +

Start of the period Ava analyses.

+
+
+ + +

End of the period. Defaults to "data as of".

+
+
+ +

+ {dateErr ? ( + {dateErr} + ) : ( + <> + Ava will compare{' '} + + {from ? shortDate(from) : effectiveTo ? '6 weeks before' : 'the last 6 weeks'} + {from || effectiveTo ? ` – ${effectiveTo ? shortDate(effectiveTo) : 'latest data'}` : ''} + {' '} + against the 8 weeks before it + {asOf ? `, treating ${shortDate(asOf)} as the latest date` : ''}. + + )} +

+ +
+