Merge pull request 'main' (#16) from StsDanilo/riseup-squad21:main into main

Reviewed-on: RiseUP/riseup-squad21#16
This commit is contained in:
LiraS2 2025-10-02 19:55:38 +00:00
commit 1db117d84c
7 changed files with 155 additions and 122 deletions

View File

@ -10,7 +10,7 @@ export default function HomePage() {
<div className="text-center mb-12"> <div className="text-center mb-12">
<h1 className="text-4xl font-bold text-gray-900 mb-4">Central de Operações <br> <h1 className="text-4xl font-bold text-gray-900 mb-4">Central de Operações <br>
</br> </br>
MidConnecta MedConnect
</h1> </h1>
<p className="text-xl text-gray-600 max-w-2xl mx-auto"> <p className="text-xl text-gray-600 max-w-2xl mx-auto">

View File

@ -10,12 +10,12 @@ export default function InicialPage() {
{} {}
<div className="bg-black text-white text-sm py-2 px-6 flex justify-between"> <div className="bg-black text-white text-sm py-2 px-6 flex justify-between">
<span> Horário: 08h00 - 21h00</span> <span> Horário: 08h00 - 21h00</span>
<span> Email: contato@midconnecta.com</span> <span> Email: contato@medconnect.com</span>
</div> </div>
{} {}
<header className="bg-white shadow-md py-4 px-6 flex justify-between items-center"> <header className="bg-white shadow-md py-4 px-6 flex justify-between items-center">
<h1 className="text-2xl font-bold text-blue-700">MidConnecta</h1> <h1 className="text-2xl font-bold text-blue-700">MedConnect</h1>
<nav className="flex space-x-6 text-gray-700 font-medium"> <nav className="flex space-x-6 text-gray-700 font-medium">
<a href="#home" className="hover:text-blue-600">Home</a> <a href="#home" className="hover:text-blue-600">Home</a>
<a href="#about" className="hover:text-blue-600">Sobre</a> <a href="#about" className="hover:text-blue-600">Sobre</a>
@ -106,7 +106,7 @@ export default function InicialPage() {
{} {}
<footer className="bg-black text-white py-6 text-center"> <footer className="bg-black text-white py-6 text-center">
<p>© 2025 MidConnecta</p> <p>© 2025 MedConnect</p>
</footer> </footer>
</div> </div>
); );

View File

@ -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("");
@ -30,12 +30,12 @@ export default function PacientesPage() {
setPatientDetails(null); setPatientDetails(null);
try { try {
const res = await patientsService.getById(patientId); const res = await patientsService.getById(patientId);
setPatientDetails(res[0]); setPatientDetails(res[0]);
} catch (e: any) { } catch (e: any) {
setPatientDetails({ error: e?.message || "Erro ao buscar detalhes" }); setPatientDetails({ error: e?.message || "Erro ao buscar detalhes" });
} }
}; };
const fetchPacientes = useCallback( const fetchPacientes = useCallback(
async (pageToFetch: number) => { async (pageToFetch: number) => {
if (isFetching || !hasNext) return; if (isFetching || !hasNext) return;
@ -44,26 +44,26 @@ export default function PacientesPage() {
try { try {
const res = await patientsService.list(); const res = await patientsService.list();
const mapped = res.map((p: any) => ({ const mapped = res.map((p: any) => ({
id: String(p.id ?? ""), id: String(p.id ?? ""),
nome: p.full_name ?? "", nome: p.full_name ?? "",
telefone: p.phone_mobile ?? p.phone1 ?? "", telefone: p.phone_mobile ?? p.phone1 ?? "",
cidade: p.city ?? "", cidade: p.city ?? "",
estado: p.state ?? "", estado: p.state ?? "",
ultimoAtendimento: p.last_visit_at ?? "", ultimoAtendimento: p.last_visit_at ?? "",
proximoAtendimento: p.next_appointment_at ?? "", proximoAtendimento: p.next_appointment_at ?? "",
vip: Boolean(p.vip ?? false), vip: Boolean(p.vip ?? false),
convenio: p.convenio ?? "", // se não existir, fica vazio convenio: p.convenio ?? "", // se não existir, fica vazio
status: p.status ?? undefined, status: p.status ?? undefined,
})); }));
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 {
@ -93,16 +93,14 @@ export default function PacientesPage() {
const handleDeletePatient = async (patientId: string) => { const handleDeletePatient = async (patientId: string) => {
// Remove from current list (client-side deletion) // Remove from current list (client-side deletion)
try{ try {
const res = await patientsService.delete(patientId); const res = await patientsService.delete(patientId);
if(res){
alert(`${res.error} ${res.message}`)
}
setPatients((prev) => prev.filter((p) => String(p.id) !== String(patientId)));
if (res) {
alert(`${res.error} ${res.message}`);
}
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");
} }
@ -127,62 +125,62 @@ export default function PacientesPage() {
<SecretaryLayout> <SecretaryLayout>
<div className="space-y-6"> <div className="space-y-6">
<div className="flex flex-col md:flex-row md:items-center md:justify-between gap-4"> <div className="flex flex-col md:flex-row md:items-center md:justify-between gap-4">
<div> <div>
<h1 className="text-xl md:text-2xl font-bold text-gray-900">Pacientes</h1> <h1 className="text-xl md:text-2xl font-bold text-gray-900">Pacientes</h1>
<p className="text-gray-600 text-sm md:text-base">Gerencie as informações de seus pacientes</p> <p className="text-gray-600 text-sm md:text-base">Gerencie as informações de seus pacientes</p>
</div> </div>
<div className="flex gap-2"> <div className="flex gap-2">
<Link href="/secretary/pacientes/novo"> <Link href="/secretary/pacientes/novo">
<Button className="bg-blue-600 hover:bg-blue-700 w-full md:w-auto"> <Button className="bg-blue-600 hover:bg-blue-700 w-full md:w-auto">
<Plus className="w-4 h-4 mr-2" /> <Plus className="w-4 h-4 mr-2" />
Adicionar Adicionar
</Button> </Button>
</Link> </Link>
</div> </div>
</div> </div>
<div className="flex flex-col md:flex-row flex-wrap gap-4 bg-white p-4 rounded-lg border border-gray-200"> <div className="flex flex-col md:flex-row flex-wrap gap-4 bg-white p-4 rounded-lg border border-gray-200">
{/* Convênio */} {/* Convênio */}
<div className="flex items-center gap-2 w-full md:w-auto"> <div className="flex items-center gap-2 w-full md:w-auto">
<span className="text-sm font-medium text-gray-700">Convênio</span> <span className="text-sm font-medium text-gray-700">Convênio</span>
<Select value={convenioFilter} onValueChange={setConvenioFilter}> <Select value={convenioFilter} onValueChange={setConvenioFilter}>
<SelectTrigger className="w-full md:w-40"> <SelectTrigger className="w-full md:w-40">
<SelectValue placeholder="Selecione o Convênio" /> <SelectValue placeholder="Selecione o Convênio" />
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
<SelectItem value="all">Todos</SelectItem> <SelectItem value="all">Todos</SelectItem>
<SelectItem value="Particular">Particular</SelectItem> <SelectItem value="Particular">Particular</SelectItem>
<SelectItem value="SUS">SUS</SelectItem> <SelectItem value="SUS">SUS</SelectItem>
<SelectItem value="Unimed">Unimed</SelectItem> <SelectItem value="Unimed">Unimed</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
</div> </div>
<div className="flex items-center gap-2 w-full md:w-auto"> <div className="flex items-center gap-2 w-full md:w-auto">
<span className="text-sm font-medium text-gray-700">VIP</span> <span className="text-sm font-medium text-gray-700">VIP</span>
<Select value={vipFilter} onValueChange={setVipFilter}> <Select value={vipFilter} onValueChange={setVipFilter}>
<SelectTrigger className="w-full md:w-32"> <SelectTrigger className="w-full md:w-32">
<SelectValue placeholder="Selecione" /> <SelectValue placeholder="Selecione" />
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
<SelectItem value="all">Todos</SelectItem> <SelectItem value="all">Todos</SelectItem>
<SelectItem value="vip">VIP</SelectItem> <SelectItem value="vip">VIP</SelectItem>
<SelectItem value="regular">Regular</SelectItem> <SelectItem value="regular">Regular</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
</div> </div>
<div className="flex items-center gap-2 w-full md:w-auto"> <div className="flex items-center gap-2 w-full md:w-auto">
<span className="text-sm font-medium text-gray-700">Aniversariantes</span> <span className="text-sm font-medium text-gray-700">Aniversariantes</span>
<Select> <Select>
<SelectTrigger className="w-full md:w-32"> <SelectTrigger className="w-full md:w-32">
<SelectValue placeholder="Selecione" /> <SelectValue placeholder="Selecione" />
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
<SelectItem value="today">Hoje</SelectItem> <SelectItem value="today">Hoje</SelectItem>
<SelectItem value="week">Esta semana</SelectItem> <SelectItem value="week">Esta semana</SelectItem>
<SelectItem value="month">Este mês</SelectItem> <SelectItem value="month">Este mês</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
</div> </div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
@ -213,28 +211,27 @@ export default function PacientesPage() {
</Select> </Select>
</div> </div>
<Button variant="outline" className="ml-auto bg-transparent w-full md:w-auto"> <Button variant="outline" className="ml-auto bg-transparent w-full md:w-auto">
<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">
<div className="overflow-x-auto"> <div className="overflow-x-auto">
{error ? ( {error ? (
<div className="p-6 text-red-600">{`Erro ao carregar pacientes: ${error}`}</div> <div className="p-6 text-red-600">{`Erro ao carregar pacientes: ${error}`}</div>
) : ( ) : (
<table className="w-full min-w-[600px]"> <table className="w-full min-w-[600px]">
<thead className="bg-gray-50 border-b border-gray-200"> <thead className="bg-gray-50 border-b border-gray-200">
<tr> <tr>
<th className="text-left p-2 md:p-4 font-medium text-gray-700">Nome</th> <th className="text-left p-2 md:p-4 font-medium text-gray-700">Nome</th>
<th className="text-left p-2 md:p-4 font-medium text-gray-700">Telefone</th> <th className="text-left p-2 md:p-4 font-medium text-gray-700">Telefone</th>
<th className="text-left p-2 md:p-4 font-medium text-gray-700">Cidade</th> <th className="text-left p-2 md:p-4 font-medium text-gray-700">Cidade</th>
<th className="text-left p-2 md:p-4 font-medium text-gray-700">Estado</th> <th className="text-left p-2 md:p-4 font-medium text-gray-700">Estado</th>
<th className="text-left p-2 md:p-4 font-medium text-gray-700">Último atendimento</th> <th className="text-left p-2 md:p-4 font-medium text-gray-700">Último atendimento</th>
<th className="text-left p-2 md:p-4 font-medium text-gray-700">Próximo atendimento</th> <th className="text-left p-2 md:p-4 font-medium text-gray-700">Próximo atendimento</th>
<th className="text-left p-2 md:p-4 font-medium text-gray-700">Ações</th> <th className="text-left p-2 md:p-4 font-medium text-gray-700">Ações</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -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>

View File

@ -158,7 +158,7 @@ useEffect(() => {
<div className="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center"> <div className="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center">
<div className="w-4 h-4 bg-white rounded-sm"></div> <div className="w-4 h-4 bg-white rounded-sm"></div>
</div> </div>
<span className="font-semibold text-gray-900">Hospital System</span> <span className="font-semibold text-gray-900">MedConnect</span>
</div> </div>
)} )}
<Button variant="ghost" size="sm" onClick={() => setSidebarCollapsed(!sidebarCollapsed)} className="p-1"> <Button variant="ghost" size="sm" onClick={() => setSidebarCollapsed(!sidebarCollapsed)} className="p-1">

View File

@ -123,7 +123,7 @@ export default function HospitalLayout({ children }: HospitalLayoutProps) {
<div className="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center"> <div className="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center">
<div className="w-4 h-4 bg-white rounded-sm"></div> <div className="w-4 h-4 bg-white rounded-sm"></div>
</div> </div>
<span className="font-semibold text-gray-900">Hospital System</span> <span className="font-semibold text-gray-900">MedConnect</span>
</div> </div>
)} )}
<Button variant="ghost" size="sm" onClick={() => setSidebarCollapsed(!sidebarCollapsed)} className="p-1"> <Button variant="ghost" size="sm" onClick={() => setSidebarCollapsed(!sidebarCollapsed)} className="p-1">

View File

@ -112,9 +112,7 @@ export default function HospitalLayout({ children }: HospitalLayoutProps) {
<div className="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center"> <div className="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center">
<div className="w-4 h-4 bg-white rounded-sm"></div> <div className="w-4 h-4 bg-white rounded-sm"></div>
</div> </div>
<span className="font-semibold text-gray-900"> <span className="font-semibold text-gray-900">MedConnect</span>
MidConnecta
</span>
</div> </div>
)} )}
<Button <Button

View File

@ -105,7 +105,7 @@ export default function SecretaryLayout({ children }: PatientLayoutProps) {
<div className="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center"> <div className="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center">
<div className="w-4 h-4 bg-white rounded-sm"></div> <div className="w-4 h-4 bg-white rounded-sm"></div>
</div> </div>
<span className="font-semibold text-gray-900">MidConnecta</span> <span className="font-semibold text-gray-900">MedConnect</span>
</div> </div>
)} )}
<Button <Button