import type { StatusCode } from "@/api/types-extra";

export const CODES: Record<StatusCode, string> = {
  "V-COMP": "Completion confirmed",
  "V-NCOMP": "Did not complete",
  "V-UNR": "Unreachable",
  "V-REF": "Refused",
  "V-INC": "Inconclusive",
};
export const OUTCOMES: [string, string][] = [
  ["reached", "Reached"],
  ["no_answer", "No answer"],
  ["busy", "Busy"],
  ["switched_off", "Switched off"],
  ["wrong_number", "Wrong number"],
  ["call_back", "Call back later"],
];
export interface Question {
  key: string;
  text: string;
  options: [string, string][];
  when?: (a: Record<string, string>) => boolean;
  multiple?: boolean;
}
const YNN: [string, string][] = [
  ["yes", "Yes"],
  ["no", "No"],
  ["not_sure", "Not sure"],
];
const OK: [string, string][] = [
  ["correct", "Correct"],
  ["not_correct", "Not correct"],
];
const consent = (a: Record<string, string>) => a["q1"] === "yes";
/** Official wording: Verification of Training Completion Rate, section 6.4. Q17 (the status) is derived by the system. */
export const INTRO =
  "Hello, my name is [Name] from ICOS Consulting PLC. I am calling regarding the training you completed under the EASE/Qiyas Project. This call is part of an independent verification process to confirm training outcomes and should take about 5–7 minutes. Your participation is voluntary, and all information you provide will be kept confidential. May I proceed?";
export const CLOSING =
  "Thank you for your time and for participating in this verification. Your responses will help us ensure the quality and accountability of the training program. Have a good day!";
export const QUESTIONS: Question[] = [
  {
    key: "q1",
    text: "Consent to proceed",
    options: [
      ["yes", "Yes"],
      ["no", "No"],
    ],
  },
  { key: "q2", text: "Confirm Full Name", options: OK, when: consent },
  { key: "q3", text: "Confirm Training Provider", options: OK, when: consent },
  { key: "q4", text: "Confirm Training Type", options: OK, when: consent },
  { key: "q5", text: "Confirm City / Location", options: OK, when: consent },
  { key: "q6", text: "Confirm Sex of Respondent", options: OK, when: consent },
  {
    key: "q7",
    text: "Did you attend the training sessions regularly throughout the training period?",
    options: [
      ["yes", "Yes"],
      ["no", "No"],
      ["partially", "Partially"],
      ["not_sure", "Not sure"],
    ],
    when: consent,
  },
  {
    key: "q8",
    text: "Approximately what percentage of the total training sessions did you attend?",
    options: [
      ["90_plus", "90% or more"],
      ["80_89", "80% – 89%"],
      ["70_79", "70% – 79%"],
      ["below_70", "Less than 70%"],
      ["not_sure", "Not sure"],
    ],
    when: consent,
  },
  {
    key: "q9",
    text: "What was the main reason you missed sessions?",
    options: [
      ["transport", "Transportation difficulties"],
      ["health", "Health issues"],
      ["family", "Family / personal reasons"],
      ["work", "Work / employment"],
      ["motivation", "Lack of motivation"],
      ["other", "Other (specify)"],
    ],
    when: (a) => consent(a) && a["q8"] === "below_70",
  },
  {
    key: "q10",
    text: "Did you successfully complete the full training program?",
    options: YNN,
    when: consent,
  },
  {
    key: "q11",
    text: "Were you informed by the training provider that you had completed the training?",
    options: [
      ["yes", "Yes"],
      ["no", "No"],
      ["not_yet", "Not yet"],
    ],
    when: consent,
  },
  {
    key: "q12",
    text: "Did you complete all required assignments, projects, or practical exercises?",
    options: [
      ["yes", "Yes"],
      ["no", "No"],
      ["partially", "Partially"],
      ["not_applicable", "Not applicable"],
    ],
    when: consent,
  },
  {
    key: "q13",
    text: "Did you take a final assessment or exam at the end of the training?",
    options: YNN,
    when: consent,
  },
  {
    key: "q14",
    text: "Did you pass the final assessment or exam?",
    options: YNN,
    when: (a) => consent(a) && a["q13"] === "yes",
  },
  {
    key: "q15",
    text: "Have you received a certificate of completion?",
    options: [
      ["yes", "Yes"],
      ["not_yet", "No, not yet"],
      ["not_sure", "Not sure"],
    ],
    when: consent,
  },
  {
    key: "q16",
    text: "If you did not complete the training, what was the main reason? (Multiple response)",
    multiple: true,
    options: [
      ["transport", "Transportation / distance"],
      ["money", "Financial difficulties"],
      ["health", "Health issues"],
      ["family", "Family or personal reasons"],
      ["job", "Found a job"],
      ["expectations", "Training was not what I expected"],
      ["equipment", "Lack of equipment or resources"],
      ["schedule", "Scheduling conflicts"],
      ["relocation", "Relocation"],
      ["other", "Other (specify)"],
    ],
    when: (a) => consent(a) && a["q10"] === "no",
  },
];
