| 284 | } |
| 285 | |
| 286 | async function addComment() { |
| 287 | if (data && data.ticket && data.ticket.locked) return; |
| 288 | |
| 289 | const res = await fetch(`/api/v1/ticket/comment`, { |
| 290 | method: "POST", |
| 291 | headers: { |
| 292 | "Content-Type": "application/json", |
| 293 | Authorization: `Bearer ${token}`, |
| 294 | }, |
| 295 | body: JSON.stringify({ |
| 296 | text: comment, |
| 297 | id, |
| 298 | public: publicComment, |
| 299 | }), |
| 300 | }).then((res) => res.json()); |
| 301 | |
| 302 | if (!res.success) { |
| 303 | toast({ |
| 304 | variant: "destructive", |
| 305 | title: "Error", |
| 306 | description: res.message || "Failed to add comment", |
| 307 | }); |
| 308 | return; |
| 309 | } |
| 310 | refetch(); |
| 311 | } |
| 312 | |
| 313 | async function deleteComment(id: string) { |
| 314 | await fetch(`/api/v1/ticket/comment/delete`, { |