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 ESSIE_ANSWER_FLOWS: Record<number, TAnswerFlow> = {
  /**************** Upon Arrival: # of OOS ****************/
  10: setDirectAnswerPreset(
    "Essie",
    "UPON ARRIVAL, BEFORE zoning or stocking, please count how many items are out of stock in the Essie Nail category",
    "text",
    (storeLabel) => GLOBAL_PRESETS[storeLabel].essie.oos_before(),
  ),

  /**************** Total Items Stocked ****************/
  20: setDirectAnswerPreset(
    "Essie",
    "What is the total number of pieces of Essie Nail you stocked today",
    "text",
    (storeLabel) => GLOBAL_PRESETS[storeLabel].essie.total_stocked(),
  ),

  /**************** Upon Completion: # of OOS ****************/
  30: setDependentAnswerPreset(
    "Essie",
    "Essie Nail: After Zoning/Stocking/Merchandising, what is the Total # of Out Of Stocks during this visit",
    "text",
    [10],
    beautyUtils.getAfterOOSCount,
  ),

  /**************** On-hand Discrepancies ****************/
  40: setDependentAnswerPreset(
    "Essie",
    "Essie Nail: 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,
  ),

  /**************** Count Corrections / DPCIs Corrected ****************/
  50: setDependentAnswerPreset(
    "Essie Count Corrections",
    "Essie Nail: 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],
  ),

  /**************** Closing Questions ****************/
  60: setDirectAnswerPreset(
    undefined,
    "Additional Task Status",
    "radio",
    () => "I completed my Additional Task for this category scheduled this week today.",
  ),
  61: setDependentAnswerPreset(
    "Essie",
    "Select why 0 Items needed a count correction",
    "radio",
    [40],
    beautyUtils.getWhyZeroItemsNeededCountCorrection,
  ),
  62: setDependentAnswerPreset(
    "Essie",
    "Confirm 0 out of stock items need a count correction",
    "radio",
    [40],
    (dependencyAnswers) => {
      const numInaccurateCounts = Number.parseInt(dependencyAnswers[0]);
      if (numInaccurateCounts > 0) return null;
      return "No out of stock items needed a count correction";
    },
  ),
  63: setDirectAnswerPreset(
    "Essie",
    "Are there shelf labels missing on the essie POG",
    "radio",
    () => "No shelf labels are missing from the POG",
  ),
  64: setDependentAnswerPreset(
    "Essie Count Corrections",
    "Did a Team Lead assist you during your service to correct any essie counts for out of stock items in the Inventory Audit",
    "radio",
    [40],
    beautyUtils.getDidATeamMemberAssistYouWithUpdatingOnHands,
  ),
  65: setDirectAnswerPreset(
    undefined,
    "Did you clean the fixtures and any product needing cleaning on the Maybelline POG & essie POG",
    "radio",
    () => "Yes- all sections on the MNY & essie POG are clean",
  ),
  66: setDirectAnswerPreset(
    undefined,
    "Did you have time to finish all Maybelline Eye, Face, Lip and Essie objectives today",
    "radio",
    () => "Yes",
  ),
};
