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.
56 lines
2.5 KiB
56 lines
2.5 KiB
import {ListQuestion} from "inquirer";
|
|
import {EntryMainMenuChoice, makeEntryMainMenuChoice} from "./EntryMainMenuPrompt";
|
|
import chalk from "chalk";
|
|
import {asDefault, identity} from "../../utils/Objects";
|
|
import {InquireFunction} from "../Inquire";
|
|
import {Suicidality} from "../../datatypes/Suicidality";
|
|
|
|
export interface SuicidalityPromptOptions extends Partial<Omit<ListQuestion, "name" | "type" | "choices">> {
|
|
}
|
|
|
|
export interface SuicidalityPromptDependencies {
|
|
inquire: InquireFunction
|
|
}
|
|
|
|
export function suicidalityPrompt(deps: SuicidalityPromptDependencies): {
|
|
(options: SuicidalityPromptOptions): Promise<Suicidality>,
|
|
mainMenu: EntryMainMenuChoice<"suicidality">,
|
|
} {
|
|
return makeEntryMainMenuChoice({
|
|
property: "suicidality",
|
|
name: (input) => typeof input === "string" ? `Change record of suicidal thoughts ${chalk.dim(`(currently ${chalk.greenBright(input)})`)}` : "Add record of suicidal thoughts",
|
|
key: "x",
|
|
injected: (options) => promptForSuicidality(options, deps),
|
|
toOptions: asDefault,
|
|
toProperty: identity,
|
|
})
|
|
}
|
|
|
|
export async function promptForSuicidality(options: SuicidalityPromptOptions, {inquire}: SuicidalityPromptDependencies): Promise<Suicidality> {
|
|
return await inquire({
|
|
type: "list",
|
|
message: "What stage are your suicidal thoughts at?",
|
|
choices: [
|
|
{value: Suicidality.NONE, name: `None ${chalk.dim("(no or only rare thoughts present)")}`},
|
|
{
|
|
value: Suicidality.PASSIVE,
|
|
name: `Passive ${chalk.dim("(faint call of the void, but without intention)")}`
|
|
},
|
|
{
|
|
value: Suicidality.INTRUSIVE,
|
|
name: `Intrusive ${chalk.dim("(intrusive thoughts with intention, not actively engaged with)")}`
|
|
},
|
|
{value: Suicidality.ACTIVE, name: `Active ${chalk.dim("(actively engaging with thoughts)")}`},
|
|
{
|
|
value: Suicidality.RESIGNED,
|
|
name: `Resigned ${chalk.dim("(given in to despair, but nothing further than that)")}`
|
|
},
|
|
{value: Suicidality.PLANNING, name: `Planning ${chalk.dim("(actively making plans to attempt)")}`},
|
|
{value: Suicidality.PLANNED, name: `Planned ${chalk.dim("(prepared a plan to attempt)")}`},
|
|
{value: Suicidality.DANGER, name: `Danger ${chalk.dim("(on the precipice of attempting)")}`},
|
|
],
|
|
default: 0,
|
|
pageSize: 999,
|
|
...options,
|
|
})
|
|
} |