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 [selectedJob, setSelectedJob] = createSignal<JobRecord | null>(null);
|
||||||
const [openMenuId, setOpenMenuId] = createSignal<string | null>(null);
|
const [openMenuId, setOpenMenuId] = createSignal<string | null>(null);
|
||||||
|
|
||||||
const load = async () => {
|
const load = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API}/api/jobs?limit=100`);
|
const res = await fetch(`${API}/api/admin/jobs`);
|
||||||
if (!res.ok) throw new Error('Fetch failed');
|
if (!res.ok) throw new Error('Fetch failed');
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
const list = Array.isArray(data) ? data : (data.jobs || []);
|
const list = Array.isArray(data) ? data : (data.jobs || []);
|
||||||
setRows(list.map((j: any) => ({
|
setRows(list.map((j: any) => ({
|
||||||
id: j.id,
|
id: j.id,
|
||||||
name: j.title || '—',
|
name: j.title || '—',
|
||||||
title: j.title || '—',
|
title: j.title || '—',
|
||||||
company: j.company_name || j.client_name || '—',
|
company: j.company_name || '—',
|
||||||
location: j.location || '—',
|
location: j.location || '—',
|
||||||
rate: j.hourly_rate_min ? `₹${j.hourly_rate_min}–₹${j.hourly_rate_max ?? j.hourly_rate_min}/hr` : '—',
|
rate: j.salary_min || j.salary_max ? `$${j.salary_min || 0}–$${j.salary_max || j.salary_min}/hr` : '—',
|
||||||
status: (j.status || 'ACTIVE').toUpperCase(),
|
status: (j.status || 'ACTIVE').toUpperCase(),
|
||||||
postedDate: j.created_at ? new Date(j.created_at).toLocaleDateString() : '—',
|
postedDate: j.posted_at || j.created_at ? new Date(j.posted_at || j.created_at).toLocaleDateString() : '—',
|
||||||
updatedAt: j.updated_at || ''
|
updatedAt: j.updated_at || ''
|
||||||
} as JobRecord)));
|
} as JobRecord)));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Jobs load error:', e);
|
console.error('Jobs load error:', e);
|
||||||
setRows([]);
|
setRows([]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(() => void load());
|
onMount(() => void load());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue