You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.3 KiB
34 lines
1.3 KiB
import {ConditionPromptOptions} from "./ConditionPrompt.js";
|
|
import {Condition} from "../../datatypes/Condition.js";
|
|
import {SummaryPromptOptions} from "./SummaryPrompt.js";
|
|
import {EntryMainMenuOptions} from "./EntryMainMenuPrompt.js";
|
|
import {Entry} from "../../datatypes/Entry.js";
|
|
|
|
interface EntryPromptOptions {
|
|
}
|
|
|
|
interface EntryPromptDependencies {
|
|
promptForCondition: (options: ConditionPromptOptions) => Promise<Condition>
|
|
promptForSummary: (options: SummaryPromptOptions) => Promise<string | null>
|
|
promptForEntryMainMenu: (options: EntryMainMenuOptions) => Promise<Entry>
|
|
}
|
|
|
|
export function entryPrompt(deps: EntryPromptDependencies): (options: EntryPromptOptions) => Promise<Entry> {
|
|
return (options) => promptForEntry(options, deps)
|
|
}
|
|
|
|
export async function promptForEntry(options: EntryPromptOptions, dependencies: EntryPromptDependencies): Promise<Entry> {
|
|
const {
|
|
promptForCondition,
|
|
promptForSummary,
|
|
promptForEntryMainMenu,
|
|
} = dependencies
|
|
const startedAt = new Date()
|
|
const condition = await promptForCondition({})
|
|
const summary = await promptForSummary({})
|
|
if (summary === null) {
|
|
return promptForEntryMainMenu({startedAt, condition})
|
|
} else {
|
|
return promptForEntryMainMenu({startedAt, condition, summary})
|
|
}
|
|
} |