-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da35864
commit 40083e0
Showing
8 changed files
with
108 additions
and
107 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,34 @@ | ||
"use client"; | ||
import { fetchApprovals, updateApproval } from "@/helpers/api"; | ||
import { fetchApprovals, updateApproval } from "@/helpers/faculty/api"; | ||
import Cookies from "js-cookie"; | ||
import TableComponent from "@/components/TableComponent/TableComponent"; | ||
import generateColumns from "@/components/TableComponent/ColumnMapping"; | ||
import { useState, useEffect } from "react"; | ||
import loadingImg from "@/components/Faculty/[email protected] (1).svg"; | ||
import loadingImg from "@/components/Faculty/loadingSpinner.svg"; | ||
|
||
const dto = [ | ||
{ | ||
// id: "string", | ||
status: "string", | ||
remarks: "string", | ||
faculty: { | ||
// id: "string", | ||
department: "string", | ||
user: { | ||
// id: "string", | ||
email: "string", | ||
name: "string", | ||
contact: "string", | ||
}, | ||
}, | ||
salary: { | ||
// id: "string", | ||
salaryPeriod: "string", | ||
totalCTC: "number", | ||
job: { | ||
// id: "string", | ||
role: "string", | ||
joiningDate: "string", | ||
season: { | ||
// id: "string", | ||
year: "string", | ||
type: "string", | ||
}, | ||
company: { | ||
// id: "string", | ||
name: "string", | ||
}, | ||
}, | ||
|
@@ -52,7 +45,10 @@ const FacultyPage = () => { | |
useEffect(() => { | ||
const fetchData = async () => { | ||
try { | ||
const jsonData = await fetchApprovals(undefined, undefined); | ||
const jsonData = await fetchApprovals( | ||
Cookies.get("accessToken"), | ||
undefined | ||
); | ||
setData(jsonData); | ||
} catch (error) { | ||
console.error("Error fetching data:", error); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const redirect = () => {}; | ||
|
||
const baseUrl = process.env.NEXT_PUBLIC_BACKEND_URL; | ||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; | ||
|
||
const url = (NextUrl: string) => { | ||
return `${baseUrl}/api/v1${NextUrl}`; | ||
}; | ||
|
||
export const fetchApprovals = async ( | ||
accessToken: string | undefined, | ||
filter: string | undefined | ||
) => { | ||
if (!accessToken || accessToken === undefined) { | ||
redirect(); | ||
return; | ||
} | ||
const res = await fetch( | ||
filter ? url(`/faculty-approvals?${filter}`) : url("/faculty-approvals"), | ||
{ | ||
next: { tags: ["AllApprovals"] }, | ||
cache: "no-store", | ||
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
} | ||
); | ||
const json = await res.json(); | ||
return json; | ||
}; | ||
|
||
export async function updateApproval( | ||
accessToken: string | undefined, | ||
data: any[] | ||
) { | ||
if (!accessToken || accessToken === undefined) { | ||
redirect(); | ||
return; | ||
} | ||
fetch(url("/faculty-approvals"), { | ||
method: "PATCH", | ||
cache: "no-store", | ||
headers: { | ||
"Content-type": "application/json", | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
body: JSON.stringify(data), | ||
}).then((response) => { | ||
return response.ok; | ||
}); | ||
} |