"use client" import { useState, useEffect } from "react" import Link from "next/link" import { Button } from "@/components/ui/button" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Plus, Edit, Trash2, Eye, Calendar, Filter } from "lucide-react" import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@/components/ui/alert-dialog" import { dataStore } from "@/lib/data-store" export default function PacientesPage() { const [searchTerm, setSearchTerm] = useState("") const [convenioFilter, setConvenioFilter] = useState("all") const [vipFilter, setVipFilter] = useState("all") const [patients, setPatients] = useState(dataStore.getPatients()) const [deleteDialogOpen, setDeleteDialogOpen] = useState(false) const [patientToDelete, setPatientToDelete] = useState(null) useEffect(() => { setPatients(dataStore.getPatients()) }, []) const handleDeletePatient = (patientId: number) => { dataStore.deletePatient(patientId) setPatients(dataStore.getPatients()) setDeleteDialogOpen(false) setPatientToDelete(null) } const openDeleteDialog = (patientId: number) => { setPatientToDelete(patientId) setDeleteDialogOpen(true) } const filteredPatients = patients.filter((patient) => { const matchesSearch = patient.nome?.toLowerCase().includes(searchTerm.toLowerCase()) || patient.telefone?.includes(searchTerm) const matchesConvenio = convenioFilter === "all" || patient.convenio === convenioFilter const matchesVip = vipFilter === "all" || (vipFilter === "vip" && patient.vip) || (vipFilter === "regular" && !patient.vip) return matchesSearch && matchesConvenio && matchesVip }) return (

Pacientes

Gerencie as informações de seus pacientes

Convênio
VIP
Aniversariantes
{filteredPatients.length === 0 ? ( ) : ( filteredPatients.map((patient) => ( )) )}
Nome Telefone Cidade Estado Último atendimento Próximo atendimento Ações
{patients.length === 0 ? "Nenhum paciente cadastrado" : "Nenhum paciente encontrado com os filtros aplicados"}
{patient.nome?.charAt(0) || "?"}
{patient.nome}
{patient.telefone} {patient.cidade} {patient.estado} {patient.ultimoAtendimento} {patient.proximoAtendimento} Ver detalhes Editar Marcar consulta openDeleteDialog(patient.id!)}> Excluir
Confirmar exclusão Tem certeza que deseja excluir este paciente? Esta ação não pode ser desfeita. Cancelar patientToDelete && handleDeletePatient(patientToDelete)} className="bg-red-600 hover:bg-red-700" > Excluir
) }