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 LOREAL_ANSWER_FLOWS: Record<number, TAnswerFlow> = {
  /**************** Upon Arrival: # of OOS ****************/
  10: setDirectAnswerPreset(
    undefined,
    "EYE CATEGORY - UPON ARRIVAL, BEFORE zoning or stocking, please count how many items are out of stock in the L'Oreal EYE category",
    "text",
    (storeLabel) => GLOBAL_PRESETS[storeLabel].loreal.eye_oos_before(),
  ),
  11: setDirectAnswerPreset(
    undefined,
    "FACE Category - UPON ARRIVAL, BEFORE zoning or stocking, please count how many items are out of stock in the L'Oreal FACE category",
    "text",
    (storeLabel) => GLOBAL_PRESETS[storeLabel].loreal.face_oos_before(),
  ),
  12: setDirectAnswerPreset(
    undefined,
    "LIP Category - UPON ARRIVAL, BEFORE zoning or stocking, please count how many items are out of stock in the L'Oreal LIP category",
    "text",
    (storeLabel) => GLOBAL_PRESETS[storeLabel].loreal.lip_oos_before(),
  ),

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

  /**************** Upon Completion: # of OOS ****************/
  30: setDependentAnswerPreset(
    undefined,
    "L'OREAL EYE: After Zoning/Stocking/Merchandising, what is the Total # of Out Of Stocks during this visit",
    "text",
    [10],
    beautyUtils.getAfterOOSCount,
  ),
  31: setDependentAnswerPreset(
    undefined,
    "L'OREAL FACE: After Zoning/Stocking/Merchandising, what is the Total # of Out Of Stocks during this visit",
    "text",
    [11],
    beautyUtils.getAfterOOSCount,
  ),
  32: setDependentAnswerPreset(
    undefined,
    "L'OREAL LIP: After Zoning/Stocking/Merchandising, what is the Total # of Out Of Stocks during this visit",
    "text",
    [12],
    beautyUtils.getAfterOOSCount,
  ),

  /**************** On-hand Discrepancies ****************/
  40: setDependentAnswerPreset(
    undefined,
    "L'OREAL EYE: How many Out Of Stock 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,
    "L'OREAL FACE: How many Out Of Stock 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,
    "L'OREAL 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,
    "L'Oreal 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],
    beautyUtils.getTotalDPCIsCountCorrected,
  ),
  51: setDependentAnswerPreset(
    undefined,
    "L'Oreal 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],
    beautyUtils.getTotalDPCIsCountCorrected,
  ),
  52: setDependentAnswerPreset(
    undefined,
    "L'Oreal 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],
    beautyUtils.getTotalDPCIsCountCorrected,
  ),

  /**************** Closing Questions ****************/
  60: setDependentAnswerPreset(
    "L'Oreal Cosmetics",
    "Select why 0 Items needed a count correction",
    "radio",
    [40, 41, 42],
    beautyUtils.getWhyZeroItemsNeededCountCorrection,
  ),
  61: setDependentAnswerPreset(
    "L'Oreal 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 needed a count correction";
    },
  ),
  62: setDirectAnswerPreset(
    "L'Oreal Cosmetics",
    "Are there shelf labels missing on the L'Oreal Cosmetic POG",
    "radio",
    () => "No shelf labels are missing from the L'Oreal POG",
  ),
  63: setDependentAnswerPreset(
    "L'Oreal Cosmetics Count Corrections",
    "Did a Team Lead assist you during your service to correct any L'Oreal Cosmetics EYE or FACE or LIP 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 NYX cosmetics",
    "radio",
    () => "Yes I have remaining time to start working on NYX",
  ),
};
