Skip to content

Commit

Permalink
dialog added in resume
Browse files Browse the repository at this point in the history
  • Loading branch information
AryanGKulkarni committed Jun 16, 2024
1 parent 4cf125d commit 6e41a22
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 72 deletions.
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
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Suspense } from "react";
const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
title: "Create Next App",
title: "TPC Portal",
description: "Generated by create next app",
};

Expand Down
35 changes: 35 additions & 0 deletions src/components/SideBar/Roles/student.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,41 @@ const StudentDashboard = () => {
{/* <JobDropDown userRole={userRole} /> */}
</div>
</Link>
<Link href={`/student/jobs`}>
<div className="hover:bg-gray-900 rounded-md my-[1vh] py-[1vh] px-[1vw]">
<div className="no-wrap flex justify-start gap-[1vw]">
<div className="w-[2vw]">
<svg
width="20"
height="20"
viewBox="0 0 15 15"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M4.2 1H4.17741H4.1774C3.86936 0.999988 3.60368 0.999978 3.38609 1.02067C3.15576 1.04257 2.92825 1.09113 2.71625 1.22104C2.51442 1.34472 2.34473 1.51442 2.22104 1.71625C2.09113 1.92825 2.04257 2.15576 2.02067 2.38609C1.99998 2.60367 1.99999 2.86935 2 3.17738V3.1774V3.2V11.8V11.8226V11.8226C1.99999 12.1307 1.99998 12.3963 2.02067 12.6139C2.04257 12.8442 2.09113 13.0717 2.22104 13.2837C2.34473 13.4856 2.51442 13.6553 2.71625 13.779C2.92825 13.9089 3.15576 13.9574 3.38609 13.9793C3.60368 14 3.86937 14 4.17741 14H4.2H10.8H10.8226C11.1306 14 11.3963 14 11.6139 13.9793C11.8442 13.9574 12.0717 13.9089 12.2837 13.779C12.4856 13.6553 12.6553 13.4856 12.779 13.2837C12.9089 13.0717 12.9574 12.8442 12.9793 12.6139C13 12.3963 13 12.1306 13 11.8226V11.8V3.2V3.17741C13 2.86936 13 2.60368 12.9793 2.38609C12.9574 2.15576 12.9089 1.92825 12.779 1.71625C12.6553 1.51442 12.4856 1.34472 12.2837 1.22104C12.0717 1.09113 11.8442 1.04257 11.6139 1.02067C11.3963 0.999978 11.1306 0.999988 10.8226 1H10.8H4.2ZM3.23875 2.07368C3.26722 2.05623 3.32362 2.03112 3.48075 2.01618C3.64532 2.00053 3.86298 2 4.2 2H10.8C11.137 2 11.3547 2.00053 11.5193 2.01618C11.6764 2.03112 11.7328 2.05623 11.7613 2.07368C11.8285 2.11491 11.8851 2.17147 11.9263 2.23875C11.9438 2.26722 11.9689 2.32362 11.9838 2.48075C11.9995 2.64532 12 2.86298 12 3.2V11.8C12 12.137 11.9995 12.3547 11.9838 12.5193C11.9689 12.6764 11.9438 12.7328 11.9263 12.7613C11.8851 12.8285 11.8285 12.8851 11.7613 12.9263C11.7328 12.9438 11.6764 12.9689 11.5193 12.9838C11.3547 12.9995 11.137 13 10.8 13H4.2C3.86298 13 3.64532 12.9995 3.48075 12.9838C3.32362 12.9689 3.26722 12.9438 3.23875 12.9263C3.17147 12.8851 3.11491 12.8285 3.07368 12.7613C3.05624 12.7328 3.03112 12.6764 3.01618 12.5193C3.00053 12.3547 3 12.137 3 11.8V3.2C3 2.86298 3.00053 2.64532 3.01618 2.48075C3.03112 2.32362 3.05624 2.26722 3.07368 2.23875C3.11491 2.17147 3.17147 2.11491 3.23875 2.07368ZM5 10C4.72386 10 4.5 10.2239 4.5 10.5C4.5 10.7761 4.72386 11 5 11H8C8.27614 11 8.5 10.7761 8.5 10.5C8.5 10.2239 8.27614 10 8 10H5ZM4.5 7.5C4.5 7.22386 4.72386 7 5 7H10C10.2761 7 10.5 7.22386 10.5 7.5C10.5 7.77614 10.2761 8 10 8H5C4.72386 8 4.5 7.77614 4.5 7.5ZM5 4C4.72386 4 4.5 4.22386 4.5 4.5C4.5 4.77614 4.72386 5 5 5H10C10.2761 5 10.5 4.77614 10.5 4.5C10.5 4.22386 10.2761 4 10 4H5Z"
fill="currentColor"
fillRule="evenodd"
clipRule="evenodd"
></path>
</svg>
</div>
<motion.div
initial={{ opacity: 1 }}
animate={context.isOpen ? "open" : "closed"}
transition={{ duration: 0.1 }}
variants={{
closed: { opacity: 0 },
open: { opacity: 1 },
}}
className={`${context.isOpen?"visible":"hidden"} w-[13rem]`} >
Jobs
</motion.div>
</div>

{/* <JobDropDown userRole={userRole} /> */}
</div>
</Link>
<Link href={`/student/offCampus`}>
<div className="hover:bg-gray-900 rounded-md my-[1vh] py-[1vh] px-[1vw]">
<div className="flex justify-start gap-[1vw]">
Expand Down
2 changes: 1 addition & 1 deletion src/components/loginForms/loginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Cookies from "js-cookie";
import { jwtDecode } from "jwt-decode";
const LoginForm = () => {
const [email, setemail] = useState<String | null>(null);
const [role, setrole] = useState<String | null>(null);
const [role, setrole] = useState<String | null>("STUDENT");
const router = useRouter();
return (
<>
Expand Down
20 changes: 2 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4696,16 +4696,7 @@ string-convert@^0.2.0:
resolved "https://registry.yarnpkg.com/string-convert/-/string-convert-0.2.1.tgz#6982cc3049fbb4cd85f8b24568b9d9bf39eeff97"
integrity sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A==

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.1.0:
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -4769,14 +4760,7 @@ string.prototype.trimstart@^1.0.8:
define-properties "^1.2.1"
es-object-atoms "^1.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down

0 comments on commit 6e41a22

Please sign in to comment.