From 3957ec8fa0486d0e81a7ad5e47fb955bb2dbcc61 Mon Sep 17 00:00:00 2001 From: princekumarofficial Date: Tue, 25 Jun 2024 12:51:10 +0530 Subject: [PATCH] types.ts in api folder and edit profile --- .../recruiter/events/[jobId]/page.tsx | 2 +- src/app/(routes)/recruiter/events/page.tsx | 2 +- src/app/(routes)/recruiter/jaf/[jaf]/page.tsx | 21 -- .../(routes)/recruiter/jobs/[jobID]/page.tsx | 5 +- src/app/(routes)/recruiter/jobs/page.tsx | 2 +- .../(routes)/recruiter/prevjaf/[jaf]/page.tsx | 135 ---------- .../(routes)/recruiter/profile/edit/page.tsx | 44 ---- src/app/(routes)/recruiter/profile/page.tsx | 16 +- src/components/Recruiters/Events.tsx | 4 +- src/components/Recruiters/editProfile.tsx | 19 +- src/components/Recruiters/profile.tsx | 153 +++++------ src/helpers/recruiter/api.ts | 237 +----------------- src/helpers/recruiter/types.ts | 225 +++++++++++++++++ 13 files changed, 352 insertions(+), 513 deletions(-) delete mode 100644 src/app/(routes)/recruiter/jaf/[jaf]/page.tsx delete mode 100644 src/app/(routes)/recruiter/prevjaf/[jaf]/page.tsx delete mode 100644 src/app/(routes)/recruiter/profile/edit/page.tsx create mode 100644 src/helpers/recruiter/types.ts diff --git a/src/app/(routes)/recruiter/events/[jobId]/page.tsx b/src/app/(routes)/recruiter/events/[jobId]/page.tsx index 63b06e77..42488ddf 100644 --- a/src/app/(routes)/recruiter/events/[jobId]/page.tsx +++ b/src/app/(routes)/recruiter/events/[jobId]/page.tsx @@ -1,7 +1,7 @@ "use client"; import React from "react"; import { useState, useEffect } from "react"; -import { JobDetailFC } from "@/helpers/recruiter/api"; +import { JobDetailFC } from "@/helpers/recruiter/types"; import Cookies from "js-cookie"; import { getJobDetail } from "@/helpers/recruiter/api"; import loadingImg from "@/../public/loadingSpinner.svg"; diff --git a/src/app/(routes)/recruiter/events/page.tsx b/src/app/(routes)/recruiter/events/page.tsx index 0a644627..8e207a99 100644 --- a/src/app/(routes)/recruiter/events/page.tsx +++ b/src/app/(routes)/recruiter/events/page.tsx @@ -1,7 +1,7 @@ "use client"; import React from "react"; import { useState, useEffect } from "react"; -import { JobsFC } from "@/helpers/recruiter/api"; +import { JobsFC } from "@/helpers/recruiter/types"; import Cookies from "js-cookie"; import { getJobs } from "@/helpers/recruiter/api"; import toast from "react-hot-toast"; diff --git a/src/app/(routes)/recruiter/jaf/[jaf]/page.tsx b/src/app/(routes)/recruiter/jaf/[jaf]/page.tsx deleted file mode 100644 index d455afd2..00000000 --- a/src/app/(routes)/recruiter/jaf/[jaf]/page.tsx +++ /dev/null @@ -1,21 +0,0 @@ -"use client"; -import React from "react"; -import JAF from "@/components/JAF/JAF"; - -interface Props {} - -const JAFPage = ({ - params, -}: { - params: { - recruiterId: String; - }; -}) => { - return ( - <> - - - ); -}; - -export default JAFPage; diff --git a/src/app/(routes)/recruiter/jobs/[jobID]/page.tsx b/src/app/(routes)/recruiter/jobs/[jobID]/page.tsx index 468769b8..f10872a9 100644 --- a/src/app/(routes)/recruiter/jobs/[jobID]/page.tsx +++ b/src/app/(routes)/recruiter/jobs/[jobID]/page.tsx @@ -1,7 +1,6 @@ "use client"; import React, { useState, useEffect } from "react"; -import { JobDetailFC } from "@/helpers/recruiter/api"; -import { JobDetail } from "@/dummyData/Recruiters"; +import { JobDetailFC } from "@/helpers/recruiter/types"; import Cookies from "js-cookie"; import { getJobDetail } from "@/helpers/recruiter/api"; import loadingImg from "@/../public/loadingSpinner.svg"; @@ -11,7 +10,7 @@ import { Button } from "@/components/ui/button"; import Link from "next/link"; import { Separator } from "@/components/ui/separator"; import { getJafDetails } from "@/helpers/recruiter/api"; -import { JAFdetailsFC } from "@/helpers/recruiter/api"; +import { JAFdetailsFC } from "@/helpers/recruiter/types"; import { patchJobData } from "@/helpers/recruiter/api"; import { patchSalaryData } from "@/helpers/recruiter/api"; diff --git a/src/app/(routes)/recruiter/jobs/page.tsx b/src/app/(routes)/recruiter/jobs/page.tsx index 4cdbaae4..771a07da 100644 --- a/src/app/(routes)/recruiter/jobs/page.tsx +++ b/src/app/(routes)/recruiter/jobs/page.tsx @@ -1,7 +1,7 @@ "use client"; import React from "react"; import { getJobs } from "@/helpers/recruiter/api"; -import { JobsFC } from "@/helpers/recruiter/api"; +import { JobsFC } from "@/helpers/recruiter/types"; import { useState, useEffect } from "react"; import Cookies from "js-cookie"; import loadingImg from "@/../public/loadingSpinner.svg"; diff --git a/src/app/(routes)/recruiter/prevjaf/[jaf]/page.tsx b/src/app/(routes)/recruiter/prevjaf/[jaf]/page.tsx deleted file mode 100644 index f29901f7..00000000 --- a/src/app/(routes)/recruiter/prevjaf/[jaf]/page.tsx +++ /dev/null @@ -1,135 +0,0 @@ -"use client"; -import React from "react"; -import { Card } from "@/components/ui/card"; -import { - Table, - TableHeader, - TableBody, - TableFooter, - TableHead, - TableRow, - TableCell, -} from "@/components/ui/table"; -import { Separator } from "@/components/ui/separator"; -import { Button } from "@/components/ui/button"; -import {jafs} from "@/dummyData/jaf" -import JafCard from "@/components/JAF/JafCard"; - -interface Props {} - -interface Address { - line1: string; - line2: string; - city: string; - state: string; - zipCode: string; - country: string; -} - -interface CompanyDetailsFilled { - name: string; - website: string; - domains: string[]; - category: string; - address: Address; - size: number; - yearOfEstablishment: string; - annualTurnover: string; - socialMediaLink: string; -} - -interface Test { - type: string; - duration: number; -} - -interface Interview { - type: string; - duration: number; -} - -interface Requirements { - numberOfMembers: number; - numberOfRooms: number; - otherRequirements: string; -} - -interface SelectionProcedure { - selectionMode: string; - shortlistFromResume: boolean; - groupDiscussion: boolean; - tests: Test[]; - interviews: Interview[]; - requirements: Requirements; - others: string; -} - -interface RecruiterDetailsFilled { - name: string; - designation: string; - email: string; - contact: string; - landline: string; -} - -interface Job { - seasonId: string; - role: string; - others: string; - companyDetailsFilled: CompanyDetailsFilled; - recruiterDetailsFilled: RecruiterDetailsFilled; - selectionProcedure: SelectionProcedure; - description: string; - skills: string; - location: string; - noOfVacancies: number; - offerLetterReleaseDate: string; - joiningDate: string; - duration: number; -} - -interface Criteria { - programs: string[]; - genders: string[]; - categories: string[]; - minCPI: number; - tenthMarks: number; - twelthMarks: number; -} - -interface Salary { - salaryPeriod: string; - criteria: Criteria; - baseSalary: number; - totalCTC: number; - takeHomeSalary: number; - grossSalary: number; - otherCompensations: number; - others: string; -} - -interface JAF { - job: Job; - salaries: Salary[]; -} - - -const JAFPage = ({ - params, -}: { - params: { - recruiterId: String; - }; -}) => { - return ( - <> - {jafs.map((jaf,index) => ( -
- -
- ))} - - ); -}; - -export default JAFPage; diff --git a/src/app/(routes)/recruiter/profile/edit/page.tsx b/src/app/(routes)/recruiter/profile/edit/page.tsx deleted file mode 100644 index b8c87c42..00000000 --- a/src/app/(routes)/recruiter/profile/edit/page.tsx +++ /dev/null @@ -1,44 +0,0 @@ -"use client"; -import React, { useEffect, useState } from "react"; -import { EditForm, EditCompanyForm } from "@/components/Recruiters/editProfile"; -import { ProfileFC, fetchProfile } from "@/helpers/recruiter/api"; -import loadingImg from "@/../public/loadingSpinner.svg"; -import Cookies from "js-cookie"; - -const EditProfilePage = () => { - const [data, setData] = useState(); - const [loading, setLoading] = useState(true); - - useEffect(() => { - const profileData = async () => { - const jsonData = await fetchProfile(Cookies.get("accessToken")); - setData(jsonData); - setLoading(false); - }; - profileData(); - }, []); - return ( -
- {loading && ( -
- -
- )} - - {data && ( -
-
-

Company Details

- -
-
-

Profile Details

- -
-
- )} -
- ); -}; - -export default EditProfilePage; diff --git a/src/app/(routes)/recruiter/profile/page.tsx b/src/app/(routes)/recruiter/profile/page.tsx index fcd55788..745d54bd 100644 --- a/src/app/(routes)/recruiter/profile/page.tsx +++ b/src/app/(routes)/recruiter/profile/page.tsx @@ -5,11 +5,13 @@ import RecruiterProfile from "@/components/Recruiters/profile"; import { fetchProfile } from "@/helpers/recruiter/api"; import Cookies from "js-cookie"; import loadingImg from "@/../public/loadingSpinner.svg"; -import { ProfileFC } from "@/helpers/recruiter/api"; +import { ProfileFC } from "@/helpers/recruiter/types"; +import EditProfilePage from "@/components/Recruiters/editProfile"; -const Profile = ({ params }: { params: { RecruiterId: string } }) => { +const Profile = () => { const [data, setData] = useState(); const [loading, setLoading] = useState(true); + const [editMode, setEditMode] = useState(false); useEffect(() => { const profileData = async () => { @@ -23,7 +25,15 @@ const Profile = ({ params }: { params: { RecruiterId: string } }) => { return (
{loading && } - {data && } + {data && + (editMode ? ( + + ) : ( + setEditMode(!editMode)} + /> + ))}
); }; diff --git a/src/components/Recruiters/Events.tsx b/src/components/Recruiters/Events.tsx index 1e4e7a38..25893a3e 100644 --- a/src/components/Recruiters/Events.tsx +++ b/src/components/Recruiters/Events.tsx @@ -1,10 +1,10 @@ "use client"; import React from "react"; import { useState, useEffect } from "react"; -import { getEvent, JobDetailFC } from "@/helpers/recruiter/api"; +import { getEvent } from "@/helpers/recruiter/api"; import Cookies from "js-cookie"; import loadingImg from "@/../public/loadingSpinner.svg"; -import { EventFC, ApplicationFC } from "@/helpers/recruiter/api"; +import { EventFC, ApplicationFC, JobDetailFC } from "@/helpers/recruiter/types"; import { CircularProgress } from "@mui/material"; import { getResume } from "@/helpers/recruiter/api"; import VerifiedIcon from "@mui/icons-material/Verified"; diff --git a/src/components/Recruiters/editProfile.tsx b/src/components/Recruiters/editProfile.tsx index 0494be39..285c7eaf 100644 --- a/src/components/Recruiters/editProfile.tsx +++ b/src/components/Recruiters/editProfile.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from "react"; -import { ProfileFC, updateProfileFC } from "@/helpers/recruiter/api"; +import { ProfileFC, updateProfileFC } from "@/helpers/recruiter/types"; import { Button } from "../ui/button"; import { patchProfile } from "@/helpers/recruiter/api"; import Cookies from "js-cookie"; @@ -333,3 +333,20 @@ export const EditCompanyForm = (params: { profile: ProfileFC }) => { ); }; + +const EditProfilePage = ({ data }: { data: ProfileFC }) => { + return ( +
+
+

Company Details

+ +
+
+

Profile Details

+ +
+
+ ); +}; + +export default EditProfilePage; diff --git a/src/components/Recruiters/profile.tsx b/src/components/Recruiters/profile.tsx index a1f1533c..ab9e3c3c 100644 --- a/src/components/Recruiters/profile.tsx +++ b/src/components/Recruiters/profile.tsx @@ -1,87 +1,92 @@ import React, { useEffect, useState } from "react"; import profileImg from "@/../public/profile-icon.svg"; -import { ProfileFC, updateProfileFC } from "@/helpers/recruiter/api"; +import { ProfileFC, updateProfileFC } from "@/helpers/recruiter/types"; import { Button } from "../ui/button"; +import PersonIcon from "@mui/icons-material/Person"; -const RecruiterProfile = (params: { profile: ProfileFC }) => { +const RecruiterProfile = (params: { + profile: ProfileFC; + setEdit: () => void; +}) => { return ( -
+
- - - - + +
-
-
- Name: - {params.profile.user.name} +
+
+
+
+ Name: + {params.profile.user.name} +
+
+ Designation: + {params.profile.designation} +
+
+ Landline: + {params.profile.landline} +
+
+ Email: + {params.profile.user.email} +
+
+ Contact: + {params.profile.user.contact} +
+
-
- Designation: - {params.profile.designation} -
-
- Landline: - {params.profile.landline} -
-
- Email: - {params.profile.user.email} -
-
- Contact: - {params.profile.user.contact} -
-
- -

- Company Details -

-
-
- Name: - {params.profile.company.name} -
-
- Domains: - - {params.profile.company.domains.map( - (domain, index) => `${domain}, ` - )} - -
-
- Category: - {params.profile.company.category} -
-
- Address: -
    - {Object.entries(params.profile.company.address).map( - ([key, value]) => ( -
  • - {key} : {value} -
  • - ) - )} -
-
-
- Size: - {params.profile.company.size} -
-
- Year of Establishment: - {params.profile.company.yearOfEstablishment} -
-
- Social Media Link: - - {params.profile.company.socialMediaLink} - +
+

+ Company Details +

+
+ Name: + {params.profile.company.name} +
+
+ Domains: + + {params.profile.company.domains.map( + (domain, index) => `${domain}, ` + )} + +
+
+ Category: + {params.profile.company.category} +
+
+ Address: +
    + {Object.entries(params.profile.company.address).map( + ([key, value]) => ( +
  • + {key} : {value} +
  • + ) + )} +
+
+
+ Size: + {params.profile.company.size} +
+
+ Year of Establishment: + {params.profile.company.yearOfEstablishment} +
+
diff --git a/src/helpers/recruiter/api.ts b/src/helpers/recruiter/api.ts index b660c03c..50a28d03 100644 --- a/src/helpers/recruiter/api.ts +++ b/src/helpers/recruiter/api.ts @@ -1,5 +1,14 @@ -// pages/api/fetchPdf.js import axios from "axios"; +import { + JobDetailFC, + JobsFC, + JAFdetailsFC, + ProfileFC, + updateProfileFC, + EventFC, + ApplicationFC, + SalaryFC, +} from "./types"; const redirect = () => {}; @@ -10,34 +19,6 @@ const url = (NextUrl: string) => { return `${baseUrl}/api/v1${NextUrl}`; }; -export interface ProfileFC { - id: string; - designation: string; - landline: string; - user: { - id: string; - email: string; - name: string; - contact: string; - }; - company: { - name: string; - domains: [string]; - category: string; - address: { - city: string; - line1: string; - line2: string; - state: string; - country: string; - zipCode: string; - }; - size: number; - yearOfEstablishment: string; - socialMediaLink: string; - }; -} - export const fetchProfile = async (accessToken: string | undefined) => { if (!accessToken || accessToken === undefined) { redirect(); @@ -53,33 +34,6 @@ export const fetchProfile = async (accessToken: string | undefined) => { return json; }; -export interface updateProfileFC { - designation?: string; - landline?: string; - company?: { - name?: string; - website?: string; - domains?: any[]; - category?: string; - address?: { - line1: string; - line2: string; - city: string; - state: string; - country: string; - }; - size?: number; - yearOfEstablishment?: string; - annualTurnover?: string; - socialMediaLink?: string; - }; - user?: { - name: string; - email: string; - contact: string; - }; -} - export const patchProfile = async ( accessToken: string | undefined, changes: updateProfileFC @@ -99,22 +53,6 @@ export const patchProfile = async ( return res.ok; }; -export interface JobsFC { - id: string; - role: string; - active: boolean; - currentStatus: string; - season: { - id: string; - year: string; - type: string; - }; - company: { - id: string; - name: string; - }; -} - export const getJobs = async (accessToken: string | undefined) => { if (!accessToken || accessToken === undefined) { redirect(); @@ -130,100 +68,6 @@ export const getJobs = async (accessToken: string | undefined) => { return json; }; -export interface JobDetailFC { - id: string; - role: string; - active: boolean; - currentStatus: string; - season: { - id: string; - year: string; - type: string; - }; - company: { - id: string; - name: string; - }; - selectionProcedure: { - selectionMode: string; - shortlistFromResume: true; - groupDiscussion: true; - tests: [ - { - type: string; - duration: number; - }, - ]; - interviews: [ - { - type: string; - duration: number; - }, - ]; - requirements: { - numberOfMembers: number; - numberOfRooms: number; - otherRequirements: string; - }; - others: string; - }; - description: string; - attachment: string; - skills: string; - offerLetterReleaseDate: string; - joiningDate: string; - location: string; - noOfVacancies: number; - duration: number; - feedback: string; - jobCoordinators: [ - { - id: string; - role: string; - tpcMember: { - id: string; - department: string; - role: string; - user: { - id: string; - email: string; - name: string; - contact: string; - }; - }; - }, - ]; - events: [ - { - id: string; - roundNumber: number; - type: string; - metadata: string; - startDateTime: string; - endDateTime: string; - visibleToRecruiter: true; - }, - ]; - salaries: [SalaryFC]; -} - -interface SalaryFC { - id: string; - baseSalary: string; - takeHomeSalary: number; - grossSalary: number; - otherCompensations: number; - totalCTC: number; - salaryPeriod: string; - genders: [string]; - programs: [string]; - facultyApprovals: [string]; - categories: [string]; - minCPI: number; - tenthMarks: number; - twelthMarks: number; -} - export const getJobDetail = async ( accessToken: string | undefined, id: string @@ -242,42 +86,6 @@ export const getJobDetail = async ( return json; }; -export interface ApplicationFC { - id: string; - student: { - id: string; - rollNo: string; - user: { - id: string; - name: string; - email: string; - contact: string; - }; - program: { - id: string; - branch: string; - course: string; - year: string; - department: string; - }; - }; - resume: { - id: string; - filepath: string; - verified: boolean; - }; -} - -export interface EventFC { - id: string; - roundNumber: number; - type: string; - metadata: string; - startDateTime: string; - endDateTime: string; - applications?: [ApplicationFC]; -} - export async function getEvent(accessToken: string | undefined, id: string) { if (!accessToken || accessToken === undefined) { redirect(); @@ -308,31 +116,6 @@ export async function getDomains(accessToken: string | undefined) { return json.domains; } -export interface JAFdetailsFC { - seasons: [ - { - id: string; - type: string; - year: string; - }, - ]; - programs: [ - { - id: string; - branch: string; - course: string; - year: string; - department: string; - }, - ]; - genders: [string]; - categories: [string]; - testTypes: [string]; - domains: [string]; - interviewTypes: [string]; - countries: [string]; -} - export async function getJafDetails(accessToken: string | undefined) { // if (!accessToken || accessToken === undefined) { // redirect(); diff --git a/src/helpers/recruiter/types.ts b/src/helpers/recruiter/types.ts new file mode 100644 index 00000000..96123561 --- /dev/null +++ b/src/helpers/recruiter/types.ts @@ -0,0 +1,225 @@ +export interface ApplicationFC { + id: string; + student: { + id: string; + rollNo: string; + user: { + id: string; + name: string; + email: string; + contact: string; + }; + program: { + id: string; + branch: string; + course: string; + year: string; + department: string; + }; + }; + resume: { + id: string; + filepath: string; + verified: boolean; + }; +} + +export interface EventFC { + id: string; + roundNumber: number; + type: string; + metadata: string; + startDateTime: string; + endDateTime: string; + applications?: [ApplicationFC]; +} + +export interface JAFdetailsFC { + seasons: [ + { + id: string; + type: string; + year: string; + }, + ]; + programs: [ + { + id: string; + branch: string; + course: string; + year: string; + department: string; + }, + ]; + genders: [string]; + categories: [string]; + testTypes: [string]; + domains: [string]; + interviewTypes: [string]; + countries: [string]; +} + +export interface JobDetailFC { + id: string; + role: string; + active: boolean; + currentStatus: string; + season: { + id: string; + year: string; + type: string; + }; + company: { + id: string; + name: string; + }; + selectionProcedure: { + selectionMode: string; + shortlistFromResume: true; + groupDiscussion: true; + tests: [ + { + type: string; + duration: number; + }, + ]; + interviews: [ + { + type: string; + duration: number; + }, + ]; + requirements: { + numberOfMembers: number; + numberOfRooms: number; + otherRequirements: string; + }; + others: string; + }; + description: string; + attachment: string; + skills: string; + offerLetterReleaseDate: string; + joiningDate: string; + location: string; + noOfVacancies: number; + duration: number; + feedback: string; + jobCoordinators: [ + { + id: string; + role: string; + tpcMember: { + id: string; + department: string; + role: string; + user: { + id: string; + email: string; + name: string; + contact: string; + }; + }; + }, + ]; + events: [ + { + id: string; + roundNumber: number; + type: string; + metadata: string; + startDateTime: string; + endDateTime: string; + visibleToRecruiter: true; + }, + ]; + salaries: [SalaryFC]; +} + +export interface SalaryFC { + id: string; + baseSalary: string; + takeHomeSalary: number; + grossSalary: number; + otherCompensations: number; + totalCTC: number; + salaryPeriod: string; + genders: [string]; + programs: [string]; + facultyApprovals: [string]; + categories: [string]; + minCPI: number; + tenthMarks: number; + twelthMarks: number; +} + +export interface JobsFC { + id: string; + role: string; + active: boolean; + currentStatus: string; + season: { + id: string; + year: string; + type: string; + }; + company: { + id: string; + name: string; + }; +} + +export interface updateProfileFC { + designation?: string; + landline?: string; + company?: { + name?: string; + website?: string; + domains?: any[]; + category?: string; + address?: { + line1: string; + line2: string; + city: string; + state: string; + country: string; + }; + size?: number; + yearOfEstablishment?: string; + annualTurnover?: string; + socialMediaLink?: string; + }; + user?: { + name: string; + email: string; + contact: string; + }; +} + +export interface ProfileFC { + id: string; + designation: string; + landline: string; + user: { + id: string; + email: string; + name: string; + contact: string; + }; + company: { + name: string; + domains: [string]; + category: string; + address: { + city: string; + line1: string; + line2: string; + state: string; + country: string; + zipCode: string; + }; + size: number; + yearOfEstablishment: string; + socialMediaLink: string; + }; +}