Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Student page changes #71

Merged
merged 8 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import Cookies from "js-cookie";

function transformEvents(events: CustomEvent[]): EventData[] {

// Get the current date

const currentDate = new Date();

// Sort events by startDateTime

const sortedEvents = events.sort((a, b) => new Date(a.startDateTime).getTime() - new Date(b.startDateTime).getTime());

// Transform the sorted events into the desired format

const result: EventData[] = sortedEvents.map(event => {
const eventDate = new Date(event.startDateTime);
let status: string;
Expand All @@ -36,18 +36,18 @@ function transformEvents(events: CustomEvent[]): EventData[] {
}

return {
date: eventDate.toLocaleDateString('en-GB'), // Convert date to DD/MM/YYYY format
date: eventDate.toLocaleDateString('en-GB'),
status,
title: event.type,
};
});

// Find the first event after the current date and mark it as 'selected'

const firstFutureEventIndex = result.findIndex(event => new Date(event.date.split('/').reverse().join('-')) >= currentDate);
if (firstFutureEventIndex !== -1) {
result[firstFutureEventIndex].status = "selected";
} else if (result.length > 0) {
// If all events have passed, mark the last event as 'selected'

result[result.length - 1].status = "selected";
}

Expand All @@ -56,10 +56,10 @@ function transformEvents(events: CustomEvent[]): EventData[] {

const transformEventsCalender = (jobData: Job): CalenderEvent[] => {
return jobData.events.map(event => ({
day: new Date(event.startDateTime).setHours(0, 0, 0, 0), // startDate at midnight
day: new Date(event.startDateTime).setHours(0, 0, 0, 0),
description: event.metadata,
id: event.id,
label: "red", // assuming a fixed label as the original data doesn't provide this
label: "red",
timeFrom: event.startDateTime,
timeTo: event.endDateTime,
title: jobData.companyDetailsFilled.name,
Expand All @@ -84,11 +84,6 @@ function formatNumber(num: number): string {
return num.toString();
}

const faculty = [
{ name: 'Emily Johnson', designation: 'Professor', email: '[email protected]', phoneNumber: '123-456-7890' },
{ name: 'Alex Smith', designation: 'Assistant Professor', email: '[email protected]', phoneNumber: '987-654-3210' },
];

const JobPage = ({ params }: { params: { jobId: string } }) => {

const [jobData, setJobData] = useState<Job | null>(null);
Expand Down Expand Up @@ -207,7 +202,7 @@ const JobPage = ({ params }: { params: { jobId: string } }) => {
<div className="flex justify-between">
<div>
<Button>
<a href={`/student/jobs/salary/${params.jobId}`} target="_blank" rel="noopener noreferrer">Salary</a>
<a href={`/student/job/salary/${params.jobId}`} target="_blank" rel="noopener noreferrer">Salary</a>
</Button>
</div>
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"use client";
import React, { useEffect, useState } from "react";
import SalaryCard from "@/components/jobs/SalaryCard";
import { GetJobById } from "@/helpers/student/api";
import Cookies from "js-cookie";
import { GetJobById, GetResumes } from "@/helpers/student/api";
import { Resume } from "@/helpers/student/types";


interface Props {}
interface Salary {
id: string;
salaryPeriod: string;
Expand All @@ -24,11 +25,15 @@ interface Salary {

const SalaryPage = ({ params }: { params: { jobId: string } }) => {
const [salaryData, setSalaryData] = useState<Salary[]>([]);
const [resumes, setResumes] = useState<Resume[]>([]);

useEffect(() => {
const fetchSalaryData = async () => {
const data = await GetJobById(params.jobId, Cookies.get("accessToken"));
setSalaryData(data.salaries);

const res = await GetResumes(Cookies.get("accessToken"));
setResumes(res);
};

fetchSalaryData();
Expand All @@ -43,7 +48,7 @@ const SalaryPage = ({ params }: { params: { jobId: string } }) => {
</div>
): (salaryData.map((item,index)=>(
<div key={index} className="my-3">
<SalaryCard salaryId={item.id}/>
<SalaryCard salaryId={item.id} resumes={resumes}/>
</div>
)))}
</div>
Expand Down
45 changes: 45 additions & 0 deletions src/app/(routes)/student/jobs/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"use client";
import React, { useEffect, useState } from "react";
import JobCard from "@/components/jobs/JobCard";
import Cookies from "js-cookie";
import { GetJobs, GetResumes } from "@/helpers/student/api";
import { Jobs, Resume } from "@/helpers/student/types";

const StudentPage = () => {

const [jobs, setJobs] = useState<Jobs[]>([]);
const [resumes, setResumes] = useState<Resume[]>([])

useEffect(() => {
const fetchJobs = async () => {
const data = await GetJobs(Cookies.get("accessToken"));
setJobs(data);

const res = await GetResumes(Cookies.get("accessToken"));
setResumes(res);

};

fetchJobs();
// setJobs(Jobs);
}, []);

return (
<div>
<div className="my-3 mx-5 font-bold text-xl">
<h1>Apply</h1>
</div>
{jobs.length===0? (
<div>
No Jobs
</div>
): (jobs.map((job)=>(
<div key={job.id} className="my-3">
<JobCard jobItem={job}/>
</div>
)))}
</div>
);
};

export default StudentPage;
2 changes: 1 addition & 1 deletion src/app/(routes)/student/offCampus/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const OffCampusPage = () => {
return (
<div>
<div className="my-3 mx-5 font-bold text-xl">
<h1>Apply</h1>
<h1>Off Campus Offers</h1>
</div>
{offCampusOffers.length===0? (
<div>
Expand Down
18 changes: 6 additions & 12 deletions src/app/(routes)/student/onCampus/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,34 @@ import { Button } from "@/components/ui/button";
import Cookies from "js-cookie";
import { GetOnCampusOffers, GetResumes } from "@/helpers/student/api";
import { OnCampusOffers, Resume } from "@/helpers/student/types";

interface Props {}
import OnCampusCard from "@/components/jobs/OnCampusCard";

const StudentPage = () => {

const [onCampusOffers, setOnCampusOffers] = useState<OnCampusOffers[]>([]);
const [resumes, setResumes] = useState<Resume[]>([])

useEffect(() => {
const fetchJobs = async () => {
const fetchOffers = async () => {
const oco = await GetOnCampusOffers(Cookies.get("accessToken"));
setOnCampusOffers(oco);

const res = await GetResumes(Cookies.get("accessToken"));
setResumes(res);

};

fetchJobs();
// setJobs(Jobs);
fetchOffers();
}, []);

return (
<div>
<div className="my-3 mx-5 font-bold text-xl">
<h1>Apply</h1>
<h1>On Campus Offers</h1>
</div>
{onCampusOffers.length===0? (
<div>
No Jobs
No Offers
</div>
): (onCampusOffers.map((job)=>(
<div key={job.id} className="my-3">
<JobCard jobItem={job} salaryId={job.salary.id} resumes={resumes}/>
<OnCampusCard jobItem={job} salaryId={job.salary.id}/>
</div>
)))}
</div>
Expand Down
72 changes: 37 additions & 35 deletions src/app/(routes)/student/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const ProfilePage = () => {
}
}

fetchStudentData();
if(studentData===null){
fetchStudentData();
}

})

Expand Down Expand Up @@ -104,36 +106,40 @@ const ProfilePage = () => {
</div>


<div className="my-4">
<Separator />
</div>

<h1 className="text-lg font-semibold my-2">Penalties</h1>
<Table className="overflow-hidden">
<TableHeader>
<TableRow>
<TableHead>Sr.</TableHead>
<TableHead>Reason</TableHead>
<TableHead>Penalty</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{studentData.penalties.map((item,index)=>(
<TableRow key={index}>
<TableCell>{index+1}</TableCell>
<TableCell>{item.reason}</TableCell>
<TableCell>{item.penalty}</TableCell>
</TableRow>
))}
</TableBody>
<TableFooter>
<TableRow>
<TableCell></TableCell>
<TableCell></TableCell>
<TableCell>{totalPenalty}</TableCell>
</TableRow>
</TableFooter>
</Table>
{totalPenalty>0 && (
<>
<div className="my-4">
<Separator />
</div>

<h1 className="text-lg font-semibold my-2">Penalties</h1>
<Table className="overflow-hidden">
<TableHeader>
<TableRow>
<TableHead>Sr.</TableHead>
<TableHead>Reason</TableHead>
<TableHead>Penalty</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{studentData.penalties.map((item,index)=>(
<TableRow key={index}>
<TableCell>{index+1}</TableCell>
<TableCell>{item.reason}</TableCell>
<TableCell>{item.penalty}</TableCell>
</TableRow>
))}
</TableBody>
<TableFooter>
<TableRow>
<TableCell></TableCell>
<TableCell></TableCell>
<TableCell>{totalPenalty}</TableCell>
</TableRow>
</TableFooter>
</Table>
</>
)}
<div className="my-4">
<Separator />
</div>
Expand Down Expand Up @@ -164,10 +170,6 @@ const ProfilePage = () => {
</TableBody>
</Table>

<div className="my-4">
<Separator />
</div>

</div>
</div>
</div>
Expand Down
58 changes: 41 additions & 17 deletions src/app/(routes)/student/resumes/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { uploadResume } from "@/helpers/student/api";
import toast, { Toaster } from "react-hot-toast";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";


const baseUrl = process.env.NEXT_PUBLIC_BACKEND_URL;
Expand All @@ -31,17 +32,13 @@ const url = (NextUrl: string) => {
const ResumePage = () => {

const [resumeData, setResumeData] = useState<Resume[]>([]);
const [showUploadForm, setShowUploadForm] = useState<boolean>(false);
const [dialogOpen, setDialogOpen] = useState<boolean>(false);

const fetchResumes = async () => {
const data = await GetResumes(Cookies.get("accessToken"));
setResumeData(data);
}

const handleUploadForm = () => {
setShowUploadForm(true);
}

const [file, setFile] = useState<File | null>(null);

const handleFileChange = (event: ChangeEvent<HTMLInputElement>) => {
Expand All @@ -67,6 +64,7 @@ const ResumePage = () => {
toast.success("Uploaded Successfully");
fetchResumes();
setFile(null);
setDialogOpen(false)
}
else{
toast.error("Error uploading file")
Expand Down Expand Up @@ -136,19 +134,45 @@ const ResumePage = () => {
<div className="my-4">
<Separator />
</div>
<Button onClick={handleUploadForm}>Add Resume</Button>
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
<DialogTrigger asChild>
<Button onClick={() => setDialogOpen(true)}>Add Resume</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Upload Resume</DialogTitle>
<DialogDescription>
Select and upload your resume file.
</DialogDescription>
</DialogHeader>
<form onSubmit={handleSubmit}>
<div className="grid w-full max-w-sm items-center gap-1.5 my-2">
<Label className="text-black" htmlFor="name">Name</Label>
<Input
id="name"
className="cursor-pointer text-black"
type="text"
required
/>
</div>
<div className="grid w-full max-w-sm items-center gap-1.5">
<Label className="text-black" htmlFor="resume">Resume</Label>
<Input
id="resume"
className="cursor-pointer text-black"
type="file"
onChange={handleFileChange}
/>
</div>
<DialogFooter>
<Button className="my-4" type="submit" >
Add
</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
</div>
{showUploadForm && (
<div className="rounded-xl bg-white text-black p-5 my-3">
<form onSubmit={handleSubmit}>
<div className="grid w-full max-w-sm items-center gap-1.5">
<Label htmlFor="resume">Resume</Label>
<Input id="resume" className="cursor-pointer" type="file" onChange={handleFileChange} />
</div>
<Button className="my-4" type="submit">Add</Button>
</form>
</div>
)}
</>
);
};
Expand Down
Loading
Loading