Spaces:
Runtime error
Runtime error
Download frontend/src/components/delete-learner-dialog.tsx from adwhytahumans/CRM_FastAPI_React: direct link, hf CLI and curl.
- Browser
- Download file 1.67 kB
-
https://huggingface.co/spaces/adwhytahumans/CRM_FastAPI_React/resolve/main/frontend/src/components/delete-learner-dialog.tsx
- Command line
-
hf download hf://spaces/adwhytahumans/CRM_FastAPI_React/frontend/src/components/delete-learner-dialog.tsx
-
curl -L -o delete-learner-dialog.tsx https://huggingface.co/spaces/adwhytahumans/CRM_FastAPI_React/resolve/main/frontend/src/components/delete-learner-dialog.tsx
1.67 kB
| import { | |
| AlertDialog, | |
| AlertDialogAction, | |
| AlertDialogCancel, | |
| AlertDialogContent, | |
| AlertDialogDescription, | |
| AlertDialogFooter, | |
| AlertDialogHeader, | |
| AlertDialogTitle, | |
| } from "@/components/ui/alert-dialog" | |
| import { useToast } from "@/components/ui/use-toast" | |
| import { deleteLearner } from "@/lib/api" | |
| import { LearnerOut } from "@/types/learner" | |
| interface DeleteLearnerDialogProps { | |
| learner: LearnerOut | |
| open: boolean | |
| onOpenChange: (open: boolean) => void | |
| onSuccess?: () => void | |
| } | |
| export function DeleteLearnerDialog({ | |
| learner, | |
| open, | |
| onOpenChange, | |
| onSuccess, | |
| }: DeleteLearnerDialogProps) { | |
| const { toast } = useToast() | |
| async function handleDelete() { | |
| try { | |
| await deleteLearner(learner.id) | |
| toast({ | |
| title: "Success", | |
| description: "Learner deleted successfully", | |
| }) | |
| onOpenChange(false) | |
| onSuccess?.() | |
| } catch (error) { | |
| toast({ | |
| title: "Error", | |
| description: "Failed to delete learner", | |
| variant: "destructive", | |
| }) | |
| } | |
| } | |
| return ( | |
| <AlertDialog open={open} onOpenChange={onOpenChange}> | |
| <AlertDialogContent> | |
| <AlertDialogHeader> | |
| <AlertDialogTitle>Are you sure?</AlertDialogTitle> | |
| <AlertDialogDescription> | |
| This will permanently delete {learner.name}'s record. This action cannot be undone. | |
| </AlertDialogDescription> | |
| </AlertDialogHeader> | |
| <AlertDialogFooter> | |
| <AlertDialogCancel>Cancel</AlertDialogCancel> | |
| <AlertDialogAction onClick={handleDelete}>Delete</AlertDialogAction> | |
| </AlertDialogFooter> | |
| </AlertDialogContent> | |
| </AlertDialog> | |
| ) | |
| } |