diff --git a/app/manager/pacientes/[id]/editar/page.tsx b/app/manager/pacientes/[id]/editar/page.tsx index ab6d7e0..73d061a 100644 --- a/app/manager/pacientes/[id]/editar/page.tsx +++ b/app/manager/pacientes/[id]/editar/page.tsx @@ -31,34 +31,35 @@ export default function EditarPacientePage() { const [isUploadingAnexo, setIsUploadingAnexo] = useState(false); const anexoInputRef = useRef(null); + // Tipagem completa do formulário type FormData = { - nome: string; // full_name + nome: string; cpf: string; - dataNascimento: string; // birth_date - sexo: string; // sex + dataNascimento: string; + sexo: string; id?: string; - nomeSocial?: string; // social_name + nomeSocial?: string; rg?: string; - documentType?: string; // document_type - documentNumber?: string; // document_number + documentType?: string; + documentNumber?: string; ethnicity?: string; race?: string; naturality?: string; nationality?: string; profession?: string; - maritalStatus?: string; // marital_status - motherName?: string; // mother_name - motherProfession?: string; // mother_profession - fatherName?: string; // father_name - fatherProfession?: string; // father_profession - guardianName?: string; // guardian_name - guardianCpf?: string; // guardian_cpf - spouseName?: string; // spouse_name - rnInInsurance?: boolean; // rn_in_insurance - legacyCode?: string; // legacy_code + maritalStatus?: string; + motherName?: string; + motherProfession?: string; + fatherName?: string; + fatherProfession?: string; + guardianName?: string; + guardianCpf?: string; + spouseName?: string; + rnInInsurance?: boolean; + legacyCode?: string; notes?: string; email?: string; - phoneMobile?: string; // phone_mobile + phoneMobile?: string; phone1?: string; phone2?: string; cep?: string; @@ -82,7 +83,6 @@ export default function EditarPacientePage() { bloodType?: string; }; - const [formData, setFormData] = useState({ nome: "", cpf: "", @@ -141,7 +141,6 @@ export default function EditarPacientePage() { async function fetchPatient() { try { const res = await patientsService.getById(patientId); - // Map API snake_case/nested to local camelCase form setFormData({ id: res[0]?.id ?? "", nome: res[0]?.full_name ?? "", @@ -206,7 +205,6 @@ export default function EditarPacientePage() { const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); - // Build API payload (snake_case) const payload = { full_name: formData.nome || null, cpf: formData.cpf || null, @@ -247,25 +245,28 @@ export default function EditarPacientePage() { return ( -
-
- - - -
-

Editar Paciente

-

Atualize as informações do paciente

+
+ {/* --- HEADER RESPONSIVO --- */} +
+
+ + + +
+

Editar Paciente

+

Atualize as informações do paciente

+
{/* Anexos Section */} -
-

Anexos

+
+

Anexos

-
@@ -279,7 +280,7 @@ export default function EditarPacientePage() { {a.nome || a.filename || `Anexo ${a.id}`}
- @@ -289,36 +290,38 @@ export default function EditarPacientePage() {
-
-
-

Dados Pessoais

+ + {/* --- DADOS PESSOAIS --- */} +
+

Dados Pessoais

-
- {/* Photo upload */} -
+
+ {/* Photo upload Responsivo */} +
-
-
+
+
{photoUrl ? ( // eslint-disable-next-line @next/next/no-img-element Foto do paciente ) : ( - Sem foto + Sem foto )}
-
+
- {photoUrl && ( - )}
+
handleInputChange("nome", e.target.value)} required /> @@ -336,7 +339,7 @@ export default function EditarPacientePage() {
-
+
handleInputChange("sexo", e.target.value)} className="w-4 h-4 text-primary" /> @@ -353,12 +356,11 @@ export default function EditarPacientePage() { handleInputChange("dataNascimento", e.target.value)} required />
+ {/* Demais campos de select e input */}
handleInputChange("race", value)}> - - - + Caucasiana Negroide @@ -391,9 +391,7 @@ export default function EditarPacientePage() {
handleInputChange("maritalStatus", value)}> - - - + Solteiro(a) Casado(a) @@ -470,26 +466,22 @@ export default function EditarPacientePage() {
- {/* Contact Section */} -
-

Contato

- -
+ {/* --- CONTATO --- */} +
+

Contato

+
handleInputChange("email", e.target.value)} required/>
-
handleInputChange("phoneMobile", e.target.value)} placeholder="(00) 00000-0000" required/>
-
handleInputChange("phone1", e.target.value)} placeholder="(00) 0000-0000" />
-
handleInputChange("phone2", e.target.value)} placeholder="(00) 0000-0000" /> @@ -497,47 +489,38 @@ export default function EditarPacientePage() {
- {/* Address Section */} -
-

Endereço

- -
+ {/* --- ENDEREÇO --- */} +
+

Endereço

+
handleInputChange("cep", e.target.value)} placeholder="00000-000" />
- -
+
handleInputChange("street", e.target.value)} />
-
handleInputChange("number", e.target.value)} />
-
handleInputChange("complement", e.target.value)} />
-
handleInputChange("neighborhood", e.target.value)} />
-
handleInputChange("city", e.target.value)} />
-
handleInputChange("bloodType", value)}> - - - + A+ A- @@ -595,40 +575,33 @@ export default function EditarPacientePage() {
-
handleInputChange("weightKg", e.target.value)} placeholder="0.0" />
-
handleInputChange("heightM", e.target.value)} placeholder="0.00" />
-
-