From bb13a434d8f4688258f8b0fe434b11fd2b05b8a0 Mon Sep 17 00:00:00 2001 From: princekumarofficial Date: Fri, 10 May 2024 16:13:37 +0530 Subject: [PATCH 01/26] 1. Faculty view done 2. FeedbackForm Added 3. API to fetch data 4. API to PATCH the feedback and update the status done --- src/app/(routes)/faculty/[facultyId]/page.tsx | 64 +++++++ src/app/(routes)/faculty/layout.tsx | 11 ++ src/components/Faculty/FeedbackFrom.tsx | 164 ++++++++++++++++++ .../TableComponent/ColumnMapping.tsx | 8 +- .../TableComponent/TableComponent.tsx | 33 ++-- src/helpers/api.ts | 74 ++++++-- 6 files changed, 323 insertions(+), 31 deletions(-) create mode 100644 src/app/(routes)/faculty/[facultyId]/page.tsx create mode 100644 src/app/(routes)/faculty/layout.tsx create mode 100644 src/components/Faculty/FeedbackFrom.tsx diff --git a/src/app/(routes)/faculty/[facultyId]/page.tsx b/src/app/(routes)/faculty/[facultyId]/page.tsx new file mode 100644 index 00000000..9a5e78eb --- /dev/null +++ b/src/app/(routes)/faculty/[facultyId]/page.tsx @@ -0,0 +1,64 @@ +"use client"; +import { fetchApprovals, updateApproval } from "@/helpers/api"; +import Cookies from "js-cookie"; +import TableComponent from "@/components/TableComponent/TableComponent"; +import generateColumns from "@/components/TableComponent/ColumnMapping"; +import { useState, useEffect } from "react"; + +const dto = [ + { + id: "string", + faculty: { + id: "string", + // user: { + // id: "string", + // email: "string", + // name: "string", + // contact: "string", + // }, + department: "string", + }, + salaryId: "string", + status: "string", + remarks: "string", + }, +]; + +const dynamicColumns = generateColumns(dto[0]); + +const FacultyPage = () => { + const [data, setData] = useState(null); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const fetchData = async () => { + try { + const jsonData = await fetchApprovals(undefined, undefined); + setData(jsonData); + } catch (error) { + console.error("Error fetching data:", error); + } finally { + setLoading(false); + } + }; + + fetchData(); + }, []); + return ( +
+

Approvals

+
+ {data && ( + + )} +
+
+ ); +}; + +export default FacultyPage; diff --git a/src/app/(routes)/faculty/layout.tsx b/src/app/(routes)/faculty/layout.tsx new file mode 100644 index 00000000..718257b2 --- /dev/null +++ b/src/app/(routes)/faculty/layout.tsx @@ -0,0 +1,11 @@ +import Link from "next/link"; + +interface Props { + children: React.ReactNode; +} + +const FacultyLayout = ({ children }: Props) => { + return
{children}
; +}; + +export default FacultyLayout; diff --git a/src/components/Faculty/FeedbackFrom.tsx b/src/components/Faculty/FeedbackFrom.tsx new file mode 100644 index 00000000..6f68cf6c --- /dev/null +++ b/src/components/Faculty/FeedbackFrom.tsx @@ -0,0 +1,164 @@ +import { + Dialog, + DialogOverlay, + DialogContent, + DialogTrigger, + DialogClose, + DialogHeader, + DialogTitle, + DialogDescription, +} from "../ui/dialog"; +import TextArea from "antd/es/input/TextArea"; +import { Button } from "@/components/ui/button"; +import { useState, useEffect } from "react"; +import { updateApproval } from "@/helpers/api"; + +interface ButtonProps { + children?: React.ReactNode; + rows?: any[]; + remarks?: string; +} + +const updateApprovalPATCH = (rows: any[], remarks: string, status: string) => { + var allAppArray = []; + for (var i = 0; i < rows.length; i++) { + allAppArray.push({ id: rows[i].id, remarks, status }); + } + updateApproval(allAppArray); +}; + +const AcceptButton: React.FC = ({ + rows = [], + children, + remarks = "", +}) => { + return ( + + ); +}; + +const RejectButton: React.FC = ({ + rows = [], + children, + remarks = "", +}) => { + return ( + + ); +}; + +interface Props { + checkedRows: any[]; // Define the prop type as an array of any type +} + +const FeedbackForm: React.FC = ({ checkedRows }) => { + const [isClient, setIsClient] = useState(false); + + useEffect(() => { + setIsClient(true); + }, []); + + const [feedbackText, setFeedbackText] = useState(""); + + return ( + <> +

Write Feedback

+