|
1 | 1 | import React from 'react'
|
2 |
| -import PostsTable from '@/components/jobs/PostsTable' |
| 2 | +import JobsTable from '@/components/jobs/JobsTable' |
3 | 3 | import VideoPlayer from '../../components/video-player'
|
4 | 4 | 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 | +}> |
5 | 16 |
|
6 | 17 | export default async function Home(props: { searchParams: Promise<{ page?: string }> }) {
|
7 | 18 | const searchParams = await props.searchParams
|
8 | 19 | const postsPerPage = 10
|
9 | 20 | const currentPage = parseInt(searchParams.page || '1', 10)
|
10 | 21 |
|
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({ |
13 | 24 | skip: (currentPage - 1) * postsPerPage,
|
14 | 25 | 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[] |
17 | 34 |
|
18 | 35 | await prisma.$disconnect()
|
19 | 36 |
|
20 | 37 | return (
|
21 | 38 | <div className="flex flex-col inset-0 z-50 bg-primary transition-transform">
|
22 | 39 | <section className={`bg-gray-100 py-4 md:py-6`}>
|
23 | 40 | <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} |
29 | 46 | currentPage={currentPage}
|
30 | 47 | />
|
31 | 48 | </div>
|
|
0 commit comments