feat: add finalise logic
Some checks failed
Format / formatting (push) Failing after 6s
Build / build (push) Successful in 41s
CI / build (push) Failing after 12s

This commit is contained in:
Mohamed Maoulainine Maoulainine 2025-05-10 17:59:05 +02:00
parent 27adc81ddc
commit f5aba70017
4 changed files with 44 additions and 7 deletions

View File

@ -3,6 +3,7 @@ import { onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import { jwtDecode } from "jwt-decode"; // i hope this doesn't break the code later
import { store } from "../main.ts";
import { checkPending } from "@/services/Apis/Unauth";
import Header from "@/components/HeaderComponent.vue";
const router = useRouter();
@ -22,18 +23,39 @@ onMounted(() => {
if (roles.includes("MyINPulse-admin")) {
router.push("/admin");
} else if (roles.includes("MyINPulse-entrepreneur")) {
return;
}
if (roles.includes("MyINPulse-entrepreneur")) {
router.push("/canvas");
return;
}
else{
router.push("/JorCproject")
}
checkPending(
(response) => {
const isValidated = response.data === true;
if (isValidated) {
router.push("/JorCproject");
} else {
router.push("/finalize");
}
},
(error) => {
if (error.response?.status === 404) {
router.push("/finalize");
} else {
console.error(
"Unexpected error during checkPending",
error
);
}
}
);
} catch (err) {
console.error("Failed to decode token", err);
}
}
});
</script>
<template>

View File

@ -40,6 +40,12 @@ const router = createRouter({
name: "JorCproject",
component: () => import("../views/JoinOrCreatProjectForEntrep.vue"),
},
{
path: "/finalize",
name: "finalize",
component: () => import("../views/FinalizeAccount.vue"),
},
],
});

View File

@ -74,8 +74,18 @@ function getAllEntrepreneurs(
});
}
function checkPending(): Promise<boolean> {
return axiosInstance
.get("/unauth/check-if-not-pending")
.then((response) => response.data)
.catch((error: AxiosError) => {
throw error;
});
}
export {
finalizeAccount,
getAllEntrepreneurs,
checkPending,
// requestJoinProject, // Not yet implemented [cite: 4]
};

View File

@ -70,7 +70,6 @@ const fallbackProjects = [
},
];
const createFirstAdmin = () => {
createAdmin(
(response) => {
@ -85,7 +84,7 @@ const createFirstAdmin = () => {
);
};
onMounted(createFirstAdmin)
onMounted(createFirstAdmin);
const fetchProjects = () => {
getAdminProjects(