Skip to content

Commit 459c52a

Browse files
Updated jobs listing to use new db structure.
1 parent e7e194c commit 459c52a

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

src/app/jobs/page.tsx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,48 @@
11
import React from 'react'
2-
import PostsTable from '@/components/jobs/PostsTable'
2+
import JobsTable from '@/components/jobs/JobsTable'
33
import VideoPlayer from '../../components/video-player'
44
import prisma from '@/lib/db'
5+
import { Prisma } from '@prisma/client'
6+
7+
// Type for jobs with relations
8+
type JobWithRelations = Prisma.JobGetPayload<{
9+
include: {
10+
company: true
11+
tags: { include: { tag: true } }
12+
metadata: true
13+
sources: true
14+
}
15+
}>
516

617
export default async function Home(props: { searchParams: Promise<{ page?: string }> }) {
718
const searchParams = await props.searchParams
819
const postsPerPage = 10
920
const currentPage = parseInt(searchParams.page || '1', 10)
1021

11-
const totalPosts = await prisma.redditPost.count()
12-
const posts = await prisma.redditPost.findMany({
22+
const totalJobs = await prisma.job.count()
23+
const jobs = (await prisma.job.findMany({
1324
skip: (currentPage - 1) * postsPerPage,
1425
take: postsPerPage,
15-
orderBy: { createdAt: 'desc' },
16-
})
26+
orderBy: { postedAt: 'desc' },
27+
include: {
28+
company: true,
29+
tags: { include: { tag: true } },
30+
metadata: true,
31+
sources: true,
32+
},
33+
})) as JobWithRelations[]
1734

1835
await prisma.$disconnect()
1936

2037
return (
2138
<div className="flex flex-col inset-0 z-50 bg-primary transition-transform">
2239
<section className={`bg-gray-100 py-4 md:py-6`}>
2340
<div className="container mx-auto py-16 px-8 md:px-20 lg:px-32">
24-
<h1 className="text-2xl font-bold mb-4">Reddit Posts</h1>
25-
<PostsTable
26-
posts={posts}
27-
totalPosts={totalPosts}
28-
postsPerPage={postsPerPage}
41+
<h1 className="text-2xl font-bold mb-4">Job Listings</h1>
42+
<JobsTable
43+
jobs={jobs}
44+
totalJobs={totalJobs}
45+
jobsPerPage={postsPerPage}
2946
currentPage={currentPage}
3047
/>
3148
</div>

0 commit comments

Comments
 (0)