fix: join or create
Some checks failed
Format / formatting (push) Failing after 6s
Build / build (push) Successful in 43s
CI / build (push) Failing after 10s

This commit is contained in:
Mohamed Maoulainine Maoulainine 2025-05-11 20:37:57 +02:00
parent 6b49bbbe57
commit 3ef2d8a198

View File

@ -1,4 +1,5 @@
<template> <template>
<Header/>
<header class="header"> <header class="header">
<img <img
src="@/components/icons/logo inpulse.png" src="@/components/icons/logo inpulse.png"
@ -38,11 +39,17 @@
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">import { ref, onMounted } from "vue";
import { ref } from "vue"; import { useRouter } from "vue-router";
import Project from "@/ApiClasses/Project"; import Project from "@/ApiClasses/Project";
import { requestProjectCreation } from "@/services/Apis/Entrepreneurs.ts"; import Header from "../components/HeaderComponent.vue";
import {
requestProjectCreation,
checkIfProjectIsActive,
checkPendingProjectRequest,
} from "@/services/Apis/Entrepreneurs";
const router = useRouter();
const choix = ref<string | null>(null); const choix = ref<string | null>(null);
const nomProjet = ref(""); const nomProjet = ref("");
@ -56,21 +63,18 @@ const validerCreation = () => {
return; return;
} }
// Obtenir la date actuelle au format YYYY-MM-DD
const today = new Date(); const today = new Date();
const yyyy = today.getFullYear(); const yyyy = today.getFullYear();
const mm = String(today.getMonth() + 1).padStart(2, "0"); const mm = String(today.getMonth() + 1).padStart(2, "0");
const dd = String(today.getDate()).padStart(2, "0"); const dd = String(today.getDate()).padStart(2, "0");
const formattedDate = `${yyyy}-${mm}-${dd}`; const formattedDate = `${yyyy}-${mm}-${dd}`;
// Créer une instance de Project
const nouveauProjet = new Project({ const nouveauProjet = new Project({
projectName: nomProjet.value.trim(), projectName: nomProjet.value.trim(),
creationDate: formattedDate, creationDate: formattedDate,
status: "PENDING", status: "PENDING",
}); });
// Appeler lAPI
requestProjectCreation( requestProjectCreation(
nouveauProjet, nouveauProjet,
(response) => { (response) => {
@ -83,6 +87,29 @@ const validerCreation = () => {
} }
); );
}; };
onMounted(() => {
checkIfProjectIsActive(
(response) => {
if (response.data === true) {
router.push("/canvas");
}
},
() => {
checkPendingProjectRequest(
(response) => {
if (response.data === true) {
router.push("/pending-approval");
}
},
(error) => {
console.warn("No active or pending project:", error);
}
);
}
);
});
</script> </script>
<style scoped> <style scoped>