From 6fec724a2c617f219e72731c86f3a468364f3c3a Mon Sep 17 00:00:00 2001 From: Ishaan Mittal Date: Sat, 15 Jun 2024 22:58:56 +0530 Subject: [PATCH] build test --- .github/workflows/build-test.yml | 19 +++++++++++++++++++ .../(routes)/student/jobs/[jobId]/page.tsx | 8 +++----- src/helpers/student/api.ts | 18 ++++++++++++++---- 3 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/build-test.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 00000000..f49d0739 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,19 @@ +name: build-test + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build-lint-test: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v3 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: yarn + cache-dependency-path: 'yarn.lock' + - run: yarn + - run: yarn build diff --git a/src/app/(routes)/student/jobs/[jobId]/page.tsx b/src/app/(routes)/student/jobs/[jobId]/page.tsx index 3cdd18da..c35bb743 100644 --- a/src/app/(routes)/student/jobs/[jobId]/page.tsx +++ b/src/app/(routes)/student/jobs/[jobId]/page.tsx @@ -1,7 +1,6 @@ "use client"; import React, { useEffect, useState } from "react"; import { Separator } from "@/components/ui/separator"; -import Link from "next/link"; import { Table, TableHeader, @@ -12,10 +11,10 @@ import { TableCell, } from "@/components/ui/table"; import { Button } from "@/components/ui/button"; -import { fetchEachJob } from "@/helpers/api"; import HorizontalTimeline from "@/components/HorizontalTimeline"; import { Job, CustomEvent, EventData, CalenderEvent } from "@/helpers/student/types"; import { GetJobById } from "@/helpers/student/api"; +import Cookies from "js-cookie"; function transformEvents(events: CustomEvent[]): EventData[] { @@ -96,7 +95,7 @@ const JobPage = ({ params }: { params: { jobId: string } }) => { useEffect(() => { const fetchJobData = async () => { - const data = await GetJobById(params.jobId); + const data = await GetJobById(params.jobId, Cookies.get("accessToken")); setJobData(data); storeCalenderEvents(data); }; @@ -122,7 +121,7 @@ const JobPage = ({ params }: { params: { jobId: string } }) => {
Website
{" "} - Link + Link
Domain
{" "} @@ -201,7 +200,6 @@ const JobPage = ({ params }: { params: { jobId: string } }) => {
- {/* */}
diff --git a/src/helpers/student/api.ts b/src/helpers/student/api.ts index 4e751bbd..bc14e843 100644 --- a/src/helpers/student/api.ts +++ b/src/helpers/student/api.ts @@ -5,9 +5,14 @@ const url = (NextUrl: string) => { return `${baseUrl}/api/v1${NextUrl}`; }; -export const GetJobById = async (jobId: string) => { +export const GetJobById = async (jobId: string, accessToken:string) => { try { - const res = await fetch(url(`/jobs/${jobId}`)); + const res = await fetch(url(`/jobs/${jobId}`),{ + method: 'GET', + headers: { + 'Authorization': `Bearer ${accessToken}` + }, + }); if (!res.ok) { throw new Error("Failed to fetch Job data"); } @@ -17,9 +22,14 @@ export const GetJobById = async (jobId: string) => { console.error("Error fetching Job data:", error); } }; -export const GetSalaryById = async (salaryId: string) => { +export const GetSalaryById = async (salaryId: string,accessToken: string) => { try { - const res = await fetch(url(`/salaries/${salaryId}`)); + const res = await fetch(url(`/salaries/${salaryId}`), { + method: 'GET', + headers: { + 'Authorization': `Bearer ${accessToken}` + } + }); if (!res.ok) { throw new Error("Failed to fetch salary data"); }