From 113b8e31218a1c6b464bf86c260ae0fcaa940876 Mon Sep 17 00:00:00 2001
From: AryanGKulkarni <95529889+AryanGKulkarni@users.noreply.github.com>
Date: Sun, 29 Sep 2024 11:09:22 +0530
Subject: [PATCH] student-feedback done (#169)
---
src/app/(routes)/student/job/[jobId]/page.tsx | 368 ++++++++++--------
src/helpers/student/types.ts | 8 +
2 files changed, 216 insertions(+), 160 deletions(-)
diff --git a/src/app/(routes)/student/job/[jobId]/page.tsx b/src/app/(routes)/student/job/[jobId]/page.tsx
index 973d379..55cff54 100644
--- a/src/app/(routes)/student/job/[jobId]/page.tsx
+++ b/src/app/(routes)/student/job/[jobId]/page.tsx
@@ -92,6 +92,30 @@ function formatNumber(num: number): string {
return num.toString();
}
+function timeAgo(dateString: string): string {
+ const date: Date = new Date(dateString);
+ const now: Date = new Date();
+ const secondsAgo: number = Math.floor((now.getTime() - date.getTime()) / 1000);
+
+ const units: { name: string; seconds: number }[] = [
+ { name: 'year', seconds: 31536000 },
+ { name: 'month', seconds: 2592000 },
+ { name: 'day', seconds: 86400 },
+ { name: 'hour', seconds: 3600 },
+ { name: 'minute', seconds: 60 },
+ { name: 'second', seconds: 1 }
+ ];
+
+ for (let unit of units) {
+ const interval: number = Math.floor(secondsAgo / unit.seconds);
+ if (interval >= 1) {
+ return interval === 1 ? `a ${unit.name} ago` : `${interval} ${unit.name}s ago`;
+ }
+ }
+
+ return 'now';
+}
+
function getNextEvent(events: StudentEvent[]) {
const now = new Date();
@@ -177,184 +201,208 @@ const JobPage = ({ params }: { params: { jobId: string } }) => {
}, [params.jobId]);
return (
-
- {loading && (
-
-
-
- )}
- {jobData && (
- <>
- {!closestEvent? (
-
- {jobData?.company.name}
-
- ): (
-
+ <>
+
+ {loading && (
+
+
+
+ )}
+ {jobData && (
+ <>
+ {!closestEvent? (
{jobData?.company.name}
-
- {closestEvent}
+ ): (
+
+
+ {jobData?.company.name}
+
+
+ {closestEvent}
+
+ )}
+
+ {jobData?.company.address.city},{" "}
+ {jobData?.company.address.state},{" "}
+ {jobData?.company.address.country}
- )}
-
- {jobData?.company.address.city},{" "}
- {jobData?.company.address.state},{" "}
- {jobData?.company.address.country}
-
-
-
-
-
-
-
Website
{" "}
-
- Link
-
+
+
-
-
Domain
{" "}
+
- {jobData?.company.domains.length === 0
- ? "Not Available"
- : jobData?.company.domains[0]}
+
Website
{" "}
+
+ Link
+
+
+
+
Domain
{" "}
+
+ {jobData?.company.domains.length === 0
+ ? "Not Available"
+ : jobData?.company.domains[0]}
+
+
+
+
Category
{" "}
+
{jobData?.company.category}
+
+
+
+ Company Size
+
{" "}
+
{(jobData?.company.size)? formatNumber(jobData?.company.size): ""}
+
+
+
+ Established
+
{" "}
+
{jobData?.company.yearOfEstablishment}
-
-
Category
{" "}
-
{jobData?.company.category}
-
-
-
- Company Size
-
{" "}
-
{(jobData?.company.size)? formatNumber(jobData?.company.size): ""}
-
-
-
- Established
-
{" "}
-
{jobData?.company.yearOfEstablishment}
+
+
-
-
-
-
-
Recruiter
-
-
-
- Name
- Designation
- Email
- Mobile Number
-
-
-
-
- {jobData?.recruiterDetailsFilled.name}
-
- {jobData?.recruiterDetailsFilled.designation}
-
- {jobData?.recruiterDetailsFilled.email}
- {jobData?.recruiterDetailsFilled.contact}
-
-
-
-
-
-
-
-
Job Coordinators
-
-
-
- Name
- Role
- Department
- Email
- Mobile Number
-
-
-
- {jobData?.jobCoordinators.map((coordinator, index) => (
-
- {coordinator.tpcMember.student.user.name}
- {coordinator.role}
- {coordinator.tpcMember.student.program.department}
- {coordinator.tpcMember.student.user.email}
- {coordinator.tpcMember.student.user.contact}
+ Recruiter
+
+
+
+ Name
+ Designation
+ Email
+ Mobile Number
- ))}
-
-
-
-
-
- Events
-
-
-
- Round
- Type
- Start Date
- End Date
- Status
-
-
-
- {studentEvents.map((event, index) => (
-
- {event.roundNumber}
- {event.type}
- {convertDate(event.startDateTime)}
- {convertDate(event.endDateTime)}
-
- {event.studentStatus}
+
+
+
+ {jobData?.recruiterDetailsFilled.name}
+
+ {jobData?.recruiterDetailsFilled.designation}
+ {jobData?.recruiterDetailsFilled.email}
+ {jobData?.recruiterDetailsFilled.contact}
- ))}
-
-
-
-
-
-
-
-
-
-
+
+
+
+
Job Coordinators
+
+
+
+ Name
+ Role
+ Department
+ Email
+ Mobile Number
+
+
+
+ {jobData?.jobCoordinators.map((coordinator, index) => (
+
+ {coordinator.tpcMember.student.user.name}
+ {coordinator.role}
+ {coordinator.tpcMember.student.program.department}
+ {coordinator.tpcMember.student.user.email}
+ {coordinator.tpcMember.student.user.contact}
+
+ ))}
+
+
+
+
+
+
Events
+
+
+
+ Round
+ Type
+ Start Date
+ End Date
+ Status
+
+
+
+ {studentEvents.map((event, index) => (
+
+ {event.roundNumber}
+ {event.type}
+ {convertDate(event.startDateTime)}
+ {convertDate(event.endDateTime)}
+
+ {event.studentStatus}
+
+
+ ))}
+
+
+
+
+
+ {/*
+
+
+
*/}
+
+ >
+ )}
+
+
+ {jobData && (
+ <>
+
+
+ FEEDBACKS
+
+
+
+
+ {jobData.feedbacks.map((feedback, index) => (
+
+
{jobData.recruiter.user.name} ({timeAgo(feedback.createdAt)})
+
+ {feedback.remarks}
+
+
+ ))}
>
)}
-
+
+ >
);
};
diff --git a/src/helpers/student/types.ts b/src/helpers/student/types.ts
index d8cd27d..684a52b 100644
--- a/src/helpers/student/types.ts
+++ b/src/helpers/student/types.ts
@@ -268,6 +268,14 @@ export interface Job {
visibleToRecruiter: boolean;
}[];
+ feedbacks: {
+ id: string;
+ studentId: string;
+ jobId: string;
+ remarks: string;
+ createdAt: string;
+ }[];
+
salaries: {
id: string;
salaryPeriod: string;