forked from RiseUP/riseup-squad21
Consertado glitch de pacientes
This commit is contained in:
parent
76125aa2d7
commit
c989c0ec22
@ -8,7 +8,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@
|
|||||||
import { Plus, Edit, Trash2, Eye, Calendar, Filter } from "lucide-react";
|
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 { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";
|
||||||
import SecretaryLayout from "@/components/secretary-layout";
|
import SecretaryLayout from "@/components/secretary-layout";
|
||||||
import { patientsService } from "@/services/patientsApi.mjs"
|
import { patientsService } from "@/services/patientsApi.mjs";
|
||||||
|
|
||||||
export default function PacientesPage() {
|
export default function PacientesPage() {
|
||||||
const [searchTerm, setSearchTerm] = useState("");
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
@ -58,12 +58,12 @@ export default function PacientesPage() {
|
|||||||
|
|
||||||
setPatients((prev) => {
|
setPatients((prev) => {
|
||||||
const all = [...prev, ...mapped];
|
const all = [...prev, ...mapped];
|
||||||
const unique = Array.from(new Map(all.map(p => [p.id, p])).values());
|
const unique = Array.from(new Map(all.map((p) => [p.id, p])).values());
|
||||||
return unique;
|
return unique;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (mapped.length === 0) setHasNext(false); // parar carregamento
|
if (!mapped.id) setHasNext(false); // parar carregamento
|
||||||
else setPage(prev => prev + 1);
|
else setPage((prev) => prev + 1);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
setError(e?.message || "Erro ao buscar pacientes");
|
setError(e?.message || "Erro ao buscar pacientes");
|
||||||
} finally {
|
} finally {
|
||||||
@ -97,12 +97,10 @@ export default function PacientesPage() {
|
|||||||
const res = await patientsService.delete(patientId);
|
const res = await patientsService.delete(patientId);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
alert(`${res.error} ${res.message}`)
|
alert(`${res.error} ${res.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPatients((prev) => prev.filter((p) => String(p.id) !== String(patientId)));
|
setPatients((prev) => prev.filter((p) => String(p.id) !== String(patientId)));
|
||||||
|
|
||||||
|
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
setError(e?.message || "Erro ao deletar paciente");
|
setError(e?.message || "Erro ao deletar paciente");
|
||||||
}
|
}
|
||||||
@ -217,7 +215,6 @@ export default function PacientesPage() {
|
|||||||
<Filter className="w-4 h-4 mr-2" />
|
<Filter className="w-4 h-4 mr-2" />
|
||||||
Filtro avançado
|
Filtro avançado
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="bg-white rounded-lg border border-gray-200">
|
<div className="bg-white rounded-lg border border-gray-200">
|
||||||
@ -325,24 +322,62 @@ export default function PacientesPage() {
|
|||||||
<div className="text-red-600">{patientDetails.error}</div>
|
<div className="text-red-600">{patientDetails.error}</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-2 text-left">
|
<div className="space-y-2 text-left">
|
||||||
<p><strong>Nome:</strong> {patientDetails.full_name}</p>
|
<p>
|
||||||
<p><strong>CPF:</strong> {patientDetails.cpf}</p>
|
<strong>Nome:</strong> {patientDetails.full_name}
|
||||||
<p><strong>Email:</strong> {patientDetails.email}</p>
|
</p>
|
||||||
<p><strong>Telefone:</strong> {patientDetails.phone_mobile ?? patientDetails.phone1 ?? patientDetails.phone2 ?? "-"}</p>
|
<p>
|
||||||
<p><strong>Nome social:</strong> {patientDetails.social_name ?? "-"}</p>
|
<strong>CPF:</strong> {patientDetails.cpf}
|
||||||
<p><strong>Sexo:</strong> {patientDetails.sex ?? "-"}</p>
|
</p>
|
||||||
<p><strong>Tipo sanguíneo:</strong> {patientDetails.blood_type ?? "-"}</p>
|
<p>
|
||||||
<p><strong>Peso:</strong> {patientDetails.weight_kg ?? "-"}{patientDetails.weight_kg ? "kg": ""}</p>
|
<strong>Email:</strong> {patientDetails.email}
|
||||||
<p><strong>Altura:</strong> {patientDetails.height_m ?? "-"}{patientDetails.height_m ? "m": ""}</p>
|
</p>
|
||||||
<p><strong>IMC:</strong> {patientDetails.bmi ?? "-"}</p>
|
<p>
|
||||||
<p><strong>Endereço:</strong> {patientDetails.street ?? "-"}</p>
|
<strong>Telefone:</strong> {patientDetails.phone_mobile ?? patientDetails.phone1 ?? patientDetails.phone2 ?? "-"}
|
||||||
<p><strong>Bairro:</strong> {patientDetails.neighborhood ?? "-"}</p>
|
</p>
|
||||||
<p><strong>Cidade:</strong> {patientDetails.city ?? "-"}</p>
|
<p>
|
||||||
<p><strong>Estado:</strong> {patientDetails.state ?? "-"}</p>
|
<strong>Nome social:</strong> {patientDetails.social_name ?? "-"}
|
||||||
<p><strong>CEP:</strong> {patientDetails.cep ?? "-"}</p>
|
</p>
|
||||||
<p><strong>Criado em:</strong> {patientDetails.created_at ?? "-"}</p>
|
<p>
|
||||||
<p><strong>Atualizado em:</strong> {patientDetails.updated_at ?? "-"}</p>
|
<strong>Sexo:</strong> {patientDetails.sex ?? "-"}
|
||||||
<p><strong>Id:</strong> {patientDetails.id ?? "-"}</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Tipo sanguíneo:</strong> {patientDetails.blood_type ?? "-"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Peso:</strong> {patientDetails.weight_kg ?? "-"}
|
||||||
|
{patientDetails.weight_kg ? "kg" : ""}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Altura:</strong> {patientDetails.height_m ?? "-"}
|
||||||
|
{patientDetails.height_m ? "m" : ""}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>IMC:</strong> {patientDetails.bmi ?? "-"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Endereço:</strong> {patientDetails.street ?? "-"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Bairro:</strong> {patientDetails.neighborhood ?? "-"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Cidade:</strong> {patientDetails.city ?? "-"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Estado:</strong> {patientDetails.state ?? "-"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>CEP:</strong> {patientDetails.cep ?? "-"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Criado em:</strong> {patientDetails.created_at ?? "-"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Atualizado em:</strong> {patientDetails.updated_at ?? "-"}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Id:</strong> {patientDetails.id ?? "-"}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user