'use client' import { LogOutIcon, UserIcon } from 'lucide-react' import Link from 'next/link' import { usePathname } from 'next/navigation' import { useState, type FormEvent } from 'react' import { logoutCampaign } from '@/app/(campaign)/campanha/actions/auth' import { getCampaignBottomNav, getCampaignOverflowNav, isCampaignNavActive, } from '@/components/campaign/shell/nav' import { Button } from '@/components/ui/button' import { Drawer, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, } from '@/components/ui/Drawer' import { Spinner } from '@/components/ui/Spinner' import { clearLastActedMunicipality } from '@/lib/campaignLastActedMunicipality' import { CAMPAIGN_PROFILE_HOME } from '@/lib/campaignPaths' import { cn } from '@/lib/utils' import { clearCampaignPwaCaches } from '@/utilities/campaignPwaClient' import { type CampaignUserShellView } from '@/utilities/campaignUserProfile' import { clearMunicipalitySavedFilters } from '@/utilities/municipality/municipalitySavedFilters' import { clearRecentVisits } from '@/utilities/recentVisits' export const CampaignBottomNav = ({ user }: { user: CampaignUserShellView }) => { const pathname = usePathname() const navItems = getCampaignBottomNav(user.role) const overflowNav = getCampaignOverflowNav(user.role) const [overflowOpen, setOverflowOpen] = useState(false) const [isLoggingOut, setIsLoggingOut] = useState(false) const handleLogout = async (event: FormEvent) => { event.preventDefault() if (isLoggingOut) return setIsLoggingOut(true) clearRecentVisits() clearLastActedMunicipality() clearMunicipalitySavedFilters() await clearCampaignPwaCaches() await logoutCampaign() } return ( <> Navegação Destinos da campanha
{overflowNav.map((item) => { const active = isCampaignNavActive(pathname, item.href) return ( setOverflowOpen(false)} className={cn( 'flex items-center gap-3 rounded-md px-3 py-2.5 text-sm font-medium text-foreground outline-none', 'hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring', active && 'bg-muted text-primary', )} >
setOverflowOpen(false)} className={cn( 'flex items-center gap-3 rounded-md px-3 py-2.5 text-sm font-medium text-foreground outline-none', 'hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring', )} >
) }