From 401d0e57e1cd770a4202b2f541d9b3028b9553ea Mon Sep 17 00:00:00 2001 From: Abhimanyu-dev Date: Mon, 17 Jun 2024 01:19:59 +0530 Subject: [PATCH 1/2] Stopped reload for admin pages --- components/Modals/AddCompanyAdmin.tsx | 10 +- components/Modals/AddCompanyAdminMD.tsx | 10 +- components/Modals/AddCompanyHR.tsx | 4 +- components/Modals/AddHRAdminMD.tsx | 4 +- pages/admin/company/index.tsx | 120 ++--- pages/admin/companyHR/index.tsx | 1 - pages/admin/rc/[rcid]/calendar/index.tsx | 138 +++--- pages/admin/rc/[rcid]/company/index.tsx | 133 +++--- .../admin/rc/[rcid]/event/[eventId]/index.tsx | 210 ++++----- pages/admin/rc/[rcid]/event/index.tsx | 153 +++---- .../rc/[rcid]/proforma/[proformaid]/index.tsx | 16 +- pages/admin/rc/[rcid]/proforma/index.tsx | 243 +++++----- .../rc/[rcid]/student/[studentid]/index.tsx | 3 +- pages/admin/rc/[rcid]/student/index.tsx | 183 ++++---- pages/admin/rc/index.tsx | 1 + pages/admin/student/index.tsx | 414 +++++++++--------- pages/admin/users/index.tsx | 1 - pages/company/hr.tsx | 8 +- sections/HRContactDetails.tsx | 11 +- 19 files changed, 872 insertions(+), 791 deletions(-) diff --git a/components/Modals/AddCompanyAdmin.tsx b/components/Modals/AddCompanyAdmin.tsx index 296e0c41..dd0bd963 100644 --- a/components/Modals/AddCompanyAdmin.tsx +++ b/components/Modals/AddCompanyAdmin.tsx @@ -25,7 +25,13 @@ const boxStyle = { alignItems: "center", }; -function AddCompany({ handleCloseNew }: { handleCloseNew: () => void }) { +function AddCompany({ + handleCloseNew, + updateCompany, +}: { + handleCloseNew: () => void; + updateCompany: () => Promise; +}) { const { register, handleSubmit, @@ -68,7 +74,7 @@ function AddCompany({ handleCloseNew }: { handleCloseNew: () => void }) { }); handleCloseNew(); } - window.location.reload(); + updateCompany(); }; return ( diff --git a/components/Modals/AddCompanyAdminMD.tsx b/components/Modals/AddCompanyAdminMD.tsx index 7287e543..ed978012 100644 --- a/components/Modals/AddCompanyAdminMD.tsx +++ b/components/Modals/AddCompanyAdminMD.tsx @@ -21,7 +21,13 @@ const boxStyle = { alignItems: "center", }; -function AddCompanyMD({ handleCloseNew }: { handleCloseNew: () => void }) { +function AddCompanyMD({ + handleCloseNew, + updateCompanies, +}: { + handleCloseNew: () => void; + updateCompanies: () => Promise; +}) { const { register, handleSubmit, @@ -39,8 +45,8 @@ function AddCompanyMD({ handleCloseNew }: { handleCloseNew: () => void }) { description: "", }); handleCloseNew(); - window.location.reload(); } + updateCompanies(); }; return ( diff --git a/components/Modals/AddCompanyHR.tsx b/components/Modals/AddCompanyHR.tsx index 7726db90..71bf9272 100644 --- a/components/Modals/AddCompanyHR.tsx +++ b/components/Modals/AddCompanyHR.tsx @@ -22,8 +22,10 @@ const boxStyle = { function AddHRMD({ handleCloseNew, + updateHR, }: { handleCloseNew: () => void; + updateHR: () => Promise; }): JSX.Element { const { register, @@ -54,7 +56,7 @@ function AddHRMD({ designation: "", }); handleCloseNew(); - window.location.reload(); + updateHR(); } }; diff --git a/components/Modals/AddHRAdminMD.tsx b/components/Modals/AddHRAdminMD.tsx index 5fb69bdb..a86084da 100644 --- a/components/Modals/AddHRAdminMD.tsx +++ b/components/Modals/AddHRAdminMD.tsx @@ -22,8 +22,10 @@ const boxStyle = { function AddHRMD({ handleCloseNew, + updateHR, }: { handleCloseNew: () => void; + updateHR: () => Promise; }): JSX.Element { const { register, @@ -54,7 +56,7 @@ function AddHRMD({ designation: "", }); handleCloseNew(); - window.location.reload(); + updateHR(); } }; diff --git a/pages/admin/company/index.tsx b/pages/admin/company/index.tsx index aa4d1b3d..636a9e3b 100644 --- a/pages/admin/company/index.tsx +++ b/pages/admin/company/index.tsx @@ -2,9 +2,12 @@ import React, { useCallback, useEffect, useRef, useState } from "react"; import { GridColDef } from "@mui/x-data-grid"; import Grid from "@mui/material/Grid"; import { IconButton, Modal, Stack, Tooltip } from "@mui/material"; +// eslint-disable-next-line import/order import AddIcon from "@mui/icons-material/Add"; // import { set } from "date-fns"; +import { useRouter } from "next/router"; + import DataGrid from "@components/DataGrid"; import ActiveButton from "@components/Buttons/ActiveButton"; import Meta from "@components/Meta"; @@ -14,63 +17,65 @@ import AddCompanyMD from "@components/Modals/AddCompanyAdminMD"; const batchSize = 100; -const columns: GridColDef[] = [ - { field: "ID", headerName: "ID" }, - { - field: "name", - headerName: "Company Name", - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "CreatedAt", - headerName: "Created At", - hide: true, - }, - { - field: "UpdatedAt", - headerName: "Updated At", - hide: true, - }, - { - field: "tags", - headerName: "Tags", - }, - { - field: "website", - headerName: "Website", - }, - { - field: "description", - headerName: "Description", - hide: true, - }, - { - field: "view_details", - headerName: "View Details", +function Index() { + const router = useRouter(); + const columns: GridColDef[] = [ + { field: "ID", headerName: "ID" }, + { + field: "name", + headerName: "Company Name", + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "CreatedAt", + headerName: "Created At", + hide: true, + }, + { + field: "UpdatedAt", + headerName: "Updated At", + hide: true, + }, + { + field: "tags", + headerName: "Tags", + }, + { + field: "website", + headerName: "Website", + }, + { + field: "description", + headerName: "Description", + hide: true, + }, + { + field: "view_details", + headerName: "View Details", - renderCell: (params) => ( - - ( + - CLICK HERE - - - ), - }, -]; - -function Index() { + { + router.push(`/admin/company/${params.row.ID}`); + }} + sx={{ height: 30 }} + > + CLICK HERE + + + ), + }, + ]; const { token } = useStore(); const [rows, setRows] = useState([]); const [loading, setLoading] = useState(true); @@ -148,7 +153,10 @@ function Index() { /> - + ); diff --git a/pages/admin/companyHR/index.tsx b/pages/admin/companyHR/index.tsx index 768adc70..0158e4e7 100644 --- a/pages/admin/companyHR/index.tsx +++ b/pages/admin/companyHR/index.tsx @@ -67,7 +67,6 @@ function Index() { const fetch = async () => { const companyHR = await CompanyHRRequest.getAll(token).catch(() => []); setRows(companyHR); - console.log(companyHR); setLoading(false); }; fetch(); diff --git a/pages/admin/rc/[rcid]/calendar/index.tsx b/pages/admin/rc/[rcid]/calendar/index.tsx index a5bbf1ae..b147bdb3 100644 --- a/pages/admin/rc/[rcid]/calendar/index.tsx +++ b/pages/admin/rc/[rcid]/calendar/index.tsx @@ -14,73 +14,6 @@ import useStore from "@store/store"; import calendarLinks from "@components/Utils/calendarUtils"; import { errorNotification } from "@callbacks/notifcation"; -const columns: GridColDef[] = [ - { - field: "ID", - headerName: "ID", - hide: true, - }, - { - field: "company_name", - headerName: "Company Name", - }, - { - field: "role", - headerName: "Role", - hide: true, - }, - { - field: "profile", - headerName: "Profile", - }, - { - field: "name", - headerName: "Event Name", - }, - { - field: "CreatedAt", - headerName: "Created At", - renderCell: (params) => - new Date(params.row.CreatedAt).toLocaleDateString("en-GB"), - hide: true, - }, - { - field: "UpdatedAt", - headerName: "Updated At", - renderCell: (params) => - new Date(params.row.UpdatedAt).toLocaleDateString("en-GB"), - hide: true, - }, - { - field: "duration", - headerName: "Event Duration", - hide: true, - }, - { - field: "start_time", - headerName: "Start Time", - renderCell: (params) => - new Date(params.row.start_time).toLocaleTimeString(), - }, - { - field: "sequence", - headerName: "Sequence", - hide: true, - }, - { - field: "View Details", - renderCell: (params) => ( - - ), - }, -]; - function Calendar() { const [value, setValue] = useState(new Date()); const [activity, setActivity] = useState([]); @@ -93,6 +26,77 @@ function Calendar() { const { token, rcName } = useStore(); + const columns: GridColDef[] = [ + { + field: "ID", + headerName: "ID", + hide: true, + }, + { + field: "company_name", + headerName: "Company Name", + }, + { + field: "role", + headerName: "Role", + hide: true, + }, + { + field: "profile", + headerName: "Profile", + }, + { + field: "name", + headerName: "Event Name", + }, + { + field: "CreatedAt", + headerName: "Created At", + renderCell: (params) => + new Date(params.row.CreatedAt).toLocaleDateString("en-GB"), + hide: true, + }, + { + field: "UpdatedAt", + headerName: "Updated At", + renderCell: (params) => + new Date(params.row.UpdatedAt).toLocaleDateString("en-GB"), + hide: true, + }, + { + field: "duration", + headerName: "Event Duration", + hide: true, + }, + { + field: "start_time", + headerName: "Start Time", + renderCell: (params) => + new Date(params.row.start_time).toLocaleTimeString(), + }, + { + field: "sequence", + headerName: "Sequence", + hide: true, + }, + { + field: "View Details", + renderCell: (params) => ( + + ), + }, + ]; + const handleClick = () => { if (calendarLinks.get(rid) !== undefined) { window.open(calendarLinks.get(rid) as string, "_blank"); diff --git a/pages/admin/rc/[rcid]/company/index.tsx b/pages/admin/rc/[rcid]/company/index.tsx index 32db9bac..dd691fd6 100644 --- a/pages/admin/rc/[rcid]/company/index.tsx +++ b/pages/admin/rc/[rcid]/company/index.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from "react"; +import React, { useCallback, useEffect, useState } from "react"; import { Button, Grid, IconButton, Modal, Stack, Tooltip } from "@mui/material"; import { GridColDef } from "@mui/x-data-grid"; import AddIcon from "@mui/icons-material/Add"; @@ -23,9 +23,12 @@ const gridMain = { justifyContent: "right", }; -function DeleteComapny(props: { id: string }) { +function DeleteComapny(props: { + id: string; + setRow: React.Dispatch>; +}) { const { token } = useStore(); - const { id } = props; + const { id, setRow } = props; const router = useRouter(); const { rcid } = router.query; const rid = (rcid || "").toString(); @@ -38,11 +41,15 @@ function DeleteComapny(props: { id: string }) { setDeleteModal(false); }; useEffect(() => { + const deleteCompany = async () => { + await requestCompany.deleteCompany(token, rid, id); + let response = await requestCompany.getall(token, rid); + setRow(response); + }; if (confirmation) { - requestCompany.deleteCompany(token, rid, id); - window.location.reload(); + deleteCompany(); } - }, [confirmation, id, rid, token]); + }, [confirmation, id, rid, token, router, setRow]); return ( <> - value && - `${new Date(value).toLocaleDateString("en-GB")} ${new Date( - value - ).toLocaleTimeString()}`, - width: 300, - align: "center", - headerAlign: "center", - hide: true, - }, - { - field: "viewdetails", - headerName: "View Details", - width: 400, - sortable: false, - align: "center", - headerAlign: "center", - renderCell: (params) => ( - - ), - }, - { - field: "options", - headerName: "", - width: 100, - align: "center", - hide: true, - renderCell: (cellValues) => ( - - ), - }, -]; - function Index() { const [showButton, setShowButton] = useState(false); const [openNew, setOpenNew] = useState(false); @@ -137,6 +91,62 @@ function Index() { const { token, rcName, role } = useStore(); const [rows, setRow] = useState([]); const [loading, setLoading] = useState(true); + const updateCompanies = useCallback(async () => { + const response = await requestCompany.getall(token, rid); + setRow(response); + }, [token, rid]); + const columns: GridColDef[] = [ + { + field: "ID", + headerName: "ID", + width: 90, + }, + { + field: "company_name", + headerName: "Company", + width: 300, + }, + { + field: "CreatedAt", + headerName: "Registered on", + valueGetter: ({ value }) => + value && + `${new Date(value).toLocaleDateString("en-GB")} ${new Date( + value + ).toLocaleTimeString()}`, + width: 300, + align: "center", + headerAlign: "center", + hide: true, + }, + { + field: "viewdetails", + headerName: "View Details", + width: 400, + sortable: false, + align: "center", + headerAlign: "center", + renderCell: (params) => ( + + ), + }, + { + field: "options", + headerName: "", + width: 100, + align: "center", + hide: true, + renderCell: (cellValues) => ( + + ), + }, + ]; useEffect(() => { const getCompanydata = async () => { @@ -189,7 +199,10 @@ function Index() { /> - + ); diff --git a/pages/admin/rc/[rcid]/event/[eventId]/index.tsx b/pages/admin/rc/[rcid]/event/[eventId]/index.tsx index 0823d13f..3306739f 100644 --- a/pages/admin/rc/[rcid]/event/[eventId]/index.tsx +++ b/pages/admin/rc/[rcid]/event/[eventId]/index.tsx @@ -50,7 +50,6 @@ function HandleEvent(props: { sid: string }) { if (confirmation) { if (rid === undefined || rid === "") return; eventRequest.delete(token, rid, eid, sid); - window.location.reload(); } }, [confirmation, eid, rid, sid, token]); return ( @@ -71,107 +70,6 @@ function HandleEvent(props: { sid: string }) { ); } -const cols: GridColDef[] = [ - { - field: "CreatedAt", - headerName: "Created At", - width: 150, - hide: true, - }, - { - field: "DeletedAt", - headerName: "Deleted At", - width: 150, - hide: true, - }, - { - field: "ID", - headerName: "Id", - width: 100, - }, - { - field: "UpdatedAt", - headerName: "Updated At", - width: 150, - hide: true, - }, - { - field: "comment", - headerName: "Comment", - width: 150, - hide: true, - }, - { - field: "name", - headerName: "Name", - width: 200, - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "email", - headerName: "Email", - width: 150, - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "program_department_id", - headerName: "Department", - width: 200, - valueGetter: (params) => getDeptProgram(params.value), - }, - { - field: "secondary_program_department_id", - headerName: "Secondary Department", - width: 200, - valueGetter: (params) => getDeptProgram(params.value), - }, - { - field: "is_frozen", - headerName: "Frozen", - width: 100, - hide: true, - }, - { - field: "is_verified", - headerName: "Verified", - width: 100, - hide: true, - }, - { - field: "student_id", - headerName: "Student Id", - width: 100, - hide: true, - }, - { - field: "type", - headerName: "Type", - width: 150, - }, - { - field: "recruitment_cycle_id", - headerName: "Recruitment Cycle Id", - width: 150, - hide: true, - }, - { - field: "button1", - headerName: "Delete", - renderCell: (params) => , - width: 100, - align: "left", - sortable: false, - filterable: false, - }, -]; function Event() { const [companyName, setCompanyName] = useState(""); @@ -227,9 +125,111 @@ function Event() { if (confirmation) { if (rid === undefined || rid === "") return; eventRequest.deleteAll(token, rid, eid); - window.location.reload(); + setStudents([]); } }, [confirmation, eid, rid, token]); + + const cols: GridColDef[] = [ + { + field: "CreatedAt", + headerName: "Created At", + width: 150, + hide: true, + }, + { + field: "DeletedAt", + headerName: "Deleted At", + width: 150, + hide: true, + }, + { + field: "ID", + headerName: "Id", + width: 100, + }, + { + field: "UpdatedAt", + headerName: "Updated At", + width: 150, + hide: true, + }, + { + field: "comment", + headerName: "Comment", + width: 150, + hide: true, + }, + { + field: "name", + headerName: "Name", + width: 200, + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "email", + headerName: "Email", + width: 150, + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "program_department_id", + headerName: "Department", + width: 200, + valueGetter: (params) => getDeptProgram(params.value), + }, + { + field: "secondary_program_department_id", + headerName: "Secondary Department", + width: 200, + valueGetter: (params) => getDeptProgram(params.value), + }, + { + field: "is_frozen", + headerName: "Frozen", + width: 100, + hide: true, + }, + { + field: "is_verified", + headerName: "Verified", + width: 100, + hide: true, + }, + { + field: "student_id", + headerName: "Student Id", + width: 100, + hide: true, + }, + { + field: "type", + headerName: "Type", + width: 150, + }, + { + field: "recruitment_cycle_id", + headerName: "Recruitment Cycle Id", + width: 150, + hide: true, + }, + { + field: "button1", + headerName: "Delete", + renderCell: (params) => , + width: 100, + align: "left", + sortable: false, + filterable: false, + }, + ]; return (
@@ -340,7 +340,9 @@ function Event() { diff --git a/pages/admin/rc/[rcid]/event/index.tsx b/pages/admin/rc/[rcid]/event/index.tsx index d4a9b2a7..36573630 100644 --- a/pages/admin/rc/[rcid]/event/index.tsx +++ b/pages/admin/rc/[rcid]/event/index.tsx @@ -8,80 +8,6 @@ import DataGrid from "@components/DataGrid"; import Meta from "@components/Meta"; import useStore from "@store/store"; -const columns: GridColDef[] = [ - { - field: "ID", - headerName: "ID", - hide: true, - }, - { - field: "company_name", - headerName: "Company Name", - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "role", - headerName: "Role", - hide: true, - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "profile", - headerName: "Profile", - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "name", - headerName: "Event Name", - }, - { - field: "CreatedAt", - headerName: "Created At", - renderCell: (params) => - new Date(params.row.CreatedAt).toLocaleDateString("en-GB"), - hide: true, - }, - { - field: "UpdatedAt", - headerName: "Updated At", - renderCell: (params) => - new Date(params.row.UpdatedAt).toLocaleDateString("en-GB"), - }, - { - field: "duration", - headerName: "Event Duration", - }, - { - field: "start_time", - headerName: "Start Time", - renderCell: (params) => - new Date(params.row.start_time).toLocaleTimeString(), - }, - { - field: "View Details", - renderCell: (params) => ( - - ), - }, -]; function Index() { const router = useRouter(); const { rcid } = router.query; @@ -104,6 +30,85 @@ function Index() { if (router.isReady) fetchData(); }, [rid, router.isReady, token]); + const columns: GridColDef[] = [ + { + field: "ID", + headerName: "ID", + hide: true, + }, + { + field: "company_name", + headerName: "Company Name", + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "role", + headerName: "Role", + hide: true, + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "profile", + headerName: "Profile", + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "name", + headerName: "Event Name", + }, + { + field: "CreatedAt", + headerName: "Created At", + renderCell: (params) => + new Date(params.row.CreatedAt).toLocaleDateString("en-GB"), + hide: true, + }, + { + field: "UpdatedAt", + headerName: "Updated At", + renderCell: (params) => + new Date(params.row.UpdatedAt).toLocaleDateString("en-GB"), + }, + { + field: "duration", + headerName: "Event Duration", + }, + { + field: "start_time", + headerName: "Start Time", + renderCell: (params) => + new Date(params.row.start_time).toLocaleTimeString(), + }, + { + field: "View Details", + renderCell: (params) => ( + + ), + }, + ]; + return (
diff --git a/pages/admin/rc/[rcid]/proforma/[proformaid]/index.tsx b/pages/admin/rc/[rcid]/proforma/[proformaid]/index.tsx index 01ebfde5..6ca2f267 100644 --- a/pages/admin/rc/[rcid]/proforma/[proformaid]/index.tsx +++ b/pages/admin/rc/[rcid]/proforma/[proformaid]/index.tsx @@ -439,14 +439,18 @@ function Index() { @@ -455,7 +459,9 @@ function Index() { @@ -488,7 +494,9 @@ function Index() { diff --git a/pages/admin/rc/[rcid]/proforma/index.tsx b/pages/admin/rc/[rcid]/proforma/index.tsx index 48b9878c..602c856f 100644 --- a/pages/admin/rc/[rcid]/proforma/index.tsx +++ b/pages/admin/rc/[rcid]/proforma/index.tsx @@ -10,125 +10,6 @@ import requestProforma, { } from "@callbacks/admin/rc/adminproforma"; import useStore from "@store/store"; -const columns: GridColDef[] = [ - { - field: "ID", - headerName: "ID", - hide: true, - }, - { - field: "company_name", - headerName: "Company Name", - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "CreatedAt", - headerName: "Created At", - hide: true, - }, - { - field: "UpdatedAt", - headerName: "Last Updated", - valueGetter: (rowData) => new Date(rowData.value).toLocaleString(), - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "company_id", - headerName: "Company ID", - hide: true, - }, - { - field: "company_recruitment_cycle_id", - headerName: "Company RC ID", - hide: true, - }, - { - field: "is_approved", - headerName: "Status", - valueGetter: (params) => - // eslint-disable-next-line no-nested-ternary - params.row.is_approved.Valid - ? params.row.is_approved?.Bool - ? "Approved" - : "Rejected" - : "Pending", - }, - { - field: "deadline", - headerName: "Application Deadline", - valueGetter(params) { - return `${ - params.row.deadline === 0 - ? "Date not Set" - : new Date(params.value).toLocaleString() - }`; - }, - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "hide_details", - headerName: "Deatils Hidden", - }, - { - field: "action_taken_by", - headerName: "Action taken By", - valueParser: (value) => value?.split("@")[0], - hide: true, - }, - { - field: "active_hr", - headerName: "Active HR", - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "role", - headerName: "Role Name", - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "profile", - headerName: "Profile", - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "Actions", - headerName: "Actions", - width: 200, - renderCell: (params) => ( - - ), - }, -]; function Index() { const router = useRouter(); const { rcid } = router.query; @@ -138,6 +19,130 @@ function Index() { const [proformas, setProformas] = useState([]); + const columns: GridColDef[] = [ + { + field: "ID", + headerName: "ID", + hide: true, + }, + { + field: "company_name", + headerName: "Company Name", + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "CreatedAt", + headerName: "Created At", + hide: true, + }, + { + field: "UpdatedAt", + headerName: "Last Updated", + valueGetter: (rowData) => new Date(rowData.value).toLocaleString(), + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "company_id", + headerName: "Company ID", + hide: true, + }, + { + field: "company_recruitment_cycle_id", + headerName: "Company RC ID", + hide: true, + }, + { + field: "is_approved", + headerName: "Status", + valueGetter: (params) => + // eslint-disable-next-line no-nested-ternary + params.row.is_approved.Valid + ? params.row.is_approved?.Bool + ? "Approved" + : "Rejected" + : "Pending", + }, + { + field: "deadline", + headerName: "Application Deadline", + valueGetter(params) { + return `${ + params.row.deadline === 0 + ? "Date not Set" + : new Date(params.value).toLocaleString() + }`; + }, + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "hide_details", + headerName: "Deatils Hidden", + }, + { + field: "action_taken_by", + headerName: "Action taken By", + valueParser: (value) => value?.split("@")[0], + hide: true, + }, + { + field: "active_hr", + headerName: "Active HR", + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "role", + headerName: "Role Name", + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "profile", + headerName: "Profile", + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "Actions", + headerName: "Actions", + width: 200, + renderCell: (params) => ( + + ), + }, + ]; + useEffect(() => { const fetchData = async () => { const response = await requestProforma.getAll(token, rid); diff --git a/pages/admin/rc/[rcid]/student/[studentid]/index.tsx b/pages/admin/rc/[rcid]/student/[studentid]/index.tsx index 054b8b84..d2f7e66c 100644 --- a/pages/admin/rc/[rcid]/student/[studentid]/index.tsx +++ b/pages/admin/rc/[rcid]/student/[studentid]/index.tsx @@ -183,6 +183,7 @@ function Index() { const [studentResume, setStudentResume] = useState( [] ); + const router = useRouter(); // const [resumeVerificationStatus, setResumeVerificationStatus] = useState(""); useEffect(() => { @@ -234,7 +235,7 @@ function Index() { { ...student, is_verified: true }, rcid.toString() ); - window.location.reload(); + router.push(`/admin/student/${sid}`); } }; diff --git a/pages/admin/rc/[rcid]/student/index.tsx b/pages/admin/rc/[rcid]/student/index.tsx index 365d171d..053d2c8e 100644 --- a/pages/admin/rc/[rcid]/student/index.tsx +++ b/pages/admin/rc/[rcid]/student/index.tsx @@ -60,95 +60,6 @@ function DeleteStudents(props: { id: string }) { ); } -const columns: GridColDef[] = [ - { - field: "id", - headerName: "ID", - width: 100, - }, - { - field: "name", - headerName: "Name", - width: 200, - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "email", - headerName: "Email", - width: 200, - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "roll_no", - headerName: "Roll No.", - width: 100, - }, - { - field: "cpi", - headerName: "CPI", - width: 100, - }, - { - field: "program_department_id", - headerName: "Department", - width: 100, - valueGetter: (params) => getDeptProgram(params.value), - }, - { - field: "secondary_program_department_id", - headerName: "Secondary Department", - width: 200, - valueGetter: (params) => getDeptProgram(params.value), - }, - { - field: "student_id", - headerName: "Student ID", - width: 100, - hide: true, - }, - { - field: "is_frozen", - headerName: "Frozen", - width: 100, - }, - { - field: "type", - headerName: "Type", - width: 100, - }, - { - field: "options", - headerName: "", - align: "center", - width: 100, - hide: true, - renderCell: (cellValues) => ( - - ), - }, - { - field: "Actions", - headerName: "Actions", - align: "center", - width: 100, - renderCell: (params) => ( - - ), - }, -]; function Index() { // eslint-disable-next-line @typescript-eslint/no-explicit-any const [rows, setRows] = useState([]); @@ -165,7 +76,99 @@ function Index() { const handleCloseEnroll = () => { setOpenEnroll(false); }; - + const columns: GridColDef[] = [ + { + field: "id", + headerName: "ID", + width: 100, + }, + { + field: "name", + headerName: "Name", + width: 200, + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "email", + headerName: "Email", + width: 200, + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "roll_no", + headerName: "Roll No.", + width: 100, + }, + { + field: "cpi", + headerName: "CPI", + width: 100, + }, + { + field: "program_department_id", + headerName: "Department", + width: 100, + valueGetter: (params) => getDeptProgram(params.value), + }, + { + field: "secondary_program_department_id", + headerName: "Secondary Department", + width: 200, + valueGetter: (params) => getDeptProgram(params.value), + }, + { + field: "student_id", + headerName: "Student ID", + width: 100, + hide: true, + }, + { + field: "is_frozen", + headerName: "Frozen", + width: 100, + }, + { + field: "type", + headerName: "Type", + width: 100, + }, + { + field: "options", + headerName: "", + align: "center", + width: 100, + hide: true, + renderCell: (cellValues) => ( + + ), + }, + { + field: "Actions", + headerName: "Actions", + align: "center", + width: 100, + renderCell: (params) => ( + + ), + }, + ]; // const [openDeregister, setOpenDeregister] = useState(false); // const handleOpenDeregister = () => { // setOpenDeregister(true); diff --git a/pages/admin/rc/index.tsx b/pages/admin/rc/index.tsx index f1a1386b..5cccc0b3 100644 --- a/pages/admin/rc/index.tsx +++ b/pages/admin/rc/index.tsx @@ -7,6 +7,7 @@ import AddIcon from "@mui/icons-material/Add"; import DataGrid from "@components/DataGrid"; import Meta from "@components/Meta"; import InactiveButton from "@components/Buttons/InactiveButton"; +// eslint-disable-next-line import/no-named-as-default import rcRequest, { RC } from "@callbacks/admin/rc/rc"; import ActiveButton from "@components/Buttons/ActiveButton"; import useStore from "@store/store"; diff --git a/pages/admin/student/index.tsx b/pages/admin/student/index.tsx index 27b56a47..1bd7094c 100644 --- a/pages/admin/student/index.tsx +++ b/pages/admin/student/index.tsx @@ -9,6 +9,7 @@ import { Tooltip, Typography, } from "@mui/material"; +import { useRouter } from "next/router"; import AdminStudentRequest, { Student, @@ -20,219 +21,224 @@ import { getDeptProgram } from "@components/Parser/parser"; const batchSize = 100; -const columns: GridColDef[] = [ - { - field: "ID", - headerName: "ID", - hide: true, - }, - { - field: "name", - headerName: "Name", - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "program_department_id", - headerName: "Program", - valueGetter: (rowData) => getDeptProgram(rowData.value), - }, - { - field: "CreatedAt", - headerName: "Created At", - hide: true, - }, - { - field: "UpdatedAt", - headerName: "Updated At", - hide: true, - }, - { - field: "secondary_program_department_id", - headerName: "Secondary Program", - valueGetter: (rowData) => getDeptProgram(rowData.value), - }, - { - field: "specialization", - headerName: "Specialisation", - hide: true, - }, - { - field: "roll_no", - headerName: "IITK Roll No.", - }, - { - field: "preference", - headerName: "Preference", - hide: true, - }, - { - field: "gender", - headerName: "Gender", - hide: true, - }, - { - field: "disability", - headerName: "Disability", - hide: true, - }, - { - field: "dob", - headerName: "DOB", - valueGetter: ({ value }) => - value && `${new Date(value).toLocaleDateString("en-GB")}`, - hide: true, - }, - { - field: "expected_graduation_year", - headerName: "Expected Graduation Year", - }, - { - field: "iitk_email", - headerName: "IITK Email", - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "personal_email", - headerName: "Personal Email", - hide: true, - renderCell: (params) => ( - -
{params.value}
-
- ), - }, - { - field: "phone", - headerName: "Contact Number", - hide: true, - }, - { - field: "alternate_phone", - headerName: "Alternate Contact Numer", - hide: true, - }, - { - field: "whatsapp_number", - headerName: "Whatsapp Number", - hide: true, - }, - { - field: "current_cpi", - headerName: "Current CPI", - }, - { - field: "ug_cpi", - headerName: "UG CPI(on for PG Students)", - hide: true, - }, - { - field: "tenth_board", - headerName: "10th Board", - hide: true, - }, - { - field: "tenth_year", - headerName: "10th Board Year", - hide: true, - }, - { - field: "tenth_marks", - headerName: "10th Marks", - hide: true, - }, - { - field: "twelfth_board", - headerName: "12th Board", - hide: true, - }, - { - field: "twelfth_year", - headerName: "12th Board Year", - hide: true, - }, - { - field: "twelfth_marks", - headerName: "12th Board Marks", - hide: true, - }, - { - field: "entrance_exam", - headerName: "Entrance Exam", - hide: true, - }, - { - field: "entrance_exam_rank", - headerName: "Entrance Exam Rank", - hide: true, - }, - { - field: "category", - headerName: "Category", - hide: true, - }, - { - field: "category_rank", - headerName: "Category Rank", - hide: true, - }, - { - field: "current_address", - headerName: "Current Address", - hide: true, - }, - { - field: "permanent_address", - headerName: "Permanent Address", - hide: true, - }, - { - field: "friend_name", - headerName: "Friends Name", - hide: true, - }, - { - field: "friend_phone", - headerName: "Friends Contact Details", - hide: true, - }, - { - field: "is_verified", - headerName: "Verified", - valueGetter: ({ value }) => (value ? "Verified" : "-"), - }, - { - field: "is_editable", - headerName: "Editable", - hide: true, - }, - { - field: "button", - headerName: "View Details", - renderCell: (params) => ( - - ), - }, -]; - function Index() { const [rows, setRows] = useState([]); const { token } = useStore(); const [loading, setLoading] = useState(true); + const router = useRouter(); const [batch, setBatch] = useState( (new Date().getFullYear() % 100) - 2 ); const startedFetching = useRef(false); + const columns: GridColDef[] = [ + { + field: "ID", + headerName: "ID", + hide: true, + }, + { + field: "name", + headerName: "Name", + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "program_department_id", + headerName: "Program", + valueGetter: (rowData) => getDeptProgram(rowData.value), + }, + { + field: "CreatedAt", + headerName: "Created At", + hide: true, + }, + { + field: "UpdatedAt", + headerName: "Updated At", + hide: true, + }, + { + field: "secondary_program_department_id", + headerName: "Secondary Program", + valueGetter: (rowData) => getDeptProgram(rowData.value), + }, + { + field: "specialization", + headerName: "Specialisation", + hide: true, + }, + { + field: "roll_no", + headerName: "IITK Roll No.", + }, + { + field: "preference", + headerName: "Preference", + hide: true, + }, + { + field: "gender", + headerName: "Gender", + hide: true, + }, + { + field: "disability", + headerName: "Disability", + hide: true, + }, + { + field: "dob", + headerName: "DOB", + valueGetter: ({ value }) => + value && `${new Date(value).toLocaleDateString("en-GB")}`, + hide: true, + }, + { + field: "expected_graduation_year", + headerName: "Expected Graduation Year", + }, + { + field: "iitk_email", + headerName: "IITK Email", + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "personal_email", + headerName: "Personal Email", + hide: true, + renderCell: (params) => ( + +
{params.value}
+
+ ), + }, + { + field: "phone", + headerName: "Contact Number", + hide: true, + }, + { + field: "alternate_phone", + headerName: "Alternate Contact Numer", + hide: true, + }, + { + field: "whatsapp_number", + headerName: "Whatsapp Number", + hide: true, + }, + { + field: "current_cpi", + headerName: "Current CPI", + }, + { + field: "ug_cpi", + headerName: "UG CPI(on for PG Students)", + hide: true, + }, + { + field: "tenth_board", + headerName: "10th Board", + hide: true, + }, + { + field: "tenth_year", + headerName: "10th Board Year", + hide: true, + }, + { + field: "tenth_marks", + headerName: "10th Marks", + hide: true, + }, + { + field: "twelfth_board", + headerName: "12th Board", + hide: true, + }, + { + field: "twelfth_year", + headerName: "12th Board Year", + hide: true, + }, + { + field: "twelfth_marks", + headerName: "12th Board Marks", + hide: true, + }, + { + field: "entrance_exam", + headerName: "Entrance Exam", + hide: true, + }, + { + field: "entrance_exam_rank", + headerName: "Entrance Exam Rank", + hide: true, + }, + { + field: "category", + headerName: "Category", + hide: true, + }, + { + field: "category_rank", + headerName: "Category Rank", + hide: true, + }, + { + field: "current_address", + headerName: "Current Address", + hide: true, + }, + { + field: "permanent_address", + headerName: "Permanent Address", + hide: true, + }, + { + field: "friend_name", + headerName: "Friends Name", + hide: true, + }, + { + field: "friend_phone", + headerName: "Friends Contact Details", + hide: true, + }, + { + field: "is_verified", + headerName: "Verified", + valueGetter: ({ value }) => (value ? "Verified" : "-"), + }, + { + field: "is_editable", + headerName: "Editable", + hide: true, + }, + { + field: "button", + headerName: "View Details", + renderCell: (params) => ( + + ), + }, + ]; + const getStudentDataInBatch = useCallback( async (pageSize: number, lastFetchedId: number, year: number) => { const students = await AdminStudentRequest.getLimited( diff --git a/pages/admin/users/index.tsx b/pages/admin/users/index.tsx index e1e53593..8a2570fc 100644 --- a/pages/admin/users/index.tsx +++ b/pages/admin/users/index.tsx @@ -167,7 +167,6 @@ function Users() { const res: returnUsersDetailsType = await userDetailsRequest.getAll( token ); - console.log(res.users); setUserData(res.users); setIsLoading(false); }; diff --git a/pages/company/hr.tsx b/pages/company/hr.tsx index 071dc8cf..e2f051e7 100644 --- a/pages/company/hr.tsx +++ b/pages/company/hr.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from "react"; +import React, { useCallback, useEffect, useState } from "react"; import { Grid, IconButton, Modal, Stack, Tooltip } from "@mui/material"; import { GridColDef } from "@mui/x-data-grid"; import AddIcon from "@mui/icons-material/Add"; @@ -23,6 +23,10 @@ function Overview(): JSX.Element { const [open, setOpen] = useState(false); const handleOpen = () => setOpen(true); const handleClose = () => setOpen(false); + const updateHR = useCallback(async () => { + const response = await companyHRRequest.get(token); + if (response?.length > 0) setRows(response); + }, [token]); useEffect(() => { const getRC = async () => { @@ -106,7 +110,7 @@ function Overview(): JSX.Element { getRowId={(row) => row.ID} /> - +
diff --git a/sections/HRContactDetails.tsx b/sections/HRContactDetails.tsx index 38c2b6be..20af538f 100644 --- a/sections/HRContactDetails.tsx +++ b/sections/HRContactDetails.tsx @@ -10,7 +10,7 @@ import { } from "@mui/material"; import { GridColDef } from "@mui/x-data-grid"; import { useRouter } from "next/router"; -import React, { useEffect, useState } from "react"; +import React, { useCallback, useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import DataGrid from "@components/DataGrid"; @@ -195,6 +195,13 @@ function HRContactDetails() { fetchHRDetails(); } }, [companyId, router.isReady, token]); + + const updateCompanyHR = useCallback(async () => { + let response = await addCompanyRequest.getAllHR(token, companyId); + setHRRows(response); + setLoading(false); + }, [token, companyId]); + return (
@@ -219,7 +226,7 @@ function HRContactDetails() { /> - +
); From b4480a1fbb61b09cce3f6551be422ee21d4f0bfe Mon Sep 17 00:00:00 2001 From: Abhimanyu-dev Date: Sun, 23 Jun 2024 23:29:49 +0530 Subject: [PATCH 2/2] Added input for files --- pages/student/profile/index.tsx | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/pages/student/profile/index.tsx b/pages/student/profile/index.tsx index d307fe3d..a188e7ab 100644 --- a/pages/student/profile/index.tsx +++ b/pages/student/profile/index.tsx @@ -350,6 +350,73 @@ function Profile() { + + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
);