import { Link2, Plus } from "lucide-react" import { useNavigate } from "react-router-dom" import { toast } from "sonner" import { Button } from "../../../components/ui/button" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "../../../components/ui/dialog" import { resolvePracticeParentFromPathOptions, type PracticeContentPathOptions, } from "../../../lib/practiceContentPaths" interface PracticeActionChoiceDialogProps { open: boolean onOpenChange: (open: boolean) => void createHref: string attachHref: string pathOptions: PracticeContentPathOptions parentLabel?: string | null } export function PracticeActionChoiceDialog({ open, onOpenChange, createHref, attachHref, pathOptions, parentLabel, }: PracticeActionChoiceDialogProps) { const navigate = useNavigate() const openAttachPage = () => { if (!resolvePracticeParentFromPathOptions(pathOptions)) { toast.error("Missing content context", { description: "Open attach practice from a course, module, or lesson so the API knows where to link the practice.", }) return } onOpenChange(false) navigate(attachHref) } return ( Add practice {parentLabel ? ( <> Choose how to add a practice for{" "} {parentLabel}. ) : ( "Create a new practice or link an existing one from your library." )}
) }