31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
import { findRecentRuns, describeDay } from './repeatRuns';
|
||
import { startFlow, advanceFlow, answerFlowStep } from './flowEngine';
|
||
|
||
// ==============================|| Doormile AI — repeat a run ||============================== //
|
||
//
|
||
// One question: which day. Everything after it — resolving customers, the drift
|
||
// check, re-quoting at today's tariff, the already-repeated guard — is a pass
|
||
// the panel runs and narrates, exactly like the bulk file's locate/price phase.
|
||
// None of it is a question, so none of it is a step.
|
||
|
||
export const REPEAT_STEPS = [
|
||
{
|
||
id: 'day',
|
||
type: 'select',
|
||
ask: 'Which day’s orders should I repeat?',
|
||
options: async () => {
|
||
const { runs } = await findRecentRuns();
|
||
return runs.map((r) => ({
|
||
value: r.day,
|
||
label: `${describeDay(r.day)} — ${r.count} order${r.count === 1 ? '' : 's'}`,
|
||
record: r
|
||
}));
|
||
},
|
||
apply: (d, v, option) => ({ ...d, day: v, sourceCount: option?.record?.count })
|
||
}
|
||
];
|
||
|
||
export const startRepeatFlow = () => startFlow(REPEAT_STEPS, 'repeatRun', {});
|
||
export const advanceRepeat = (flow) => advanceFlow(REPEAT_STEPS, flow);
|
||
export const answerRepeatStep = (flow, raw, option) => answerFlowStep(REPEAT_STEPS, flow, raw, option);
|