import { GLOBAL_PRESETS } from "../global-presets";
import { setDependentAnswerPreset, setDirectAnswerPreset } from "../util/answer-flow";
import { TAnswerFlow } from "../util/types";
import * as beautyUtils from "../util/utils";

export const NYX_ANSWER_FLOWS: Record<number, TAnswerFlow> = {
  /**************** Upon Arrival: # of OOS ****************/
  10: setDirectAnswerPreset(undefined, /BEFORE zoning.*NYX EYE/i, "text", (storeLabel) =>
    GLOBAL_PRESETS[storeLabel].nyx.eye_oos_before(),
  ),
  11: setDirectAnswerPreset(undefined, /BEFORE zoning.*NYX FACE/i, "text", (storeLabel) =>
    GLOBAL_PRESETS[storeLabel].nyx.face_oos_before(),
  ),
  12: setDirectAnswerPreset(undefined, /BEFORE zoning.*NYX LIP/i, "text", (storeLabel) =>
    GLOBAL_PRESETS[storeLabel].nyx.lip_oos_before(),
  ),

  /**************** Total Items Stocked ****************/
  20: setDirectAnswerPreset(
    undefined,
    "What is the total number of pieces of NYX Cosmetics products you stocked today",
    "text",
    (storeLabel) => GLOBAL_PRESETS[storeLabel].nyx.total_stocked(),
  ),

  /**************** Upon Completion: # of OOS ****************/
  30: setDependentAnswerPreset(
    undefined,
    /nyx.*eye.*after zoning|after zoning.*nyx.*eye/i,
    "text",
    [10],
    beautyUtils.getAfterOOSCount,
  ),
  31: setDependentAnswerPreset(
    undefined,
    /nyx.*face.*after zoning|after zoning.*nyx.*face/i,
    "text",
    [11],
    beautyUtils.getAfterOOSCount,
  ),
  32: setDependentAnswerPreset(
    undefined,
    /nyx.*lip.*after zoning|after zoning.*nyx.*lip/i,
    "text",
    [12],
    beautyUtils.getAfterOOSCount,
  ),

  /**************** On-hand Discrepancies ****************/
  40: setDependentAnswerPreset(
    undefined,
    "NYX COSMETICS EYE: How many Out Of Stock EYE items with 0 in the backroom show an on hand count (on hand in parentheses) greater than 0",
    "text",
    [30],
    beautyUtils.getOOSWithOnHandsGreaterThanZero,
  ),
  41: setDependentAnswerPreset(
    undefined,
    "NYX Cosmetics FACE: How many Out Of Stock FACE items with 0 in the backroom show an on hand count (on hand in parentheses) greater than 0",
    "text",
    [31],
    beautyUtils.getOOSWithOnHandsGreaterThanZero,
  ),
  42: setDependentAnswerPreset(
    undefined,
    "NYX Cosmetics LIP: How many Out Of Stock items with 0 in the backroom show an on hand count (on hand in parentheses) greater than 0",
    "text",
    [32],
    beautyUtils.getOOSWithOnHandsGreaterThanZero,
  ),

  /**************** Count Corrections / DPCIs Corrected ****************/
  50: setDependentAnswerPreset(
    undefined,
    "NYX COSMETICS EYE: What is the total number DPCIs in which the counts WERE CORRECTED in the INVENTORY AUDIT in your presence during this visit",
    "text",
    [40],
    (dependencyAnswers) => dependencyAnswers[0],
  ),
  51: setDependentAnswerPreset(
    undefined,
    "NYX Cosmetics FACE: What is the total number DPCIs in which the counts WERE CORRECTED in the INVENTORY AUDIT in your presence during this visit",
    "text",
    [41],
    (dependencyAnswers) => dependencyAnswers[0],
  ),
  52: setDependentAnswerPreset(
    undefined,
    "NYX Cosmetics LIP: What is the total number DPCIs in which the counts WERE CORRECTED in the INVENTORY AUDIT in your presence during this visit",
    "text",
    [42],
    (dependencyAnswers) => dependencyAnswers[0],
  ),

  /**************** Closing Questions ****************/
  60: setDependentAnswerPreset(
    "NYX Cosmetics",
    "Select why 0 Items needed a count correction",
    "text",
    [40, 41, 42],
    beautyUtils.getWhyZeroItemsNeededCountCorrection,
  ),
  61: setDependentAnswerPreset(
    "NYX Cosmetics",
    "Confirm 0 out of stock items need a count correction",
    "radio",
    [40, 41, 42],
    (dependencyAnswers) => {
      if (beautyUtils.getWhyZeroItemsNeededCountCorrection(dependencyAnswers) === null) return null;
      return "No out of stock items needzed a count correction";
    },
  ),
  62: setDirectAnswerPreset(
    "NYX Cosmetics",
    "Are there shelf labels missing on the NYX Cosmetic POG",
    "radio",
    () => "No shelf labels are missing from the NYX POG",
  ),
  63: setDependentAnswerPreset(
    "NYX Cosmetics Count Corrections",
    "Did a Team Lead assist you during your service to correct any NYX Cosmetics incorrect counts for out of stock items in the Inventory Audit",
    "radio",
    [40, 41, 42],
    beautyUtils.getDidATeamMemberAssistYouWithUpdatingOnHands,
  ),
  64: setDirectAnswerPreset(
    undefined,
    "TIME CHECK - Do you have time to start working on L'Oreal Cosmetics",
    "radio",
    () => "Yes I have remaining time to start working on L'Oreal Cosmetics",
  ),
  65: setDirectAnswerPreset(
    undefined,
    "Did you clean the fixtures and any product needing cleaning on the L'Oreal POG & NYX Cosmetics POG",
    "radio",
    () => "Yes- all sections on the L'Oreal & NYX POG are clean",
  ),
  66: setDirectAnswerPreset(
    undefined,
    "Did you have time to finish all Eye and Face and Lip section Service objectives today",
    "radio",
    () => "Yes",
  ),
};
