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 SKINCARE_ANSWER_FLOWS: Record<number, TAnswerFlow> = {
  /**************** Upon Arrival: # of OOS ****************/
  10: setDirectAnswerPreset(
    undefined,
    "Thayers Skin Care Category - UPON ARRIVAL, BEFORE zoning or stocking, please count how many items are out of stock in the Thayers Skin Care category",
    "text",
    (storeLabel) => GLOBAL_PRESETS[storeLabel].skincare.thayers_oos_before(),
  ),
  11: setDirectAnswerPreset(
    undefined,
    "L'Oreal Skin Care Category - UPON ARRIVAL, BEFORE zoning or stocking, please count how many items are out of stock in the L'Oreal Skin Care category",
    "text",
    (storeLabel) => GLOBAL_PRESETS[storeLabel].skincare.loreal_oos_before(),
  ),
  12: setDirectAnswerPreset(
    undefined,
    "Garnier Skin Care Category - UPON ARRIVAL, BEFORE zoning or stocking, please count how many items are out of stock in the Garnier Skin Care category",
    "text",
    (storeLabel) => GLOBAL_PRESETS[storeLabel].skincare.garnier_oos_before(),
  ),

  /**************** Total Items Stocked ****************/
  20: setDirectAnswerPreset(
    undefined,
    "What is the total number of pieces of Thayers Skin Care products you stocked today",
    "text",
    (storeLabel) => GLOBAL_PRESETS[storeLabel].skincare.thayers_stocked(),
  ),
  21: setDirectAnswerPreset(
    undefined,
    "What is the total number of pieces of L'Oreal Skin Care products you stocked today",
    "text",
    (storeLabel) => GLOBAL_PRESETS[storeLabel].skincare.loreal_stocked(),
  ),
  22: setDirectAnswerPreset(
    undefined,
    "What is the total number of pieces of Garnier Skin Care products you stocked today",
    "text",
    (storeLabel) => GLOBAL_PRESETS[storeLabel].skincare.garnier_stocked(),
  ),

  /**************** Upon Completion: # of OOS ****************/
  30: setDependentAnswerPreset(
    undefined,
    "Thayers Skin Care: After Zoning/Stocking/Merchandising, what is the Total # of Out Of Stocks during this visit",
    "text",
    [10],
    beautyUtils.getAfterOOSCount,
  ),
  31: setDependentAnswerPreset(
    undefined,
    "L'Oreal Skin Care: After Zoning/Stocking/Merchandising, what is the Total # of Out Of Stocks during this visit",
    "text",
    [11],
    beautyUtils.getAfterOOSCount,
  ),
  32: setDependentAnswerPreset(
    undefined,
    "Garnier Skin Care: 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,
    "Thayers Skin Care: 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 Skin Care: 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,
    "Garnier Skin Care: 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,
    "Thayers Skin Care: What is the total number DPCIs in which the counts WERE CORRECTED",
    "text",
    [40],
    beautyUtils.getTotalDPCIsCountCorrected,
  ),
  51: setDependentAnswerPreset(
    undefined,
    "L'Oreal Skin Care: What is the total number DPCIs in which the counts WERE CORRECTED",
    "text",
    [41],
    beautyUtils.getTotalDPCIsCountCorrected,
  ),
  52: setDependentAnswerPreset(
    undefined,
    "Garnier Skin Care: What is the total number DPCIs in which the counts WERE CORRECTED",
    "text",
    [42],
    beautyUtils.getTotalDPCIsCountCorrected,
  ),

  /**************** Closing Questions ****************/
  60: setDependentAnswerPreset(
    undefined,
    "Did a Team Lead assist you during your service to correct any Skin Care",
    "radio",
    [40, 41, 42],
    beautyUtils.getDidATeamMemberAssistYouWithUpdatingOnHands,
  ),
  61: setDependentAnswerPreset(
    /Skin Care/i,
    "Select why 0 Items needed a count correction",
    "radio",
    [40, 41, 42],
    beautyUtils.getWhyZeroItemsNeededCountCorrection,
  ),
  62: setDependentAnswerPreset(
    /Skin Care/i,
    "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";
    },
  ),
  63: setDirectAnswerPreset(
    undefined,
    "Are there shelf labels missing on the Thayers",
    "radio",
    () => "No shelf labels are missing from the POG",
  ),
};
