import React, { useState } from 'react'; import { Map } from '../ui/map'; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '../ui/card'; import { Button } from '../ui/button'; import { Badge } from '../ui/badge'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs'; import { MapPin, Store, Home, Building2, Navigation } from 'lucide-react'; /** * LocationPickerExample * * Exemplo avançado que demonstra: * - Seleção de localização em um mapa * - Múltiplas categorias de locais * - Estado interativo * - Integração com outros componentes UI */ interface Location { id: string; name: string; address: string; category: 'store' | 'office' | 'home'; coords: { lat: number; lng: number }; description: string; isOpen?: boolean; phone?: string; } const mockLocations: Location[] = [ { id: '1', name: 'Loja Centro', address: 'Av. Paulista, 1000 - Bela Vista, São Paulo', category: 'store', coords: { lat: -23.5505, lng: -46.6333 }, description: 'Nossa loja principal no centro da cidade', isOpen: true, phone: '(11) 3456-7890', }, { id: '2', name: 'Loja Shopping', address: 'Shopping Ibirapuera - Vila Clementino, São Paulo', category: 'store', coords: { lat: -23.5965, lng: -46.652 }, description: 'Loja no Shopping Ibirapuera', isOpen: true, phone: '(11) 3456-7891', }, { id: '3', name: 'Escritório Administrativo', address: 'Rua Augusta, 2000 - Consolação, São Paulo', category: 'office', coords: { lat: -23.5558, lng: -46.66 }, description: 'Sede administrativa da empresa', isOpen: false, phone: '(11) 3456-7892', }, { id: '4', name: 'Centro de Distribuição', address: 'Rodovia dos Bandeirantes, km 24', category: 'office', coords: { lat: -23.485, lng: -46.685 }, description: 'Centro de logística e distribuição', isOpen: true, phone: '(11) 3456-7893', }, ]; export function LocationPickerExample() { const [selectedLocation, setSelectedLocation] = useState(mockLocations[0]); const [activeCategory, setActiveCategory] = useState('all'); // Filtrar localizações por categoria const filteredLocations = activeCategory === 'all' ? mockLocations : mockLocations.filter(loc => loc.category === activeCategory); // Criar marcadores para o mapa const markers = filteredLocations.map(loc => ({ position: loc.coords, title: loc.name, info: loc.address, label: loc.category === 'store' ? '🏪' : loc.category === 'office' ? '🏢' : '🏠', })); // Calcular centro do mapa baseado nos locais filtrados const mapCenter = selectedLocation?.coords || { lat: -23.5505, lng: -46.6333 }; const getCategoryIcon = (category: string) => { switch (category) { case 'store': return ; case 'office': return ; case 'home': return ; default: return ; } }; const getCategoryLabel = (category: string) => { switch (category) { case 'store': return 'Loja'; case 'office': return 'Escritório'; case 'home': return 'Residência'; default: return 'Local'; } }; return (

Encontre uma Localização

Selecione um local para ver mais informações e como chegar

Todos ({mockLocations.length}) Lojas ({mockLocations.filter(l => l.category === 'store').length}) Escritórios ({mockLocations.filter(l => l.category === 'office').length}) Outros ({mockLocations.filter(l => l.category === 'home').length})
{/* Lista de Locais */}

{filteredLocations.length} {filteredLocations.length === 1 ? 'local' : 'locais'}{' '} encontrado{filteredLocations.length !== 1 ? 's' : ''}

{filteredLocations.map(location => ( setSelectedLocation(location)} >
{getCategoryIcon(location.category)} {location.name} {location.address}
{location.isOpen !== undefined && ( {location.isOpen ? 'Aberto' : 'Fechado'} )}
))}
{/* Mapa e Detalhes */}
{/* Mapa */} {/* Informações do Local Selecionado */} {selectedLocation && (
{getCategoryIcon(selectedLocation.category)} {selectedLocation.name}
{getCategoryLabel(selectedLocation.category)}
{selectedLocation.isOpen !== undefined && ( {selectedLocation.isOpen ? 'Aberto agora' : 'Fechado'} )}
{selectedLocation.address}
{selectedLocation.phone && (
📞 {selectedLocation.phone}
)}

{selectedLocation.description}

)}
); } /** * VARIAÇÃO: Seletor de Endereço de Entrega */ export function DeliveryAddressSelector() { const [selectedAddress, setSelectedAddress] = useState(null); const addresses = [ { id: '1', label: 'Casa', address: 'Rua das Flores, 123', coords: { lat: -23.5505, lng: -46.6333 }, }, { id: '2', label: 'Trabalho', address: 'Av. Paulista, 1000', coords: { lat: -23.5615, lng: -46.656 }, }, { id: '3', label: 'Outro', address: 'Rua Augusta, 2000', coords: { lat: -23.5558, lng: -46.66 }, }, ]; const selectedCoords = addresses.find(a => a.id === selectedAddress)?.coords || addresses[0].coords; return ( Selecione o Endereço de Entrega Escolha onde deseja receber seu pedido
{addresses.map(addr => ( ))}
); }