Compare commits
13 Commits
feature/au
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c633f57fd | |||
| 17a69ed57b | |||
| 94c0dd13dc | |||
| 7a9f2b3da2 | |||
| cfd4790bf1 | |||
| eff11fc075 | |||
| 6f3a49575c | |||
| 07ed113291 | |||
| 0de772457e | |||
| c736f44604 | |||
| 3b8e73535b | |||
| e5e5d0928b | |||
| e5f260e7c3 |
633
package-lock.json
generated
633
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -14,6 +14,7 @@
|
|||||||
"@fullcalendar/react": "^6.1.19",
|
"@fullcalendar/react": "^6.1.19",
|
||||||
"@fullcalendar/timegrid": "^6.1.19",
|
"@fullcalendar/timegrid": "^6.1.19",
|
||||||
"@jitsi/react-sdk": "^1.4.0",
|
"@jitsi/react-sdk": "^1.4.0",
|
||||||
|
"@supabase/supabase-js": "^2.86.0",
|
||||||
"@sweetalert2/theme-dark": "^5.0.27",
|
"@sweetalert2/theme-dark": "^5.0.27",
|
||||||
"@testing-library/dom": "^10.4.1",
|
"@testing-library/dom": "^10.4.1",
|
||||||
"@testing-library/jest-dom": "^6.8.0",
|
"@testing-library/jest-dom": "^6.8.0",
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useMemo, useEffect, useCallback } from "react";
|
import React, { useState, useMemo, useEffect, useCallback } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import API_KEY from "../components/utils/apiKeys.js";
|
import API_KEY from "../components/utils/apiKeys.js";
|
||||||
import AgendamentoCadastroManager from "../pages/AgendamentoCadastroManager.jsx";
|
import AgendamentoCadastroManager from "../pages/AgendamentoCadastroManager.jsx";
|
||||||
@ -15,6 +15,7 @@ import {
|
|||||||
Edit,
|
Edit,
|
||||||
Trash2,
|
Trash2,
|
||||||
CheckCircle,
|
CheckCircle,
|
||||||
|
FileText,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import "../pages/style/Agendamento.css";
|
import "../pages/style/Agendamento.css";
|
||||||
import "../pages/style/FilaEspera.css";
|
import "../pages/style/FilaEspera.css";
|
||||||
@ -29,7 +30,8 @@ const Agendamento = () => {
|
|||||||
const { getAuthorizationHeader, user } = useAuth();
|
const { getAuthorizationHeader, user } = useAuth();
|
||||||
const authHeader = getAuthorizationHeader();
|
const authHeader = getAuthorizationHeader();
|
||||||
|
|
||||||
const ID_MEDICO_ESPECIFICO = "078d2a67-b4c1-43c8-ae32-c1e75bb5b3df";
|
const ID_MEDICO_ESPECIFICO = "31689310-b76c-4ecb-9027-ef6deb71b08d";
|
||||||
|
|
||||||
|
|
||||||
const [listaTodosAgendamentos, setListaTodosAgendamentos] = useState([]);
|
const [listaTodosAgendamentos, setListaTodosAgendamentos] = useState([]);
|
||||||
const [selectedID, setSelectedId] = useState("0");
|
const [selectedID, setSelectedId] = useState("0");
|
||||||
@ -39,12 +41,16 @@ const Agendamento = () => {
|
|||||||
const [DictAgendamentosOrganizados, setAgendamentosOrganizados] = useState(
|
const [DictAgendamentosOrganizados, setAgendamentosOrganizados] = useState(
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||||
const [ListaDeMedicos, setListaDeMedicos] = useState([]);
|
const [ListaDeMedicos, setListaDeMedicos] = useState([]);
|
||||||
const [FiltredTodosMedicos, setFiltredTodosMedicos] = useState([]);
|
const [FiltredTodosMedicos, setFiltredTodosMedicos] = useState([]);
|
||||||
const [searchTermDoctor, setSearchTermDoctor] = useState("");
|
const [searchTermDoctor, setSearchTermDoctor] = useState("");
|
||||||
const [MedicoFiltrado, setMedicoFiltrado] = useState({ id: "vazio" });
|
const [MedicoFiltrado, setMedicoFiltrado] = useState({ id: "vazio" });
|
||||||
const [motivoCancelamento, setMotivoCancelamento] = useState("");
|
const [motivoCancelamento, setMotivoCancelamento] = useState("");
|
||||||
|
const [searchTermPatient, setSearchTermPatient] = useState("");
|
||||||
|
const [patientDropdownOpen, setPatientDropdownOpen] = useState(false);
|
||||||
const [showSpinner, setShowSpinner] = useState(true);
|
const [showSpinner, setShowSpinner] = useState(true);
|
||||||
const [waitlistSearch, setWaitlistSearch] = useState("");
|
const [waitlistSearch, setWaitlistSearch] = useState("");
|
||||||
const [waitSortKey, setWaitSortKey] = useState(null);
|
const [waitSortKey, setWaitSortKey] = useState(null);
|
||||||
@ -290,6 +296,18 @@ const Agendamento = () => {
|
|||||||
setPageConsulta(true);
|
setPageConsulta(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCreateReport = (appointment) => {
|
||||||
|
navigate("/medico/novo-relatorio", {
|
||||||
|
state: {
|
||||||
|
appointment,
|
||||||
|
patient_id: appointment.patient_id,
|
||||||
|
doctor_id: appointment.doctor_id,
|
||||||
|
paciente_nome: appointment.paciente_nome,
|
||||||
|
medico_nome: appointment.medico_nome,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleSearchMedicos = (term) => {
|
const handleSearchMedicos = (term) => {
|
||||||
setSearchTermDoctor(term);
|
setSearchTermDoctor(term);
|
||||||
if (term.trim()) {
|
if (term.trim()) {
|
||||||
@ -302,6 +320,14 @@ const Agendamento = () => {
|
|||||||
setMedicoFiltrado({ id: "vazio" });
|
setMedicoFiltrado({ id: "vazio" });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const filtrarPorPaciente = (appointments) => {
|
||||||
|
if (!searchTermPatient.trim()) return appointments;
|
||||||
|
const term = searchTermPatient.toLowerCase();
|
||||||
|
return appointments.filter((app) =>
|
||||||
|
app.paciente_nome?.toLowerCase().includes(term)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const generateDateGrid = () => {
|
const generateDateGrid = () => {
|
||||||
const grid = [];
|
const grid = [];
|
||||||
@ -411,6 +437,13 @@ const Agendamento = () => {
|
|||||||
() => applySortingWaitlist(filaEsperaFiltrada),
|
() => applySortingWaitlist(filaEsperaFiltrada),
|
||||||
[filaEsperaFiltrada, applySortingWaitlist]
|
[filaEsperaFiltrada, applySortingWaitlist]
|
||||||
);
|
);
|
||||||
|
const listaPacientesUnicos = useMemo(() => {
|
||||||
|
const pacientes = Object.values(cachePacientes || {});
|
||||||
|
return pacientes.sort((a, b) =>
|
||||||
|
(a.full_name || "").localeCompare(b.full_name || "")
|
||||||
|
);
|
||||||
|
}, [cachePacientes]);
|
||||||
|
|
||||||
const waitTotalPages =
|
const waitTotalPages =
|
||||||
Math.ceil(filaEsperaOrdenada.length / waitPerPage) || 1;
|
Math.ceil(filaEsperaOrdenada.length / waitPerPage) || 1;
|
||||||
const waitIndiceInicial = (waitPage - 1) * waitPerPage;
|
const waitIndiceInicial = (waitPage - 1) * waitPerPage;
|
||||||
@ -449,71 +482,11 @@ const Agendamento = () => {
|
|||||||
<h1>Agendar nova consulta</h1>
|
<h1>Agendar nova consulta</h1>
|
||||||
{!PageNovaConsulta ? (
|
{!PageNovaConsulta ? (
|
||||||
<div className="atendimento-eprocura">
|
<div className="atendimento-eprocura">
|
||||||
{user?.role !== "doctor" && (
|
|
||||||
<div className="card p-3 mb-3 table-paciente-filters">
|
|
||||||
<h5 className="mb-3">
|
|
||||||
<i className="bi bi-funnel-fill me-2 text-primary"></i>
|
|
||||||
Filtrar por Médico
|
|
||||||
</h5>
|
|
||||||
<div className="position-relative">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control"
|
|
||||||
placeholder="Digite o nome do médico..."
|
|
||||||
value={searchTermDoctor}
|
|
||||||
onChange={(e) => handleSearchMedicos(e.target.value)}
|
|
||||||
/>
|
|
||||||
<small className="text-muted">
|
|
||||||
Buscar médico para filtrar consultas
|
|
||||||
</small>
|
|
||||||
|
|
||||||
{searchTermDoctor && FiltredTodosMedicos.length > 0 && (
|
|
||||||
<div
|
|
||||||
className="list-group position-absolute w-100"
|
|
||||||
style={{
|
|
||||||
zIndex: 1000,
|
|
||||||
maxHeight: "200px",
|
|
||||||
overflowY: "auto",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{FiltredTodosMedicos.map((medico) => (
|
|
||||||
<button
|
|
||||||
key={medico.idMedico}
|
|
||||||
type="button"
|
|
||||||
className="list-group-item list-group-item-action"
|
|
||||||
onClick={() => {
|
|
||||||
setSearchTermDoctor(medico.nomeMedico);
|
|
||||||
setFiltredTodosMedicos([]);
|
|
||||||
setMedicoFiltrado({ id: medico.idMedico });
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{medico.nomeMedico}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{MedicoFiltrado.id !== "vazio" && (
|
|
||||||
<div className="mt-3">
|
|
||||||
<span className="badge bg-primary me-2">
|
|
||||||
<i className="bi bi-person-check me-1"></i>
|
|
||||||
{searchTermDoctor}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn-close btn-close-white ms-2"
|
|
||||||
style={{ fontSize: "0.6rem" }}
|
|
||||||
onClick={() => {
|
|
||||||
setMedicoFiltrado({ id: "vazio" });
|
|
||||||
setSearchTermDoctor("");
|
|
||||||
}}
|
|
||||||
></button>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div className="container-btns-agenda-fila_esepera">
|
<div className="container-btns-agenda-fila_esepera">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className="tabs-agenda-fila">
|
<div className="tabs-agenda-fila">
|
||||||
<button
|
<button
|
||||||
className={`btn-agenda ${
|
className={`btn-agenda ${
|
||||||
@ -538,7 +511,7 @@ const Agendamento = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="btns-gerenciamento-e-consulta"
|
className="btns-gerenciamento-e-consulta"
|
||||||
style={{ display: "flex", gap: "10px", marginBottom: "20px" }}
|
style={{ display: "flex", gap: "10px" }}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
className="btn btn-primary"
|
className="btn btn-primary"
|
||||||
@ -575,99 +548,201 @@ const Agendamento = () => {
|
|||||||
<div className="info-details">
|
<div className="info-details">
|
||||||
<h3>{selectedDay.format("dddd")}</h3>
|
<h3>{selectedDay.format("dddd")}</h3>
|
||||||
<p>{selectedDay.format("D [de] MMMM [de] YYYY")}</p>
|
<p>{selectedDay.format("D [de] MMMM [de] YYYY")}</p>
|
||||||
|
<div className="calendar-legend">
|
||||||
|
<div className="legend-item" data-status="completed">Realizado</div>
|
||||||
|
<div className="legend-item" data-status="confirmed">Confirmado</div>
|
||||||
|
<div className="legend-item" data-status="agendado">Agendado</div>
|
||||||
|
<div className="legend-item" data-status="cancelled">Cancelado</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div className="appointments-list">
|
<div className="appointments-list">
|
||||||
<h4>Consultas para {selectedDay.format("DD/MM")}</h4>
|
<h4>Consultas para {selectedDay.format("DD/MM")}</h4>
|
||||||
{showSpinner ? (
|
{showSpinner ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : DictAgendamentosOrganizados[
|
) : (() => {
|
||||||
selectedDay.format("YYYY-MM-DD")
|
const appointmentsForDay =
|
||||||
]?.filter(
|
DictAgendamentosOrganizados[selectedDay.format("YYYY-MM-DD")] || [];
|
||||||
(app) =>
|
|
||||||
MedicoFiltrado.id === "vazio" ||
|
// 1º filtro: por médico (se tiver)
|
||||||
app.doctor_id === MedicoFiltrado.id
|
const filteredByDoctor = appointmentsForDay.filter(
|
||||||
).length > 0 ? (
|
(app) =>
|
||||||
DictAgendamentosOrganizados[
|
MedicoFiltrado.id === "vazio" ||
|
||||||
selectedDay.format("YYYY-MM-DD")
|
app.doctor_id === MedicoFiltrado.id
|
||||||
]
|
);
|
||||||
.filter(
|
|
||||||
(app) =>
|
// 2º filtro: por paciente (campo de cima)
|
||||||
MedicoFiltrado.id === "vazio" ||
|
const filteredByPatient = filtrarPorPaciente(filteredByDoctor);
|
||||||
app.doctor_id === MedicoFiltrado.id
|
|
||||||
)
|
if (filteredByPatient.length === 0) {
|
||||||
.map((app) => (
|
return (
|
||||||
<div
|
<div className="no-appointments-info">
|
||||||
key={app.id}
|
<p>
|
||||||
className="appointment-item"
|
{searchTermPatient
|
||||||
data-status={app.status}
|
? `Nenhuma consulta encontrada para "${searchTermPatient}".`
|
||||||
>
|
: "Nenhuma consulta agendada."}
|
||||||
<div className="item-time">
|
</p>
|
||||||
{dayjs(app.scheduled_at).format("HH:mm")}
|
</div>
|
||||||
</div>
|
);
|
||||||
<div className="item-details">
|
}
|
||||||
<span>{app.paciente_nome}</span>
|
|
||||||
<small>Dr(a). {app.medico_nome}</small>
|
return filteredByPatient.map((app) => (
|
||||||
</div>
|
<div
|
||||||
<div className="appointment-actions">
|
key={app.id}
|
||||||
{app.status === "cancelled" ? (
|
className="appointment-item"
|
||||||
<button
|
data-status={app.status}
|
||||||
className="btn-action btn-edit"
|
>
|
||||||
onClick={() => {
|
<div className="item-time">
|
||||||
setSelectedId(app.id);
|
{dayjs(app.scheduled_at).add(3, "hour").format("HH:mm")}
|
||||||
confirmConsulta(app.id);
|
</div>
|
||||||
}}
|
<div className="item-details">
|
||||||
>
|
<span>{app.paciente_nome}</span>
|
||||||
<CheckCircle
|
<small>Dr(a). {app.medico_nome}</small>
|
||||||
size={16}
|
</div>
|
||||||
title="Reverter Cancelamento"
|
<div className="appointment-actions">
|
||||||
/>
|
{app.status === "cancelled" ? (
|
||||||
</button>
|
<button
|
||||||
) : (
|
className="btn-action btn-edit"
|
||||||
<button
|
onClick={() => {
|
||||||
className="btn-action btn-edit"
|
setSelectedId(app.id);
|
||||||
onClick={() => handleEditConsulta(app)}
|
confirmConsulta(app.id);
|
||||||
title="Editar Agendamento"
|
}}
|
||||||
>
|
>
|
||||||
<Edit size={16} />
|
<CheckCircle
|
||||||
</button>
|
size={16}
|
||||||
)}
|
title="Reverter Cancelamento"
|
||||||
{app.status !== "cancelled" && (
|
/>
|
||||||
<button
|
</button>
|
||||||
className="btn-action btn-delete"
|
) : (
|
||||||
onClick={() => {
|
<button
|
||||||
setSelectedId(app.id);
|
className="btn-action btn-edit"
|
||||||
setShowDeleteModal(true);
|
onClick={() => handleEditConsulta(app)}
|
||||||
}}
|
title="Editar Agendamento"
|
||||||
title="Cancelar Agendamento"
|
>
|
||||||
>
|
<Edit size={16} />
|
||||||
<Trash2 size={16} />
|
</button>
|
||||||
</button>
|
)}
|
||||||
)}
|
{app.status !== "cancelled" && (
|
||||||
</div>
|
<button
|
||||||
</div>
|
className="btn-action btn-report-blue"
|
||||||
))
|
onClick={() => handleCreateReport(app)}
|
||||||
) : (
|
title="Criar Relatório / Laudo"
|
||||||
<div className="no-appointments-info">
|
aria-label={`Criar relatório para ${app.paciente_nome}`}
|
||||||
<p>Nenhuma consulta agendada.</p>
|
>
|
||||||
</div>
|
<FileText size={16} />
|
||||||
)}
|
</button>
|
||||||
|
)}
|
||||||
|
{app.status !== "cancelled" && (
|
||||||
|
<button
|
||||||
|
className="btn-action btn-delete"
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedId(app.id);
|
||||||
|
setShowDeleteModal(true);
|
||||||
|
}}
|
||||||
|
title="Cancelar Agendamento"
|
||||||
|
>
|
||||||
|
<Trash2 size={16} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
));
|
||||||
|
})()}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="calendar-main">
|
<div className="calendar-main">
|
||||||
|
<div className="patient-filter-container" style={{ marginBottom: "20px" }}>
|
||||||
|
<div className="card p-3">
|
||||||
|
<div className="filter-header d-flex align-items-center gap-2 mb-2">
|
||||||
|
<i className="bi bi-funnel-fill text-primary"></i>
|
||||||
|
<h5 className="mb-0">Filtrar por Paciente</h5>
|
||||||
|
</div>
|
||||||
|
<div className="position-relative">
|
||||||
|
<Search
|
||||||
|
size={20}
|
||||||
|
className="position-absolute"
|
||||||
|
style={{ left: "10px", top: "50%", transform: "translateY(-50%)", color: "#6c757d" }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control ps-5"
|
||||||
|
placeholder="Buscar paciente para filtrar consultas"
|
||||||
|
value={searchTermPatient}
|
||||||
|
onChange={(e) => {
|
||||||
|
setSearchTermPatient(e.target.value);
|
||||||
|
setPatientDropdownOpen(true);
|
||||||
|
}}
|
||||||
|
onFocus={() => {
|
||||||
|
if (searchTermPatient.trim()) {
|
||||||
|
setPatientDropdownOpen(true);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
style={{ paddingLeft: "40px" }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{patientDropdownOpen && searchTermPatient.trim() && (
|
||||||
|
<div
|
||||||
|
className="patient-suggestions"
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
top: "100%",
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
zIndex: 10,
|
||||||
|
backgroundColor: "white",
|
||||||
|
border: "1px solid #ced4da",
|
||||||
|
borderTop: "none",
|
||||||
|
maxHeight: "250px",
|
||||||
|
overflowY: "auto",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{listaPacientesUnicos
|
||||||
|
.filter((p) => {
|
||||||
|
const nome = (p.full_name || "").toLowerCase();
|
||||||
|
const term = searchTermPatient.toLowerCase();
|
||||||
|
return nome.startsWith(term); // só começo do nome
|
||||||
|
})
|
||||||
|
.slice(0, 20)
|
||||||
|
.map((p) => (
|
||||||
|
<button
|
||||||
|
key={p.id}
|
||||||
|
type="button"
|
||||||
|
className="w-100 text-start px-3 py-1"
|
||||||
|
style={{
|
||||||
|
border: "none",
|
||||||
|
background: "white",
|
||||||
|
fontSize: "0.9rem",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
setSearchTermPatient(p.full_name);
|
||||||
|
setPatientDropdownOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{p.full_name} - {p.cpf}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{searchTermPatient && (
|
||||||
|
<div className="mt-2">
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-outline-secondary"
|
||||||
|
onClick={() => setSearchTermPatient("")}
|
||||||
|
>
|
||||||
|
<i className="bi bi-x-circle me-1"></i>
|
||||||
|
Limpar filtro
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div className="calendar-legend">
|
<div className="calendar-legend">
|
||||||
<div className="legend-item" data-status="completed">
|
|
||||||
Realizado
|
</div>
|
||||||
</div>
|
|
||||||
<div className="legend-item" data-status="confirmed">
|
|
||||||
Confirmado
|
|
||||||
</div>
|
|
||||||
<div className="legend-item" data-status="agendado">
|
|
||||||
Agendado
|
|
||||||
</div>
|
|
||||||
<div className="legend-item" data-status="cancelled">
|
|
||||||
Cancelado
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="calendar-controls">
|
<div className="calendar-controls">
|
||||||
<div className="date-indicator">
|
<div className="date-indicator">
|
||||||
<h2>{currentDate.format("MMMM [de] YYYY")}</h2>
|
<h2>{currentDate.format("MMMM [de] YYYY")}</h2>
|
||||||
@ -755,13 +830,17 @@ const Agendamento = () => {
|
|||||||
))}
|
))}
|
||||||
{dateGrid.map((day, index) => {
|
{dateGrid.map((day, index) => {
|
||||||
const dayString = day.format("YYYY-MM-DD");
|
const dayString = day.format("YYYY-MM-DD");
|
||||||
const appointmentsOnDay =
|
const appointmentsOnDay =
|
||||||
DictAgendamentosOrganizados[dayString] || [];
|
DictAgendamentosOrganizados[dayString] || [];
|
||||||
const filteredAppointments = appointmentsOnDay.filter(
|
|
||||||
(app) =>
|
const filteredAppointments = filtrarPorPaciente(
|
||||||
MedicoFiltrado.id === "vazio" ||
|
appointmentsOnDay.filter(
|
||||||
app.doctor_id === MedicoFiltrado.id
|
(app) =>
|
||||||
);
|
MedicoFiltrado.id === "vazio" ||
|
||||||
|
app.doctor_id === MedicoFiltrado.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
const cellClasses = `day-cell ${
|
const cellClasses = `day-cell ${
|
||||||
day.isSame(currentDate, "month")
|
day.isSame(currentDate, "month")
|
||||||
? "current-month"
|
? "current-month"
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
|
// src/PagesMedico/FormNovoRelatorio.jsx
|
||||||
import React, { useEffect, useState, useRef } from 'react';
|
import React, { useEffect, useState, useRef } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate, useLocation } from 'react-router-dom';
|
||||||
import API_KEY from '../components/utils/apiKeys';
|
import API_KEY from '../components/utils/apiKeys';
|
||||||
import { useAuth } from '../components/utils/AuthProvider';
|
import { useAuth } from '../components/utils/AuthProvider';
|
||||||
import TiptapEditor from './TiptapEditor';
|
import TiptapEditor from './TiptapEditor';
|
||||||
@ -12,6 +13,7 @@ const FormNovoRelatorio = () => {
|
|||||||
const { getAuthorizationHeader } = useAuth();
|
const { getAuthorizationHeader } = useAuth();
|
||||||
const authHeader = getAuthorizationHeader();
|
const authHeader = getAuthorizationHeader();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
const [patients, setPatients] = useState([]);
|
const [patients, setPatients] = useState([]);
|
||||||
const [doctors, setDoctors] = useState([]);
|
const [doctors, setDoctors] = useState([]);
|
||||||
@ -33,6 +35,7 @@ const FormNovoRelatorio = () => {
|
|||||||
const [showDoctorDropdown, setShowDoctorDropdown] = useState(false);
|
const [showDoctorDropdown, setShowDoctorDropdown] = useState(false);
|
||||||
const patientRef = useRef();
|
const patientRef = useRef();
|
||||||
const doctorRef = useRef();
|
const doctorRef = useRef();
|
||||||
|
const [lockedFromAppointment, setLockedFromAppointment] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let mounted = true;
|
let mounted = true;
|
||||||
@ -129,7 +132,24 @@ const FormNovoRelatorio = () => {
|
|||||||
|
|
||||||
const handleEditorChange = (html) => setForm(prev => ({ ...prev, contentHtml: html }));
|
const handleEditorChange = (html) => setForm(prev => ({ ...prev, contentHtml: html }));
|
||||||
|
|
||||||
// 🔹 Agora com created_by sendo o ID do usuário logado
|
useEffect(() => {
|
||||||
|
if (location && location.state && location.state.appointment) {
|
||||||
|
const appt = location.state.appointment;
|
||||||
|
const paciente_nome = location.state.paciente_nome || appt.paciente_nome || '';
|
||||||
|
const medico_nome = location.state.medico_nome || appt.medico_nome || '';
|
||||||
|
setForm(prev => ({
|
||||||
|
...prev,
|
||||||
|
patient_id: appt.patient_id || prev.patient_id,
|
||||||
|
patient_name: paciente_nome || prev.patient_name,
|
||||||
|
patient_birth: prev.patient_birth || '',
|
||||||
|
doctor_id: appt.doctor_id || prev.doctor_id,
|
||||||
|
doctor_name: medico_nome || prev.doctor_name,
|
||||||
|
contentHtml: generateTemplate(paciente_nome, prev.patient_birth || '', medico_nome)
|
||||||
|
}));
|
||||||
|
setLockedFromAppointment(true);
|
||||||
|
}
|
||||||
|
}, [location]);
|
||||||
|
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!form.patient_id) return alert('Selecione o paciente (clicando no item) antes de salvar.');
|
if (!form.patient_id) return alert('Selecione o paciente (clicando no item) antes de salvar.');
|
||||||
@ -149,7 +169,6 @@ const FormNovoRelatorio = () => {
|
|||||||
requested_by: form.doctor_name || ''
|
requested_by: form.doctor_name || ''
|
||||||
};
|
};
|
||||||
|
|
||||||
// Busca o id do usuário logado (via token)
|
|
||||||
let userId = null;
|
let userId = null;
|
||||||
try {
|
try {
|
||||||
const token = authHeader?.replace(/^Bearer\s+/i, '') || '';
|
const token = authHeader?.replace(/^Bearer\s+/i, '') || '';
|
||||||
@ -189,8 +208,6 @@ const FormNovoRelatorio = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const created = await res.json();
|
const created = await res.json();
|
||||||
console.log('Relatório criado:', created);
|
|
||||||
|
|
||||||
window.dispatchEvent(new Event('reports:refresh'));
|
window.dispatchEvent(new Event('reports:refresh'));
|
||||||
alert('Relatório criado com sucesso!');
|
alert('Relatório criado com sucesso!');
|
||||||
navigate('/medico/relatorios');
|
navigate('/medico/relatorios');
|
||||||
@ -211,11 +228,12 @@ const FormNovoRelatorio = () => {
|
|||||||
<input
|
<input
|
||||||
className="form-control"
|
className="form-control"
|
||||||
placeholder="Comece a digitar (ex.: m para pacientes que começam com m)"
|
placeholder="Comece a digitar (ex.: m para pacientes que começam com m)"
|
||||||
value={patientQuery}
|
value={lockedFromAppointment ? form.patient_name : patientQuery}
|
||||||
onChange={(e) => { setPatientQuery(e.target.value); setShowPatientDropdown(true); }}
|
onChange={(e) => { if (!lockedFromAppointment) { setPatientQuery(e.target.value); setShowPatientDropdown(true); } }}
|
||||||
onFocus={() => setShowPatientDropdown(true)}
|
onFocus={() => { if (!lockedFromAppointment) setShowPatientDropdown(true); }}
|
||||||
|
disabled={lockedFromAppointment}
|
||||||
/>
|
/>
|
||||||
{showPatientDropdown && patientQuery && (
|
{!lockedFromAppointment && showPatientDropdown && patientQuery && (
|
||||||
<ul className="list-group position-absolute" style={{ zIndex: 50, maxHeight: 220, overflowY: 'auto', width: '100%' }}>
|
<ul className="list-group position-absolute" style={{ zIndex: 50, maxHeight: 220, overflowY: 'auto', width: '100%' }}>
|
||||||
{filteredPatients.length > 0 ? filteredPatients.map(p => (
|
{filteredPatients.length > 0 ? filteredPatients.map(p => (
|
||||||
<li key={p.id} className="list-group-item list-group-item-action" onClick={() => choosePatient(p)}>
|
<li key={p.id} className="list-group-item list-group-item-action" onClick={() => choosePatient(p)}>
|
||||||
@ -232,11 +250,12 @@ const FormNovoRelatorio = () => {
|
|||||||
<input
|
<input
|
||||||
className="form-control"
|
className="form-control"
|
||||||
placeholder="Comece a digitar o nome do médico"
|
placeholder="Comece a digitar o nome do médico"
|
||||||
value={doctorQuery}
|
value={lockedFromAppointment ? form.doctor_name : doctorQuery}
|
||||||
onChange={(e) => { setDoctorQuery(e.target.value); setShowDoctorDropdown(true); }}
|
onChange={(e) => { if (!lockedFromAppointment) { setDoctorQuery(e.target.value); setShowDoctorDropdown(true); } }}
|
||||||
onFocus={() => setShowDoctorDropdown(true)}
|
onFocus={() => { if (!lockedFromAppointment) setShowDoctorDropdown(true); }}
|
||||||
|
disabled={lockedFromAppointment}
|
||||||
/>
|
/>
|
||||||
{showDoctorDropdown && doctorQuery && (
|
{!lockedFromAppointment && showDoctorDropdown && doctorQuery && (
|
||||||
<ul className="list-group position-absolute" style={{ zIndex: 50, maxHeight: 220, overflowY: 'auto', width: '100%' }}>
|
<ul className="list-group position-absolute" style={{ zIndex: 50, maxHeight: 220, overflowY: 'auto', width: '100%' }}>
|
||||||
{filteredDoctors.length > 0 ? filteredDoctors.map(d => (
|
{filteredDoctors.length > 0 ? filteredDoctors.map(d => (
|
||||||
<li key={d.id} className="list-group-item list-group-item-action" onClick={() => chooseDoctor(d)}>
|
<li key={d.id} className="list-group-item list-group-item-action" onClick={() => chooseDoctor(d)}>
|
||||||
@ -261,4 +280,4 @@ const FormNovoRelatorio = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default FormNovoRelatorio;
|
export default FormNovoRelatorio;
|
||||||
|
|||||||
@ -6,18 +6,58 @@
|
|||||||
/* --- Posiciona a barra de busca corretamente --- */
|
/* --- Posiciona a barra de busca corretamente --- */
|
||||||
.busca-atendimento {
|
.busca-atendimento {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center; /* Alinha os itens verticalmente */
|
align-items: center;
|
||||||
margin-top: 20px; /* Espaço acima da barra de busca */
|
margin-top: 20px;
|
||||||
padding: 0 10px; /* Adiciona um padding lateral para alinhar com o resto */
|
padding: 0 10px;
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.busca-atendimento > div:first-child {
|
.busca-atendimento > div:first-child {
|
||||||
width: 400px; /* Define um tamanho para a barra de pesquisa */
|
width: 400px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.busca-atendimento {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.busca-atendimento > div:first-child {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btns-e-legenda-container {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legenda-tabela {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.busca-atendimento {
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btns-e-legenda-container {
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-selecionar-tabeladia,
|
||||||
|
.btn-selecionar-tabelasemana,
|
||||||
|
.btn-selecionar-tabelames {
|
||||||
|
padding: 6px 8px;
|
||||||
|
font-size: medium;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.busca-atendimento input {
|
.busca-atendimento input {
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
@ -126,13 +166,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.container-btns-agenda-fila_esepera {
|
.container-btns-agenda-fila_esepera {
|
||||||
margin-top: 30px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-end;
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
margin-left: 20px;
|
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
margin-left: 0;
|
||||||
|
padding: 0 20px 0;
|
||||||
|
border-bottom: 1px solid #edf1f7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.btn-fila-espera,
|
.btn-fila-espera,
|
||||||
.btn-agenda {
|
.btn-agenda {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
@ -229,4 +276,10 @@ html[data-bs-theme="dark"] .legenda-item-agendado {
|
|||||||
background-color: #2e2e1e;
|
background-color: #2e2e1e;
|
||||||
border: 3px solid #4d4d2e;
|
border: 3px solid #4d4d2e;
|
||||||
color: #f7f7c4;
|
color: #f7f7c4;
|
||||||
}
|
}
|
||||||
|
.calendar-legend {
|
||||||
|
margin-top: 8px;
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|||||||
@ -85,13 +85,35 @@
|
|||||||
@media (max-width: 900px) {
|
@media (max-width: 900px) {
|
||||||
.ai-editor-container {
|
.ai-editor-container {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
min-height: auto;
|
||||||
}
|
}
|
||||||
.editor-sidebar {
|
.editor-sidebar {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
|
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
.preview-area {
|
||||||
|
padding: 20px;
|
||||||
}
|
}
|
||||||
.paper-a4 {
|
.paper-a4 {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
min-height: auto;
|
||||||
padding: 15mm;
|
padding: 15mm;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.ai-editor-container {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.editor-sidebar {
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
.preview-area {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.paper-a4 {
|
||||||
|
padding: 10mm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,83 +1,110 @@
|
|||||||
import React from 'react'
|
import React, { useState, useEffect } from 'react';
|
||||||
import FormConsultaPaciente from './FormConsultaPaciente'
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useState, useEffect } from 'react'
|
import dayjs from 'dayjs';
|
||||||
import { useNavigate } from 'react-router-dom'
|
|
||||||
import { useAuth } from '../components/utils/AuthProvider'
|
import FormConsultaPaciente from './FormConsultaPaciente';
|
||||||
import API_KEY from '../components/utils/apiKeys'
|
import { useAuth } from '../components/utils/AuthProvider';
|
||||||
|
import API_KEY from '../components/utils/apiKeys';
|
||||||
|
import { UserInfos } from '../components/utils/Functions-Endpoints/General';
|
||||||
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { UserInfos } from '../components/utils/Functions-Endpoints/General'
|
|
||||||
const ConsultaCadastroManager = () => {
|
const ConsultaCadastroManager = () => {
|
||||||
|
const { getAuthorizationHeader, user } = useAuth();
|
||||||
const {getAuthorizationHeader} = useAuth()
|
const navigate = useNavigate();
|
||||||
const [Dict, setDict] = useState({})
|
|
||||||
const navigate = useNavigate()
|
|
||||||
const [idUsuario, setIDusuario] = useState("")
|
|
||||||
|
|
||||||
let authHeader = getAuthorizationHeader()
|
|
||||||
|
|
||||||
|
|
||||||
|
const [Dict, setDict] = useState({});
|
||||||
|
// patient_id fixo do Pedro Abravanel
|
||||||
|
const [patientId, setPatientId] = useState('bf7d8323-05e1-437a-817c-f08eb5f174ef');
|
||||||
|
const [idUsuario, setIDusuario] = useState('');
|
||||||
|
|
||||||
|
const authHeader = getAuthorizationHeader();
|
||||||
|
|
||||||
|
// Opcional: ainda tenta buscar infos do usuário, mas NÃO mostra mais alerta
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const ColherInfoUsuario =async () => {
|
const ColherInfoUsuario = async () => {
|
||||||
const result = await UserInfos(authHeader)
|
try {
|
||||||
|
if (!authHeader) return;
|
||||||
setIDusuario(result?.profile?.id)
|
|
||||||
|
|
||||||
}
|
|
||||||
ColherInfoUsuario()
|
|
||||||
|
|
||||||
|
|
||||||
}, [])
|
const result = await UserInfos(authHeader);
|
||||||
|
|
||||||
const handleSave = (Dict) => {
|
const pid =
|
||||||
|
result?.patient_id ||
|
||||||
let DataAtual = dayjs()
|
result?.profile?.id ||
|
||||||
var myHeaders = new Headers();
|
user?.patient_id ||
|
||||||
myHeaders.append("apikey", API_KEY);
|
user?.profile?.id ||
|
||||||
myHeaders.append("Authorization", authHeader);
|
user?.user?.id;
|
||||||
myHeaders.append("Content-Type", "application/json");
|
|
||||||
|
|
||||||
|
|
||||||
var raw = JSON.stringify({
|
if (pid) {
|
||||||
"patient_id": "6e7f8829-0574-42df-9290-8dbb70f75ada",
|
setPatientId(pid);
|
||||||
"doctor_id": Dict.doctor_id,
|
}
|
||||||
"scheduled_at": `${Dict.dataAtendimento}T${Dict.horarioInicio}:00.000Z`,
|
|
||||||
"duration_minutes": 30,
|
setIDusuario(result?.profile?.id || pid || '');
|
||||||
"appointment_type": Dict.tipo_consulta,
|
} catch (e) {
|
||||||
|
console.error('Erro ao colher infos do usuário:', e);
|
||||||
"patient_notes": "Prefiro horário pela manhã",
|
|
||||||
"insurance_provider": Dict.convenio,
|
|
||||||
"status": "confirmed",
|
|
||||||
"created_by": idUsuario
|
|
||||||
});
|
|
||||||
|
|
||||||
var requestOptions = {
|
|
||||||
method: 'POST',
|
|
||||||
headers: myHeaders,
|
|
||||||
body: raw,
|
|
||||||
redirect: 'follow'
|
|
||||||
};
|
|
||||||
|
|
||||||
fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments", requestOptions)
|
|
||||||
.then(response => response.text())
|
|
||||||
.then(result => console.log(result))
|
|
||||||
.catch(error => console.log('error', error));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ColherInfoUsuario();
|
||||||
|
}, [authHeader, user]);
|
||||||
|
|
||||||
|
const handleSave = (Dict) => {
|
||||||
|
// se por algum motivo não tiver, usa o fixo do Pedro
|
||||||
|
const finalPatientId = patientId || 'bf7d8323-05e1-437a-817c-f08eb5f174ef';
|
||||||
|
|
||||||
return (
|
|
||||||
|
|
||||||
|
const myHeaders = new Headers();
|
||||||
|
myHeaders.append('apikey', API_KEY);
|
||||||
|
myHeaders.append('Authorization', authHeader);
|
||||||
|
myHeaders.append('Content-Type', 'application/json');
|
||||||
|
|
||||||
|
const raw = JSON.stringify({
|
||||||
|
patient_id: finalPatientId, // paciente Pedro
|
||||||
|
doctor_id: Dict.doctor_id,
|
||||||
|
scheduled_at: `${Dict.dataAtendimento}T${Dict.horarioInicio}:00.000Z`,
|
||||||
|
duration_minutes: 30,
|
||||||
|
appointment_type: Dict.tipo_consulta,
|
||||||
|
patient_notes: 'Prefiro horário pela manhã',
|
||||||
|
insurance_provider: Dict.convenio,
|
||||||
|
status: 'confirmed',
|
||||||
|
created_by: idUsuario || finalPatientId,
|
||||||
|
});
|
||||||
|
|
||||||
|
const requestOptions = {
|
||||||
|
method: 'POST',
|
||||||
|
headers: myHeaders,
|
||||||
|
body: raw,
|
||||||
|
redirect: 'follow',
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch(
|
||||||
|
'https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments',
|
||||||
|
requestOptions
|
||||||
|
)
|
||||||
|
.then(async (response) => {
|
||||||
|
if (!response.ok) {
|
||||||
|
const text = await response.text();
|
||||||
|
throw new Error(`Erro ao salvar consulta: ${response.status} - ${text}`);
|
||||||
|
}
|
||||||
|
return response.text();
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
alert('Consulta solicitada com sucesso!');
|
||||||
|
navigate('/paciente/agendamento/'); // volta para o calendário
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('error', error);
|
||||||
|
alert('Erro ao salvar a consulta. Tente novamente.');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
<div>
|
<div>
|
||||||
<FormConsultaPaciente agendamento={Dict} setAgendamento={setDict} onSave={handleSave} onCancel={() => navigate("/paciente/agendamento/")}/>
|
<FormConsultaPaciente
|
||||||
|
agendamento={Dict}
|
||||||
|
setAgendamento={setDict}
|
||||||
|
onSave={handleSave}
|
||||||
|
onCancel={() => navigate('/paciente/agendamento/')}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default ConsultaCadastroManager
|
export default ConsultaCadastroManager;
|
||||||
|
|||||||
@ -7,8 +7,8 @@ import dayjs from 'dayjs';
|
|||||||
import 'dayjs/locale/pt-br';
|
import 'dayjs/locale/pt-br';
|
||||||
import isBetween from 'dayjs/plugin/isBetween';
|
import isBetween from 'dayjs/plugin/isBetween';
|
||||||
import localeData from 'dayjs/plugin/localeData';
|
import localeData from 'dayjs/plugin/localeData';
|
||||||
import { ChevronLeft, ChevronRight, Edit, Trash2 } from 'lucide-react';
|
import { ChevronLeft, ChevronRight, Trash2 } from 'lucide-react';
|
||||||
import "../pages/style/Agendamento.css";
|
import '../pages/style/Agendamento.css';
|
||||||
import '../pages/style/FilaEspera.css';
|
import '../pages/style/FilaEspera.css';
|
||||||
import Spinner from '../components/Spinner.jsx';
|
import Spinner from '../components/Spinner.jsx';
|
||||||
|
|
||||||
@ -20,8 +20,12 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { getAuthorizationHeader, user } = useAuth();
|
const { getAuthorizationHeader, user } = useAuth();
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
console.log('USER NO AGENDAMENTO:', user);
|
||||||
const [DictAgendamentosOrganizados, setDictAgendamentosOrganizados] = useState({});
|
|
||||||
|
const [patientId, setPatientId] = useState('bf7d8323-05e1-437a-817c-f08eb5f174ef');
|
||||||
|
const [isLoading, setIsLoading] = useState(false); // começa false
|
||||||
|
const [DictAgendamentosOrganizados, setDictAgendamentosOrganizados] =
|
||||||
|
useState({});
|
||||||
const [filaEsperaData, setFilaDeEsperaData] = useState([]);
|
const [filaEsperaData, setFilaDeEsperaData] = useState([]);
|
||||||
const [FiladeEspera, setFiladeEspera] = useState(false);
|
const [FiladeEspera, setFiladeEspera] = useState(false);
|
||||||
const [PageNovaConsulta, setPageConsulta] = useState(false);
|
const [PageNovaConsulta, setPageConsulta] = useState(false);
|
||||||
@ -30,83 +34,115 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
const [selectedDay, setSelectedDay] = useState(dayjs());
|
const [selectedDay, setSelectedDay] = useState(dayjs());
|
||||||
const [quickJump, setQuickJump] = useState({
|
const [quickJump, setQuickJump] = useState({
|
||||||
month: currentDate.month(),
|
month: currentDate.month(),
|
||||||
year: currentDate.year()
|
year: currentDate.year(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const [isCancelModalOpen, setIsCancelModalOpen] = useState(false);
|
const [isCancelModalOpen, setIsCancelModalOpen] = useState(false);
|
||||||
const [appointmentToCancel, setAppointmentToCancel] = useState(null);
|
const [appointmentToCancel, setAppointmentToCancel] = useState(null);
|
||||||
const [cancellationReason, setCancellationReason] = useState('');
|
const [cancellationReason, setCancellationReason] = useState('');
|
||||||
|
|
||||||
const authHeader = useMemo(() => getAuthorizationHeader(), [getAuthorizationHeader]);
|
const authHeader = useMemo(
|
||||||
|
() => getAuthorizationHeader(),
|
||||||
|
[getAuthorizationHeader]
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
// Buscar consultas desse paciente
|
||||||
const carregarDados = async () => {
|
const carregarDados = async () => {
|
||||||
const patientId = user?.patient_id || "6e7f8829-0574-42df-9290-8dbb70f75ada";
|
// só tenta buscar quando tiver header e patientId
|
||||||
|
if (!authHeader) {
|
||||||
|
console.warn('Header de autorização não disponível.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!authHeader) {
|
if (!patientId) {
|
||||||
console.warn("Header de autorização não disponível.");
|
console.warn('patientId ainda não carregado, aguardando contexto.');
|
||||||
setIsLoading(false);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const myHeaders = new Headers({ "Authorization": authHeader, "apikey": API_KEY });
|
const myHeaders = new Headers({
|
||||||
const requestOptions = { method: 'GET', headers: myHeaders };
|
Authorization: authHeader,
|
||||||
const response = await fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?select=*,doctors(full_name)&patient_id=eq.${patientId}`, requestOptions);
|
apikey: API_KEY,
|
||||||
|
});
|
||||||
|
const requestOptions = { method: 'GET', headers: myHeaders };
|
||||||
|
|
||||||
if (!response.ok) throw new Error(`Erro na requisição: ${response.statusText}`);
|
const response = await fetch(
|
||||||
|
`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?select=*,doctors(full_name)&patient_id=eq.${patientId}`,
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
|
|
||||||
const consultasBrutas = await response.json() || [];
|
if (!response.ok)
|
||||||
|
throw new Error(`Erro na requisição: ${response.statusText}`);
|
||||||
|
|
||||||
const newDict = {};
|
const consultasBrutas = (await response.json()) || [];
|
||||||
const newFila = [];
|
console.log('CONSULTAS BRUTAS PACIENTE:', consultasBrutas);
|
||||||
|
|
||||||
for (const agendamento of consultasBrutas) {
|
const newDict = {};
|
||||||
const agendamentoMelhorado = {
|
const newFila = [];
|
||||||
...agendamento,
|
|
||||||
medico_nome: agendamento.doctors?.full_name || 'Médico não informado'
|
|
||||||
};
|
|
||||||
|
|
||||||
if (agendamento.status === "requested") {
|
for (const agendamento of consultasBrutas) {
|
||||||
newFila.push({ agendamento: agendamentoMelhorado, Infos: agendamentoMelhorado });
|
const agendamentoMelhorado = {
|
||||||
|
...agendamento,
|
||||||
|
medico_nome: agendamento.doctors?.full_name || 'Médico não informado',
|
||||||
|
};
|
||||||
|
|
||||||
|
if (agendamento.status === 'requested') {
|
||||||
|
newFila.push({
|
||||||
|
agendamento: agendamentoMelhorado,
|
||||||
|
Infos: agendamentoMelhorado,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const diaAgendamento = dayjs(
|
||||||
|
agendamento.scheduled_at
|
||||||
|
).format('YYYY-MM-DD');
|
||||||
|
if (newDict[diaAgendamento]) {
|
||||||
|
newDict[diaAgendamento].push(agendamentoMelhorado);
|
||||||
} else {
|
} else {
|
||||||
const diaAgendamento = dayjs(agendamento.scheduled_at).format("YYYY-MM-DD");
|
newDict[diaAgendamento] = [agendamentoMelhorado];
|
||||||
if (newDict[diaAgendamento]) {
|
|
||||||
newDict[diaAgendamento].push(agendamentoMelhorado);
|
|
||||||
} else {
|
|
||||||
newDict[diaAgendamento] = [agendamentoMelhorado];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const key in newDict) {
|
|
||||||
newDict[key].sort((a, b) => a.scheduled_at.localeCompare(b.scheduled_at));
|
|
||||||
}
|
|
||||||
|
|
||||||
setDictAgendamentosOrganizados(newDict);
|
|
||||||
setFilaDeEsperaData(newFila);
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Falha ao buscar ou processar agendamentos:', err);
|
|
||||||
setDictAgendamentosOrganizados({});
|
|
||||||
setFilaDeEsperaData([]);
|
|
||||||
} finally {
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
for (const key in newDict) {
|
||||||
|
newDict[key].sort((a, b) =>
|
||||||
|
a.scheduled_at.localeCompare(b.scheduled_at)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
setDictAgendamentosOrganizados(newDict);
|
||||||
|
setFilaDeEsperaData(newFila);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Falha ao buscar ou processar agendamentos:', err);
|
||||||
|
setDictAgendamentosOrganizados({});
|
||||||
|
setFilaDeEsperaData([]);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// roda quando authHeader ou patientId mudarem
|
||||||
|
useEffect(() => {
|
||||||
carregarDados();
|
carregarDados();
|
||||||
}, [authHeader, user]);
|
}, [authHeader, patientId]); // padrão recomendado para fetch com useEffect [web:46][web:82]
|
||||||
|
|
||||||
const updateAppointmentStatus = async (id, updates) => {
|
const updateAppointmentStatus = async (id, updates) => {
|
||||||
const myHeaders = new Headers({
|
const myHeaders = new Headers({
|
||||||
"Authorization": authHeader, "apikey": API_KEY, "Content-Type": "application/json"
|
Authorization: authHeader,
|
||||||
|
apikey: API_KEY,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
});
|
});
|
||||||
const requestOptions = { method: 'PATCH', headers: myHeaders, body: JSON.stringify(updates) };
|
const requestOptions = {
|
||||||
|
method: 'PATCH',
|
||||||
|
headers: myHeaders,
|
||||||
|
body: JSON.stringify(updates),
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?id=eq.${id}`, requestOptions);
|
const response = await fetch(
|
||||||
|
`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?id=eq.${id}`,
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
if (!response.ok) throw new Error('Falha ao atualizar o status.');
|
if (!response.ok) throw new Error('Falha ao atualizar o status.');
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -124,11 +160,13 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
const executeCancellation = async () => {
|
const executeCancellation = async () => {
|
||||||
if (!appointmentToCancel) return;
|
if (!appointmentToCancel) return;
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const motivo = cancellationReason.trim() || "Cancelado pelo paciente (motivo não especificado)";
|
const motivo =
|
||||||
|
cancellationReason.trim() ||
|
||||||
|
'Cancelado pelo paciente (motivo não especificado)';
|
||||||
const success = await updateAppointmentStatus(appointmentToCancel, {
|
const success = await updateAppointmentStatus(appointmentToCancel, {
|
||||||
status: "cancelled",
|
status: 'cancelled',
|
||||||
cancellation_reason: motivo,
|
cancellation_reason: motivo,
|
||||||
updated_at: new Date().toISOString()
|
updated_at: new Date().toISOString(),
|
||||||
});
|
});
|
||||||
|
|
||||||
setIsCancelModalOpen(false);
|
setIsCancelModalOpen(false);
|
||||||
@ -136,28 +174,38 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
setCancellationReason('');
|
setCancellationReason('');
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
alert("Solicitação cancelada com sucesso!");
|
alert('Solicitação cancelada com sucesso!');
|
||||||
|
|
||||||
setDictAgendamentosOrganizados(prev => {
|
setDictAgendamentosOrganizados((prev) => {
|
||||||
const newDict = { ...prev };
|
const newDict = { ...prev };
|
||||||
for (const date in newDict) {
|
for (const date in newDict) {
|
||||||
newDict[date] = newDict[date].filter(app => app.id !== appointmentToCancel);
|
newDict[date] = newDict[date].filter(
|
||||||
|
(app) => app.id !== appointmentToCancel
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return newDict;
|
return newDict;
|
||||||
});
|
});
|
||||||
setFilaDeEsperaData(prev => prev.filter(item => item.agendamento.id !== appointmentToCancel));
|
setFilaDeEsperaData((prev) =>
|
||||||
|
prev.filter((item) => item.agendamento.id !== appointmentToCancel)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
alert("Falha ao cancelar a solicitação.");
|
alert('Falha ao cancelar a solicitação.');
|
||||||
}
|
}
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleQuickJumpChange = (type, value) => setQuickJump(prev => ({ ...prev, [type]: Number(value) }));
|
const handleQuickJumpChange = (type, value) =>
|
||||||
|
setQuickJump((prev) => ({ ...prev, [type]: Number(value) }));
|
||||||
|
|
||||||
const applyQuickJump = () => {
|
const applyQuickJump = () => {
|
||||||
const newDate = dayjs().year(quickJump.year).month(quickJump.month).date(1);
|
const newDate = dayjs()
|
||||||
|
.year(quickJump.year)
|
||||||
|
.month(quickJump.month)
|
||||||
|
.date(1);
|
||||||
setCurrentDate(newDate);
|
setCurrentDate(newDate);
|
||||||
setSelectedDay(newDate);
|
setSelectedDay(newDate);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dateGrid = useMemo(() => {
|
const dateGrid = useMemo(() => {
|
||||||
const grid = [];
|
const grid = [];
|
||||||
const startOfMonth = currentDate.startOf('month');
|
const startOfMonth = currentDate.startOf('month');
|
||||||
@ -168,111 +216,247 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
}
|
}
|
||||||
return grid;
|
return grid;
|
||||||
}, [currentDate]);
|
}, [currentDate]);
|
||||||
|
|
||||||
const weekDays = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'];
|
const weekDays = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'];
|
||||||
const handleDateClick = (day) => setSelectedDay(day);
|
const handleDateClick = (day) => setSelectedDay(day);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="form-container" style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '50vh' }}>
|
<div
|
||||||
|
className="form-container"
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
height: '50vh',
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Spinner />
|
<Spinner />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1>Minhas consultas</h1>
|
<h1>Minhas consultas</h1>
|
||||||
<div className="btns-gerenciamento-e-consulta" style={{ display: 'flex', gap: '10px', marginBottom: '20px' }}>
|
<div
|
||||||
<button
|
className="btns-gerenciamento-e-consulta"
|
||||||
className="btn-adicionar-consulta"
|
style={{ display: 'flex', gap: '10px', marginBottom: '20px' }}
|
||||||
onClick={() => {
|
>
|
||||||
setPageConsulta(true);
|
<button
|
||||||
setFiladeEspera(false);
|
className="btn btn-primary btn-consulta-paciente"
|
||||||
}}
|
onClick={() => {
|
||||||
style={{
|
setPageConsulta(true);
|
||||||
backgroundColor: PageNovaConsulta ? '#1d4ed8' : undefined
|
setFiladeEspera(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<i className="bi bi-plus-circle"></i> Solicitar Agendamento
|
<i className="bi bi-plus-circle"></i> Solicitar Agendamento
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className="btn-adicionar-consulta"
|
className="btn btn-primary btn-consulta-paciente"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setFiladeEspera(!FiladeEspera);
|
setFiladeEspera(!FiladeEspera);
|
||||||
setPageConsulta(false);
|
setPageConsulta(false);
|
||||||
}}
|
}}
|
||||||
style={{
|
>
|
||||||
backgroundColor: FiladeEspera && !PageNovaConsulta ? '#1d4ed8' : undefined
|
<i className="bi bi-list-task me-1"></i> Fila de Espera ({filaEsperaData.length})
|
||||||
}}
|
</button>
|
||||||
>
|
</div>
|
||||||
<i className="bi bi-list-task me-1"></i> Fila de Espera ({filaEsperaData.length})
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{!PageNovaConsulta ? (
|
{!PageNovaConsulta ? (
|
||||||
<div className='atendimento-eprocura'>
|
<div className="atendimento-eprocura">
|
||||||
<section className='calendario-ou-filaespera'>
|
<section className="calendario-ou-filaespera">
|
||||||
{!FiladeEspera ? (
|
{!FiladeEspera ? (
|
||||||
<div className="calendar-wrapper">
|
<div className="calendar-wrapper">
|
||||||
<div className="calendar-info-panel">
|
<div className="calendar-info-panel">
|
||||||
<div className="info-date-display"><span>{selectedDay.format('MMM')}</span><strong>{selectedDay.format('DD')}</strong></div>
|
<div className="info-date-display">
|
||||||
<div className="info-details"><h3>{selectedDay.format('dddd')}</h3><p>{selectedDay.format('D [de] MMMM [de] YYYY')}</p></div>
|
<span>{selectedDay.format('MMM')}</span>
|
||||||
|
<strong>{selectedDay.format('DD')}</strong>
|
||||||
|
</div>
|
||||||
|
<div className="info-details">
|
||||||
|
<h3>{selectedDay.format('dddd')}</h3>
|
||||||
|
<p>{selectedDay.format('D [de] MMMM [de] YYYY')}</p>
|
||||||
|
</div>
|
||||||
<div className="appointments-list">
|
<div className="appointments-list">
|
||||||
|
<div
|
||||||
|
className="calendar-legend compact-legend"
|
||||||
|
style={{
|
||||||
|
marginTop: 4,
|
||||||
|
gap: 3,
|
||||||
|
fontSize: 8,
|
||||||
|
lineHeight: 1.1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="legend-item"
|
||||||
|
data-status="completed"
|
||||||
|
style={{ padding: '0px 5px' }}
|
||||||
|
>
|
||||||
|
Realizado
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="legend-item"
|
||||||
|
data-status="confirmed"
|
||||||
|
style={{ padding: '0px 5px' }}
|
||||||
|
>
|
||||||
|
Confirmado
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="legend-item"
|
||||||
|
data-status="agendado"
|
||||||
|
style={{ padding: '0px 5px' }}
|
||||||
|
>
|
||||||
|
Agendado
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="legend-item"
|
||||||
|
data-status="cancelled"
|
||||||
|
style={{ padding: '0px 5px' }}
|
||||||
|
>
|
||||||
|
Cancelado
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h4>Consultas para {selectedDay.format('DD/MM')}</h4>
|
<h4>Consultas para {selectedDay.format('DD/MM')}</h4>
|
||||||
{(DictAgendamentosOrganizados[selectedDay.format('YYYY-MM-DD')]?.length > 0) ? (
|
{DictAgendamentosOrganizados[
|
||||||
DictAgendamentosOrganizados[selectedDay.format('YYYY-MM-DD')].map(app => (
|
selectedDay.format('YYYY-MM-DD')
|
||||||
<div key={app.id} className="appointment-item" data-status={app.status}>
|
]?.length > 0 ? (
|
||||||
<div className="item-time">{dayjs(app.scheduled_at).format('HH:mm')}</div>
|
DictAgendamentosOrganizados[
|
||||||
|
selectedDay.format('YYYY-MM-DD')
|
||||||
|
].map((app) => (
|
||||||
|
<div
|
||||||
|
key={app.id}
|
||||||
|
className="appointment-item"
|
||||||
|
data-status={app.status}
|
||||||
|
>
|
||||||
|
<div className="item-time">
|
||||||
|
{dayjs(app.scheduled_at).add(3, 'hour').format('HH:mm')}
|
||||||
|
|
||||||
|
</div>
|
||||||
<div className="item-details">
|
<div className="item-details">
|
||||||
<span>Consulta com Dr(a). {app.medico_nome}</span>
|
<span>Consulta com Dr(a). {app.medico_nome}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className='item-actions'>
|
<div className="item-actions">
|
||||||
{app.status !== 'cancelled' && dayjs(app.scheduled_at).isAfter(dayjs()) && (
|
{app.status !== 'cancelled' &&
|
||||||
<button className="btn btn-sm btn-outline-danger" onClick={() => handleCancelClick(app.id)} title="Cancelar Consulta">
|
dayjs(app.scheduled_at).isAfter(dayjs()) && (
|
||||||
<Trash2 size={16} />
|
<button
|
||||||
</button>
|
className="btn btn-sm btn-outline-danger"
|
||||||
)}
|
onClick={() => handleCancelClick(app.id)}
|
||||||
|
title="Cancelar Consulta"
|
||||||
|
>
|
||||||
|
<Trash2 size={16} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
) : (<div className="no-appointments-info"><p>Nenhuma consulta agendada para esta data.</p></div>)}
|
) : (
|
||||||
|
<div className="no-appointments-info">
|
||||||
|
<p>Nenhuma consulta agendada para esta data.</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="calendar-main">
|
<div className="calendar-main">
|
||||||
<div className="calendar-legend">
|
<div className="calendar-legend"></div>
|
||||||
<div className="legend-item" data-status="completed">Realizado</div>
|
|
||||||
<div className="legend-item" data-status="confirmed">Confirmado</div>
|
|
||||||
<div className="legend-item" data-status="agendado">Agendado</div>
|
|
||||||
<div className="legend-item" data-status="cancelled">Cancelado</div>
|
|
||||||
</div>
|
|
||||||
<div className="calendar-controls">
|
<div className="calendar-controls">
|
||||||
<div className="date-indicator">
|
<div className="date-indicator">
|
||||||
<h2>{currentDate.format('MMMM [de] YYYY')}</h2>
|
<h2>{currentDate.format('MMMM [de] YYYY')}</h2>
|
||||||
<div className="quick-jump-controls" style={{ display: 'flex', gap: '5px', marginTop: '10px' }}>
|
<div
|
||||||
<select value={quickJump.month} onChange={(e) => handleQuickJumpChange('month', e.target.value)} className="form-select form-select-sm w-auto">
|
className="quick-jump-controls"
|
||||||
{dayjs.months().map((month, index) => (<option key={index} value={index}>{month.charAt(0).toUpperCase() + month.slice(1)}</option>))}
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
gap: '5px',
|
||||||
|
marginTop: '10px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
value={quickJump.month}
|
||||||
|
onChange={(e) =>
|
||||||
|
handleQuickJumpChange('month', e.target.value)
|
||||||
|
}
|
||||||
|
className="form-select form-select-sm w-auto"
|
||||||
|
>
|
||||||
|
{dayjs.months().map((month, index) => (
|
||||||
|
<option key={index} value={index}>
|
||||||
|
{month.charAt(0).toUpperCase() + month.slice(1)}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
<select value={quickJump.year} onChange={(e) => handleQuickJumpChange('year', e.target.value)} className="form-select form-select-sm w-auto">
|
<select
|
||||||
{Array.from({ length: 11 }, (_, i) => dayjs().year() - 5 + i).map(year => (<option key={year} value={year}>{year}</option>))}
|
value={quickJump.year}
|
||||||
|
onChange={(e) =>
|
||||||
|
handleQuickJumpChange('year', e.target.value)
|
||||||
|
}
|
||||||
|
className="form-select form-select-sm w-auto"
|
||||||
|
>
|
||||||
|
{Array.from({ length: 11 }, (_, i) =>
|
||||||
|
dayjs().year() - 5 + i
|
||||||
|
).map((year) => (
|
||||||
|
<option key={year} value={year}>
|
||||||
|
{year}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
<button className="btn btn-sm btn-outline-primary" onClick={applyQuickJump} disabled={quickJump.month === currentDate.month() && quickJump.year === currentDate.year()}>Ir</button>
|
<button
|
||||||
|
className="btn btn-sm btn-outline-primary"
|
||||||
|
onClick={applyQuickJump}
|
||||||
|
disabled={
|
||||||
|
quickJump.month === currentDate.month() &&
|
||||||
|
quickJump.year === currentDate.year()
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Ir
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="nav-buttons">
|
<div className="nav-buttons">
|
||||||
<button onClick={() => setCurrentDate(c => c.subtract(1, 'month'))}><ChevronLeft size={20} /></button>
|
<button
|
||||||
<button onClick={() => setCurrentDate(dayjs())}>Hoje</button>
|
onClick={() => setCurrentDate((c) => c.subtract(1, 'month'))}
|
||||||
<button onClick={() => setCurrentDate(c => c.add(1, 'month'))}><ChevronRight size={20} /></button>
|
>
|
||||||
|
<ChevronLeft size={20} />
|
||||||
|
</button>
|
||||||
|
<button onClick={() => setCurrentDate(dayjs())}>
|
||||||
|
Hoje
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => setCurrentDate((c) => c.add(1, 'month'))}
|
||||||
|
>
|
||||||
|
<ChevronRight size={20} />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="calendar-grid">
|
<div className="calendar-grid">
|
||||||
{weekDays.map(day => <div key={day} className="day-header">{day}</div>)}
|
{weekDays.map((day) => (
|
||||||
|
<div key={day} className="day-header">
|
||||||
|
{day}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
{dateGrid.map((day, index) => {
|
{dateGrid.map((day, index) => {
|
||||||
const appointmentsOnDay = DictAgendamentosOrganizados[day.format('YYYY-MM-DD')] || [];
|
const appointmentsOnDay =
|
||||||
const cellClasses = `day-cell ${day.isSame(currentDate, 'month') ? 'current-month' : 'other-month'} ${day.isSame(dayjs(), 'day') ? 'today' : ''} ${day.isSame(selectedDay, 'day') ? 'selected' : ''}`;
|
DictAgendamentosOrganizados[
|
||||||
|
day.format('YYYY-MM-DD')
|
||||||
|
] || [];
|
||||||
|
const cellClasses = `day-cell ${
|
||||||
|
day.isSame(currentDate, 'month')
|
||||||
|
? 'current-month'
|
||||||
|
: 'other-month'
|
||||||
|
} ${day.isSame(dayjs(), 'day') ? 'today' : ''} ${
|
||||||
|
day.isSame(selectedDay, 'day') ? 'selected' : ''
|
||||||
|
}`;
|
||||||
return (
|
return (
|
||||||
<div key={index} className={cellClasses} onClick={() => handleDateClick(day)}>
|
<div
|
||||||
|
key={index}
|
||||||
|
className={cellClasses}
|
||||||
|
onClick={() => handleDateClick(day)}
|
||||||
|
>
|
||||||
<span>{day.format('D')}</span>
|
<span>{day.format('D')}</span>
|
||||||
{appointmentsOnDay.length > 0 && <div className="appointments-indicator">{appointmentsOnDay.length}</div>}
|
{appointmentsOnDay.length > 0 && (
|
||||||
|
<div className="appointments-indicator">
|
||||||
|
{appointmentsOnDay.length}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@ -284,7 +468,11 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
<section className="row">
|
<section className="row">
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<div className="card table-paciente-card">
|
<div className="card table-paciente-card">
|
||||||
<div className="card-header"><h4 className="card-title mb-0">Minhas Solicitações em Fila de Espera</h4></div>
|
<div className="card-header">
|
||||||
|
<h4 className="card-title mb-0">
|
||||||
|
Minhas Solicitações em Fila de Espera
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
<div className="table-responsive">
|
<div className="table-responsive">
|
||||||
<table className="table table-striped table-hover">
|
<table className="table table-striped table-hover">
|
||||||
@ -296,20 +484,37 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{filaEsperaData.length > 0 ? (filaEsperaData.map((item) => (
|
{filaEsperaData.length > 0 ? (
|
||||||
<tr key={item.agendamento.id}>
|
filaEsperaData.map((item) => (
|
||||||
<td>Dr(a). {item.Infos?.medico_nome}</td>
|
<tr key={item.agendamento.id}>
|
||||||
<td>{dayjs(item.agendamento.created_at).format('DD/MM/YYYY HH:mm')}</td>
|
<td>Dr(a). {item.Infos?.medico_nome}</td>
|
||||||
<td>
|
<td>
|
||||||
<button className="btn btn-sm btn-danger" onClick={() => handleCancelClick(item.agendamento.id)}>
|
{dayjs(
|
||||||
<i className="bi bi-trash me-1"></i> Cancelar
|
item.agendamento.created_at
|
||||||
</button>
|
).format('DD/MM/YYYY HH:mm')}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
<td>
|
||||||
))) : (
|
<button
|
||||||
|
className="btn btn-sm btn-danger"
|
||||||
|
onClick={() =>
|
||||||
|
handleCancelClick(item.agendamento.id)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<i className="bi bi-trash me-1"></i>{' '}
|
||||||
|
Cancelar
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan="3" className="text-center py-4">
|
<td
|
||||||
<div className="text-muted">Nenhuma solicitação na fila de espera.</div>
|
colSpan="3"
|
||||||
|
className="text-center py-4"
|
||||||
|
>
|
||||||
|
<div className="text-muted">
|
||||||
|
Nenhuma solicitação na fila de espera.
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
)}
|
)}
|
||||||
@ -325,15 +530,42 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<AgendamentoCadastroManager setPageConsulta={setPageConsulta} />
|
<AgendamentoCadastroManager
|
||||||
|
setPageConsulta={setPageConsulta}
|
||||||
|
onSaved={() => {
|
||||||
|
carregarDados(); // recarrega consultas do paciente
|
||||||
|
setPageConsulta(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isCancelModalOpen && (
|
{isCancelModalOpen && (
|
||||||
<div className="modal-overlay">
|
<div className="modal-overlay">
|
||||||
<div className="modal-content" style={{ maxWidth: '400px' }}>
|
<div className="modal-content" style={{ maxWidth: '400px' }}>
|
||||||
<div className="modal-header" style={{ backgroundColor: '#fee2e2', borderBottom: '1px solid #fca5a5', padding: '15px', borderRadius: '8px 8px 0 0' }}>
|
<div
|
||||||
<h4 style={{ margin: 0, color: '#dc2626' }}>Confirmação de Cancelamento</h4>
|
className="modal-header"
|
||||||
<button className="close-button" onClick={() => setIsCancelModalOpen(false)} style={{ background: 'none', border: 'none', fontSize: '1.5rem', cursor: 'pointer' }}>×</button>
|
style={{
|
||||||
|
backgroundColor: '#fee2e2',
|
||||||
|
borderBottom: '1px solid #fca5a5',
|
||||||
|
padding: '15px',
|
||||||
|
borderRadius: '8px 8px 0 0',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<h4 style={{ margin: 0, color: '#dc2626' }}>
|
||||||
|
Confirmação de Cancelamento
|
||||||
|
</h4>
|
||||||
|
<button
|
||||||
|
className="close-button"
|
||||||
|
onClick={() => setIsCancelModalOpen(false)}
|
||||||
|
style={{
|
||||||
|
background: 'none',
|
||||||
|
border: 'none',
|
||||||
|
fontSize: '1.5rem',
|
||||||
|
cursor: 'pointer',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
×
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-body" style={{ padding: '20px' }}>
|
<div className="modal-body" style={{ padding: '20px' }}>
|
||||||
<p>Qual o motivo do cancelamento?</p>
|
<p>Qual o motivo do cancelamento?</p>
|
||||||
@ -342,21 +574,48 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
onChange={(e) => setCancellationReason(e.target.value)}
|
onChange={(e) => setCancellationReason(e.target.value)}
|
||||||
placeholder="Ex: Precisei viajar, motivo pessoal, etc."
|
placeholder="Ex: Precisei viajar, motivo pessoal, etc."
|
||||||
rows="4"
|
rows="4"
|
||||||
style={{ width: '100%', padding: '10px', resize: 'none', border: '1px solid #ccc', borderRadius: '4px' }}
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
padding: '10px',
|
||||||
|
resize: 'none',
|
||||||
|
border: '1px solid #ccc',
|
||||||
|
borderRadius: '4px',
|
||||||
|
}}
|
||||||
></textarea>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-footer" style={{ display: 'flex', justifyContent: 'flex-end', gap: '10px', padding: '15px', borderTop: '1px solid #eee' }}>
|
<div
|
||||||
|
className="modal-footer"
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'flex-end',
|
||||||
|
gap: '10px',
|
||||||
|
padding: '15px',
|
||||||
|
borderTop: '1px solid #eee',
|
||||||
|
}}
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
className="btn btn-secondary"
|
className="btn btn-secondary"
|
||||||
onClick={() => setIsCancelModalOpen(false)}
|
onClick={() => setIsCancelModalOpen(false)}
|
||||||
style={{ backgroundColor: '#6c757d', color: 'white', border: 'none', padding: '8px 15px', borderRadius: '4px' }}
|
style={{
|
||||||
|
backgroundColor: '#6c757d',
|
||||||
|
color: 'white',
|
||||||
|
border: 'none',
|
||||||
|
padding: '8px 15px',
|
||||||
|
borderRadius: '4px',
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Cancelar
|
Cancelar
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className="btn btn-danger"
|
className="btn btn-danger"
|
||||||
onClick={executeCancellation}
|
onClick={executeCancellation}
|
||||||
style={{ backgroundColor: '#dc3545', color: 'white', border: 'none', padding: '8px 15px', borderRadius: '4px' }}
|
style={{
|
||||||
|
backgroundColor: '#dc3545',
|
||||||
|
color: 'white',
|
||||||
|
border: 'none',
|
||||||
|
padding: '8px 15px',
|
||||||
|
borderRadius: '4px',
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Trash2 size={16} style={{ marginRight: '5px' }} /> Excluir
|
<Trash2 size={16} style={{ marginRight: '5px' }} /> Excluir
|
||||||
</button>
|
</button>
|
||||||
@ -365,7 +624,7 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Agendamento;
|
export default Agendamento;
|
||||||
|
|||||||
@ -1,14 +1,71 @@
|
|||||||
|
|
||||||
/* Estilo geral do card para agrupar e dar um formato */
|
/* Estilo geral do card para agrupar e dar um formato */
|
||||||
.card-consulta {
|
.card-consulta {
|
||||||
background-color: #007bff; /* Um tom de azul padrão */
|
background-color: #007bff;
|
||||||
display: flex; /* Para colocar horário e info lado a lado */
|
display: flex;
|
||||||
border-radius: 10px; /* Cantos arredondados */
|
border-radius: 10px;
|
||||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Sombra suave */
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||||
overflow: hidden; /* Garante que o fundo azul não 'vaze' */
|
overflow: hidden;
|
||||||
/* width: 280px; /* Largura de exemplo */
|
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
font-family: Arial, sans-serif; /* Fonte legível */
|
font-family: Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.card-consulta {
|
||||||
|
flex-direction: column;
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.horario-container {
|
||||||
|
border-right: none;
|
||||||
|
border-bottom: 1px solid #0056b3;
|
||||||
|
padding: 10px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.horario {
|
||||||
|
font-size: 1.8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-container {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions-container {
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
background: none;
|
||||||
|
backdrop-filter: none;
|
||||||
|
-webkit-backdrop-filter: none;
|
||||||
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
|
margin-left: 0;
|
||||||
|
padding: 0;
|
||||||
|
justify-content: flex-start;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-consulta:hover .actions-container {
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.horario {
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.informacao {
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-edit-custom-style,
|
||||||
|
.btn-delete-custom-style {
|
||||||
|
padding: 6px 10px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 1. Estilo para o Horário (Fundo Azul e Texto Branco/Grande) */
|
/* 1. Estilo para o Horário (Fundo Azul e Texto Branco/Grande) */
|
||||||
|
|||||||
@ -6,98 +6,156 @@ import { GetAllDoctors } from "../utils/Functions-Endpoints/Doctor";
|
|||||||
import { useAuth } from "../utils/AuthProvider";
|
import { useAuth } from "../utils/AuthProvider";
|
||||||
import API_KEY from "../utils/apiKeys";
|
import API_KEY from "../utils/apiKeys";
|
||||||
|
|
||||||
|
|
||||||
const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) => {
|
const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) => {
|
||||||
const { getAuthorizationHeader } = useAuth();
|
const { getAuthorizationHeader } = useAuth();
|
||||||
|
|
||||||
const [sessoes, setSessoes] = useState(1);
|
const [sessoes, setSessoes] = useState(1);
|
||||||
const [tempoBaseConsulta] = useState(30);
|
const [tempoBaseConsulta] = useState(30);
|
||||||
const [showSuccessModal, setShowSuccessModal] = useState(false);
|
const [horarioInicio, setHorarioInicio] = useState("");
|
||||||
|
const [horarioTermino, setHorarioTermino] = useState("");
|
||||||
|
const [horariosDisponiveis, sethorariosDisponiveis] = useState([]);
|
||||||
|
const [status, setStatus] = useState(agendamento?.status || "confirmed");
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
const [todosProfissionais, setTodosProfissionais] = useState([]);
|
const [todosProfissionais, setTodosProfissionais] = useState([]);
|
||||||
const [profissionaisFiltrados, setProfissionaisFiltrados] = useState([]);
|
const [profissionaisFiltrados, setProfissionaisFiltrados] = useState([]);
|
||||||
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
||||||
const [horarioInicio, setHorarioInicio] = useState('');
|
|
||||||
const [horarioTermino, setHorarioTermino] = useState('');
|
|
||||||
const [horariosDisponiveis, sethorariosDisponiveis] = useState([]);
|
|
||||||
|
|
||||||
const [todosPacientes, setTodosPacientes] = useState([])
|
const [todosPacientes, setTodosPacientes] = useState([]);
|
||||||
const [pacientesFiltrados, setPacientesFiltrados] = useState([])
|
const [pacientesFiltrados, setPacientesFiltrados] = useState([]);
|
||||||
const [isDropdownPacienteOpen, setIsDropdownPacienteOpen] = useState(false)
|
const [isDropdownPacienteOpen, setIsDropdownPacienteOpen] = useState(false);
|
||||||
|
|
||||||
const [status, setStatus] = useState("confirmed")
|
const authHeader = getAuthorizationHeader();
|
||||||
|
|
||||||
let authHeader = getAuthorizationHeader()
|
|
||||||
|
|
||||||
const FormatCPF = (valor) => {
|
const FormatCPF = (valor) => {
|
||||||
const digits = String(valor).replace(/\D/g, '').slice(0, 11);
|
const digits = String(valor).replace(/\D/g, "").slice(0, 11);
|
||||||
return digits
|
return digits
|
||||||
.replace(/(\d{3})(\d)/, '$1.$2')
|
.replace(/(\d{3})(\d)/, "$1.$2")
|
||||||
.replace(/(\d{3})(\d)/, '$1.$2')
|
.replace(/(\d{3})(\d)/, "$1.$2")
|
||||||
.replace(/(\d{3})(\d{1,2})$/, '$1-$2');
|
.replace(/(\d{3})(\d{1,2})$/, "$1-$2");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
const { value, name } = e.target;
|
const { value, name } = e.target;
|
||||||
|
|
||||||
if (name === 'email') {
|
if (name === "email") {
|
||||||
setAgendamento(prev => ({
|
setAgendamento((prev) => ({
|
||||||
...prev,
|
|
||||||
contato: { ...prev.contato, email: value }
|
|
||||||
}));
|
|
||||||
} else if (name === 'status') {
|
|
||||||
setAgendamento(prev => ({
|
|
||||||
...prev,
|
...prev,
|
||||||
status: prev.status === 'requested' ? 'confirmed' : 'requested'
|
contato: {
|
||||||
|
...(prev.contato || {}),
|
||||||
|
email: value,
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
} else if (name === 'paciente_cpf') {
|
} else if (name === "status") {
|
||||||
|
setAgendamento((prev) => ({
|
||||||
|
...prev,
|
||||||
|
status: prev.status === "requested" ? "confirmed" : "requested",
|
||||||
|
}));
|
||||||
|
setStatus((prev) => (prev === "confirmed" ? "requested" : "confirmed"));
|
||||||
|
} else if (name === "paciente_cpf") {
|
||||||
const cpfFormatted = FormatCPF(value);
|
const cpfFormatted = FormatCPF(value);
|
||||||
const fetchPatient = async () => {
|
const fetchPatient = async () => {
|
||||||
const patientData = await GetPatientByCPF(cpfFormatted, authHeader);
|
const patientData = await GetPatientByCPF(cpfFormatted, authHeader);
|
||||||
if (patientData) {
|
if (patientData) {
|
||||||
setAgendamento(prev => ({
|
setAgendamento((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
paciente_nome: patientData.full_name,
|
paciente_nome: patientData.full_name,
|
||||||
patient_id: patientData.id
|
patient_id: patientData.id,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setAgendamento(prev => ({ ...prev, paciente_cpf: cpfFormatted }));
|
setAgendamento((prev) => ({ ...prev, paciente_cpf: cpfFormatted }));
|
||||||
fetchPatient();
|
fetchPatient();
|
||||||
} else if (name === 'convenio') {
|
} else if (name === "convenio") {
|
||||||
setAgendamento(prev => ({ ...prev, insurance_provider: value }));
|
setAgendamento((prev) => ({ ...prev, insurance_provider: value }));
|
||||||
} else {
|
} else {
|
||||||
setAgendamento(prev => ({ ...prev, [name]: value }));
|
setAgendamento((prev) => ({ ...prev, [name]: value }));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ChamarMedicos = useCallback(async () => {
|
const ChamarMedicos = useCallback(async () => {
|
||||||
const Medicos = await GetAllDoctors(authHeader);
|
const Medicos = await GetAllDoctors(authHeader);
|
||||||
setTodosProfissionais(Medicos);
|
setTodosProfissionais(Medicos || []);
|
||||||
}, [authHeader]);
|
}, [authHeader]);
|
||||||
|
|
||||||
const ChamarPacientes = useCallback (async () => {
|
const ChamarPacientes = useCallback(async () => {
|
||||||
const Pacientes = await GetAllPatients(authHeader);
|
const Pacientes = await GetAllPatients(authHeader);
|
||||||
setTodosPacientes(Pacientes)
|
setTodosPacientes(Pacientes || []);
|
||||||
console.log("pacientes")
|
}, [authHeader]);
|
||||||
console.log(Pacientes)
|
|
||||||
}, [authHeader])
|
// AUTOCOMPLETE PACIENTE
|
||||||
|
const handleSearchPaciente = (e) => {
|
||||||
|
const term = e.target.value;
|
||||||
|
setAgendamento((prev) => ({ ...prev, paciente_nome: term }));
|
||||||
|
|
||||||
|
if (term.trim() === "") {
|
||||||
|
setPacientesFiltrados([]);
|
||||||
|
setIsDropdownPacienteOpen(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const filtered = todosPacientes.filter((p) =>
|
||||||
|
p.full_name.toLowerCase().includes(term.toLowerCase())
|
||||||
|
);
|
||||||
|
|
||||||
|
setPacientesFiltrados(filtered);
|
||||||
|
setIsDropdownPacienteOpen(filtered.length > 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSelectPaciente = (paciente) => {
|
||||||
|
setAgendamento((prev) => ({
|
||||||
|
...prev,
|
||||||
|
patient_id: paciente.id,
|
||||||
|
paciente_nome: paciente.full_name,
|
||||||
|
paciente_cpf: paciente.cpf,
|
||||||
|
}));
|
||||||
|
setPacientesFiltrados([]);
|
||||||
|
setIsDropdownPacienteOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
// AUTOCOMPLETE PROFISSIONAL
|
||||||
|
const handleSearchProfissional = (e) => {
|
||||||
|
const term = e.target.value;
|
||||||
|
handleChange(e);
|
||||||
|
|
||||||
|
if (term.trim() === "") {
|
||||||
|
setProfissionaisFiltrados([]);
|
||||||
|
setIsDropdownOpen(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const filtered = todosProfissionais.filter((p) =>
|
||||||
|
p.full_name.toLowerCase().includes(term.toLowerCase())
|
||||||
|
);
|
||||||
|
|
||||||
|
setProfissionaisFiltrados(filtered);
|
||||||
|
setIsDropdownOpen(filtered.length > 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSelectProfissional = (profissional) => {
|
||||||
|
setAgendamento((prev) => ({
|
||||||
|
...prev,
|
||||||
|
doctor_id: profissional.id,
|
||||||
|
nome_medico: profissional.full_name,
|
||||||
|
}));
|
||||||
|
setProfissionaisFiltrados([]);
|
||||||
|
setIsDropdownOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatarHora = (datetimeString) => {
|
||||||
|
return datetimeString?.substring(11, 16) || "";
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (agendamento?.scheduled_at) {
|
||||||
console.log("Horario","tessssste" )
|
setHorarioInicio(formatarHora(agendamento.scheduled_at));
|
||||||
if (agendamento?.scheduled_at) {
|
}
|
||||||
setHorarioInicio(formatarHora(agendamento.scheduled_at));
|
}, []);
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
ChamarMedicos();
|
ChamarMedicos();
|
||||||
}, [ChamarMedicos]);
|
ChamarPacientes();
|
||||||
|
}, [ChamarMedicos, ChamarPacientes]);
|
||||||
useEffect(() => {
|
|
||||||
|
|
||||||
ChamarPacientes()
|
|
||||||
}, [ChamarPacientes])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!agendamento.dataAtendimento || !agendamento.doctor_id) return;
|
if (!agendamento.dataAtendimento || !agendamento.doctor_id) return;
|
||||||
@ -105,7 +163,7 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
|||||||
const myHeaders = new Headers();
|
const myHeaders = new Headers();
|
||||||
myHeaders.append("Content-Type", "application/json");
|
myHeaders.append("Content-Type", "application/json");
|
||||||
myHeaders.append("apikey", API_KEY);
|
myHeaders.append("apikey", API_KEY);
|
||||||
myHeaders.append("Authorization", `Bearer ${authHeader.split(' ')[1]}`);
|
myHeaders.append("Authorization", `Bearer ${authHeader.split(" ")[1]}`);
|
||||||
|
|
||||||
const raw = JSON.stringify({
|
const raw = JSON.stringify({
|
||||||
doctor_id: agendamento.doctor_id,
|
doctor_id: agendamento.doctor_id,
|
||||||
@ -114,321 +172,304 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
headers: myHeaders,
|
headers: myHeaders,
|
||||||
body: raw,
|
body: raw,
|
||||||
};
|
};
|
||||||
|
|
||||||
fetch("https://yuanqfswhberkoevtmfr.supabase.co/functions/v1/get-available-slots", requestOptions)
|
fetch(
|
||||||
.then(response => response.json())
|
"https://yuanqfswhberkoevtmfr.supabase.co/functions/v1/get-available-slots",
|
||||||
.then(result => sethorariosDisponiveis(result))
|
requestOptions
|
||||||
.catch(error => console.log('error', error));
|
)
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((result) => {
|
||||||
|
sethorariosDisponiveis(result);
|
||||||
|
})
|
||||||
|
.catch((error) => console.log("error", error));
|
||||||
}, [agendamento.dataAtendimento, agendamento.doctor_id, authHeader]);
|
}, [agendamento.dataAtendimento, agendamento.doctor_id, authHeader]);
|
||||||
|
|
||||||
const handleSearchProfissional = (e) => {
|
const slotsArray = Array.isArray(horariosDisponiveis)
|
||||||
const term = e.target.value;
|
? horariosDisponiveis
|
||||||
handleChange(e);
|
: horariosDisponiveis?.slots || [];
|
||||||
|
|
||||||
if (term.trim() === '') {
|
|
||||||
setProfissionaisFiltrados([]);
|
|
||||||
setIsDropdownOpen(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const filtered = todosProfissionais.filter(p =>
|
const opcoesDeHorario = slotsArray.map((item) => ({
|
||||||
p.full_name.toLowerCase().includes(term.toLowerCase())
|
|
||||||
);
|
|
||||||
|
|
||||||
setProfissionaisFiltrados(filtered);
|
|
||||||
setIsDropdownOpen(filtered.length > 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSearchPaciente = (e) => {
|
|
||||||
const term = e.target.value;
|
|
||||||
handleChange(e);
|
|
||||||
|
|
||||||
if (term.trim() === '') {
|
|
||||||
setPacientesFiltrados([]);
|
|
||||||
setIsDropdownPacienteOpen(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const filtered = todosPacientes.filter(p =>
|
|
||||||
p.full_name.toLowerCase().includes(term.toLowerCase())
|
|
||||||
);
|
|
||||||
console.log(filtered.length > 0, "filtrados")
|
|
||||||
|
|
||||||
setPacientesFiltrados(filtered);
|
|
||||||
setIsDropdownPacienteOpen(filtered.length > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSelectProfissional = (profissional) => {
|
|
||||||
setAgendamento(prev => ({
|
|
||||||
...prev,
|
|
||||||
doctor_id: profissional.id,
|
|
||||||
nome_medico: profissional.full_name
|
|
||||||
}));
|
|
||||||
setProfissionaisFiltrados([]);
|
|
||||||
setIsDropdownOpen(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSelectPaciente = (paciente) => {
|
|
||||||
setAgendamento(prev => ({
|
|
||||||
...prev,
|
|
||||||
patient_id:paciente.id,
|
|
||||||
paciente_nome: paciente.full_name,
|
|
||||||
paciente_cpf: paciente.cpf
|
|
||||||
}))
|
|
||||||
setProfissionaisFiltrados([])
|
|
||||||
setIsDropdownPacienteOpen(false)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const formatarHora = (datetimeString) => {
|
|
||||||
return datetimeString?.substring(11, 16) || '';
|
|
||||||
};
|
|
||||||
|
|
||||||
const opcoesDeHorario = horariosDisponiveis?.slots?.map(item => ({
|
|
||||||
value: formatarHora(item.datetime),
|
value: formatarHora(item.datetime),
|
||||||
label: formatarHora(item.datetime),
|
label: formatarHora(item.datetime),
|
||||||
disabled: !item.available
|
disabled: !item.available,
|
||||||
})) || [];
|
}));
|
||||||
|
|
||||||
const calcularHorarioTermino = useCallback((inicio, sessoes, tempoBase) => {
|
const calcularHorarioTermino = useCallback((inicio, sessoesParam, tempoBase) => {
|
||||||
if (!inicio || inicio.length !== 5 || !inicio.includes(':')) return '';
|
if (!inicio || inicio.length !== 5 || !inicio.includes(":")) return "";
|
||||||
|
|
||||||
const [horas, minutos] = inicio.split(':').map(Number);
|
const [horas, minutos] = inicio.split(":").map(Number);
|
||||||
const minutosInicio = (horas * 60) + minutos;
|
const minutosInicio = horas * 60 + minutos;
|
||||||
const duracaoTotalMinutos = sessoes * tempoBase;
|
const duracaoTotalMinutos = sessoesParam * tempoBase;
|
||||||
const minutosTermino = minutosInicio + duracaoTotalMinutos;
|
const minutosTermino = minutosInicio + duracaoTotalMinutos;
|
||||||
|
|
||||||
const horaTermino = Math.floor(minutosTermino / 60) % 24;
|
const horaTermino = Math.floor(minutosTermino / 60) % 24;
|
||||||
const minutoTermino = minutosTermino % 60;
|
const minutoTermino = minutosTermino % 60;
|
||||||
|
|
||||||
const formatar = (num) => String(num).padStart(2, '0');
|
const formatar = (num) => String(num).padStart(2, "0");
|
||||||
return `${formatar(horaTermino)}:${formatar(minutoTermino)}`;
|
return `${formatar(horaTermino)}:${formatar(minutoTermino)}`;
|
||||||
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const novoTermino = calcularHorarioTermino(horarioInicio, sessoes, tempoBaseConsulta);
|
const novoTermino = calcularHorarioTermino(
|
||||||
|
horarioInicio,
|
||||||
|
sessoes,
|
||||||
|
tempoBaseConsulta
|
||||||
|
);
|
||||||
|
|
||||||
setHorarioTermino(novoTermino);
|
setHorarioTermino(novoTermino);
|
||||||
setAgendamento(prev => ({
|
setAgendamento((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
horarioTermino: novoTermino
|
horarioTermino: novoTermino,
|
||||||
}));
|
}));
|
||||||
}, [horarioInicio, sessoes, tempoBaseConsulta, setAgendamento, calcularHorarioTermino]);
|
}, [horarioInicio, sessoes, tempoBaseConsulta, calcularHorarioTermino, setAgendamento]);
|
||||||
|
|
||||||
const handleSubmit = (e) => {
|
const handleSubmit = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setShowSuccessModal(true);
|
if (isSubmitting) return;
|
||||||
};
|
|
||||||
|
|
||||||
const handleCloseModal = () => {
|
if (
|
||||||
setShowSuccessModal(false);
|
!agendamento.doctor_id ||
|
||||||
onSave({ ...agendamento, horarioInicio: horarioInicio, status:status });
|
!agendamento.patient_id ||
|
||||||
|
!agendamento.dataAtendimento ||
|
||||||
|
!horarioInicio
|
||||||
|
) {
|
||||||
|
alert(
|
||||||
|
"Por favor, preencha o profissional, paciente, data e horário de início."
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSubmitting(true);
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
...agendamento,
|
||||||
|
horarioInicio,
|
||||||
|
status,
|
||||||
|
duration_minutes: sessoes * tempoBaseConsulta,
|
||||||
|
};
|
||||||
|
|
||||||
|
onSave?.(payload);
|
||||||
|
setIsSubmitting(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCheckbox = () => {
|
const handleCheckbox = () => {
|
||||||
if(status === "confirmed"){
|
if (status === "confirmed") {
|
||||||
setStatus("requested")
|
setStatus("requested");
|
||||||
}else{
|
setAgendamento((prev) => ({ ...prev, status: "requested" }));
|
||||||
setStatus("confirmed")
|
} else {
|
||||||
|
setStatus("confirmed");
|
||||||
|
setAgendamento((prev) => ({ ...prev, status: "confirmed" }));
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return (<div className="form-container">
|
return (
|
||||||
{showSuccessModal && (
|
<div className="form-container">
|
||||||
<div className="modal-overlay">
|
<form className="form-agendamento" onSubmit={handleSubmit}>
|
||||||
<div className="modal-content">
|
<h2 className="section-title">Informações do paciente</h2>
|
||||||
<div className="modal-header">
|
|
||||||
<h5 className="modal-title">Sucesso</h5>
|
|
||||||
</div>
|
|
||||||
<div className="modal-body">
|
|
||||||
<p className="modal-message">Agendamento salvo com sucesso!</p>
|
|
||||||
</div>
|
|
||||||
<div className="modal-footer">
|
|
||||||
<button onClick={handleCloseModal} className="modal-confirm-btn">Fechar</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<form className="form-agendamento" onSubmit={handleSubmit}>
|
<div
|
||||||
<h2 className="section-title">Informações do paciente</h2>
|
className="campos-informacoes-paciente"
|
||||||
|
id="informacoes-paciente-linha-um"
|
||||||
|
>
|
||||||
|
<div className="campo-de-input-container">
|
||||||
|
<div className="campo-de-input">
|
||||||
|
<label>Nome *</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="paciente_nome"
|
||||||
|
value={agendamento.paciente_nome || ""}
|
||||||
|
placeholder="Insira o nome do paciente"
|
||||||
|
required
|
||||||
|
onChange={handleSearchPaciente}
|
||||||
|
autoComplete="off"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="campos-informacoes-paciente" id="informacoes-paciente-linha-um">
|
<div className="campo-de-input">
|
||||||
<div className="campo-de-input-container">
|
<label>CPF do paciente</label>
|
||||||
<div className="campo-de-input">
|
<InputMask
|
||||||
<label>Nome *</label>
|
mask="999.999.999-99"
|
||||||
<input
|
maskChar={null}
|
||||||
type="text"
|
type="text"
|
||||||
name="paciente_nome"
|
name="paciente_cpf"
|
||||||
placeholder="Insira o nome do paciente"
|
placeholder="000.000.000-00"
|
||||||
required
|
value={agendamento.paciente_cpf || ""}
|
||||||
onChange={(e) => handleSearchPaciente(e)}
|
onChange={handleChange}
|
||||||
value={agendamento?.paciente_nome || ""}
|
autoComplete="off"
|
||||||
autoComplete="off"
|
/>
|
||||||
/>
|
</div>
|
||||||
</div>
|
|
||||||
{isDropdownPacienteOpen && pacientesFiltrados.length > 0 && (
|
{isDropdownPacienteOpen && pacientesFiltrados.length > 0 && (
|
||||||
<div className="dropdown-pacientes">
|
<div className="dropdown-pacientes">
|
||||||
{pacientesFiltrados.map((paciente) => (
|
{pacientesFiltrados.map((paciente) => (
|
||||||
<div
|
<div
|
||||||
key={paciente.id}
|
key={paciente.id}
|
||||||
className="dropdown-item"
|
className="dropdown-item"
|
||||||
onClick={() => handleSelectPaciente(paciente)}
|
onClick={() => handleSelectPaciente(paciente)}
|
||||||
>
|
>
|
||||||
{`${paciente.full_name.split(" ")[0]} ${paciente.full_name.split(" ")[1]} - ${paciente.cpf}`}
|
{`${paciente.full_name} - ${paciente.cpf}`}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
))}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="campo-de-input campo-cpf">
|
<div
|
||||||
<label>CPF do paciente</label>
|
className="campos-informacoes-paciente"
|
||||||
<input
|
id="informacoes-paciente-linha-tres"
|
||||||
type="text"
|
>
|
||||||
name="paciente_cpf"
|
<div>
|
||||||
placeholder="000.000.000-00"
|
<label>Convênio</label>
|
||||||
onChange={handleChange}
|
|
||||||
value={agendamento.paciente_cpf}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="campos-informacoes-paciente" id="informacoes-paciente-linha-tres">
|
|
||||||
<div>
|
|
||||||
<label>Convênio</label>
|
|
||||||
<select name="convenio" onChange={handleChange} value={agendamento.insurance_provider}>
|
|
||||||
<option value="publico">Público</option>
|
|
||||||
<option value="unimed">Unimed</option>
|
|
||||||
<option value="bradesco_saude">Bradesco Saúde</option>
|
|
||||||
<option value="hapvida">Hapvida</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2 className="section-title">Informações do atendimento</h2>
|
|
||||||
|
|
||||||
<div className="campo-informacoes-atendimento">
|
|
||||||
<div className="campo-de-input-container">
|
|
||||||
<div className="campo-de-input">
|
|
||||||
<label>Nome do profissional *</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="nome_medico"
|
|
||||||
onChange={handleSearchProfissional}
|
|
||||||
value={agendamento?.nome_medico || ''}
|
|
||||||
autoComplete="off"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{isDropdownOpen && profissionaisFiltrados.length > 0 && (
|
|
||||||
<div className="dropdown-profissionais">
|
|
||||||
{profissionaisFiltrados.map((profissional) => (
|
|
||||||
<div
|
|
||||||
key={profissional.id}
|
|
||||||
className="dropdown-item"
|
|
||||||
onClick={() => handleSelectProfissional(profissional)}
|
|
||||||
>
|
|
||||||
{profissional.full_name}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="tipo_atendimento">
|
|
||||||
<label>Tipo de atendimento *</label>
|
|
||||||
<select name="tipo_atendimento" onChange={handleChange} value={agendamento.tipo_atendimento}>
|
|
||||||
<option value="presencial">Presencial</option>
|
|
||||||
<option value="teleconsulta">Teleconsulta</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<section id="informacoes-atendimento-segunda-linha">
|
|
||||||
<div className="campo-informacoes-atendimento">
|
|
||||||
<div className="campo-de-input">
|
|
||||||
<label>Data *</label>
|
|
||||||
<input
|
|
||||||
type="date"
|
|
||||||
name="dataAtendimento"
|
|
||||||
onChange={handleChange}
|
|
||||||
value={agendamento.dataAtendimento}
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="linha">
|
|
||||||
<div className="campo-de-input">
|
|
||||||
<label htmlFor="inicio">Início *</label>
|
|
||||||
<select
|
<select
|
||||||
id="inicio"
|
name="convenio"
|
||||||
name="inicio"
|
onChange={handleChange}
|
||||||
required
|
value={agendamento.insurance_provider || "publico"}
|
||||||
value={horarioInicio}
|
|
||||||
onChange={(e) => setHorarioInicio(e.target.value)}
|
|
||||||
>
|
>
|
||||||
<option value="" disabled>Selecione a hora de início</option>
|
<option value="publico">Público</option>
|
||||||
{opcoesDeHorario.map((opcao, index) => (
|
<option value="unimed">Unimed</option>
|
||||||
<option key={index} value={opcao.value} disabled={opcao.disabled}>
|
<option value="bradesco_saude">Bradesco Saúde</option>
|
||||||
{opcao.label}
|
<option value="hapvida">Hapvida</option>
|
||||||
{opcao.disabled && " (Indisponível)"}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="campo-de-input">
|
<h2 className="section-title">Informações do atendimento</h2>
|
||||||
<label htmlFor="termino">Término *</label>
|
|
||||||
<input
|
<div className="campo-informacoes-atendimento">
|
||||||
type="text"
|
<div className="campo-de-input-container">
|
||||||
id="termino"
|
<div className="campo-de-input">
|
||||||
name="termino"
|
<label>Nome do profissional *</label>
|
||||||
value={horarioTermino || '— —'}
|
<input
|
||||||
readOnly
|
type="text"
|
||||||
className="horario-termino-readonly"
|
name="nome_medico"
|
||||||
/>
|
onChange={handleSearchProfissional}
|
||||||
|
value={agendamento?.nome_medico || ""}
|
||||||
|
autoComplete="off"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isDropdownOpen && profissionaisFiltrados.length > 0 && (
|
||||||
|
<div className="dropdown-profissionais">
|
||||||
|
{profissionaisFiltrados.map((profissional) => (
|
||||||
|
<div
|
||||||
|
key={profissional.id}
|
||||||
|
className="dropdown-item"
|
||||||
|
onClick={() => handleSelectProfissional(profissional)}
|
||||||
|
>
|
||||||
|
{profissional.full_name}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="tipo_atendimento">
|
||||||
|
<label>Tipo de atendimento *</label>
|
||||||
|
<select
|
||||||
|
name="tipo_atendimento"
|
||||||
|
onChange={handleChange}
|
||||||
|
value={agendamento.tipo_atendimento || "presencial"}
|
||||||
|
>
|
||||||
|
<option value="presencial">Presencial</option>
|
||||||
|
<option value="teleconsulta">Teleconsulta</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="campo-de-input observacoes">
|
<section id="informacoes-atendimento-segunda-linha">
|
||||||
<label>Observações</label>
|
<section id="informacoes-atendimento-segunda-linha-esquerda">
|
||||||
<textarea
|
<div className="campo-informacoes-atendimento">
|
||||||
name="observacoes"
|
<div className="campo-de-input">
|
||||||
rows="4"
|
<label>Data *</label>
|
||||||
cols="1"
|
<input
|
||||||
onChange={handleChange}
|
type="date"
|
||||||
value={agendamento.observacoes || ''}
|
name="dataAtendimento"
|
||||||
/>
|
onChange={handleChange}
|
||||||
</div>
|
value={agendamento.dataAtendimento || ""}
|
||||||
</section>
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="campo-de-input-check">
|
<div className="linha">
|
||||||
<input
|
<div className="campo-de-input">
|
||||||
className="form-check-input form-custom-check"
|
<label htmlFor="inicio">Início *</label>
|
||||||
type="checkbox"
|
<select
|
||||||
name="status"
|
id="inicio"
|
||||||
onChange={handleCheckbox}
|
name="inicio"
|
||||||
checked={status === "requested"}
|
value={horarioInicio}
|
||||||
/>
|
onChange={(e) => setHorarioInicio(e.target.value)}
|
||||||
<label className="form-check-label checkbox-label" htmlFor="status">
|
required
|
||||||
Adicionar à fila de espera
|
>
|
||||||
</label>
|
<option value="" disabled>
|
||||||
|
Selecione a hora de início
|
||||||
|
</option>
|
||||||
|
{opcoesDeHorario.map((opcao, index) => (
|
||||||
|
<option
|
||||||
|
key={index}
|
||||||
|
value={opcao.value}
|
||||||
|
disabled={opcao.disabled}
|
||||||
|
>
|
||||||
|
{opcao.label}
|
||||||
|
{opcao.disabled && " (Indisponível)"}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="campo-de-input">
|
||||||
|
<label htmlFor="termino">Término *</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="termino"
|
||||||
|
name="termino"
|
||||||
|
value={horarioTermino || "— —"}
|
||||||
|
readOnly
|
||||||
|
className="horario-termino-readonly"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section className="informacoes-atendimento-segunda-linha-direita">
|
||||||
|
<div className="campo-de-input">
|
||||||
|
<label>Observações</label>
|
||||||
|
<textarea
|
||||||
|
name="observacoes"
|
||||||
|
rows="4"
|
||||||
|
cols="1"
|
||||||
|
onChange={handleChange}
|
||||||
|
value={agendamento.observacoes || ""}
|
||||||
|
></textarea>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div className="form-actions">
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn-primary"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
{isSubmitting ? "Salvando..." : "Salvar agendamento"}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn-cancel"
|
||||||
|
onClick={onCancel}
|
||||||
|
>
|
||||||
|
Cancelar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form-actions">
|
|
||||||
<button type="submit" className="btn-primary">Salvar agendamento</button>
|
|
||||||
<button type="button" className="btn-cancel" onClick={onCancel}>Cancelar</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
@media (max-width: 768px) {
|
||||||
|
.container-cardconsulta {
|
||||||
|
padding-right: 80px; /* Espaço para os botões */
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.actions-container {
|
.actions-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
@ -84,4 +91,50 @@
|
|||||||
.tabelamensal .container-cardconsulta{
|
.tabelamensal .container-cardconsulta{
|
||||||
width: 24rem;
|
width: 24rem;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.actions-container {
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
background: none;
|
||||||
|
backdrop-filter: none;
|
||||||
|
-webkit-backdrop-filter: none;
|
||||||
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
|
margin-left: 0;
|
||||||
|
padding: 0;
|
||||||
|
justify-content: flex-end;
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-cardconsulta:hover .actions-container {
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabelamensal .container-cardconsulta {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.container-cardconsulta {
|
||||||
|
padding-right: 10px; /* Remove o padding extra para telas muito pequenas */
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions-container {
|
||||||
|
position: static;
|
||||||
|
margin-top: 10px;
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-edit-custom-style,
|
||||||
|
.btn-delete-custom-style,
|
||||||
|
.btn-confirm-style {
|
||||||
|
padding: 6px 10px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -183,6 +183,67 @@ textarea{
|
|||||||
gap: 16px;
|
gap: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.campos-informacoes-paciente,
|
||||||
|
.campo-informacoes-atendimento {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#informacoes-atendimento-segunda-linha {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#informacoes-atendimento-segunda-linha-esquerda select[name="unidade"],
|
||||||
|
input[type="time"],
|
||||||
|
select[name=solicitante],
|
||||||
|
.campo-de-input {
|
||||||
|
width: 100% !important;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tipo_atendimento {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.linha {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sessao-contador {
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.form-container {
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-title {
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-agendamento input,
|
||||||
|
.form-agendamento select,
|
||||||
|
.form-agendamento textarea {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary,
|
||||||
|
.btn-cancel {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.campo-de-input {
|
.campo-de-input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -689,4 +750,94 @@ input[name="paciente_cpf"]{
|
|||||||
z-index: 100;
|
z-index: 100;
|
||||||
max-height: 200px;
|
max-height: 200px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
#informacoes-atendimento-segunda-linha .linha-horarios {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: flex-end; /* alinha pela base dos inputs */
|
||||||
|
}
|
||||||
|
|
||||||
|
#informacoes-atendimento-segunda-linha .linha-horarios .campo-de-input {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.campo-de-input-container {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px; /* nome e cpf na mesma linha */
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.campo-de-input {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.campo-de-input label {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.campo-de-input input,
|
||||||
|
.campo-de-input select,
|
||||||
|
.campo-de-input textarea {
|
||||||
|
width: 220px; /* ajuste pro layout que você quer */
|
||||||
|
padding: 6px 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* placeholder visível e suave */
|
||||||
|
.campo-de-input input::placeholder {
|
||||||
|
color: #999;
|
||||||
|
opacity: 1; /* garante no Firefox */
|
||||||
|
}
|
||||||
|
/* bloco da coluna esquerda (Data, Início, Término) */
|
||||||
|
#informacoes-atendimento-segunda-linha-esquerda {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* linha com Início e Término */
|
||||||
|
#informacoes-atendimento-segunda-linha-esquerda .linha {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* mesma largura pros três campos */
|
||||||
|
#informacoes-atendimento-segunda-linha-esquerda .campo-de-input input,
|
||||||
|
#informacoes-atendimento-segunda-linha-esquerda .campo-de-input select {
|
||||||
|
width: 230px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.informacoes-atendimento-segunda-linha-direita {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.informacoes-atendimento-segunda-linha-direita .campo-de-input textarea {
|
||||||
|
width: 100%; /* ocupa toda a coluna da direita */
|
||||||
|
min-height: 150px; /* aumenta a altura (muda pra 200, 250 se quiser maior) */
|
||||||
|
resize: vertical;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
#informacoes-atendimento-segunda-linha {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto 1.8fr; /* coluna da direita grande, mas não infinita */
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* garante que o container da direita não estoure */
|
||||||
|
.informacoes-atendimento-segunda-linha-direita {
|
||||||
|
max-width: 800px; /* ajusta se quiser menor/maior */
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.informacoes-atendimento-segunda-linha-direita .campo-de-input textarea {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 150px;
|
||||||
|
resize: vertical;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|||||||
@ -223,6 +223,8 @@
|
|||||||
z-index: 2001;
|
z-index: 2001;
|
||||||
margin-top: 80px;
|
margin-top: 80px;
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
|
/* Adicionado para responsividade */
|
||||||
|
max-width: 90vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.suporte-card {
|
.suporte-card {
|
||||||
@ -309,6 +311,8 @@
|
|||||||
z-index: 3001;
|
z-index: 3001;
|
||||||
margin-top: 80px;
|
margin-top: 80px;
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
|
/* Adicionado para responsividade */
|
||||||
|
max-width: 90vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-online {
|
.chat-online {
|
||||||
@ -462,6 +466,81 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Responsividade */
|
/* Responsividade */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.header-container {
|
||||||
|
padding: 10px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-corner-elements {
|
||||||
|
gap: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-picture-container {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.suporte-card-container,
|
||||||
|
.chat-container {
|
||||||
|
margin-top: 60px;
|
||||||
|
margin-right: 10px;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.suporte-card,
|
||||||
|
.chat-online {
|
||||||
|
width: calc(100vw - 20px);
|
||||||
|
max-width: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.header-container {
|
||||||
|
padding: 8px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-corner-elements {
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-picture-container {
|
||||||
|
width: 35px;
|
||||||
|
height: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phone-icon-container {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.suporte-card-container,
|
||||||
|
.chat-container {
|
||||||
|
margin-top: 50px;
|
||||||
|
margin-right: 5px;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.suporte-card {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-online {
|
||||||
|
width: calc(100vw - 10px);
|
||||||
|
height: 80vh; /* Limita a altura para telas pequenas */
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-input {
|
||||||
|
padding: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-campo {
|
||||||
|
padding: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-enviar {
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.header-container {
|
.header-container {
|
||||||
padding: 10px 15px;
|
padding: 10px 15px;
|
||||||
|
|||||||
@ -1,13 +1,19 @@
|
|||||||
body {
|
*,
|
||||||
margin: 0;
|
*::before,
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
*::after {
|
||||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
box-sizing: border-box;
|
||||||
sans-serif;
|
}
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
body {
|
||||||
}
|
margin: 0;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||||
code {
|
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
sans-serif;
|
||||||
monospace;
|
-webkit-font-smoothing: antialiased;
|
||||||
}
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||||
|
monospace;
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -4,179 +4,98 @@ import API_KEY from '../components/utils/apiKeys';
|
|||||||
import { useAuth } from '../components/utils/AuthProvider';
|
import { useAuth } from '../components/utils/AuthProvider';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { UserInfos } from '../components/utils/Functions-Endpoints/General';
|
import { UserInfos } from '../components/utils/Functions-Endpoints/General';
|
||||||
import { toast } from 'react-toastify';
|
|
||||||
const AgendamentoCadastroManager = ({ setPageConsulta, agendamentoInicial }) => {
|
|
||||||
|
|
||||||
const { getAuthorizationHeader } = useAuth();
|
const AgendamentoCadastroManager = ({ setPageConsulta, Dict, onSaved }) => {
|
||||||
|
const { getAuthorizationHeader, user } = useAuth();
|
||||||
|
const [agendamento, setAgendamento] = useState({ status: 'confirmed' });
|
||||||
|
const [idUsuario, setIDusuario] = useState('0');
|
||||||
|
|
||||||
|
// patient_id do paciente logado (ou fallback para o Pedro)
|
||||||
|
|
||||||
const [agendamento, setAgendamento] = useState({ status: 'agendado' });
|
const patientId = 'bf7d8323-05e1-437a-817c-f08eb5f174ef';
|
||||||
const [idUsuario, setIDusuario] = useState('0');
|
|
||||||
const [isEditMode, setIsEditMode] = useState(false);
|
|
||||||
|
|
||||||
let authHeader = getAuthorizationHeader();
|
const authHeader = getAuthorizationHeader();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!Dict) {
|
||||||
|
setAgendamento({ status: 'confirmed' });
|
||||||
if (agendamentoInicial && agendamentoInicial.id) {
|
} else {
|
||||||
|
setAgendamento(Dict);
|
||||||
const scheduled_at = dayjs(agendamentoInicial.scheduled_at);
|
|
||||||
|
|
||||||
setAgendamento({
|
|
||||||
...agendamentoInicial,
|
|
||||||
|
|
||||||
dataAtendimento: scheduled_at.format('YYYY-MM-DD'),
|
|
||||||
horarioInicio: scheduled_at.format('HH:mm'),
|
|
||||||
|
|
||||||
|
|
||||||
tipo_consulta: agendamentoInicial.appointment_type || 'Presencial',
|
|
||||||
convenio: agendamentoInicial.insurance_provider || 'Público',
|
|
||||||
|
|
||||||
|
|
||||||
paciente_nome: agendamentoInicial.paciente_nome || '',
|
|
||||||
paciente_cpf: agendamentoInicial.paciente_cpf || '',
|
|
||||||
medico_nome: agendamentoInicial.medico_nome || '',
|
|
||||||
|
|
||||||
|
|
||||||
patient_id: agendamentoInicial.patient_id,
|
|
||||||
doctor_id: agendamentoInicial.doctor_id,
|
|
||||||
status: agendamentoInicial.status,
|
|
||||||
});
|
|
||||||
setIsEditMode(true);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
setAgendamento({
|
|
||||||
status: 'agendado',
|
|
||||||
patient_id: null,
|
|
||||||
doctor_id: null,
|
|
||||||
dataAtendimento: dayjs().format('YYYY-MM-DD'),
|
|
||||||
horarioInicio: '',
|
|
||||||
tipo_consulta: 'Presencial',
|
|
||||||
convenio: 'Público',
|
|
||||||
paciente_nome: '',
|
|
||||||
paciente_cpf: '',
|
|
||||||
medico_nome: ''
|
|
||||||
});
|
|
||||||
setIsEditMode(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const ColherInfoUsuario = async () => {
|
|
||||||
const result = await UserInfos(authHeader);
|
|
||||||
setIDusuario(result?.profile?.id);
|
|
||||||
};
|
|
||||||
ColherInfoUsuario();
|
|
||||||
|
|
||||||
|
|
||||||
}, [agendamentoInicial, authHeader]);
|
|
||||||
const handleSave = async (Dict) => {
|
|
||||||
var myHeaders = new Headers();
|
|
||||||
myHeaders.append("apikey", API_KEY);
|
|
||||||
myHeaders.append("Authorization", authHeader);
|
|
||||||
myHeaders.append("Content-Type", "application/json");
|
|
||||||
myHeaders.append("Prefer", "return=representation");
|
|
||||||
|
|
||||||
var raw = JSON.stringify({
|
|
||||||
"patient_id": Dict.patient_id,
|
|
||||||
"doctor_id": Dict.doctor_id,
|
|
||||||
"scheduled_at": `${Dict.dataAtendimento}T${Dict.horarioInicio}:00.000Z`,
|
|
||||||
"duration_minutes": Dict.duration_minutes || 30,
|
|
||||||
"appointment_type": Dict.tipo_consulta,
|
|
||||||
"insurance_provider": Dict.convenio,
|
|
||||||
"status": Dict.status || 'agendado',
|
|
||||||
"created_by": idUsuario,
|
|
||||||
"created_at": dayjs().toISOString(),
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
var requestOptions = {
|
|
||||||
method: 'POST',
|
|
||||||
headers: myHeaders,
|
|
||||||
body: raw,
|
|
||||||
redirect: 'follow'
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments", requestOptions);
|
|
||||||
if (response.ok) {
|
|
||||||
toast.success("Agendamento criado com sucesso! ✅");
|
|
||||||
setPageConsulta(false);
|
|
||||||
} else {
|
|
||||||
const errorText = await response.text();
|
|
||||||
console.error('Erro ao cadastrar agendamento:', errorText);
|
|
||||||
toast.error(`Falha ao criar agendamento: ${JSON.parse(errorText)?.message || 'Erro desconhecido'}`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Erro de rede:', error);
|
|
||||||
toast.error("Erro de rede ao salvar. ❌");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const handleUpdate = async (Dict) => {
|
|
||||||
const appointmentId = agendamentoInicial.id;
|
|
||||||
|
|
||||||
var myHeaders = new Headers();
|
|
||||||
myHeaders.append("apikey", API_KEY);
|
|
||||||
myHeaders.append("Authorization", authHeader);
|
|
||||||
myHeaders.append("Content-Type", "application/json");
|
|
||||||
myHeaders.append("Prefer", "return=representation");
|
|
||||||
|
|
||||||
var raw = JSON.stringify({
|
|
||||||
"patient_id": Dict.patient_id,
|
|
||||||
"doctor_id": Dict.doctor_id,
|
|
||||||
"scheduled_at": `${Dict.dataAtendimento}T${Dict.horarioInicio}:00.000Z`,
|
|
||||||
"duration_minutes": Dict.duration_minutes || 30,
|
|
||||||
"appointment_type": Dict.tipo_consulta,
|
|
||||||
"insurance_provider": Dict.convenio,
|
|
||||||
"status": Dict.status,
|
|
||||||
"updated_at": dayjs().toISOString(),
|
|
||||||
"updated_by": idUsuario,
|
|
||||||
});
|
|
||||||
|
|
||||||
var requestOptions = {
|
|
||||||
method: 'PATCH',
|
|
||||||
headers: myHeaders,
|
|
||||||
body: raw,
|
|
||||||
redirect: 'follow'
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?id=eq.${appointmentId}`, requestOptions);
|
|
||||||
if (response.ok) {
|
|
||||||
toast.success("Agendamento atualizado com sucesso! 📝");
|
|
||||||
setPageConsulta(false);
|
|
||||||
} else {
|
|
||||||
const errorText = await response.text();
|
|
||||||
console.error('Erro ao atualizar agendamento:', errorText);
|
|
||||||
toast.error(`Falha ao atualizar agendamento: ${JSON.parse(errorText)?.message || 'Erro desconhecido'}`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Erro de rede:', error);
|
|
||||||
toast.error("Erro de rede ao atualizar. ❌");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const handleFormSubmit = (Dict) => {
|
|
||||||
if (isEditMode) {
|
|
||||||
|
|
||||||
handleUpdate(Dict);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
handleSave(Dict);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ColherInfoUsuario = async () => {
|
||||||
|
try {
|
||||||
|
const result = await UserInfos(authHeader);
|
||||||
|
setIDusuario(result?.profile?.id);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Erro ao buscar infos do usuário:', e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
if (authHeader) {
|
||||||
<div>
|
ColherInfoUsuario();
|
||||||
{}
|
}
|
||||||
<FormNovaConsulta
|
}, [Dict, authHeader]);
|
||||||
onSave={handleFormSubmit}
|
|
||||||
agendamento={agendamento}
|
const handleSave = async (DictForm) => {
|
||||||
setAgendamento={setAgendamento}
|
if (!authHeader) {
|
||||||
onCancel={() => setPageConsulta(false)}
|
alert('Sem autorização. Faça login novamente.');
|
||||||
/>
|
return;
|
||||||
</div>
|
}
|
||||||
);
|
|
||||||
|
const myHeaders = new Headers();
|
||||||
|
myHeaders.append('apikey', API_KEY);
|
||||||
|
myHeaders.append('Authorization', authHeader);
|
||||||
|
myHeaders.append('Content-Type', 'application/json');
|
||||||
|
|
||||||
|
const raw = JSON.stringify({
|
||||||
|
patient_id: patientId, // paciente logado
|
||||||
|
doctor_id: DictForm.doctor_id,
|
||||||
|
scheduled_at: `${DictForm.dataAtendimento}T${DictForm.horarioInicio}:00`,
|
||||||
|
duration_minutes: 30,
|
||||||
|
appointment_type: DictForm.tipo_consulta,
|
||||||
|
patient_notes: '',
|
||||||
|
insurance_provider: DictForm.convenio,
|
||||||
|
status: 'confirmed', // ou 'confirmed'
|
||||||
|
created_by: idUsuario,
|
||||||
|
created_at: dayjs().toISOString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const requestOptions = {
|
||||||
|
method: 'POST',
|
||||||
|
headers: myHeaders,
|
||||||
|
body: raw,
|
||||||
|
redirect: 'follow',
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
'https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments',
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
|
if (response.ok) {
|
||||||
|
if (onSaved) onSaved(); // pai recarrega e fecha
|
||||||
|
else setPageConsulta(false);
|
||||||
|
} else {
|
||||||
|
console.error('Erro ao criar agendamento:', await response.text());
|
||||||
|
alert('Falha ao criar agendamento.');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erro de rede:', error);
|
||||||
|
alert('Erro de rede ao salvar agendamento.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<FormNovaConsulta
|
||||||
|
onSave={handleSave}
|
||||||
|
agendamento={agendamento}
|
||||||
|
setAgendamento={setAgendamento}
|
||||||
|
onCancel={() => setPageConsulta(false)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AgendamentoCadastroManager;
|
export default AgendamentoCadastroManager;
|
||||||
|
|||||||
@ -57,7 +57,7 @@
|
|||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-bottom: 2px solid transparent;
|
border-bottom: 2px solid transparent;
|
||||||
padding: 12px 24px;
|
padding: 10px 12px;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #718096;
|
color: #718096;
|
||||||
@ -108,7 +108,9 @@
|
|||||||
font-family: 'Inter', sans-serif;
|
font-family: 'Inter', sans-serif;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.calendar-info-panel { flex: 0 0 300px; border-right: 1px solid #E2E8F0; padding-right: 24px; display: flex; flex-direction: column; }
|
.calendar-info-panel { flex: 0 0 300px; border-right: 1px solid #E2E8F0; padding-right: 24px; display: flex; flex-direction: column; }
|
||||||
|
|
||||||
.info-date-display { background-color: #EDF2F7; border-radius: 8px; padding: 12px; text-align: center; margin-bottom: 16px; }
|
.info-date-display { background-color: #EDF2F7; border-radius: 8px; padding: 12px; text-align: center; margin-bottom: 16px; }
|
||||||
.info-date-display span { font-weight: 600; color: #718096; text-transform: uppercase; font-size: 0.9rem; }
|
.info-date-display span { font-weight: 600; color: #718096; text-transform: uppercase; font-size: 0.9rem; }
|
||||||
.info-date-display strong { display: block; font-size: 2.5rem; font-weight: 700; color: #2D3748; }
|
.info-date-display strong { display: block; font-size: 2.5rem; font-weight: 700; color: #2D3748; }
|
||||||
@ -135,6 +137,7 @@
|
|||||||
.nav-buttons button { padding: 8px 12px; border-radius: 6px; border: 1px solid #CBD5E0; background-color: #fff; font-weight: 600; cursor: pointer; transition: all 0.2s; }
|
.nav-buttons button { padding: 8px 12px; border-radius: 6px; border: 1px solid #CBD5E0; background-color: #fff; font-weight: 600; cursor: pointer; transition: all 0.2s; }
|
||||||
.nav-buttons button:hover { background-color: #EDF2F7; }
|
.nav-buttons button:hover { background-color: #EDF2F7; }
|
||||||
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
|
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
|
||||||
|
|
||||||
.day-header { font-weight: 600; color: #718096; text-align: center; padding: 8px 0; font-size: 0.875rem; }
|
.day-header { font-weight: 600; color: #718096; text-align: center; padding: 8px 0; font-size: 0.875rem; }
|
||||||
.day-cell { min-height: 110px; border-radius: 8px; border: 1px solid #E2E8F0; padding: 8px; transition: background-color 0.2s, border-color 0.2s; cursor: pointer; position: relative; }
|
.day-cell { min-height: 110px; border-radius: 8px; border: 1px solid #E2E8F0; padding: 8px; transition: background-color 0.2s, border-color 0.2s; cursor: pointer; position: relative; }
|
||||||
.day-cell span { font-weight: 600; color: #4A5568; }
|
.day-cell span { font-weight: 600; color: #4A5568; }
|
||||||
@ -181,7 +184,6 @@
|
|||||||
color: #C53030;
|
color: #C53030;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.appointment-item {
|
.appointment-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -224,81 +226,194 @@
|
|||||||
background-color: #C53030;
|
background-color: #C53030;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.table-wrapper {
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
min-width: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.unidade-selecionarprofissional { flex-direction: column; align-items: stretch; gap: 12px; }
|
.busca-atendimento {
|
||||||
.calendar-wrapper { flex-direction: column; padding: 16px; }
|
flex-direction: column;
|
||||||
.calendar-info-panel { flex: 0 0 auto; border-right: none; border-bottom: 1px solid #E2E8F0; padding-right: 0; padding-bottom: 16px; }
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-btns-agenda-fila_esepera {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 10px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btns-gerenciamento-e-consulta {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-adicionar-consulta {
|
||||||
|
padding: 8px 12px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
white-space: normal;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unidade-selecionarprofissional {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar-wrapper {
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar-info-panel {
|
||||||
|
border-right: none;
|
||||||
|
border-bottom: 1px solid #E2E8F0;
|
||||||
|
padding-right: 0;
|
||||||
|
padding-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
.calendar-grid { grid-template-columns: repeat(4, 1fr); }
|
.calendar-grid { grid-template-columns: repeat(4, 1fr); }
|
||||||
.calendar-controls { flex-direction: column; align-items: flex-start; gap: 8px; }
|
.calendar-controls { flex-direction: column; align-items: flex-start; gap: 8px; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 576px) {
|
@media (max-width: 576px) {
|
||||||
.calendar-grid { grid-template-columns: repeat(2, 1fr); }
|
.calendar-grid { grid-template-columns: 1fr; }
|
||||||
.date-indicator h2 { font-size: 1.25rem; }
|
.date-indicator h2 { font-size: 1.25rem; }
|
||||||
.legend-item { font-size: 0.75rem; padding: 4px 8px; }
|
.legend-item { font-size: 0.75rem; padding: 4px 8px; }
|
||||||
.appointment-item { flex-direction: column; align-items: stretch; gap: 8px; }
|
.appointment-item { flex-direction: column; align-items: stretch; gap: 8px; }
|
||||||
.appointment-actions { width: 100%; }
|
.appointment-actions { width: 100%; }
|
||||||
.btn-action { width: 100%; }
|
.btn-action { width: 100%; }
|
||||||
}
|
}
|
||||||
.btn-adicionar-consulta {
|
|
||||||
background-color: #2a67e2;
|
@media (max-width: 425px) {
|
||||||
color: #fff;
|
.calendar-main {
|
||||||
padding: 10px 24px;
|
overflow-x: auto;
|
||||||
border-radius: 8px;
|
}
|
||||||
border: none;
|
.calendar-grid {
|
||||||
font-weight: 600;
|
min-width: 400px;
|
||||||
font-size: 1rem;
|
grid-template-columns: repeat(7, 1fr);
|
||||||
display: flex;
|
}
|
||||||
align-items: center;
|
.day-cell {
|
||||||
gap: 8px;
|
min-height: 80px;
|
||||||
cursor: pointer;
|
}
|
||||||
transition: background 0.2s;
|
|
||||||
|
|
||||||
|
.table-wrapper {
|
||||||
|
overflow-x: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
border: 1px solid #E2E8F0;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
min-width: 600px;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
table th,
|
||||||
|
table td {
|
||||||
|
padding: 8px;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.btn-adicionar-consulta:hover {
|
|
||||||
background-color: #1d4ed8;
|
|
||||||
}
|
|
||||||
.btn-adicionar-consulta i {
|
|
||||||
font-size: 1.2em;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.btn-adicionar-consulta i {
|
|
||||||
font-size: 1.2em;
|
|
||||||
vertical-align: middle;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
}
|
||||||
.container-btns-agenda-fila_esepera {
|
.container-btns-agenda-fila_esepera {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between; /* abas à esquerda, botões à direita */
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin: 15px 0 20px;
|
gap: 16px; /* opcional: espaço entre os blocos */
|
||||||
color: #fff;
|
width: 100%;
|
||||||
}
|
|
||||||
|
|
||||||
.tabs-agenda-fila {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* garante que os botões fiquem em linha */
|
||||||
.btns-gerenciamento-e-consulta {
|
.btns-gerenciamento-e-consulta {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* em telas muito pequenas, pode empilhar verticalmente */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.container-btns-agenda-fila_esepera {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btns-gerenciamento-e-consulta {
|
||||||
|
justify-content: flex-start; /* ou center se preferir */
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* barra de abas + botões */
|
||||||
.container-btns-agenda-fila_esepera {
|
.container-btns-agenda-fila_esepera {
|
||||||
display: flex;
|
margin-bottom: 0; /* cola com a linha de baixo */
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin: 0 0 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* dá só um respiro pequeno entre as abas e o conteúdo,
|
||||||
|
mas igual para Agenda e Fila de espera */
|
||||||
.calendario-ou-filaespera {
|
.calendario-ou-filaespera {
|
||||||
margin-top: 0;
|
margin-top: 4px; /* aumenta um pouquinho, não 20px */
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* se o título "Fila de Espera" estiver mais distante,
|
||||||
|
aproxima só o conteúdo dessa área também */
|
||||||
|
.page-content.table-paciente-container {
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
/* 1) container das abas + botões: encostado no topo */
|
||||||
|
.container-btns-agenda-fila_esepera {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.calendar-wrapper {
|
/* 2) sempre cria um espaçamento logo DEPOIS das abas,
|
||||||
margin-top: 0;
|
antes de qualquer conteúdo (Agenda ou Fila) */
|
||||||
}
|
.container-btns-agenda-fila_esepera + .calendario-ou-filaespera {
|
||||||
|
margin-top: 8px; /* aumenta ou diminui aqui */
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 3) garante que o primeiro filho da section não roube/colapse margens */
|
||||||
|
.calendario-ou-filaespera > *:first-child {
|
||||||
|
margin-top: 0 !important;
|
||||||
|
}
|
||||||
|
/* mesmos blocos azuis e quadrados */
|
||||||
|
.btn-consulta-paciente {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center; /* alinha ícone + texto verticalmente */
|
||||||
|
justify-content: center;
|
||||||
|
gap: 6px; /* espaço entre ícone e texto */
|
||||||
|
padding: 10px 22px; /* altura/largura parecidas com os azuis */
|
||||||
|
border-radius: 6px; /* se os outros forem 6px, mantém igual */
|
||||||
|
font-weight: 500;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* garante mesma cor dos blocos da secretaria */
|
||||||
|
.btn-consulta-paciente.btn-primary {
|
||||||
|
background-color: #1d4ed8; /* azul escuro do primeiro bloco */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* se quiser hover igual */
|
||||||
|
.btn-consulta-paciente.btn-primary:hover {
|
||||||
|
background-color: #1437a3;
|
||||||
|
}
|
||||||
|
.btn-consulta-paciente {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 10px 22px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-weight: 500;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|||||||
@ -190,6 +190,12 @@ html, body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ===== Fila de Espera ===== */
|
/* ===== Fila de Espera ===== */
|
||||||
|
|
||||||
|
@media (max-width: 992px) {
|
||||||
|
.fila-container {
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
.fila-container {
|
.fila-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: none;
|
max-width: none;
|
||||||
@ -286,6 +292,13 @@ html, body {
|
|||||||
transition: border-color 0.2s;
|
transition: border-color 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.busca-fila-espera {
|
||||||
|
width: 100%;
|
||||||
|
position: static;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.busca-fila-espera:focus {
|
.busca-fila-espera:focus {
|
||||||
border-color: #888;
|
border-color: #888;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,12 @@
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1200px) {
|
||||||
|
.summary-card {
|
||||||
|
min-width: 180px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.summary-card {
|
.summary-card {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
@ -232,6 +238,13 @@ html[data-bs-theme="dark"] .btn-delete {
|
|||||||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.modal-card {
|
||||||
|
padding: 16px;
|
||||||
|
max-height: 95vh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.modal-header {
|
.modal-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@ -336,6 +349,14 @@ textarea {
|
|||||||
width: 30%;
|
width: 30%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.financeiro-wrap .input-field:not(.modal-card *),
|
||||||
|
.financeiro-wrap .select-field:not(.modal-card *),
|
||||||
|
.financeiro-wrap textarea:not(.modal-card *) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.modal-card .input-field,
|
.modal-card .input-field,
|
||||||
.modal-card .select-field,
|
.modal-card .select-field,
|
||||||
.modal-card textarea {
|
.modal-card textarea {
|
||||||
|
|||||||
@ -1,3 +1,134 @@
|
|||||||
|
/* Container Principal */
|
||||||
|
|
||||||
|
/* Responsividade */
|
||||||
|
@media (max-width: 1200px) {
|
||||||
|
.dashboard-container {
|
||||||
|
padding: 1.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.dashboard-container {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-header h1 {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-header p {
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-grid {
|
||||||
|
grid-template-columns: 1fr 1fr; /* 2 colunas em tablets */
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-value {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-icon-wrapper {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-icon {
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions-grid {
|
||||||
|
grid-template-columns: 1fr; /* 1 coluna em tablets */
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-icon {
|
||||||
|
font-size: 1.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-title {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.appointments-section {
|
||||||
|
padding: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-info {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-time-date {
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 1rem;
|
||||||
|
min-width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-detalhes {
|
||||||
|
min-width: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.dashboard-container {
|
||||||
|
padding: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-header h1 {
|
||||||
|
font-size: 1.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-header p {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-grid {
|
||||||
|
grid-template-columns: 1fr; /* 1 coluna em celulares */
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-value {
|
||||||
|
font-size: 1.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-button {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.appointments-section {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-item {
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-hora {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-data {
|
||||||
|
font-size: 0.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agendamento-paciente,
|
||||||
|
.agendamento-medico {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.manage-button,
|
||||||
|
.view-all-button {
|
||||||
|
padding: 0.6rem 1.2rem;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Container Principal */
|
/* Container Principal */
|
||||||
.dashboard-container {
|
.dashboard-container {
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
|
|||||||
@ -2,6 +2,17 @@
|
|||||||
line-height: 2.5;
|
line-height: 2.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Adiciona responsividade para a tabela */
|
||||||
|
@media (max-width: 992px) {
|
||||||
|
.table-doctor-card {
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-doctor-container {
|
||||||
|
line-height: 2.5;
|
||||||
|
}
|
||||||
|
|
||||||
.table-doctor-card {
|
.table-doctor-card {
|
||||||
border: none;
|
border: none;
|
||||||
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
|
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
|
||||||
|
|||||||
@ -2,6 +2,17 @@
|
|||||||
line-height: 2.5;
|
line-height: 2.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Adiciona responsividade para a tabela */
|
||||||
|
@media (max-width: 992px) {
|
||||||
|
.table-paciente-card {
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-paciente-container {
|
||||||
|
line-height: 2.5;
|
||||||
|
}
|
||||||
|
|
||||||
.table-paciente-card {
|
.table-paciente-card {
|
||||||
border: none;
|
border: none;
|
||||||
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
|
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user