'use client' import { usePathname } from 'next/navigation' import { useEffect, useRef } from 'react' import { CampaignGlobalSearchBody } from '@/components/campaign/dashboard/CampaignGlobalSearchMount' import { CampaignHomeActionStrip } from '@/components/campaign/dashboard/CampaignHomeActionStrip' import { useHomeSearch } from '@/components/campaign/dashboard/HomeSearchContext' import { HomeSearchExcludeProvider } from '@/components/campaign/dashboard/HomeSearchExcludeContext' import { useCampaignQuickActionContext } from '@/components/campaign/shell/CampaignQuickActionContext' import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { Drawer, DrawerContent, DrawerDescription, DrawerTitle } from '@/components/ui/Drawer' import { useIsMobile } from '@/hooks/use-mobile' import type { CampaignQuickAction } from '@/lib/campaignQuickActionTypes' import { resolveHomeSearchExcludeContext } from '@/lib/homeSearchExcludeCurrentEntity' import { cn } from '@/lib/utils' const overlayRetractionClass = (retracted: boolean) => cn( 'grid min-h-0 transition-[grid-template-rows,opacity] duration-[220ms] ease-out motion-reduce:transition-none', retracted ? 'grid-rows-[0fr] opacity-0 pointer-events-none motion-reduce:opacity-0' : 'grid-rows-[1fr] opacity-100 motion-reduce:opacity-100', ) const OverlayActionsChrome = ({ actions, retracted, onActionClick, }: { actions: readonly CampaignQuickAction[] retracted: boolean /** Fired after an `onAction` (dialog-style) quick action runs — closes the drawer. */ onActionClick: () => void }) => { if (actions.length === 0) return null return (
({ id: action.id, label: action.label, icon: action.icon, description: action.description, // Dialog-style actions win over a route when both are present // (`CampaignHomeActionButton` renders the href branch without // onClick, which would silently drop the action and the close). href: action.onAction ? undefined : action.href, onClick: action.onAction ? () => { action.onAction?.() onActionClick() } : undefined, }))} className="w-full" />
) } const OverlaySearchChrome = ({ className }: { className?: string }) => (
) const CampaignQuickActionsOverlayBody = ({ actions, onActionClick, }: { actions: readonly CampaignQuickAction[] onActionClick: () => void }) => { const { uiFocused: focused } = useHomeSearch() return (
) } const CampaignQuickActionsOverlayContent = ({ actions, onActionClick, }: { actions: readonly CampaignQuickAction[] onActionClick: () => void }) => { const pathname = usePathname() const { context } = useCampaignQuickActionContext() const excludeContext = resolveHomeSearchExcludeContext(pathname, context) return ( ) } export const CampaignQuickActionsOverlay = ({ open, onOpenChange, actions, }: { open: boolean onOpenChange: (open: boolean) => void actions: readonly CampaignQuickAction[] }) => { const isMobile = useIsMobile() const { clear } = useHomeSearch() const titleRef = useRef(null) useEffect(() => { if (!open) clear() }, [open, clear]) if (isMobile) { return ( Ações rápidas Ações do contexto e busca na campanha
onOpenChange(false)} />
) } return ( { event.preventDefault() titleRef.current?.focus() }} > Ações rápidas Ações do contexto e busca na campanha
onOpenChange(false)} />
) }