Skip to content

Commit

Permalink
added CompanyHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
yashlm committed Jan 21, 2024
1 parent ddc6bf9 commit 3d00881
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 5 deletions.
24 changes: 23 additions & 1 deletion callbacks/admin/company/company.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import axios, { AxiosResponse } from "axios";

import {
ADMIN_COMPANY_URL,
ADMIN_RC_URL,
ErrorType,
SERVER_ERROR,
StatusResponse,
Expand All @@ -26,12 +27,23 @@ export interface HR {
phone: string;
designation: string;
}
export interface CompanyHistory {
id: number;
recruitmentDrive: string;
comments: string;
}
const adminCompanyInstance = axios.create({
baseURL: ADMIN_COMPANY_URL,
timeout: 15000,
timeoutErrorMessage: SERVER_ERROR,
});

const adminRcInstance = axios.create({
baseURL: ADMIN_RC_URL,
timeout: 15000,
timeoutErrorMessage: SERVER_ERROR,
});

const addCompanyRequest = {
post: (body: Company, token: string) =>
adminCompanyInstance
Expand Down Expand Up @@ -158,9 +170,19 @@ const addCompanyRequest = {
return false;
});
},
getCompanyHistory: (token: string, companyId: string) =>
adminRcInstance
.get<CompanyHistory[]>(`/${companyId}/history`, setConfig(token))
.then(responseBody)
.catch((err: ErrorType) => {
errorNotification(
"Error in fetching Company History",
err.response?.data?.error || err.message
);
return [] as CompanyHistory[];
}),
};

export default addCompanyRequest;

// get compnay, edit company, bulk add company
// delete
33 changes: 29 additions & 4 deletions sections/CompanyHistory.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { FormControl, IconButton, Stack, TextField } from "@mui/material";
import { GridColDef } from "@mui/x-data-grid";
import React from "react";
import { useRouter } from "next/router";
import React, { useEffect, useState } from "react";
import MoreVertIcon from "@mui/icons-material/MoreVert";

import DataGrid from "@components/DataGrid";
import addCompanyRequest, {
CompanyHistory,
} from "@callbacks/admin/company/company";
import useStore from "@store/store";

const CompanyHistoryColumns: GridColDef[] = [
{
Expand All @@ -20,7 +25,7 @@ const CompanyHistoryColumns: GridColDef[] = [
field: "Comments",
headerName: "Comments",
flex: 1,
renderCell: () => (
renderCell: (params) => (
<Stack
direction="row"
alignItems="center"
Expand All @@ -32,7 +37,9 @@ const CompanyHistoryColumns: GridColDef[] = [
label="Comment"
id="comment"
variant="standard"
value={params.row.Comments}
sx={{ minWidth: "20vw" }}
disabled
/>
</FormControl>
<IconButton>
Expand All @@ -43,9 +50,27 @@ const CompanyHistoryColumns: GridColDef[] = [
},
];

const companyHistoryRows: never[] = [];

function CompanyHistory() {
const [companyHistoryRows, setCompanyHistoryRows] = useState<
CompanyHistory[]
>([]);
const { token } = useStore();
const router = useRouter();

useEffect(() => {
const fetchCompanyHistory = async () => {
const companyId = router.query.companyId?.toString() || "";

const historyData = await addCompanyRequest.getCompanyHistory(
token,
companyId
);
setCompanyHistoryRows(historyData);
};

fetchCompanyHistory();
}, [router.query.companyId, token]);

return (
<div>
<Stack>
Expand Down

0 comments on commit 3d00881

Please sign in to comment.