Skip to content

Commit

Permalink
Merge pull request #17 from Pradeep-Kumar-Rebbavarapu/main
Browse files Browse the repository at this point in the history
Added Events , Add and Delete in the Job Page and Made the Get Request for All Students
  • Loading branch information
harshtalati2410 authored Jan 12, 2024
2 parents 4de0e1a + d81ffc5 commit 46ecab0
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 74 deletions.
15 changes: 0 additions & 15 deletions src/app/(routes)/admin/jobs/[jobId]/error.tsx

This file was deleted.

27 changes: 22 additions & 5 deletions src/app/(routes)/admin/jobs/[jobId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Separator } from "@/components/ui/separator";
import { Jobs } from "../../../../../dummyData/job";
import { fetchEachJob } from "@/helpers/api";
import { fetchEachJob, fetchJobEvents } from "@/helpers/api";
import { cookies } from "next/headers";
import { Button } from "@/components/ui/button";
import EventCard from "@/components/jobs/EventCard";
import { AddEventDialog } from "@/components/jobs/AddEventDialog";

interface Props {
params: {
Expand All @@ -15,6 +17,8 @@ const EachJobPage = async ({ params }: Props) => {
cookies()?.get("accessToken")?.value,
params.jobId,
);

const AllEvents = await fetchJobEvents(cookies()?.get("accessToken")?.value, params.jobId)
return (
<div className="m-10 bg-white p-5 border-2 rounded-xl">
<div className=" font-semibold text-xl">
Expand Down Expand Up @@ -66,15 +70,28 @@ const EachJobPage = async ({ params }: Props) => {
<li> have relevant skills and interests</li>
</ul>
</div>
<div>
<h1 className="text-lg font-semibold my-2">Our Events</h1>
<div className="mx-10 grid lg:grid-cols-3 grid-cols-1 gap-2">
{AllEvents?.event?.map((ele: any, index: number) => {
return (
<div key={index} className="flex justify-center items-center my-2">
<EventCard ele={ele} jobId={params.jobId} />
</div>
)
})}
</div>
</div>
<div className="my-5 flex justify-between mx-5 items-center">
<Button >Apply Now</Button>
<div className="flex justify-center items-center">
<Button className="mx-2 my-2">Update</Button>
<Button variant={"destructive"} className="mx-2 my-2">Delete</Button>
</div>
<AddEventDialog jobId={params.jobId} />
<Button className="mx-2 my-2">Update Job</Button>
<Button variant={"destructive"} className="mx-2 my-2">Delete Job</Button>
</div>

</div>


</div>
);
Expand Down
15 changes: 0 additions & 15 deletions src/app/(routes)/admin/jobs/error.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions src/app/(routes)/admin/students/error.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/(routes)/admin/students/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const StudentPage = async () => {
<div>
<h1 className="text-center font-bold text-3xl my-5">Students</h1>
<div>
<StudentTable data={AllStudents} />
<StudentTable data={AllStudents?.students} />
</div>
</div>
);
Expand Down
28 changes: 9 additions & 19 deletions src/components/Students/StudentsTable/StudentTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interface Student {
totalPenalty: number;
createdAt: string;
updatedAt: string;
member: {
user: {
id: string;
email: string;
name: string;
Expand Down Expand Up @@ -114,44 +114,34 @@ export const columns: ColumnDef<Student>[] = [
enableHiding: false,
},
{
accessorKey: "name",
accessorKey: "user.name",
header: "Name",
cell: ({ row }) => <div className="lowercase">{row.getValue("name")}</div>,
cell: ({ row }) => <div className="lowercase">{row.original.user.name}</div>,
},
{
accessorKey: "rollNo",
header: "Roll Number",
cell: ({ row }) => <div>{row.getValue("rollNo")}</div>,
cell: ({ row }) => <div>{row.getValue('rollNo')}</div>,
},
{
accessorKey: "category",
header: "Category",
cell: ({ row }) => <div>{row.getValue("category")}</div>,
},
{
accessorKey: "member.email",
accessorKey: "user.email",
header: "Email",
cell: ({ row }) => <div>{row.original.member.email}</div>,
cell: ({ row }) => <div>{row.original.user.email}</div>,
},
{
accessorKey: "gender",
header: "Gender",
cell: ({ row }) => <div>{row.getValue("gender")}</div>,
},
{
accessorKey: "branch",
header: "Branch",
cell: ({ row }) => <div>{row.getValue("branch")}</div>,
},
{
accessorKey: "graduationYear",
header: "Graduation Year",
cell: ({ row }) => <div>{row.getValue("graduationYear")}</div>,
},
{
accessorKey: "currentCPI",
header: "Current CPI",
cell: ({ row }) => <div>{row.getValue("currentCPI")}</div>,
accessorKey: "contact",
header: "Contact",
cell: ({ row }) => <div>{row.original.user.contact}</div>,
},
{
id: "actions",
Expand Down
95 changes: 95 additions & 0 deletions src/components/jobs/AddEventDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
'use client'
import { Button } from "@/components/ui/button"
import Cookies from "js-cookie"
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import axios from "axios"
import { useState } from "react"
import submit from "../action"


interface Props{
jobId : String
}

export function AddEventDialog({jobId}:Props) {
const [type,settype] = useState<string | null>(null);
const [round,setround] = useState<string | null>(null);
const [date,setdate] = useState<string | null>(null);
const [loading,setloading] = useState<boolean>(false);
return (
<div className="mx-2">
<Dialog >
<DialogTrigger asChild>
<Button >Add Event</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
<DialogTitle className="text-black">Add An Event</DialogTitle>
</DialogHeader>
<div className="grid gap-4 py-4">
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="name" className="text-right text-black">
Event Type
</Label>
<Input
id="name"
onChange={(e)=>{
settype(e?.target?.value)
}}
className="col-span-3 text-black"
/>
</div>
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="username" className="text-right w-full text-black">
Round
</Label>
<Input
id="username"
className="col-span-3 text-black"
onChange={(e)=>{
setround(e?.target?.value)
}}
/>
</div>
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="username" className="text-right w-full text-black">
Start Date and Time
</Label>
<Input
id="username"
type="datetime-local"
onChange={(e)=>{
setdate(e?.target?.value)
}}
className="col-span-3 text-black"
/>
</div>
</div>
<DialogFooter>
<Button type="submit" disabled={loading} onClick={async ()=>{
setloading(true)
await axios.post(`http://tpc.iiti.ac.in/api/v1/jobs/${jobId}/events`,{type:type,roundNumber:round,startDateTime:date},{
headers:{
Authorization:`Bearer ${Cookies.get('accessToken')}`
}
}).then((response)=>{
submit('AllEvents');
setloading(false)
})
}}>{loading?"Submitting...":"Save changes"}</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</div>
)
}
94 changes: 94 additions & 0 deletions src/components/jobs/EventCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
'use client'
import { MdDelete } from "react-icons/md";
import { JobDeleteModal } from "./JobDeleteModal";
export default function EventCard({ ele ,jobId}: any) {
var date = ele.startDateTime;
date = date.substring(0, 10).split('-')
date = date[1] + '-' + date[2] + '-' + date[0]
return (
<div>
<div className="card">
<h3 className="card__title">{ele?.type}
</h3>
<p className="card__content">Round Number : {ele?.roundNumber} </p>

<div className="card__date">
{date}
</div>

<div className="card__arrow">
<JobDeleteModal jobId={jobId} eventId={ele.id} />
</div>

</div>
<style jsx>
{`
/* this card is inspired form this - https://georgefrancis.dev/ */
.card {
--border-radius: 0.75rem;
--primary-color: #7257fa;
--secondary-color: #3c3852;
width: 210px;
font-family: "Arial";
padding: 1rem;
cursor: pointer;
border-radius: var(--border-radius);
background: #f1f1f3;
box-shadow: 0px 8px 16px 0px rgb(0 0 0 / 3%);
position: relative;
}
.card > * + * {
margin-top: 1.1em;
}
.card .card__content {
color: var(--secondary-color);
font-size: 0.86rem;
}
.card .card__title {
padding: 0;
font-size: 1.3rem;
font-weight: bold;
}
.card .card__date {
color: #6e6b80;
font-size: 0.8rem;
}
.card .card__arrow {
position: absolute;
background: var(--primary-color);
padding: 0.4rem;
border-top-left-radius: var(--border-radius);
border-bottom-right-radius: var(--border-radius);
bottom: 0;
right: 0;
transition: 0.2s;
display: flex;
justify-content: center;
align-items: center;
}
.card svg {
transition: 0.2s;
}
/* hover */
.card:hover .card__arrow {
background: #111;
}
.card:hover .card__arrow svg {
transform: translateX(3px);
}
`}
</style>
</div>
)
}
Loading

1 comment on commit 46ecab0

@vercel
Copy link

@vercel vercel bot commented on 46ecab0 Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.