'use client'; import * as React from 'react'; import { useIsDesktop } from '@/hooks/use-media-query'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, } from '@/components/ui/sheet'; interface ResponsiveDialogProps { open: boolean; onOpenChange: (open: boolean) => void; title: string; description?: string; children: React.ReactNode; footer?: React.ReactNode; className?: string; } /** * Um único componente para modal (Etapa 12): centralizado no desktop * (`Dialog`), bottom sheet no mobile (`Sheet` com `side="bottom"`) — * escolhido em vez de tela cheia porque a maioria dos formulários deste * projeto (confirmações, cadastro rápido de cliente, edição de parcela) * é curta o bastante para caber sem precisar ocupar a tela inteira; * `max-h-[85vh]` com scroll interno cobre os casos mais longos. Alterna * no mesmo breakpoint `md` usado pela `Table`. */ function ResponsiveDialog({ open, onOpenChange, title, description, children, footer, className, }: ResponsiveDialogProps) { const isDesktop = useIsDesktop(); if (isDesktop) { return ( {title} {description && {description}} {children} {footer && {footer}} ); } return ( {title} {description && {description}}
{children}
{footer && {footer}}
); } export { ResponsiveDialog };