| 255 | } |
| 256 | |
| 257 | async function updateTicketPriority(ticket: any, priority: string) { |
| 258 | try { |
| 259 | const response = await fetch(`/api/v1/ticket/update`, { |
| 260 | method: "PUT", |
| 261 | headers: { |
| 262 | "Content-Type": "application/json", |
| 263 | Authorization: `Bearer ${token}`, |
| 264 | }, |
| 265 | body: JSON.stringify({ |
| 266 | id: ticket.id, |
| 267 | detail: ticket.detail, |
| 268 | note: ticket.note, |
| 269 | title: ticket.title, |
| 270 | priority: priority, |
| 271 | status: ticket.status, |
| 272 | }), |
| 273 | }).then((res) => res.json()); |
| 274 | |
| 275 | if (!response.success) throw new Error("Failed to update priority"); |
| 276 | |
| 277 | toast({ |
| 278 | title: "Priority updated", |
| 279 | description: `Ticket priority set to ${priority}`, |
| 280 | duration: 3000, |
| 281 | }); |
| 282 | refetch(); |
| 283 | } catch (error) { |
| 284 | toast({ |
| 285 | title: "Error", |
| 286 | description: "Failed to update priority", |
| 287 | variant: "destructive", |
| 288 | duration: 3000, |
| 289 | }); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | useEffect(() => { |
| 294 | fetchUsers(); |