This commit is contained in:
parent
6d70187cb9
commit
c578538fe0
10 changed files with 195 additions and 107 deletions
45
src/stores/brief.js
Normal file
45
src/stores/brief.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { usePageStore } from "./page";
|
||||
|
||||
export const useBriefStore = defineStore("brief", () => {
|
||||
async function addPdf(event, briefUri, redirectToParent = false) {
|
||||
const file = event.target.files[0];
|
||||
const { page } = usePageStore();
|
||||
|
||||
if (file) {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
|
||||
try {
|
||||
const response = await fetch("/upload-pdf.json?pageUri=" + briefUri, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
page.value = result;
|
||||
if (redirectToParent) {
|
||||
location.href =
|
||||
location.origin +
|
||||
"/" +
|
||||
page.value.parent +
|
||||
"?dialog=client-brief";
|
||||
} else {
|
||||
location.href = location.href + "?dialog=client-brief";
|
||||
}
|
||||
} else {
|
||||
console.error("Error uploading file:", result.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Request failed:", error);
|
||||
}
|
||||
} else {
|
||||
console.error("No file selected.");
|
||||
}
|
||||
}
|
||||
|
||||
return { addPdf };
|
||||
});
|
||||
|
|
@ -30,5 +30,12 @@ export const useProjectStore = defineStore("project", () => {
|
|||
}
|
||||
}
|
||||
|
||||
return { stepsLabels, setStatus };
|
||||
function isEmptyBrief(project) {
|
||||
return (
|
||||
project.currentStep === "clientBrief" &&
|
||||
project.steps[0].files.length === 0
|
||||
);
|
||||
}
|
||||
|
||||
return { stepsLabels, setStatus, isEmptyBrief };
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue