diff --git a/susconecta/app/(main-routes)/consultas/page.tsx b/susconecta/app/(main-routes)/consultas/page.tsx index 74c66fa..ff03be3 100644 --- a/susconecta/app/(main-routes)/consultas/page.tsx +++ b/susconecta/app/(main-routes)/consultas/page.tsx @@ -9,6 +9,7 @@ import { Eye, Edit, Trash2, + ArrowLeft, } from "lucide-react"; import { Badge } from "@/components/ui/badge"; @@ -43,11 +44,10 @@ import { SelectValue, } from "@/components/ui/select"; -import { - mockAppointments, - mockProfessionals, -} from "@/lib/mocks/appointment-mocks"; +import { mockAppointments, mockProfessionals } from "@/lib/mocks/appointment-mocks"; +import { AppointmentForm } from "@/components/forms/appointment-form"; +// --- Helper Functions --- const formatDate = (date: string | Date) => { return new Date(date).toLocaleDateString("pt-BR", { day: "2-digit", @@ -60,8 +60,38 @@ const formatDate = (date: string | Date) => { const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1); +// --- Main Page Component --- export default function ConsultasPage() { const [appointments, setAppointments] = useState(mockAppointments); + const [showForm, setShowForm] = useState(false); + const [editingAppointment, setEditingAppointment] = useState(null); + + // Converte o objeto da consulta para o formato esperado pelo formulário + const mapAppointmentToFormData = (appointment: any) => { + const professional = mockProfessionals.find(p => p.id === appointment.professional); + const appointmentDate = new Date(appointment.time); + + return { + id: appointment.id, + patientName: appointment.patient, + professionalName: professional ? professional.name : '', + appointmentDate: appointmentDate.toISOString().split('T')[0], // Formato YYYY-MM-DD + startTime: appointmentDate.toTimeString().split(' ')[0].substring(0, 5), // Formato HH:MM + endTime: new Date(appointmentDate.getTime() + appointment.duration * 60000).toTimeString().split(' ')[0].substring(0, 5), + status: appointment.status, + appointmentType: appointment.type, + notes: appointment.notes, + // Adicione outros campos do paciente aqui se necessário (cpf, rg, etc.) + // Eles não existem no mock de agendamento, então virão vazios + cpf: '', + rg: '', + birthDate: '', + phoneCode: '+55', + phoneNumber: '', + email: '', + unit: 'nei', + }; + }; const handleDelete = (appointmentId: string) => { if (window.confirm("Tem certeza que deseja excluir esta consulta?")) { @@ -69,6 +99,56 @@ export default function ConsultasPage() { } }; + const handleEdit = (appointment: any) => { + const formData = mapAppointmentToFormData(appointment); + setEditingAppointment(formData); + setShowForm(true); + }; + + const handleCancel = () => { + setEditingAppointment(null); + setShowForm(false); + }; + + const handleSave = (formData: any) => { + // Como o formulário edita campos que não estão na tabela, + // precisamos mapear de volta para o formato original do agendamento. + // Para a simulação, vamos atualizar apenas os campos que existem no mock. + const updatedAppointment = { + id: formData.id, + patient: formData.patientName, + time: new Date(`${formData.appointmentDate}T${formData.startTime}`).toISOString(), + duration: 30, // Duração não está no form, então mantemos um valor fixo + type: formData.appointmentType as any, + status: formData.status as any, + professional: appointments.find(a => a.id === formData.id)?.professional || '', // Mantém o ID do profissional + notes: formData.notes, + }; + + setAppointments(prev => + prev.map(a => a.id === updatedAppointment.id ? updatedAppointment : a) + ); + handleCancel(); // Fecha o formulário + }; + + if (showForm && editingAppointment) { + return ( +
+
+ +

Editar Consulta

+
+ +
+ ) + } + return (
@@ -176,9 +256,7 @@ export default function ConsultasPage() { Ver - alert(`Editando: ${appointment.patient}`)} - > + handleEdit(appointment)}> Editar @@ -201,4 +279,4 @@ export default function ConsultasPage() {
); -} +} \ No newline at end of file diff --git a/susconecta/app/agenda/page.tsx b/susconecta/app/agenda/page.tsx index 1cf8b4e..7c6fabb 100644 --- a/susconecta/app/agenda/page.tsx +++ b/susconecta/app/agenda/page.tsx @@ -1,373 +1,35 @@ "use client"; -import { useState } from "react"; -import Link from "next/link"; -import { usePathname, useRouter } from "next/navigation"; - -import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; -import { Textarea } from "@/components/ui/textarea"; -import { Switch } from "@/components/ui/switch"; -import { Calendar } from "lucide-react"; - -import { - RotateCcw, - Accessibility, - Volume2, - Flame, - Settings, - Clipboard, - Search, - ChevronDown, - Upload, - FileDown, - Tag, - Save, -} from "lucide-react"; +import { useRouter } from "next/navigation"; +import { AppointmentForm } from "@/components/forms/appointment-form"; import HeaderAgenda from "@/components/agenda/HeaderAgenda"; import FooterAgenda from "@/components/agenda/FooterAgenda"; export default function NovoAgendamentoPage() { - const [bloqueio, setBloqueio] = useState(false); + const router = useRouter(); + + const handleSave = (data: any) => { + console.log("Salvando novo agendamento...", data); + // Aqui viria a chamada da API para criar um novo agendamento + alert("Novo agendamento salvo (simulado)!"); + router.push("/consultas"); // Volta para a lista após salvar + }; + + const handleCancel = () => { + router.back(); // Simplesmente volta para a página anterior + }; return ( - // ====== WRAPPER COM ESPAÇAMENTO GERAL ======
- {/* HEADER fora do
, usando o MESMO container do footer */} - - {/* Conteúdo */} -
- {/* ==== INFORMAÇÕES DO PACIENTE — layout idêntico ao print ==== */} -
-

Informações do paciente

- - {/* grade principal: 12 colunas para controlar as larguras */} -
- {/* ===== Linha 1 ===== */} -
- -
- - -
-
- -
- - -
- -
- - -
- - {/* ===== Linha 2 ===== */} - {/* 1ª coluna (span 6) com sub-grid: Data (5 col) + Telefone (7 col) */} -
-
-
- - -
- -
- -
- - -
-
-
-
- - {/* 2ª coluna da linha 2: E-mail (span 6) */} -
- - -
- - {/* ===== Linha 3 ===== */} -
- -
- - -
-
- -
-
- - -
-
- - -
-
-
- - {/* link Informações adicionais */} - - - {/* barra Documentos e anexos */} -
- Documentos e anexos -
- - - -
-
-
- - {/* ==== INFORMAÇÕES DO ATENDIMENTO ==== */} -
-

Informações do atendimento

- - {/* GRID PRINCIPAL: 12 colunas */} -
- {/* COLUNA ESQUERDA (span 6) */} -
- {/* Nome do profissional */} -
- -
- - - - RA - -
-
- -
- {/* Unidade */} -
- - -
- - {/* Data com ícone */} -
- -
- - -
-
-
- - {/* Início / Término / Profissional solicitante (na mesma linha) */} -
- {/* Início (maior) */} -
- - -
- - {/* Término (maior) */} -
- - -
- - {/* Profissional solicitante */} -
- -
- {/* ícone de busca à esquerda */} - - - - - - - - - - -
-
-
-
- - {/* COLUNA DIREITA — altura/posição como a imagem 1 */} -
- {/* toolbar */} -
- - - - - -
- - {/* Tipo de atendimento + campo de busca */} -
-
- - -
- -
- - - -
-
- - {/* Observações + imprimir */} -
- - -
- - {/* Textarea mais baixo e compacto */} -