fix: use admin jobs endpoint in admin jobs management page
- Change fetch from /api/jobs to /api/admin/jobs - Adjust fields to match new endpoint: use salary_min/salary_max, posted_at, company_name
This commit is contained in:
parent
88a00db3bd
commit
65156aafde
1 changed files with 22 additions and 22 deletions
|
|
@ -46,28 +46,28 @@ export default function JobsManagementPage() {
|
|||
const [selectedJob, setSelectedJob] = createSignal<JobRecord | null>(null);
|
||||
const [openMenuId, setOpenMenuId] = createSignal<string | null>(null);
|
||||
|
||||
const load = async () => {
|
||||
try {
|
||||
const res = await fetch(`${API}/api/jobs?limit=100`);
|
||||
if (!res.ok) throw new Error('Fetch failed');
|
||||
const data = await res.json();
|
||||
const list = Array.isArray(data) ? data : (data.jobs || []);
|
||||
setRows(list.map((j: any) => ({
|
||||
id: j.id,
|
||||
name: j.title || '—',
|
||||
title: j.title || '—',
|
||||
company: j.company_name || j.client_name || '—',
|
||||
location: j.location || '—',
|
||||
rate: j.hourly_rate_min ? `₹${j.hourly_rate_min}–₹${j.hourly_rate_max ?? j.hourly_rate_min}/hr` : '—',
|
||||
status: (j.status || 'ACTIVE').toUpperCase(),
|
||||
postedDate: j.created_at ? new Date(j.created_at).toLocaleDateString() : '—',
|
||||
updatedAt: j.updated_at || ''
|
||||
} as JobRecord)));
|
||||
} catch (e) {
|
||||
console.error('Jobs load error:', e);
|
||||
setRows([]);
|
||||
}
|
||||
};
|
||||
const load = async () => {
|
||||
try {
|
||||
const res = await fetch(`${API}/api/admin/jobs`);
|
||||
if (!res.ok) throw new Error('Fetch failed');
|
||||
const data = await res.json();
|
||||
const list = Array.isArray(data) ? data : (data.jobs || []);
|
||||
setRows(list.map((j: any) => ({
|
||||
id: j.id,
|
||||
name: j.title || '—',
|
||||
title: j.title || '—',
|
||||
company: j.company_name || '—',
|
||||
location: j.location || '—',
|
||||
rate: j.salary_min || j.salary_max ? `$${j.salary_min || 0}–$${j.salary_max || j.salary_min}/hr` : '—',
|
||||
status: (j.status || 'ACTIVE').toUpperCase(),
|
||||
postedDate: j.posted_at || j.created_at ? new Date(j.posted_at || j.created_at).toLocaleDateString() : '—',
|
||||
updatedAt: j.updated_at || ''
|
||||
} as JobRecord)));
|
||||
} catch (e) {
|
||||
console.error('Jobs load error:', e);
|
||||
setRows([]);
|
||||
}
|
||||
};
|
||||
|
||||
onMount(() => void load());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue