-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix build #164
fix build #164
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,8 +3,6 @@ import ClientResumes from './ClientResumes'; | |||||||||
import gravatar from 'gravatar'; | ||||||||||
|
||||||||||
const supabaseUrl = 'https://itxuhvvwryeuzuyihpkp.supabase.co'; | ||||||||||
const supabaseKey = process.env.SUPABASE_KEY; | ||||||||||
const supabase = createClient(supabaseUrl, supabaseKey); | ||||||||||
|
||||||||||
const ITEMS_PER_PAGE = 100; | ||||||||||
|
||||||||||
|
@@ -20,8 +18,18 @@ export const metadata = { | |||||||||
}, | ||||||||||
}; | ||||||||||
|
||||||||||
// This makes the page static at build time | ||||||||||
export const dynamic = 'force-dynamic'; | ||||||||||
Comment on lines
+21
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix incorrect comment about page behavior The comment "This makes the page static at build time" contradicts the actual behavior of -// This makes the page static at build time
+// This ensures the page is dynamically rendered at runtime
export const dynamic = 'force-dynamic'; 📝 Committable suggestion
Suggested change
|
||||||||||
|
||||||||||
async function getResumes(page = 1, search = '') { | ||||||||||
try { | ||||||||||
// During build time, return empty data | ||||||||||
if (!process.env.SUPABASE_KEY) { | ||||||||||
return { resumes: [], totalCount: 0, totalPages: 0 }; | ||||||||||
} | ||||||||||
|
||||||||||
const supabase = createClient(supabaseUrl, process.env.SUPABASE_KEY); | ||||||||||
|
||||||||||
// First get the total count | ||||||||||
let countQuery = supabase | ||||||||||
.from('resumes') | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -7,29 +7,40 @@ const ClientJobBoard = dynamic(() => import('./ClientJobBoard'), { | |||||||
}); | ||||||||
|
||||||||
const supabaseUrl = 'https://itxuhvvwryeuzuyihpkp.supabase.co'; | ||||||||
const supabaseKey = process.env.SUPABASE_KEY; | ||||||||
const supabase = createClient(supabaseUrl, supabaseKey); | ||||||||
|
||||||||
// This ensures the page is dynamic at runtime | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add export configuration for Next.js dynamic behavior The comment indicates the page should be dynamic, but the configuration is missing. Add the following configuration: +export const dynamic = 'force-dynamic'; 📝 Committable suggestion
Suggested change
|
||||||||
|
||||||||
async function getJobs() { | ||||||||
const ninetyDaysAgo = new Date(); | ||||||||
ninetyDaysAgo.setDate(ninetyDaysAgo.getDate() - 90); | ||||||||
|
||||||||
const { data: jobs, error } = await supabase | ||||||||
.from('jobs') | ||||||||
.select('*') | ||||||||
.gte('created_at', ninetyDaysAgo.toISOString()) | ||||||||
.order('created_at', { ascending: false }); | ||||||||
|
||||||||
if (error) { | ||||||||
console.error('Error fetching jobs:', error); | ||||||||
return []; | ||||||||
// During build time or when SUPABASE_KEY is not available | ||||||||
if (!process.env.SUPABASE_KEY) { | ||||||||
return { jobs: [], error: null }; | ||||||||
} | ||||||||
|
||||||||
return jobs || []; | ||||||||
try { | ||||||||
const supabase = createClient(supabaseUrl, process.env.SUPABASE_KEY); | ||||||||
const ninetyDaysAgo = new Date(); | ||||||||
ninetyDaysAgo.setDate(ninetyDaysAgo.getDate() - 90); | ||||||||
|
||||||||
const { data: jobs, error } = await supabase | ||||||||
.from('jobs') | ||||||||
.select('*') | ||||||||
.gte('created_at', ninetyDaysAgo.toISOString()) | ||||||||
.order('created_at', { ascending: false }); | ||||||||
|
||||||||
if (error) { | ||||||||
console.error('Error fetching jobs:', error); | ||||||||
return { jobs: [], error }; | ||||||||
} | ||||||||
|
||||||||
return { jobs: jobs || [], error: null }; | ||||||||
} catch (error) { | ||||||||
console.error('Error:', error); | ||||||||
return { jobs: [], error }; | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
export default async function JobsPage() { | ||||||||
const initialJobs = await getJobs(); | ||||||||
const { jobs } = await getJobs(); | ||||||||
|
||||||||
return ( | ||||||||
<div className="min-h-screen bg-gray-100 p-8"> | ||||||||
|
@@ -42,7 +53,7 @@ export default async function JobsPage() { | |||||||
</div> | ||||||||
} | ||||||||
> | ||||||||
<ClientJobBoard initialJobs={initialJobs} /> | ||||||||
<ClientJobBoard initialJobs={jobs} /> | ||||||||
</Suspense> | ||||||||
</div> | ||||||||
</div> | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,39 @@ | ||
const { createClient } = require('@supabase/supabase-js'); | ||
|
||
const supabaseUrl = 'https://itxuhvvwryeuzuyihpkp.supabase.co'; | ||
const supabaseKey = process.env.SUPABASE_KEY; | ||
const supabase = createClient(supabaseUrl, supabaseKey); | ||
|
||
export const config = { | ||
runtime: 'edge', | ||
}; | ||
|
||
export default async function handler(req, res) { | ||
if (req.method !== 'GET') { | ||
return res.status(405).json({ message: 'Method not allowed' }); | ||
} | ||
|
||
// During build time or when SUPABASE_KEY is not available | ||
if (!process.env.SUPABASE_KEY) { | ||
return res.status(503).json({ message: 'API not available during build' }); | ||
} | ||
|
||
try { | ||
const supabase = createClient(supabaseUrl, process.env.SUPABASE_KEY); | ||
|
||
// Get all jobs from the last 90 days, sorted by creation date descending | ||
const { data: jobs, error } = await supabase | ||
.from('jobs') | ||
.select('*') | ||
.gte('created_at', new Date(Date.now() - 60 * 24 * 60 * 90 * 1000).toISOString()) | ||
.gte( | ||
'created_at', | ||
new Date(Date.now() - 60 * 24 * 60 * 90 * 1000).toISOString() | ||
) | ||
.order('created_at', { ascending: false }); | ||
|
||
if (error) throw error; | ||
|
||
return res.status(200).json(jobs); | ||
return res.status(200).json(jobs || []); | ||
} catch (error) { | ||
console.error('Error fetching jobs:', error); | ||
return res.status(500).json({ message: 'Error fetching jobs', error: error.message }); | ||
return res.status(500).json({ message: 'Internal server error' }); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Refactor duplicate gravatar URL construction
The gravatar URL construction logic is duplicated between the success and error cases. Consider extracting this into a helper function.
📝 Committable suggestion