From 6392e689e3cc1425edb2aaf0582a9a843d4a4290 Mon Sep 17 00:00:00 2001 From: christian Date: Sun, 9 Jun 2024 08:27:12 +0200 Subject: [PATCH] updated jobcards --- src/app/_jobcard/JobCard.tsx | 51 +++++++++++++++++++++++++----------- src/app/page.tsx | 45 ++++++------------------------- 2 files changed, 43 insertions(+), 53 deletions(-) diff --git a/src/app/_jobcard/JobCard.tsx b/src/app/_jobcard/JobCard.tsx index 4e8fdca..a9c1cee 100644 --- a/src/app/_jobcard/JobCard.tsx +++ b/src/app/_jobcard/JobCard.tsx @@ -1,17 +1,36 @@ -import { Job } from "../page"; +interface JobPosting { + title: string; + logo: string; + company: string; + location: string; + type: string; + description: string; + link: string; + skills: { + react: boolean; + python: boolean; + golang: boolean; + svelte: boolean; + nextjs: boolean; + typescript: boolean; + tailwind: boolean; + }; +} - - -export default async function JobCard(props: {job: Job}) { - const { title, company, date_posted, description, img, link, location, url } = props.job; - return ( - - - - - - - - - ) -} \ No newline at end of file +export default async function JobCard(props: { job: JobPosting }) { + const { title, logo, company, location, type, description, link, skills } = + props.job; + return ( +
+

{title}

+

+ {company} - {location} +

+

{type}

+

{description.slice(0, 400)}...

+ + Link + +
+ ); +} diff --git a/src/app/page.tsx b/src/app/page.tsx index 88b9c48..cb73ac5 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,8 +1,7 @@ -"use client"; -import { useState, useEffect } from "react"; +import { revalidatePath } from "next/cache"; +import JobCard from "./_jobcard/JobCard"; interface JobPosting { - id: number; // Assuming each job has an id title: string; logo: string; company: string; @@ -26,44 +25,16 @@ async function fetchJobs(): Promise { if (!response.ok) { throw new Error("Failed to fetch jobs"); } + revalidatePath("/"); return response.json(); } -export default function Home() { - const [jobs, setJobs] = useState([]); - - useEffect(() => { - const getJobs = async () => { - try { - const jobsData = await fetchJobs(); - setJobs(jobsData); - } catch (error) { - console.error("Error fetching jobs:", error); - } - }; - getJobs(); - }, []); - +export default async function Home() { + const jobs = await fetchJobs(); return ( -
- {jobs.map((job) => ( -
-

{job.title}

-

- {job.company} - {job.location} -

-

{job.type}

-

{job.description}

- - Link - -

- Skills:{" "} - {Object.keys(job.skills) - .filter((skill) => job.skills[skill as keyof typeof job.skills]) - .join(", ")} -

-
+
+ {jobs.map((job, i) => ( + ))}
);