import { defineStore } from "pinia";
import { usePageStore } from "./page";

export const useProjectStore = defineStore("project", () => {
  const { page } = usePageStore();

  const stepsLabels = {
    Brief: "Votre brief",
    proposal: "Proposition commerciale",
    extendedBrief: "Brief enrichi",
    industrialIdeation: "Idéation industrielle",
    virtualSample: "Échantillon virtuel",
    physicalSample: "Échantillon physique",
  };

  function setStatus(steps, currentStepId, targetStep) {
    const currentStepIndex = steps.findIndex(
      (item) => item.id === currentStepId
    );
    const stepIndex = steps.findIndex((item) => item.id === targetStep.id);

    if (currentStepIndex === stepIndex) {
      return "in-progress";
    }
    if (currentStepIndex > stepIndex) {
      return "done";
    }
    if (currentStepIndex < stepIndex) {
      return "uncompleted";
    }
  }

  function isEmptyBrief(project) {
    return (
      project.currentStep === "clientBrief" &&
      project.steps[0].files.length === 0
    );
  }

  return { stepsLabels, setStatus, isEmptyBrief };
});
