Skip to content

Commit 77db9f9

Browse files
Added static build script & updated jobs pages to use api route instead of prisma locally.
1 parent a08deb9 commit 77db9f9

3 files changed

Lines changed: 25 additions & 56 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"// -- CORE DEVELOPMENT COMMANDS --": "",
77
"dev": "next dev --turbopack",
88
"build": "next build",
9+
"build:static": "next build && next export",
910
"start": "next start",
1011
"lint": "next lint",
1112
"// -- LOCAL DATABASE & PRISMA --": "",
@@ -42,7 +43,7 @@
4243
"framer-motion": "^12.23.5",
4344
"gsap": "^3.13.0",
4445
"motion": "^12.18.1",
45-
"next": "^15.4.4",
46+
"next": "^15.4.4vf",
4647
"next-nprogress-bar": "^2.4.7",
4748
"next-transition-router": "^0.2.11",
4849
"prisma-dbml-generator": "^0.12.0",

src/app/jobs/[id]/page.tsx

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1+
12
import React from 'react'
23
import Link from 'next/link'
34
import { notFound } from 'next/navigation'
4-
import prisma from '@/lib/db'
5-
import { Prisma } from '@prisma/client'
65
import JobDetails from '@/components/jobs/JobDetails'
76

8-
// Type for job with relations
9-
type JobWithRelations = Prisma.JobGetPayload<{
10-
include: {
11-
company: true
12-
tags: { include: { tag: true } }
13-
metadata: true
14-
}
15-
}>
16-
177
interface JobPageProps {
188
params: Promise<{ id: string }>
199
}
@@ -26,21 +16,16 @@ export default async function JobPage({ params }: JobPageProps) {
2616
notFound()
2717
}
2818

29-
const job = (await prisma.job.findUnique({
30-
where: { id: jobId },
31-
include: {
32-
company: true,
33-
tags: { include: { tag: true } },
34-
metadata: true,
35-
},
36-
})) as JobWithRelations | null
37-
19+
// Fetch job from external API
20+
const res = await fetch(`https://api.codebuilder.org/jobs/${jobId}`)
21+
if (!res.ok) {
22+
notFound()
23+
}
24+
const job = await res.json()
3825
if (!job) {
3926
notFound()
4027
}
4128

42-
await prisma.$disconnect()
43-
4429
return (
4530
<div className="flex flex-col inset-0 z-50 bg-primary transition-transform">
4631
<section className={`bg-gray-100 py-4 md:py-6`}>
@@ -62,7 +47,6 @@ export default async function JobPage({ params }: JobPageProps) {
6247
</div>
6348
)
6449
}
65-
6650
// Generate metadata for SEO
6751
export async function generateMetadata({ params }: JobPageProps) {
6852
const { id } = await params
@@ -74,15 +58,14 @@ export async function generateMetadata({ params }: JobPageProps) {
7458
}
7559
}
7660

77-
const job = await prisma.job.findUnique({
78-
where: { id: jobId },
79-
select: {
80-
title: true,
81-
company: { select: { name: true } },
82-
description: true,
83-
},
84-
})
85-
61+
// Fetch job from external API
62+
const res = await fetch(`https://api.codebuilder.org/jobs/${jobId}`)
63+
if (!res.ok) {
64+
return {
65+
title: 'Job Not Found',
66+
}
67+
}
68+
const job = await res.json()
8669
if (!job) {
8770
return {
8871
title: 'Job Not Found',

src/app/jobs/page.tsx

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,21 @@
11
import React from 'react'
22
import JobsTable from '@/components/jobs/JobsTable'
33
import VideoPlayer from '../../components/video-player'
4-
import prisma from '@/lib/db'
5-
import { Prisma } from '@prisma/client'
64

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-
}
14-
}>
155

166
export default async function Home(props: { searchParams: Promise<{ page?: string }> }) {
177
const searchParams = await props.searchParams
188
const postsPerPage = 10
199
const currentPage = parseInt(searchParams.page || '1', 10)
2010

21-
const totalJobs = await prisma.job.count()
22-
const jobs = (await prisma.job.findMany({
23-
skip: (currentPage - 1) * postsPerPage,
24-
take: postsPerPage,
25-
orderBy: { postedAt: 'desc' },
26-
include: {
27-
company: true,
28-
tags: { include: { tag: true } },
29-
metadata: true,
30-
},
31-
})) as JobWithRelations[]
32-
33-
await prisma.$disconnect()
11+
// Fetch jobs from external API
12+
const res = await fetch(`https://api.codebuilder.org/jobs?page=${currentPage}&limit=${postsPerPage}`)
13+
if (!res.ok) {
14+
throw new Error('Failed to fetch jobs from external API')
15+
}
16+
const data = await res.json()
17+
const jobs = data.jobs || []
18+
const totalJobs = data.total || 0
3419

3520
return (
3621
<div className="flex flex-col inset-0 z-50 bg-primary transition-transform">

0 commit comments

Comments
 (0)