fix(frontend): fix string/number ID comparison in jobs page

- handleDeleteJob: compare string IDs directly instead of parseInt
- handleSaveEdit: use string ID for future update logic
- IDs are now UUIDs (strings) after migration
This commit is contained in:
Tiago Yamamoto 2025-12-25 21:49:09 -03:00
parent 39fde338b4
commit 39d1eff80f

View file

@ -173,12 +173,9 @@ export default function AdminJobsPage() {
setIsEditDialogOpen(true)
}
const handleDeleteJob = async (idStr: string) => {
const handleDeleteJob = async (id: string) => {
if (!confirm("Are you sure you want to delete this job?")) return
const id = parseInt(idStr)
if (isNaN(id)) return
try {
// await adminJobsApi.delete(id)
setJobs((prevJobs) => prevJobs.filter((job) => job.id !== id))
@ -190,13 +187,11 @@ export default function AdminJobsPage() {
const handleSaveEdit = async () => {
if (!selectedJob) return
const id = parseInt(selectedJob.id)
if (isNaN(id)) return
try {
setIsLoading(true)
// const updated = await adminJobsApi.update(id, editForm)
// setJobs((prev) => prev.map((j) => (j.id === id ? updated : j)))
// const updated = await adminJobsApi.update(selectedJob.id, editForm)
// setJobs((prev) => prev.map((j) => (j.id === selectedJob.id ? updated : j)))
setIsEditDialogOpen(false)
} catch (error) {
console.error("Failed to update job:", error)