Mega recruitment pipeline overhaul
This commit is contained in:
@@ -17,48 +17,95 @@ const decisionDate = ref<Date | null>(null);
|
||||
const submitDate = ref<Date | null>(null);
|
||||
const loading = ref<boolean>(true);
|
||||
const member_name = ref<string>();
|
||||
|
||||
const props = defineProps<{
|
||||
mode?: "create" | "view-self" | "view-recruiter"
|
||||
}>()
|
||||
|
||||
const finalMode = ref<"create" | "view-self" | "view-recruiter">("create");
|
||||
|
||||
async function loadByID(id: number | string) {
|
||||
const raw = await loadApplication(id);
|
||||
|
||||
const data = raw.application;
|
||||
|
||||
appID.value = data.id;
|
||||
appData.value = data.app_data;
|
||||
chatData.value = raw.comments;
|
||||
status.value = data.app_status;
|
||||
decisionDate.value = new Date(data.decision_at);
|
||||
submitDate.value = data.submitted_at ? new Date(data.submitted_at) : null;
|
||||
member_name.value = data.member_name;
|
||||
newApp.value = false;
|
||||
readOnly.value = true;
|
||||
}
|
||||
|
||||
const router = useRoute();
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
//get app ID from URL param
|
||||
const router = useRoute();
|
||||
const appIDRaw = router.params.id;
|
||||
if (appIDRaw === undefined) {
|
||||
//new app
|
||||
appData.value = null
|
||||
readOnly.value = false;
|
||||
newApp.value = true;
|
||||
} else {
|
||||
//load app
|
||||
const raw = await loadApplication(appIDRaw.toString());
|
||||
|
||||
const data = raw.application;
|
||||
|
||||
appID.value = data.id;
|
||||
appData.value = data.app_data;
|
||||
chatData.value = raw.comments;
|
||||
status.value = data.app_status;
|
||||
decisionDate.value = new Date(data.decision_at);
|
||||
submitDate.value = data.submitted_at ? new Date(data.submitted_at) : null;
|
||||
member_name.value = data.member_name;
|
||||
newApp.value = false;
|
||||
readOnly.value = true;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
//recruiter mode
|
||||
if (props.mode === 'view-recruiter') {
|
||||
finalMode.value = 'view-recruiter';
|
||||
await loadByID(Number(router.params.id));
|
||||
}
|
||||
|
||||
//viewer mode
|
||||
if (props.mode === 'view-self') {
|
||||
finalMode.value = 'view-self';
|
||||
await loadByID('me');
|
||||
}
|
||||
|
||||
//creator mode
|
||||
if (props.mode === 'create') {
|
||||
finalMode.value = 'create';
|
||||
appData.value = null
|
||||
readOnly.value = false;
|
||||
newApp.value = true;
|
||||
}
|
||||
|
||||
loading.value = false;
|
||||
|
||||
// try {
|
||||
// //get app ID from URL param
|
||||
// if (appIDRaw === undefined) {
|
||||
// //new app
|
||||
// appData.value = null
|
||||
// readOnly.value = false;
|
||||
// newApp.value = true;
|
||||
// } else {
|
||||
// //load app
|
||||
// const raw = await loadApplication(appIDRaw.toString());
|
||||
|
||||
// const data = raw.application;
|
||||
|
||||
// appID.value = data.id;
|
||||
// appData.value = data.app_data;
|
||||
// chatData.value = raw.comments;
|
||||
// status.value = data.app_status;
|
||||
// decisionDate.value = new Date(data.decision_at);
|
||||
// submitDate.value = data.submitted_at ? new Date(data.submitted_at) : null;
|
||||
// member_name.value = data.member_name;
|
||||
// newApp.value = false;
|
||||
// readOnly.value = true;
|
||||
// }
|
||||
// } catch (e) {
|
||||
// console.error(e);
|
||||
// }
|
||||
})
|
||||
|
||||
async function postComment(comment) {
|
||||
chatData.value.push(await postChatMessage(comment, appID.value));
|
||||
}
|
||||
|
||||
const emit = defineEmits(['submit']);
|
||||
|
||||
async function postApp(appData) {
|
||||
console.log("test")
|
||||
const res = await postApplication(appData);
|
||||
if (res.ok) {
|
||||
readOnly.value = true;
|
||||
newApp.value = false;
|
||||
emit('submit');
|
||||
}
|
||||
// TODO: Handle fail to post
|
||||
}
|
||||
@@ -74,7 +121,7 @@ async function handleDeny(id) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="!loading" class="max-w-3xl mx-auto my-20">
|
||||
<div v-if="!loading" class="max-w-3xl mx-auto">
|
||||
<div v-if="!newApp" class="flex flex-row justify-between items-center py-2 mb-8">
|
||||
<!-- Application header -->
|
||||
<div>
|
||||
@@ -102,7 +149,7 @@ async function handleDeny(id) {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit"
|
||||
}) }}</p>
|
||||
<div class="mt-2" v-else>
|
||||
<div class="mt-2" v-else-if="finalMode === 'view-recruiter'">
|
||||
<Button variant="success" class="mr-2" :onclick="() => { handleApprove(appID) }">
|
||||
<CheckIcon></CheckIcon>
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user