home (projects) : dynamize steps

This commit is contained in:
isUnknown 2024-11-21 11:27:14 +01:00
parent 8bcba4ca9c
commit 837b741c47
4 changed files with 49 additions and 37 deletions

View file

@ -1,6 +1,9 @@
import { defineStore } from "pinia";
import { usePageStore } from "./page";
export const useProjectStore = defineStore("project", () => {
const { page } = usePageStore();
const stepsLabels = {
Brief: "Votre brief",
proposal: "Proposition commerciale",
@ -10,5 +13,24 @@ export const useProjectStore = defineStore("project", () => {
physicalSample: "Échantillon physique",
};
return { stepsLabels };
function setStatus(steps, step) {
const currentStepId = page.content.currentstep;
const currentStepIndex = steps.findIndex(
(item) => item.id === currentStepId
);
const stepIndex = steps.findIndex((item) => item.id === step.id);
if (currentStepIndex === stepIndex) {
return "in-progress";
}
if (currentStepIndex > stepIndex) {
return "done";
}
if (currentStepIndex < stepIndex) {
return "uncompleted";
}
}
return { stepsLabels, setStatus };
});