feat: add finalise logic
This commit is contained in:
parent
27adc81ddc
commit
f5aba70017
@ -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>
|
||||
|
@ -40,6 +40,12 @@ const router = createRouter({
|
||||
name: "JorCproject",
|
||||
component: () => import("../views/JoinOrCreatProjectForEntrep.vue"),
|
||||
},
|
||||
|
||||
{
|
||||
path: "/finalize",
|
||||
name: "finalize",
|
||||
component: () => import("../views/FinalizeAccount.vue"),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
|
@ -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]
|
||||
};
|
||||
|
@ -70,7 +70,6 @@ const fallbackProjects = [
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
const createFirstAdmin = () => {
|
||||
createAdmin(
|
||||
(response) => {
|
||||
@ -85,7 +84,7 @@ const createFirstAdmin = () => {
|
||||
);
|
||||
};
|
||||
|
||||
onMounted(createFirstAdmin)
|
||||
onMounted(createFirstAdmin);
|
||||
|
||||
const fetchProjects = () => {
|
||||
getAdminProjects(
|
||||
|
Loading…
x
Reference in New Issue
Block a user