Skip to content

Commit

Permalink
Merge pull request #72 from Princekumarofficial/faculty-view-api-fix
Browse files Browse the repository at this point in the history
Faculty view api fix
  • Loading branch information
AryanGKulkarni authored Jun 18, 2024
2 parents be02902 + 87c3cc7 commit 8d4bc50
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
16 changes: 4 additions & 12 deletions src/app/(routes)/faculty/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,24 @@ import TableComponent from "@/components/TableComponent/TableComponent";
import generateColumns from "@/components/TableComponent/ColumnMapping";
import { useState, useEffect } from "react";
import loadingImg from "@/components/Faculty/loadingSpinner.svg";
import { number } from "yup";

const dto = [
{
status: "string",
remarks: "string",
faculty: {
department: "string",
user: {
email: "string",
name: "string",
contact: "string",
},
},
salary: {
salaryPeriod: "string",
totalCTC: "number",
job: {
role: "string",
joiningDate: "string",
company: {
name: "string",
},
season: {
year: "string",
type: "string",
},
company: {
name: "string",
},
},
},
},
Expand Down
16 changes: 9 additions & 7 deletions src/components/Faculty/FeedbackFrom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ interface ButtonProps {
}

const UpdateApprovalPATCH = (rows: any[], remarks: string, status: string) => {
var allAppArray: any[] = [];
for (var i = 0; i < rows.length; i++) {
allAppArray.push({ id: rows[i].id, remarks, status });
updateApproval(Cookies.get("accessToken"), {
id: rows[i].id,
remarks: remarks,
status: status,
});
}
updateApproval(Cookies.get("accessToken"), allAppArray);
window.location.reload();
};

Expand All @@ -41,7 +43,7 @@ const AcceptButton: React.FC<ButtonProps> = ({
return (
<Button
variant={"default"}
className="bg-sky-600 mx-4 hover:bg-blue-600"
className={`bg-sky-600 mx-4 hover:bg-blue-600 ${finalButton && "w-full"}`}
onClick={() => {
if (finalButton) {
UpdateApprovalPATCH(rows, remarks, "APPROVED");
Expand All @@ -63,7 +65,7 @@ const RejectButton: React.FC<ButtonProps> = ({
return (
<Button
variant={"destructive"}
className="bg-red-500 hover:bg-red-400"
className={`bg-red-500 hover:bg-red-400 ${finalButton && "w-full"}`}
onClick={() => {
if (finalButton) {
UpdateApprovalPATCH(rows, remarks, "REJECTED");
Expand Down Expand Up @@ -115,7 +117,7 @@ const FeedbackForm: React.FC<Props> = ({ checkedRows }) => {
<DialogContent className="text-black">
Are you sure to Accept the Request?
<DialogClose asChild>
<div>
<div className="flex justify-center">
{isClient ? (
<AcceptButton
rows={checkedRows}
Expand All @@ -131,7 +133,7 @@ const FeedbackForm: React.FC<Props> = ({ checkedRows }) => {
</Dialog>
<Dialog>
<DialogTrigger asChild>
<div>
<div className="flex justify-center">
{isClient ? (
<RejectButton finalButton={false} />
) : (
Expand Down
12 changes: 6 additions & 6 deletions src/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const DialogOverlay = React.forwardRef<
ref={ref}
className={cn(
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className,
className
)}
{...props}
/>
Expand All @@ -39,13 +39,13 @@ const DialogContent = React.forwardRef<
ref={ref}
className={cn(
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200 bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg dark:border-gray-800 dark:bg-gray-950",
className,
className
)}
{...props}
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100 data-[state=open]:text-gray-500 dark:ring-offset-gray-950 dark:focus:ring-gray-300 dark:data-[state=open]:bg-gray-800 dark:data-[state=open]:text-gray-400">
<X className="h-4 w-4 bg-black dark:bg-white" />
<X className="h-4 w-4 bg-black" color="white" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
Expand All @@ -60,7 +60,7 @@ const DialogHeader = ({
<div
className={cn(
"flex flex-col space-y-1.5 text-center sm:text-left",
className,
className
)}
{...props}
/>
Expand All @@ -74,7 +74,7 @@ const DialogFooter = ({
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className,
className
)}
{...props}
/>
Expand All @@ -89,7 +89,7 @@ const DialogTitle = React.forwardRef<
ref={ref}
className={cn(
"text-lg font-semibold leading-none tracking-tight",
className,
className
)}
{...props}
/>
Expand Down
12 changes: 9 additions & 3 deletions src/helpers/faculty/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export const fetchApprovals = async (
return;
}
const res = await fetch(
filter ? url(`/faculty-approvals?${filter}`) : url("/faculty-approvals"),
filter
? url(`/faculty-view/approvals?${filter}`)
: url("/faculty-view/approvals"),
{
next: { tags: ["AllApprovals"] },
cache: "no-store",
Expand All @@ -31,13 +33,17 @@ export const fetchApprovals = async (

export async function updateApproval(
accessToken: string | undefined,
data: any[]
data: {
id: string;
remarks: string;
status: string;
}
) {
if (!accessToken || accessToken === undefined) {
redirect();
return;
}
fetch(url("/faculty-approvals"), {
fetch(url("/faculty-view/approval-status"), {
method: "PATCH",
cache: "no-store",
headers: {
Expand Down

0 comments on commit 8d4bc50

Please sign in to comment.