import { type ReactNode, createContext, useContext } from "react"; import { Button } from "./button"; import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTitle, } from "./dialog"; const FormCancelContext = createContext(undefined); export function FormDialog({ open, onOpenChange, title, cancelLabel, children, wide = false, formActions = false, }: { open: boolean; onOpenChange: (open: boolean) => void; title: string; cancelLabel: string; children: ReactNode; wide?: boolean; formActions?: boolean; }) { return ( {title} {children} {!formActions && ( }> {cancelLabel} )} ); } export function FormActions({ children }: { children: ReactNode }) { const cancelLabel = useContext(FormCancelContext); return ( {children} {cancelLabel && ( }>{cancelLabel} )} ); }