From 56166a7545b02bacae6e6b51bd182b669cdd3851 Mon Sep 17 00:00:00 2001 From: Abhimanyu-dev Date: Sun, 1 Dec 2024 00:09:39 +0530 Subject: [PATCH 1/2] Added Wak In --- callbacks/admin/addquestion.ts | 1 + callbacks/admin/rc/proforma/question.ts | 1 + callbacks/constants.ts | 1 + callbacks/student/rc/applyQuestions.ts | 6 +- components/Modals/AddApplyQuestion.tsx | 13 ++ .../proforma/[proformaid]/question/index.tsx | 5 + .../opening/[openingid]/application.tsx | 208 ++++++++++++++++++ .../rc/[rcid]/opening/[openingid]/walkin.tsx | 206 +++++++++++++++++ pages/student/rc/[rcid]/opening/index.tsx | 152 ++++++++++++- .../[walkinid]}/apply.tsx | 0 10 files changed, 589 insertions(+), 4 deletions(-) create mode 100644 pages/student/rc/[rcid]/opening/[openingid]/application.tsx create mode 100644 pages/student/rc/[rcid]/opening/[openingid]/walkin.tsx rename pages/student/rc/[rcid]/{opening/[openingid] => walkin/[walkinid]}/apply.tsx (100%) diff --git a/callbacks/admin/addquestion.ts b/callbacks/admin/addquestion.ts index 9e1234f3..30cba859 100644 --- a/callbacks/admin/addquestion.ts +++ b/callbacks/admin/addquestion.ts @@ -13,6 +13,7 @@ export interface QuestionType { ID: number; CreatedAt: string; UpdatedAt: string; + event: string; type: string; question: string; recruitment_cycle_id: number; diff --git a/callbacks/admin/rc/proforma/question.ts b/callbacks/admin/rc/proforma/question.ts index cab68bc2..bf98e231 100644 --- a/callbacks/admin/rc/proforma/question.ts +++ b/callbacks/admin/rc/proforma/question.ts @@ -14,6 +14,7 @@ export interface QuestionProforma { qid: number; CreatedAt: string; UpdatedAt: string; + event: string; type: string; question: string; recruitment_cycle_id: number; diff --git a/callbacks/constants.ts b/callbacks/constants.ts index 1a2c611e..2e1a7a76 100644 --- a/callbacks/constants.ts +++ b/callbacks/constants.ts @@ -12,6 +12,7 @@ export const ADMIN_RC_URL = `${BASE_URL}/api/admin/rc`; export const ADMIN_STUDENT_URL = `${BASE_URL}/api/admin/student`; export const ADMIN_COMPANY_URL = `${BASE_URL}/api/admin/company`; export const ADMIN_APPLICATION_URL = `${BASE_URL}/api/admin/application`; +export const ADMIN_URL = `${BASE_URL}/api/admin`; export const CDN_URL = `${BASE_URL}/cdn`; diff --git a/callbacks/student/rc/applyQuestions.ts b/callbacks/student/rc/applyQuestions.ts index 2306fad5..c995fc91 100644 --- a/callbacks/student/rc/applyQuestions.ts +++ b/callbacks/student/rc/applyQuestions.ts @@ -11,6 +11,7 @@ import { errorNotification, successNotification } from "@callbacks/notifcation"; export interface studentApplicationQuestions { ID: number; proforma_id: number; + event: string; type: string; question: string; options: string; @@ -37,7 +38,10 @@ const responseBody = (response: AxiosResponse) => response.data; const applicationRequest = { getApplicationQuestion: (token: string, rcid: string, pid: string) => instance - .get(`/application/rc/${rcid}/opening/${pid}`, setConfig(token)) + .get( + `/application/rc/${rcid}/opening/${pid}`, + setConfig(token) + ) .then(responseBody) .catch((err: ErrorType) => { errorNotification("Error", err.response?.data?.error || err.message); diff --git a/components/Modals/AddApplyQuestion.tsx b/components/Modals/AddApplyQuestion.tsx index 88df55ac..83896fd2 100644 --- a/components/Modals/AddApplyQuestion.tsx +++ b/components/Modals/AddApplyQuestion.tsx @@ -64,6 +64,7 @@ function AddApplyQuestion({ ); if (response) { reset({ + event: "", question: "", mandatory: false, options: "", @@ -81,6 +82,18 @@ function AddApplyQuestion({

Additional Questions

+ + Application / Walk In Interview + + Type of Question { + let temp = [...selected]; + temp[params.row.ID] = e.target.value; + setSelected(temp); + }} + > + + None + + {resumes.map((resume) => { + if ( + resume.verified.Bool && + resume.verified.Valid && + resume.resume_type === "SINGLE" + ) { + return {resume.ID}; + } + return null; + })} + + + ), + }, + { + field: "action", + headerName: "Action", + width: 200, + sortable: false, + align: "center", + headerAlign: "center", + renderCell: (params) => ( + + + + ), + }, + ]; useEffect(() => { + const getEvents = async (res: ProformaParams[]) => { + let walkIns: (ProformaEvent & { company_name: string })[] = []; + await Promise.all( + res.map(async (proforma) => { + const ID = (proforma.ID || "").toString(); + const events = await sProformaRequest.getEvent(token, rid, ID); + events.forEach((event) => { + if (event.name === "Walk In") { + walkIns.push({ ...event, company_name: proforma.company_name }); + } + }); + }) + ); + setRow2(walkIns); + }; const getProforma = async () => { const res = await sProformaRequest.getAllOpenings(token, rid); setRows(res); setSelected(Array(res.length).fill("")); + getEvents(res); }; const getResume = async () => { const resume = await resumeRequest.get(token, rid); @@ -172,9 +306,21 @@ function Openings() { return (
- +

Job Openings

- row.ID} /> + row.ID} + /> +

Walk Ins

+ row.ID} + />
); diff --git a/pages/student/rc/[rcid]/opening/[openingid]/apply.tsx b/pages/student/rc/[rcid]/walkin/[walkinid]/apply.tsx similarity index 100% rename from pages/student/rc/[rcid]/opening/[openingid]/apply.tsx rename to pages/student/rc/[rcid]/walkin/[walkinid]/apply.tsx From 642b764cf6a11439b0f477fc1b4fc304052f5cad Mon Sep 17 00:00:00 2001 From: Abhimanyu-dev Date: Sun, 1 Dec 2024 00:33:49 +0530 Subject: [PATCH 2/2] Deployment Error Fix --- .../rc/[rcid]/opening/[openingid]/walkin.tsx | 2 +- .../rc/[rcid]/walkin/[walkinid]/apply.tsx | 206 ------------------ 2 files changed, 1 insertion(+), 207 deletions(-) delete mode 100644 pages/student/rc/[rcid]/walkin/[walkinid]/apply.tsx diff --git a/pages/student/rc/[rcid]/opening/[openingid]/walkin.tsx b/pages/student/rc/[rcid]/opening/[openingid]/walkin.tsx index 305ab32a..687752ff 100644 --- a/pages/student/rc/[rcid]/opening/[openingid]/walkin.tsx +++ b/pages/student/rc/[rcid]/opening/[openingid]/walkin.tsx @@ -165,7 +165,7 @@ function Apply() { -

Application Questions

+

Walk In Questions

{questions && questions.length > 0 && questions.map((question, index) => ( diff --git a/pages/student/rc/[rcid]/walkin/[walkinid]/apply.tsx b/pages/student/rc/[rcid]/walkin/[walkinid]/apply.tsx deleted file mode 100644 index ab79956e..00000000 --- a/pages/student/rc/[rcid]/walkin/[walkinid]/apply.tsx +++ /dev/null @@ -1,206 +0,0 @@ -import { useRouter } from "next/router"; -import React, { useEffect, useState } from "react"; -import { - Box, - Button, - FormControl, - FormControlLabel, - Radio, - RadioGroup, - Stack, - TextField, - Typography, -} from "@mui/material"; -import { useForm } from "react-hook-form"; - -import applicationRequest, { - answerApplication, - studentApplicationQuestions, -} from "@callbacks/student/rc/applyQuestions"; -import Meta from "@components/Meta"; -import useStore from "@store/store"; - -const boxStyle = { - width: { xs: "330px", md: "500px" }, - bgcolor: "background.paper", - border: "white solid 2px", - borderRadius: "10px", - boxShadow: 24, - p: 4, - marginTop: 5, - marginBottom: 10, - alignItems: "center", -}; -function Apply() { - const { - register, - handleSubmit, - formState: { errors }, - } = useForm(); - - const router = useRouter(); - const { rcid, openingid, rsid } = router.query; - - const { token } = useStore(); - const [questions, setQuestions] = useState(); - useEffect(() => { - if (!rcid || !openingid) return; - const fetch = async () => { - const response = await applicationRequest - .getApplicationQuestion(token, rcid.toString(), openingid.toString()) - .catch(() => ({ type: "null" } as studentApplicationQuestions)); - setQuestions(response); - }; - fetch(); - }, [rcid, token, router, openingid]); - - const onSubmit = async (data: any) => { - if (questions) { - let res: answerApplication[] = []; - questions.forEach((question) => { - let obj: answerApplication = { - application_question_id: question.ID, - answer: data[question.ID], - }; - res.push(obj); - }); - if (rcid && openingid && rsid) { - await applicationRequest.postApplicationAnswer( - token, - rcid.toString(), - openingid.toString(), - { resume_id: parseInt(rsid.toString(), 10), answers: res } - ); - } - } - router.push(`/student/rc/${rcid}/opening`); - }; - - const renderSwitch = ( - index: number, - question: studentApplicationQuestions - ) => { - if (question) { - let name = question.ID.toString(); - switch (question?.type) { - case "MCQ": - return ( - - - {question.options - .toString() - .split(",") - .map((option) => ( - } - label={option} - {...register(name)} - /> - ))} - - {errors[name] && ( - - *Required - - )} - - ); - case "Short Answer": - return ( - - ); - case "Boolean": - return ( - - - } - label="True" - {...register(name)} - /> - } - label="False" - {...register(name)} - /> - - {errors[name] && ( - - *Required - - )} - - ); - default: - return
; - } - } - return
; - }; - - return ( -
- - - - - -

Application Questions

- {questions && - questions.length > 0 && - questions.map((question, index) => ( - -

- Ques: {questions[index]?.question} -

- {questions && renderSwitch(index, question)} -
- ))} - {questions && questions.length === 0 && ( -

No Questions Found!

- )} -
- - - - -
-
-
-
- ); -} -Apply.layout = "studentPhaseDashboard"; -export default Apply;