Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…pc-frontend into Api-fix
  • Loading branch information
JaiPannu-IITI committed Jul 14, 2024
2 parents 2e1d03b + 9373735 commit 3f537d3
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 64 deletions.
2 changes: 0 additions & 2 deletions src/app/(authroutes)/passwordless/[token]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import React, { useEffect, useState } from "react";
import { useRouter } from "next/navigation";
import Cookies from "js-cookie";
import { jwtDecode } from "jwt-decode";
import loadingImg from "@/components/Faculty/loadingSpinner.svg";
import Loader from "@/components/Loader/loader";
interface Props {}

const LoginPage = ({
params,
Expand Down
1 change: 0 additions & 1 deletion src/app/(routes)/admin/companies/allcompanies/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import CompanyCard from "@/components/company/CompanyCard";
import { cookies } from "next/headers";
import { fetchCompany } from "@/helpers/api";
import { ChevronRight } from "lucide-react";
import { ChevronLeft } from "lucide-react";
Expand Down
2 changes: 0 additions & 2 deletions src/app/(routes)/admin/jobs/[...filter]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"use client";
import { fetchAllJobs } from "@/helpers/api";
import Cookies from "js-cookie";
import TableComponent from "@/components/TableComponent/TableComponent";
import generateColumns from "@/components/TableComponent/ColumnMapping";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";


Expand Down
1 change: 0 additions & 1 deletion src/app/(routes)/admin/jobs/[jobId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
GenderSelectList,
} from "@/components/Recruiters/jobEdit";
import { fetchJobById } from "@/helpers/api";
import Cookies from "js-cookie";
import Loader from "@/components/Loader/loader";
import toast from "react-hot-toast";
import JobCoordinatorForm from "@/components/Admin/AddForms";
Expand Down
1 change: 0 additions & 1 deletion src/app/(routes)/admin/jobs/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import React, { Component } from "react";
import { CircularProgress } from "@mui/material";
import Loader from "@/components/Loader/loader"

class Loading extends Component {
Expand Down
8 changes: 1 addition & 7 deletions src/app/(routes)/admin/jobs/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
"use client";
import { fetchAllJobs } from "@/helpers/api";
import Cookies from "js-cookie";
import TableComponent from "@/components/TableComponent/TableComponent";
import generateColumns from "@/components/NewTableComponent/ColumnMapping";
import type { RecruitmentDTO } from "@/dto/JobDto";
import { recruitmentDTO } from "@/dto/JobDto";
import {
MaterialReactTable,
useMaterialReactTable,
type MRT_Row,
createMRTColumnHelper,
} from "material-react-table";
import Table from "@/components/NewTableComponent/Table";
Expand All @@ -24,7 +19,6 @@ const hiddenColumns = [
];

const JobPage = () => {
const columnHelper = createMRTColumnHelper<RecruitmentDTO>();
const columns = generateColumns(recruitmentDTO);
const [loading, setLoading] = useState(true);
const [allJobs, setAllJobs] = useState();
Expand All @@ -34,7 +28,7 @@ const JobPage = () => {

useEffect(() => {
const getData = async () => {
const data = await fetchAllJobs( undefined);
const data = await fetchAllJobs();
setAllJobs(data);
setLoading(false);
};
Expand Down
11 changes: 1 addition & 10 deletions src/app/(routes)/admin/recruiters/page.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
"use client";
import { fetchRecruiterData } from "@/helpers/api";
import Cookies from "js-cookie";
import Table from "@/components/NewTableComponent/Table";
import type {DTO} from '@/dto/StudentDto'
import {
MaterialReactTable,
useMaterialReactTable,
type MRT_Row,
createMRTColumnHelper,
} from 'material-react-table';
import generateColumns from "@/components/NewTableComponent/ColumnMapping";
import { recruiterdto } from "@/dto/RecruiterDto";
import type { RecruiterDTO } from "@/dto/RecruiterDto";

const hiddenColumns = ['id','user.id','company.id'];


const StudentPage = async () => {
const columns = generateColumns(recruiterdto)
console.log(columns)
const AllRecruiters = await fetchRecruiterData(null);
const AllRecruiters = await fetchRecruiterData();
const visibleColumns = columns.filter(
(column:any) => !hiddenColumns.includes(column?.accessorKey)
);
Expand Down
1 change: 0 additions & 1 deletion src/app/(routes)/admin/resumes/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";
import React, { useEffect, useState } from "react";
import { fetchResumes, getResumeFile, patchResumeVerify } from "@/helpers/api";
import Cookies from "js-cookie";
import generateColumns from "@/components/NewTableComponent/ColumnMapping";
import Table from "@/components/NewTableComponent/Table";
import { resumeDto, Resume, ResumeTableData } from "@/dto/ResumeDto";
Expand Down
1 change: 0 additions & 1 deletion src/app/(routes)/admin/students/[...filter]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client";
import { fetchStudentData } from "@/helpers/api";
import Cookies from "js-cookie";
import TableComponent from "@/components/TableComponent/TableComponent";
import generateColumns from "@/components/TableComponent/ColumnMapping";
import { useRouter } from "next/router";
Expand Down
15 changes: 2 additions & 13 deletions src/app/(routes)/admin/students/page.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
"use client";
import { useState, useEffect } from 'react';
import { fetchStudentData, } from "@/helpers/api";
import Cookies from "js-cookie";
import Table from "@/components/NewTableComponent/Table";
import type { DTO } from '@/dto/StudentDto';
import { createMRTColumnHelper } from 'material-react-table';
import generateColumns from "@/components/NewTableComponent/ColumnMapping";
import { jsondto } from "@/dto/StudentDto";
import { Form } from 'antd';
import { cookies } from 'next/headers';

const hiddenColumns = ['userId', 'programId','id'];

const StudentPage = () => {
const [students, setStudents] = useState<DTO[]>([]);
const columnHelper = createMRTColumnHelper<DTO>();
const columns = generateColumns(jsondto);






const visibleColumns = columns.filter(
(column: any) => !hiddenColumns.includes(column?.accessorKey)
);

useEffect(() => {
const fetchData = async () => {
const data = await fetchStudentData(null);
const data = await fetchStudentData();
setStudents(data);
console.log(data);
};


fetchData();
}, []);

Expand Down
2 changes: 0 additions & 2 deletions src/components/NewTableComponent/StudentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';
import { useEffect, useState } from 'react';
import CircularProgress from '@mui/material/CircularProgress';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { grey } from '@mui/material/colors';
import { Button } from '@mui/material';
import {fetchRegistrations} from '@/helpers/api';
import Cookies from 'js-cookie';
import Loader from '@/components/Loader/loader';
import { fetchStudentDataById, fetchRegistrationDataById } from '@/helpers/api';
const redirect = () => {};
Expand Down
2 changes: 0 additions & 2 deletions src/components/TableComponent/TableComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import * as React from "react";
import { useState } from "react";
import Modal from "react-modal";
import { fetchStudentData } from "@/helpers/api";
import Cookies from "js-cookie";
import {
ColumnDef,
ColumnFiltersState,
Expand Down
4 changes: 0 additions & 4 deletions src/components/company/AllCompaniesComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Separator } from "@/components/ui/separator";
import Cookies from "js-cookie";
import Link from "next/link";
import { revalidateTag } from "next/cache";
import EachCompanyDiv from "./EachCompanyDiv";
interface Props {}

interface company {
id: string;
Expand All @@ -31,7 +28,6 @@ const AllCompaniesComponent = async () => {
const Recruiters = await fetchCompanyRecruiters(
cookies()?.get("companyId")?.value,
);
console.log("Recruiters", Recruiters);
return (
<div className="">
<div className="border-r-2 rounded-md">
Expand Down
4 changes: 2 additions & 2 deletions src/components/loginForms/loginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import GoogleLogin from "./googleLogin";
import { LoginWithEmail } from "@/components/loginForms/loginWithEmail";

const LoginForm = () => {
const [email, setemail] = useState<String | null>(null);
const [role, setrole] = useState<String | null>("STUDENT");
const [email, setemail] = useState<string | null>(null);
const [role, setrole] = useState<string | null>("STUDENT");
const router = useRouter();
return (
<>
Expand Down
10 changes: 3 additions & 7 deletions src/components/loginForms/loginWithEmail.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import React from "react";
import { url } from "../../helpers/api";
import LockImg from "@/../public/icons/lock.svg";
import toast from "react-hot-toast";
import { apiCall } from "@/helpers/api";
export const LoginWithEmail = (params: { email: String }) => {
import { loginWithEmail } from "@/helpers/api";
export const LoginWithEmail = (params: { email: string }) => {
const onClick = async () => {
try {
const { email } = params;
const response = await apiCall("/auth/passwordless", {
method: "POST",
body: { email },
});
const response = await loginWithEmail(email);

if (response.ok) {
toast.success("Email has been sent");
Expand Down
20 changes: 13 additions & 7 deletions src/helpers/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ export const assignRecruiter = async (
};

export const fetchAllJobs = async (

filter: string | undefined
filter?: string
) => {
return apiCall(filter ? `/jobs?${filter}` : "/jobs", {

Expand All @@ -176,8 +175,7 @@ export const fetchAllJobs = async (
};

export const fetchStudentData = async (

filter: string | undefined
filter?: string
) => {
return apiCall(filter ? `/students?${filter}` : "/students", {

Expand Down Expand Up @@ -258,8 +256,7 @@ export const promoteStudent = async (body: any, eventId: string) => {
};

export const fetchRecruiterData = async (

filter: string | undefined
filter?: string
) => {

return apiCall(filter ? `/recruiters?${filter}` : "/recruiters", {
Expand Down Expand Up @@ -356,6 +353,7 @@ export const fetchRegistrationDataById = async (studentId: any) => {
};



//OnClick Functions

export const createJobEvent = async (
Expand Down Expand Up @@ -401,4 +399,12 @@ export const deleteEvent = async (jobId: string, eventId: string) => {
} catch (error) {
throw new Error("Error deleting event");
}
};
};

export const loginWithEmail = async (email: string) => {
return apiCall("/auth/passwordless", {
method: "POST",
body: { email },
});
}

1 change: 0 additions & 1 deletion src/helpers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {
import type { NextAuthOptions } from "next-auth";
import { getServerSession } from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import { format } from "path";

// You'll need to import and pass this
// to `NextAuth` in `app/api/auth/[...nextauth]/route.ts`
Expand Down

0 comments on commit 3f537d3

Please sign in to comment.