designtopack/src/stores/project.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-11-05 14:26:23 +01:00
import { defineStore } from "pinia";
2024-11-21 11:27:14 +01:00
import { usePageStore } from "./page";
2024-11-05 14:26:23 +01:00
export const useProjectStore = defineStore("project", () => {
2024-11-21 11:27:14 +01:00
const { page } = usePageStore();
2024-11-05 14:26:23 +01:00
const stepsLabels = {
2024-11-19 14:10:35 +01:00
Brief: "Votre brief",
2024-11-05 14:26:23 +01:00
proposal: "Proposition commerciale",
extendedBrief: "Brief enrichi",
industrialIdeation: "Idéation industrielle",
virtualSample: "Échantillon virtuel",
physicalSample: "Échantillon physique",
};
2024-11-21 11:47:36 +01:00
function setStatus(steps, currentStepId, targetStep) {
2024-11-21 11:27:14 +01:00
const currentStepIndex = steps.findIndex(
(item) => item.id === currentStepId
);
2024-11-21 11:47:36 +01:00
const stepIndex = steps.findIndex((item) => item.id === targetStep.id);
2024-11-21 11:27:14 +01:00
if (currentStepIndex === stepIndex) {
return "in-progress";
}
if (currentStepIndex > stepIndex) {
return "done";
}
if (currentStepIndex < stepIndex) {
return "uncompleted";
}
}
2024-12-19 19:27:38 +01:00
function isEmptyBrief(project) {
return (
project.currentStep === "clientBrief" &&
project.steps[0].files.length === 0
);
}
return { stepsLabels, setStatus, isEmptyBrief };
2024-11-05 14:26:23 +01:00
});