Compare commits
17 Commits
aperfeicoa
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c633f57fd | |||
| 17a69ed57b | |||
| 94c0dd13dc | |||
| 7a9f2b3da2 | |||
| cfd4790bf1 | |||
| eff11fc075 | |||
| 6f3a49575c | |||
| 07ed113291 | |||
| 0de772457e | |||
| c736f44604 | |||
| 3b8e73535b | |||
| e5e5d0928b | |||
| e5f260e7c3 | |||
|
|
b208d2ac73 | ||
| b1ac9ea3ff | |||
| d67f4d6db4 | |||
|
|
220e436fa0 |
96
package-lock.json
generated
96
package-lock.json
generated
@ -19,6 +19,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",
|
||||||
@ -18260,6 +18261,86 @@
|
|||||||
"integrity": "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==",
|
"integrity": "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@supabase/auth-js": {
|
||||||
|
"version": "2.86.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@supabase/auth-js/-/auth-js-2.86.0.tgz",
|
||||||
|
"integrity": "sha512-3xPqMvBWC6Haqpr6hEWmSUqDq+6SA1BAEdbiaHdAZM9QjZ5uiQJ+6iD9pZOzOa6MVXZh4GmwjhC9ObIG0K1NcA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "2.8.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@supabase/functions-js": {
|
||||||
|
"version": "2.86.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@supabase/functions-js/-/functions-js-2.86.0.tgz",
|
||||||
|
"integrity": "sha512-AlOoVfeaq9XGlBFIyXTmb+y+CZzxNO4wWbfgRM6iPpNU5WCXKawtQYSnhivi3UVxS7GA0rWovY4d6cIAxZAojA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "2.8.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@supabase/postgrest-js": {
|
||||||
|
"version": "2.86.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@supabase/postgrest-js/-/postgrest-js-2.86.0.tgz",
|
||||||
|
"integrity": "sha512-QVf+wIXILcZJ7IhWhWn+ozdf8B+oO0Ulizh2AAPxD/6nQL+x3r9lJ47a+fpc/jvAOGXMbkeW534Kw6jz7e8iIA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "2.8.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@supabase/realtime-js": {
|
||||||
|
"version": "2.86.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-2.86.0.tgz",
|
||||||
|
"integrity": "sha512-dyS8bFoP29R/sj5zLi0AP3JfgG8ar1nuImcz5jxSx7UIW7fbFsXhUCVrSY2Ofo0+Ev6wiATiSdBOzBfWaiFyPA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/phoenix": "^1.6.6",
|
||||||
|
"@types/ws": "^8.18.1",
|
||||||
|
"tslib": "2.8.1",
|
||||||
|
"ws": "^8.18.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@supabase/storage-js": {
|
||||||
|
"version": "2.86.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-2.86.0.tgz",
|
||||||
|
"integrity": "sha512-PM47jX/Mfobdtx7NNpoj9EvlrkapAVTQBZgGGslEXD6NS70EcGjhgRPBItwHdxZPM5GwqQ0cGMN06uhjeY2mHQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"iceberg-js": "^0.8.0",
|
||||||
|
"tslib": "2.8.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@supabase/supabase-js": {
|
||||||
|
"version": "2.86.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.86.0.tgz",
|
||||||
|
"integrity": "sha512-BaC9sv5+HGNy1ulZwY8/Ev7EjfYYmWD4fOMw9bDBqTawEj6JHAiOHeTwXLRzVaeSay4p17xYLN2NSCoGgXMQnw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@supabase/auth-js": "2.86.0",
|
||||||
|
"@supabase/functions-js": "2.86.0",
|
||||||
|
"@supabase/postgrest-js": "2.86.0",
|
||||||
|
"@supabase/realtime-js": "2.86.0",
|
||||||
|
"@supabase/storage-js": "2.86.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@surma/rollup-plugin-off-main-thread": {
|
"node_modules/@surma/rollup-plugin-off-main-thread": {
|
||||||
"version": "2.2.3",
|
"version": "2.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz",
|
||||||
@ -19505,6 +19586,12 @@
|
|||||||
"integrity": "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==",
|
"integrity": "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/phoenix": {
|
||||||
|
"version": "1.6.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/phoenix/-/phoenix-1.6.6.tgz",
|
||||||
|
"integrity": "sha512-PIzZZlEppgrpoT2QgbnDU+MMzuR6BbCjllj0bM70lWoejMeNJAxCchxnv7J3XFkI8MpygtRpzXrIlmWUBclP5A==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/prettier": {
|
"node_modules/@types/prettier": {
|
||||||
"version": "2.7.3",
|
"version": "2.7.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz",
|
||||||
@ -26324,6 +26411,15 @@
|
|||||||
"node": ">=10.17.0"
|
"node": ">=10.17.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/iceberg-js": {
|
||||||
|
"version": "0.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/iceberg-js/-/iceberg-js-0.8.0.tgz",
|
||||||
|
"integrity": "sha512-kmgmea2nguZEvRqW79gDqNXyxA3OS5WIgMVffrHpqXV4F/J4UmNIw2vstixioLTNSkd5rFB8G0s3Lwzogm6OFw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/iconv-lite": {
|
"node_modules/iconv-lite": {
|
||||||
"version": "0.6.3",
|
"version": "0.6.3",
|
||||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||||
|
|||||||
@ -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,14 +1,22 @@
|
|||||||
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";
|
||||||
import { GetAllDoctors } from '../components/utils/Functions-Endpoints/Doctor.js';
|
import { GetAllDoctors } from "../components/utils/Functions-Endpoints/Doctor.js";
|
||||||
import { useAuth } from '../components/utils/AuthProvider.js';
|
import { useAuth } from "../components/utils/AuthProvider.js";
|
||||||
import dayjs from 'dayjs';
|
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 { Search, ChevronLeft, ChevronRight, Edit, Trash2, CheckCircle } from 'lucide-react';
|
import {
|
||||||
|
Search,
|
||||||
|
ChevronLeft,
|
||||||
|
ChevronRight,
|
||||||
|
Edit,
|
||||||
|
Trash2,
|
||||||
|
CheckCircle,
|
||||||
|
FileText,
|
||||||
|
} 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";
|
||||||
@ -22,8 +30,8 @@ const Agendamento = () => {
|
|||||||
const { getAuthorizationHeader, user } = useAuth();
|
const { getAuthorizationHeader, user } = useAuth();
|
||||||
const authHeader = getAuthorizationHeader();
|
const authHeader = getAuthorizationHeader();
|
||||||
|
|
||||||
|
const ID_MEDICO_ESPECIFICO = "31689310-b76c-4ecb-9027-ef6deb71b08d";
|
||||||
|
|
||||||
const ID_MEDICO_ESPECIFICO = "078d2a67-b4c1-43c8-ae32-c1e75bb5b3df";
|
|
||||||
|
|
||||||
const [listaTodosAgendamentos, setListaTodosAgendamentos] = useState([]);
|
const [listaTodosAgendamentos, setListaTodosAgendamentos] = useState([]);
|
||||||
const [selectedID, setSelectedId] = useState("0");
|
const [selectedID, setSelectedId] = useState("0");
|
||||||
@ -33,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);
|
||||||
@ -55,15 +67,17 @@ const Agendamento = () => {
|
|||||||
year: currentDate.year(),
|
year: currentDate.year(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const fetchAppointments = useCallback(async () => {
|
const fetchAppointments = useCallback(async () => {
|
||||||
if (!authHeader) return;
|
if (!authHeader) return;
|
||||||
setShowSpinner(true);
|
setShowSpinner(true);
|
||||||
const myHeaders = new Headers();
|
const myHeaders = new Headers();
|
||||||
myHeaders.append("Authorization", authHeader);
|
myHeaders.append("Authorization", authHeader);
|
||||||
myHeaders.append("apikey", API_KEY);
|
myHeaders.append("apikey", API_KEY);
|
||||||
const requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' };
|
const requestOptions = {
|
||||||
|
method: "GET",
|
||||||
|
headers: myHeaders,
|
||||||
|
redirect: "follow",
|
||||||
|
};
|
||||||
|
|
||||||
const apiUrl = `https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?doctor_id=eq.${ID_MEDICO_ESPECIFICO}&select=*`;
|
const apiUrl = `https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?doctor_id=eq.${ID_MEDICO_ESPECIFICO}&select=*`;
|
||||||
|
|
||||||
@ -152,13 +166,15 @@ const Agendamento = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(authHeader) {
|
if (authHeader) {
|
||||||
fetchAppointments();
|
fetchAppointments();
|
||||||
|
|
||||||
if (user?.role !== 'doctor') {
|
if (user?.role !== "doctor") {
|
||||||
GetAllDoctors(authHeader).then(docs => {
|
GetAllDoctors(authHeader).then((docs) => {
|
||||||
if (docs) {
|
if (docs) {
|
||||||
setListaDeMedicos(docs.map(d => ({ nomeMedico: d.full_name, idMedico: d.id })));
|
setListaDeMedicos(
|
||||||
|
docs.map((d) => ({ nomeMedico: d.full_name, idMedico: d.id }))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -167,7 +183,6 @@ const Agendamento = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const processData = async () => {
|
const processData = async () => {
|
||||||
|
|
||||||
if (!listaTodosAgendamentos.length) {
|
if (!listaTodosAgendamentos.length) {
|
||||||
setAgendamentosOrganizados({});
|
setAgendamentosOrganizados({});
|
||||||
setFilaEsperaData([]);
|
setFilaEsperaData([]);
|
||||||
@ -176,7 +191,6 @@ const Agendamento = () => {
|
|||||||
|
|
||||||
setShowSpinner(true);
|
setShowSpinner(true);
|
||||||
|
|
||||||
|
|
||||||
const appointmentsToShow = listaTodosAgendamentos;
|
const appointmentsToShow = listaTodosAgendamentos;
|
||||||
|
|
||||||
const patientIdsToFetch = new Set();
|
const patientIdsToFetch = new Set();
|
||||||
@ -194,11 +208,14 @@ const Agendamento = () => {
|
|||||||
const fetchPromises = [];
|
const fetchPromises = [];
|
||||||
|
|
||||||
if (patientIdsToFetch.size > 0) {
|
if (patientIdsToFetch.size > 0) {
|
||||||
const query = `id=in.(${Array.from(patientIdsToFetch).join(',')})`;
|
const query = `id=in.(${Array.from(patientIdsToFetch).join(",")})`;
|
||||||
fetchPromises.push(
|
fetchPromises.push(
|
||||||
fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/patients?${query}&select=*`, {
|
fetch(
|
||||||
headers: { apikey: API_KEY, Authorization: authHeader }
|
`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/patients?${query}&select=*`,
|
||||||
}).then(res => res.json())
|
{
|
||||||
|
headers: { apikey: API_KEY, Authorization: authHeader },
|
||||||
|
}
|
||||||
|
).then((res) => res.json())
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
fetchPromises.push(Promise.resolve(null));
|
fetchPromises.push(Promise.resolve(null));
|
||||||
@ -274,13 +291,23 @@ const Agendamento = () => {
|
|||||||
processData();
|
processData();
|
||||||
}, [listaTodosAgendamentos, authHeader]);
|
}, [listaTodosAgendamentos, authHeader]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const handleEditConsulta = (agendamento) => {
|
const handleEditConsulta = (agendamento) => {
|
||||||
setAgendamentoParaEdicao(agendamento);
|
setAgendamentoParaEdicao(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()) {
|
||||||
@ -294,6 +321,14 @@ const Agendamento = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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 = [];
|
||||||
const startOfMonth = currentDate.startOf("month");
|
const startOfMonth = currentDate.startOf("month");
|
||||||
@ -306,22 +341,48 @@ const Agendamento = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const dateGrid = useMemo(() => generateDateGrid(), [currentDate]);
|
const dateGrid = useMemo(() => generateDateGrid(), [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);
|
||||||
const DeleteModal = () => (
|
const DeleteModal = () => (
|
||||||
<div className="modal fade show delete-modal" style={{ display: "block", backgroundColor: "rgba(0,0,0,0.5)" }} tabIndex="-1">
|
<div
|
||||||
|
className="modal fade show delete-modal"
|
||||||
|
style={{ display: "block", backgroundColor: "rgba(0,0,0,0.5)" }}
|
||||||
|
tabIndex="-1"
|
||||||
|
>
|
||||||
<div className="modal-dialog modal-dialog-centered">
|
<div className="modal-dialog modal-dialog-centered">
|
||||||
<div className="modal-content">
|
<div className="modal-content">
|
||||||
<div className="modal-header" style={{ backgroundColor: '#dc3545', color: 'white' }}>
|
<div
|
||||||
|
className="modal-header"
|
||||||
|
style={{ backgroundColor: "#dc3545", color: "white" }}
|
||||||
|
>
|
||||||
<h5 className="modal-title">Confirmação de Cancelamento</h5>
|
<h5 className="modal-title">Confirmação de Cancelamento</h5>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<p>Qual o motivo do cancelamento?</p>
|
<p>Qual o motivo do cancelamento?</p>
|
||||||
<textarea className="form-control" rows="3" value={motivoCancelamento} onChange={(e) => setMotivoCancelamento(e.target.value)} placeholder="Ex: Motivo pessoal, reagendamento, etc."></textarea>
|
<textarea
|
||||||
|
className="form-control"
|
||||||
|
rows="3"
|
||||||
|
value={motivoCancelamento}
|
||||||
|
onChange={(e) => setMotivoCancelamento(e.target.value)}
|
||||||
|
placeholder="Ex: Motivo pessoal, reagendamento, etc."
|
||||||
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-footer">
|
<div className="modal-footer">
|
||||||
<button type="button" className="btn btn-primary" onClick={() => { setShowDeleteModal(false); setMotivoCancelamento(""); }}>Cancelar</button>
|
<button
|
||||||
<button type="button" className="btn btn-danger" onClick={() => deleteConsulta(selectedID)}>
|
type="button"
|
||||||
|
className="btn btn-primary"
|
||||||
|
onClick={() => {
|
||||||
|
setShowDeleteModal(false);
|
||||||
|
setMotivoCancelamento("");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Cancelar
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-danger"
|
||||||
|
onClick={() => deleteConsulta(selectedID)}
|
||||||
|
>
|
||||||
Confirmar Cancelamento
|
Confirmar Cancelamento
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -376,6 +437,13 @@ const DeleteModal = () => (
|
|||||||
() => 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;
|
||||||
@ -412,7 +480,39 @@ const DeleteModal = () => (
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1>Agendar nova consulta</h1>
|
<h1>Agendar nova consulta</h1>
|
||||||
<div className="btns-gerenciamento-e-consulta" style={{ display: 'flex', gap: '10px', marginBottom: '20px' }}>
|
{!PageNovaConsulta ? (
|
||||||
|
<div className="atendimento-eprocura">
|
||||||
|
|
||||||
|
<div className="container-btns-agenda-fila_esepera">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div className="tabs-agenda-fila">
|
||||||
|
<button
|
||||||
|
className={`btn-agenda ${
|
||||||
|
!FiladeEspera ? "opc-agenda-ativo" : ""
|
||||||
|
}`}
|
||||||
|
onClick={() => {
|
||||||
|
setFiladeEspera(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Agenda
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={`btn-fila-espera ${
|
||||||
|
FiladeEspera ? "opc-filaespera-ativo" : ""
|
||||||
|
}`}
|
||||||
|
onClick={() => {
|
||||||
|
setFiladeEspera(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Fila de espera
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="btns-gerenciamento-e-consulta"
|
||||||
|
style={{ display: "flex", gap: "10px" }}
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
className="btn btn-primary"
|
className="btn btn-primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@ -422,89 +522,96 @@ const DeleteModal = () => (
|
|||||||
>
|
>
|
||||||
<i className="bi bi-plus-circle"></i> Adicionar Consulta
|
<i className="bi bi-plus-circle"></i> Adicionar Consulta
|
||||||
</button>
|
</button>
|
||||||
<button className="manage-button btn" onClick={() => navigate("/secretaria/excecoes-disponibilidade")}><i className="bi bi-gear-fill me-1"></i> Gerenciar Exceções</button>
|
|
||||||
<button className='manage-button btn' onClick={() => navigate('/secretaria/disponibilidade')}><i className="bi bi-gear-fill me-1"></i> Mudar Disponibilidade</button>
|
|
||||||
</div>
|
|
||||||
{!PageNovaConsulta ? (
|
|
||||||
<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
|
<button
|
||||||
key={medico.idMedico}
|
className="manage-button btn"
|
||||||
type="button"
|
onClick={() => navigate("/secretaria/excecoes-disponibilidade")}
|
||||||
className="list-group-item list-group-item-action"
|
|
||||||
onClick={() => {
|
|
||||||
setSearchTermDoctor(medico.nomeMedico);
|
|
||||||
setFiltredTodosMedicos([]);
|
|
||||||
setMedicoFiltrado({ id: medico.idMedico });
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{medico.nomeMedico}
|
<i className="bi bi-gear-fill me-1"></i> Gerenciar Exceções
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="manage-button btn"
|
||||||
|
onClick={() => navigate("/secretaria/disponibilidade")}
|
||||||
|
>
|
||||||
|
<i className="bi bi-gear-fill me-1"></i> Mudar Disponibilidade
|
||||||
</button>
|
</button>
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{MedicoFiltrado.id !== "vazio" && (
|
<section className="calendario-ou-filaespera">
|
||||||
<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'>
|
|
||||||
<button className={`btn-agenda ${!FiladeEspera ? "opc-agenda-ativo" : ""}`} onClick={() => { setFiladeEspera(false); }}>Agenda</button>
|
|
||||||
<button className={`btn-fila-espera ${FiladeEspera ? "opc-filaespera-ativo" : ""}`} onClick={() => { setFiladeEspera(true); }}>Fila de espera</button>
|
|
||||||
</div>
|
|
||||||
<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 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 className="appointments-list">
|
<div className="appointments-list">
|
||||||
<h4>Consultas para {selectedDay.format('DD/MM')}</h4>
|
<h4>Consultas para {selectedDay.format("DD/MM")}</h4>
|
||||||
{showSpinner ? <Spinner /> : (DictAgendamentosOrganizados[selectedDay.format('YYYY-MM-DD')]?.filter(app => MedicoFiltrado.id === "vazio" || app.doctor_id === MedicoFiltrado.id).length > 0) ? (
|
{showSpinner ? (
|
||||||
DictAgendamentosOrganizados[selectedDay.format('YYYY-MM-DD')]
|
<Spinner />
|
||||||
.filter(app => MedicoFiltrado.id === "vazio" || app.doctor_id === MedicoFiltrado.id)
|
) : (() => {
|
||||||
.map(app => (
|
const appointmentsForDay =
|
||||||
<div key={app.id} className="appointment-item" data-status={app.status}>
|
DictAgendamentosOrganizados[selectedDay.format("YYYY-MM-DD")] || [];
|
||||||
<div className="item-time">{dayjs(app.scheduled_at).format('HH:mm')}</div>
|
|
||||||
<div className="item-details"><span>{app.paciente_nome}</span><small>Dr(a). {app.medico_nome}</small></div>
|
// 1º filtro: por médico (se tiver)
|
||||||
|
const filteredByDoctor = appointmentsForDay.filter(
|
||||||
|
(app) =>
|
||||||
|
MedicoFiltrado.id === "vazio" ||
|
||||||
|
app.doctor_id === MedicoFiltrado.id
|
||||||
|
);
|
||||||
|
|
||||||
|
// 2º filtro: por paciente (campo de cima)
|
||||||
|
const filteredByPatient = filtrarPorPaciente(filteredByDoctor);
|
||||||
|
|
||||||
|
if (filteredByPatient.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className="no-appointments-info">
|
||||||
|
<p>
|
||||||
|
{searchTermPatient
|
||||||
|
? `Nenhuma consulta encontrada para "${searchTermPatient}".`
|
||||||
|
: "Nenhuma consulta agendada."}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return filteredByPatient.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">
|
||||||
|
<span>{app.paciente_nome}</span>
|
||||||
|
<small>Dr(a). {app.medico_nome}</small>
|
||||||
|
</div>
|
||||||
<div className="appointment-actions">
|
<div className="appointment-actions">
|
||||||
{app.status === 'cancelled' ? (
|
{app.status === "cancelled" ? (
|
||||||
<button className="btn-action btn-edit" onClick={() => { setSelectedId(app.id); confirmConsulta(app.id); }}>
|
<button
|
||||||
<CheckCircle size={16} title="Reverter Cancelamento" />
|
className="btn-action btn-edit"
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedId(app.id);
|
||||||
|
confirmConsulta(app.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CheckCircle
|
||||||
|
size={16}
|
||||||
|
title="Reverter Cancelamento"
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
) : (
|
) : (
|
||||||
<button
|
<button
|
||||||
@ -515,72 +622,244 @@ const DeleteModal = () => (
|
|||||||
<Edit size={16} />
|
<Edit size={16} />
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{app.status !== 'cancelled' && (
|
{app.status !== "cancelled" && (
|
||||||
<button className="btn-action btn-delete" onClick={() => { setSelectedId(app.id); setShowDeleteModal(true); }} title="Cancelar Agendamento">
|
<button
|
||||||
|
className="btn-action btn-report-blue"
|
||||||
|
onClick={() => handleCreateReport(app)}
|
||||||
|
title="Criar Relatório / Laudo"
|
||||||
|
aria-label={`Criar relatório para ${app.paciente_nome}`}
|
||||||
|
>
|
||||||
|
<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} />
|
<Trash2 size={16} />
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))
|
));
|
||||||
) : (<div className="no-appointments-info"><p>Nenhuma consulta agendada.</p></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 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 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
|
||||||
|
className="quick-jump-controls"
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
gap: "5px",
|
||||||
|
marginTop: "10px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
<select
|
<select
|
||||||
value={quickJump.month}
|
value={quickJump.month}
|
||||||
onChange={(e) => handleQuickJumpChange('month', e.target.value)}
|
onChange={(e) =>
|
||||||
|
handleQuickJumpChange("month", e.target.value)
|
||||||
|
}
|
||||||
className="form-select form-select-sm w-auto"
|
className="form-select form-select-sm w-auto"
|
||||||
>
|
>
|
||||||
{dayjs.months().map((month, index) => (
|
{dayjs.months().map((month, index) => (
|
||||||
<option key={index} value={index}>{month.charAt(0).toUpperCase() + month.slice(1)}</option>
|
<option key={index} value={index}>
|
||||||
|
{month.charAt(0).toUpperCase() + month.slice(1)}
|
||||||
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
<select
|
<select
|
||||||
value={quickJump.year}
|
value={quickJump.year}
|
||||||
onChange={(e) => handleQuickJumpChange('year', e.target.value)}
|
onChange={(e) =>
|
||||||
|
handleQuickJumpChange("year", e.target.value)
|
||||||
|
}
|
||||||
className="form-select form-select-sm w-auto"
|
className="form-select form-select-sm w-auto"
|
||||||
>
|
>
|
||||||
{Array.from({ length: 11 }, (_, i) => dayjs().year() - 5 + i).map(year => (
|
{Array.from(
|
||||||
<option key={year} value={year}>{year}</option>
|
{ length: 11 },
|
||||||
|
(_, i) => dayjs().year() - 5 + i
|
||||||
|
).map((year) => (
|
||||||
|
<option key={year} value={year}>
|
||||||
|
{year}
|
||||||
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-outline-primary"
|
className="btn btn-sm btn-outline-primary"
|
||||||
onClick={applyQuickJump}
|
onClick={applyQuickJump}
|
||||||
disabled={quickJump.month === currentDate.month() && quickJump.year === currentDate.year()}
|
disabled={
|
||||||
|
quickJump.month === currentDate.month() &&
|
||||||
|
quickJump.year === currentDate.year()
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Ir
|
Ir
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="nav-buttons">
|
<div className="nav-buttons">
|
||||||
<button onClick={() => { setCurrentDate(currentDate.subtract(1, 'month')); setSelectedDay(currentDate.subtract(1, 'month')); }}><ChevronLeft size={20} /></button>
|
<button
|
||||||
<button onClick={() => { setCurrentDate(dayjs()); setSelectedDay(dayjs()); }}>Hoje</button>
|
onClick={() => {
|
||||||
<button onClick={() => { setCurrentDate(currentDate.add(1, 'month')); setSelectedDay(currentDate.add(1, 'month')); }}><ChevronRight size={20} /></button>
|
setCurrentDate(currentDate.subtract(1, "month"));
|
||||||
|
setSelectedDay(currentDate.subtract(1, "month"));
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ChevronLeft size={20} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
setCurrentDate(dayjs());
|
||||||
|
setSelectedDay(dayjs());
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Hoje
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
setCurrentDate(currentDate.add(1, "month"));
|
||||||
|
setSelectedDay(currentDate.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 dayString = day.format('YYYY-MM-DD');
|
const dayString = day.format("YYYY-MM-DD");
|
||||||
const appointmentsOnDay = DictAgendamentosOrganizados[dayString] || [];
|
const appointmentsOnDay =
|
||||||
const filteredAppointments = appointmentsOnDay.filter(app => MedicoFiltrado.id === "vazio" || app.doctor_id === MedicoFiltrado.id);
|
DictAgendamentosOrganizados[dayString] || [];
|
||||||
const cellClasses = `day-cell ${day.isSame(currentDate, 'month') ? 'current-month' : 'other-month'} ${day.isSame(dayjs(), 'day') ? 'today' : ''} ${day.isSame(selectedDay, 'day') ? 'selected' : ''}`;
|
|
||||||
|
const filteredAppointments = filtrarPorPaciente(
|
||||||
|
appointmentsOnDay.filter(
|
||||||
|
(app) =>
|
||||||
|
MedicoFiltrado.id === "vazio" ||
|
||||||
|
app.doctor_id === MedicoFiltrado.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
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
|
||||||
<span>{day.format('D')}</span>
|
key={index}
|
||||||
{filteredAppointments.length > 0 && <div className="appointments-indicator">{filteredAppointments.length}</div>}
|
className={cellClasses}
|
||||||
|
onClick={() => handleDateClick(day)}
|
||||||
|
>
|
||||||
|
<span>{day.format("D")}</span>
|
||||||
|
{filteredAppointments.length > 0 && (
|
||||||
|
<div className="appointments-indicator">
|
||||||
|
{filteredAppointments.length}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@ -592,37 +871,78 @@ const DeleteModal = () => (
|
|||||||
<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">Fila de Espera</h4></div>
|
<div className="card-header">
|
||||||
|
<h4 className="card-title mb-0">Fila de Espera</h4>
|
||||||
|
</div>
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
<div className="card p-3 mb-3 table-paciente-filters">
|
<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> Filtros</h5>
|
<h5 className="mb-3">
|
||||||
<div className="mb-3"><input type="text" className="form-control" placeholder="Buscar por paciente, CPF ou médico..." value={waitlistSearch} onChange={(e) => setWaitlistSearch(e.target.value)} /><small className="text-muted">Digite o nome do paciente, CPF ou nome do médico</small></div>
|
<i className="bi bi-funnel-fill me-2 text-primary"></i>{" "}
|
||||||
|
Filtros
|
||||||
|
</h5>
|
||||||
|
<div className="mb-3">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
placeholder="Buscar por paciente, CPF ou médico..."
|
||||||
|
value={waitlistSearch}
|
||||||
|
onChange={(e) =>
|
||||||
|
setWaitlistSearch(e.target.value)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<small className="text-muted">
|
||||||
|
Digite o nome do paciente, CPF ou nome do médico
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
<div className="d-flex flex-wrap align-items-center gap-2 mb-3">
|
<div className="d-flex flex-wrap align-items-center gap-2 mb-3">
|
||||||
<div className="d-flex align-items-center gap-2">
|
<div className="d-flex align-items-center gap-2">
|
||||||
<span className="me-2 text-muted small">Ordenar por:</span>
|
<span className="me-2 text-muted small">
|
||||||
|
Ordenar por:
|
||||||
|
</span>
|
||||||
<select
|
<select
|
||||||
className="form-select compact-select sort-select w-auto"
|
className="form-select compact-select sort-select w-auto"
|
||||||
value={waitSortKey ? `${waitSortKey}-${waitSortDir}` : ''}
|
value={
|
||||||
|
waitSortKey
|
||||||
|
? `${waitSortKey}-${waitSortDir}`
|
||||||
|
: ""
|
||||||
|
}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const v = e.target.value;
|
const v = e.target.value;
|
||||||
if (!v) { setWaitSortKey(null); setWaitSortDir('asc'); return; }
|
if (!v) {
|
||||||
const [k, d] = v.split('-');
|
setWaitSortKey(null);
|
||||||
|
setWaitSortDir("asc");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const [k, d] = v.split("-");
|
||||||
setWaitSortKey(k);
|
setWaitSortKey(k);
|
||||||
setWaitSortDir(d);
|
setWaitSortDir(d);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<option value="">Sem ordenação</option>
|
<option value="">Sem ordenação</option>
|
||||||
<option value="paciente-asc">Paciente (A-Z)</option>
|
<option value="paciente-asc">
|
||||||
<option value="paciente-desc">Paciente (Z-A)</option>
|
Paciente (A-Z)
|
||||||
|
</option>
|
||||||
|
<option value="paciente-desc">
|
||||||
|
Paciente (Z-A)
|
||||||
|
</option>
|
||||||
<option value="medico-asc">Médico (A-Z)</option>
|
<option value="medico-asc">Médico (A-Z)</option>
|
||||||
<option value="medico-desc">Médico (Z-A)</option>
|
<option value="medico-desc">
|
||||||
<option value="data-asc">Data (mais antiga)</option>
|
Médico (Z-A)
|
||||||
<option value="data-desc">Data (mais recente)</option>
|
</option>
|
||||||
|
<option value="data-asc">
|
||||||
|
Data (mais antiga)
|
||||||
|
</option>
|
||||||
|
<option value="data-desc">
|
||||||
|
Data (mais recente)
|
||||||
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-3">
|
<div className="mt-3">
|
||||||
<div className="contador-pacientes">{filaEsperaFiltrada.length} DE {filaEsperaData.length} SOLICITAÇÕES ENCONTRADAS</div>
|
<div className="contador-pacientes">
|
||||||
|
{filaEsperaFiltrada.length} DE{" "}
|
||||||
|
{filaEsperaData.length} SOLICITAÇÕES ENCONTRADAS
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="table-responsive">
|
<div className="table-responsive">
|
||||||
@ -643,10 +963,21 @@ const DeleteModal = () => (
|
|||||||
<td>{item?.Infos?.paciente_nome}</td>
|
<td>{item?.Infos?.paciente_nome}</td>
|
||||||
<td>{item?.Infos?.paciente_cpf}</td>
|
<td>{item?.Infos?.paciente_cpf}</td>
|
||||||
<td>{item?.Infos?.medico_nome}</td>
|
<td>{item?.Infos?.medico_nome}</td>
|
||||||
<td>{dayjs(item.agendamento.scheduled_at).format('DD/MM/YYYY')}</td>
|
|
||||||
<td>
|
<td>
|
||||||
<button className="btn btn-sm btn-delete" onClick={() => { setSelectedId(item.agendamento.id); setShowDeleteModal(true); }}>
|
{dayjs(
|
||||||
<i className="bi bi-trash me-1"></i> Excluir
|
item.agendamento.scheduled_at
|
||||||
|
).format("DD/MM/YYYY")}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-delete"
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedId(item.agendamento.id);
|
||||||
|
setShowDeleteModal(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<i className="bi bi-trash me-1"></i>{" "}
|
||||||
|
Excluir
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -655,7 +986,16 @@ const DeleteModal = () => (
|
|||||||
<tr>
|
<tr>
|
||||||
<td colSpan="5" className="text-center py-4">
|
<td colSpan="5" className="text-center py-4">
|
||||||
<div className="text-muted">
|
<div className="text-muted">
|
||||||
{showSpinner ? <Spinner /> : (<><i className="bi bi-inbox display-4"></i><p className="mt-2">Nenhuma solicitação encontrada.</p></>)}
|
{showSpinner ? (
|
||||||
|
<Spinner />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<i className="bi bi-inbox display-4"></i>
|
||||||
|
<p className="mt-2">
|
||||||
|
Nenhuma solicitação encontrada.
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -665,11 +1005,16 @@ const DeleteModal = () => (
|
|||||||
{filaEsperaFiltrada.length > 0 && (
|
{filaEsperaFiltrada.length > 0 && (
|
||||||
<div className="d-flex justify-content-between align-items-center mt-3">
|
<div className="d-flex justify-content-between align-items-center mt-3">
|
||||||
<div className="d-flex align-items-center">
|
<div className="d-flex align-items-center">
|
||||||
<span className="me-2 text-muted">Itens por página:</span>
|
<span className="me-2 text-muted">
|
||||||
|
Itens por página:
|
||||||
|
</span>
|
||||||
<select
|
<select
|
||||||
className="form-select form-select-sm w-auto"
|
className="form-select form-select-sm w-auto"
|
||||||
value={waitPerPage}
|
value={waitPerPage}
|
||||||
onChange={(e) => { setWaitPerPage(Number(e.target.value)); setWaitPage(1); }}
|
onChange={(e) => {
|
||||||
|
setWaitPerPage(Number(e.target.value));
|
||||||
|
setWaitPage(1);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<option value={5}>5</option>
|
<option value={5}>5</option>
|
||||||
<option value={10}>10</option>
|
<option value={10}>10</option>
|
||||||
@ -678,21 +1023,61 @@ const DeleteModal = () => (
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div className="d-flex align-items-center">
|
<div className="d-flex align-items-center">
|
||||||
<span className="me-3 text-muted">Página {waitPage} de {waitTotalPages} • Mostrando {waitIndiceInicial + 1}-{Math.min(waitIndiceFinal, filaEsperaFiltrada.length)} de {filaEsperaFiltrada.length}</span>
|
<span className="me-3 text-muted">
|
||||||
|
Página {waitPage} de {waitTotalPages} •
|
||||||
|
Mostrando {waitIndiceInicial + 1}-
|
||||||
|
{Math.min(
|
||||||
|
waitIndiceFinal,
|
||||||
|
filaEsperaFiltrada.length
|
||||||
|
)}{" "}
|
||||||
|
de {filaEsperaFiltrada.length}
|
||||||
|
</span>
|
||||||
<nav>
|
<nav>
|
||||||
<ul className="pagination pagination-sm mb-0">
|
<ul className="pagination pagination-sm mb-0">
|
||||||
<li className={`page-item ${waitPage === 1 ? 'disabled' : ''}`}>
|
<li
|
||||||
<button className="page-link" onClick={() => setWaitPage(p => Math.max(1, p - 1))}>
|
className={`page-item ${
|
||||||
|
waitPage === 1 ? "disabled" : ""
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className="page-link"
|
||||||
|
onClick={() =>
|
||||||
|
setWaitPage((p) => Math.max(1, p - 1))
|
||||||
|
}
|
||||||
|
>
|
||||||
<i className="bi bi-chevron-left"></i>
|
<i className="bi bi-chevron-left"></i>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
{gerarNumerosWaitPages().map(pagina => (
|
{gerarNumerosWaitPages().map((pagina) => (
|
||||||
<li key={pagina} className={`page-item ${pagina === waitPage ? 'active' : ''}`}>
|
<li
|
||||||
<button className="page-link" onClick={() => setWaitPage(pagina)}>{pagina}</button>
|
key={pagina}
|
||||||
|
className={`page-item ${
|
||||||
|
pagina === waitPage ? "active" : ""
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className="page-link"
|
||||||
|
onClick={() => setWaitPage(pagina)}
|
||||||
|
>
|
||||||
|
{pagina}
|
||||||
|
</button>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
<li className={`page-item ${waitPage === waitTotalPages ? 'disabled' : ''}`}>
|
<li
|
||||||
<button className="page-link" onClick={() => setWaitPage(p => Math.min(waitTotalPages, p + 1))}>
|
className={`page-item ${
|
||||||
|
waitPage === waitTotalPages
|
||||||
|
? "disabled"
|
||||||
|
: ""
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className="page-link"
|
||||||
|
onClick={() =>
|
||||||
|
setWaitPage((p) =>
|
||||||
|
Math.min(waitTotalPages, p + 1)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
<i className="bi bi-chevron-right"></i>
|
<i className="bi bi-chevron-right"></i>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
@ -723,6 +1108,6 @@ const DeleteModal = () => (
|
|||||||
{showDeleteModal && <DeleteModal />}
|
{showDeleteModal && <DeleteModal />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Agendamento;
|
export default Agendamento;
|
||||||
|
|||||||
@ -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)}>
|
||||||
|
|||||||
215
src/PagesMedico/NovoRelatorioAudio.jsx
Normal file
215
src/PagesMedico/NovoRelatorioAudio.jsx
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import html2pdf from 'html2pdf.js';
|
||||||
|
import './styleMedico/NovoRelatorioAudio.css';
|
||||||
|
|
||||||
|
const NovoRelatorioAudio = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const [formData, setFormData] = useState({
|
||||||
|
paciente_nome: '',
|
||||||
|
data_exame: new Date().toISOString().split('T')[0],
|
||||||
|
exam: '',
|
||||||
|
diagnostico: '',
|
||||||
|
conclusao: '',
|
||||||
|
medico_nome: 'Dr.______________________'
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleAudioUpload = async (e) => {
|
||||||
|
const file = e.target.files[0];
|
||||||
|
if (!file) return;
|
||||||
|
|
||||||
|
setLoading(true);
|
||||||
|
const data = new FormData();
|
||||||
|
data.append('audio', file);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('http://localhost:3001/api/transcrever-relatorio', {
|
||||||
|
method: 'POST',
|
||||||
|
body: data,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error('Erro na comunicação com a API');
|
||||||
|
|
||||||
|
const result = await response.json();
|
||||||
|
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
exam: result.exam || prev.exam,
|
||||||
|
diagnostico: result.diagnostico || prev.diagnostico,
|
||||||
|
conclusao: result.conclusao || prev.conclusao
|
||||||
|
}));
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
alert("Erro: Verifique se o backend (porta 3001) está rodando.");
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
e.target.value = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChange = (e) => {
|
||||||
|
const { name, value } = e.target;
|
||||||
|
setFormData(prev => ({ ...prev, [name]: value }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePrintPDF = () => {
|
||||||
|
const element = document.getElementById('documento-final');
|
||||||
|
const opt = {
|
||||||
|
margin: 0,
|
||||||
|
filename: `Laudo_${formData.paciente_nome || 'SemNome'}.pdf`,
|
||||||
|
image: { type: 'jpeg', quality: 0.98 },
|
||||||
|
html2canvas: { scale: 2 },
|
||||||
|
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
|
||||||
|
};
|
||||||
|
html2pdf().set(opt).from(element).save();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="ai-editor-container">
|
||||||
|
|
||||||
|
<div className="editor-sidebar">
|
||||||
|
<div>
|
||||||
|
<h4><i className="bi bi-robot me-2"></i>AI Report</h4>
|
||||||
|
<p className="text-muted small">Gerador de laudos automatizado</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="ai-upload-box">
|
||||||
|
{loading ? (
|
||||||
|
<div className="spinner-border text-info" role="status"></div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<label htmlFor="audioFile" style={{cursor:'pointer', width:'100%', display:'block'}}>
|
||||||
|
<i className="bi bi-mic fs-2 text-info"></i>
|
||||||
|
<div style={{color:'#fff', fontWeight:'bold', marginTop:'10px'}}>Gravar / Enviar Áudio</div>
|
||||||
|
<div className="small text-muted mt-1">Clique para selecionar</div>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="audioFile"
|
||||||
|
type="file"
|
||||||
|
accept="audio/*"
|
||||||
|
style={{display:'none'}}
|
||||||
|
onChange={handleAudioUpload}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr className="border-secondary" />
|
||||||
|
|
||||||
|
<div className="form-group">
|
||||||
|
<label>NOME DO PACIENTE</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="paciente_nome"
|
||||||
|
className="form-control dark-input"
|
||||||
|
value={formData.paciente_nome}
|
||||||
|
onChange={handleChange}
|
||||||
|
placeholder="Ex: Maria Silva"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="form-group">
|
||||||
|
<label>EXAME REALIZADO</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="exam"
|
||||||
|
className="form-control dark-input"
|
||||||
|
value={formData.exam}
|
||||||
|
onChange={handleChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="form-group">
|
||||||
|
<label>DIAGNÓSTICO (TEXTO)</label>
|
||||||
|
<textarea
|
||||||
|
name="diagnostico"
|
||||||
|
rows="5"
|
||||||
|
className="form-control dark-input"
|
||||||
|
value={formData.diagnostico}
|
||||||
|
onChange={handleChange}
|
||||||
|
></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="form-group">
|
||||||
|
<label>CONCLUSÃO</label>
|
||||||
|
<textarea
|
||||||
|
name="conclusao"
|
||||||
|
rows="3"
|
||||||
|
className="form-control dark-input"
|
||||||
|
value={formData.conclusao}
|
||||||
|
onChange={handleChange}
|
||||||
|
></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-auto d-flex gap-2">
|
||||||
|
<button className="btn btn-outline-light flex-grow-1" onClick={() => navigate(-1)}>Voltar</button>
|
||||||
|
<button className="btn btn-info flex-grow-1 fw-bold" onClick={handlePrintPDF}>
|
||||||
|
<i className="bi bi-printer me-2"></i>PDF
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="preview-area">
|
||||||
|
<div id="documento-final" className="paper-a4">
|
||||||
|
|
||||||
|
<div style={{borderBottom: '2px solid #000', paddingBottom: '20px', marginBottom: '30px', display:'flex', justifyContent:'space-between'}}>
|
||||||
|
<div>
|
||||||
|
<h2 style={{margin:0, fontSize:'18pt', fontWeight:'bold'}}>CLÍNICA RISE UP</h2>
|
||||||
|
<p style={{margin:0, fontSize:'10pt'}}>Excelência em Diagnóstico por Imagem</p>
|
||||||
|
</div>
|
||||||
|
<div style={{textAlign:'right', fontSize:'10pt'}}>
|
||||||
|
<p style={{margin:0}}><strong>{formData.medico_nome}</strong></p>
|
||||||
|
<p style={{margin:0}}>CRM/SP 123456</p>
|
||||||
|
<p style={{margin:0}}>{new Date().toLocaleDateString()}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style={{backgroundColor:'#f8f9fa', padding:'15px', borderRadius:'4px', marginBottom:'30px'}}>
|
||||||
|
<table style={{width:'100%', fontSize:'11pt'}}>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style={{width:'15%', fontWeight:'bold'}}>Paciente:</td>
|
||||||
|
<td>{formData.paciente_nome || '__________________________'}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style={{fontWeight:'bold'}}>Exame:</td>
|
||||||
|
<td>{formData.exam || '__________________________'}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style={{fontWeight:'bold'}}>Data:</td>
|
||||||
|
<td>{new Date(formData.data_exame).toLocaleDateString('pt-BR')}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="laudo-body">
|
||||||
|
<h4 style={{textTransform:'uppercase', borderBottom:'1px solid #ccc', paddingBottom:'5px', marginBottom:'15px'}}>Relatório Médico</h4>
|
||||||
|
|
||||||
|
<p style={{fontWeight:'bold', marginBottom:'5px'}}>Análise:</p>
|
||||||
|
<p style={{marginBottom:'25px', textAlign:'justify', whiteSpace:'pre-wrap'}}>
|
||||||
|
{formData.diagnostico || <span style={{color:'#ccc'}}>O diagnóstico aparecerá aqui após o processamento do áudio...</span>}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p style={{fontWeight:'bold', marginBottom:'5px'}}>Conclusão:</p>
|
||||||
|
<p style={{marginBottom:'40px', textAlign:'justify', fontWeight:'500'}}>
|
||||||
|
{formData.conclusao}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style={{marginTop:'50px', textAlign:'center', pageBreakInside:'avoid'}}>
|
||||||
|
<p style={{marginBottom:0}}>________________________________________</p>
|
||||||
|
<p style={{fontWeight:'bold', margin:0}}>{formData.medico_nome}</p>
|
||||||
|
<p style={{fontSize:'10pt', color:'#666'}}>Assinatura Eletrônica</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default NovoRelatorioAudio;
|
||||||
@ -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;
|
||||||
@ -140,6 +187,7 @@
|
|||||||
border-bottom: 3px solid transparent;
|
border-bottom: 3px solid transparent;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
border-radius: 10px 10px 0px 0px;
|
border-radius: 10px 10px 0px 0px;
|
||||||
|
color: #fff;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
@ -229,3 +277,9 @@ html[data-bs-theme="dark"] .legenda-item-agendado {
|
|||||||
border: 3px solid #4d4d2e;
|
border: 3px solid #4d4d2e;
|
||||||
color: #f7f7c4;
|
color: #f7f7c4;
|
||||||
}
|
}
|
||||||
|
.calendar-legend {
|
||||||
|
margin-top: 8px;
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|||||||
119
src/PagesMedico/styleMedico/NovoRelatorioAudio.css
Normal file
119
src/PagesMedico/styleMedico/NovoRelatorioAudio.css
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/* Container que ocupa toda a altura da tela (menos o header do site) */
|
||||||
|
.ai-editor-container {
|
||||||
|
display: flex;
|
||||||
|
min-height: calc(100vh - 80px); /* Ajuste conforme seu header */
|
||||||
|
background-color: #e9ecef; /* Cor de "Mesa" */
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- LADO ESQUERDO: PAINEL DE CONTROLE --- */
|
||||||
|
.editor-sidebar {
|
||||||
|
width: 400px;
|
||||||
|
background-color: #212529; /* Dark Mode para o painel */
|
||||||
|
color: #fff;
|
||||||
|
padding: 20px;
|
||||||
|
overflow-y: auto;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 15px;
|
||||||
|
box-shadow: 4px 0 10px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-sidebar h4 {
|
||||||
|
color: #0dcaf0; /* Ciano para destaque */
|
||||||
|
margin-bottom: 20px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-sidebar label {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #adb5bd;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Estilo customizado para inputs no fundo escuro */
|
||||||
|
.dark-input {
|
||||||
|
background-color: #343a40;
|
||||||
|
border: 1px solid #495057;
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
.dark-input:focus {
|
||||||
|
background-color: #3b4248;
|
||||||
|
color: #fff;
|
||||||
|
border-color: #0dcaf0;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Área de Upload Destacada */
|
||||||
|
.ai-upload-box {
|
||||||
|
border: 2px dashed #0dcaf0;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
background: rgba(13, 202, 240, 0.1);
|
||||||
|
transition: 0.3s;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.ai-upload-box:hover {
|
||||||
|
background: rgba(13, 202, 240, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- LADO DIREITO: PREVIEW A4 --- */
|
||||||
|
.preview-area {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: flex-start;
|
||||||
|
padding: 40px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.paper-a4 {
|
||||||
|
width: 210mm;
|
||||||
|
min-height: 297mm;
|
||||||
|
background: white;
|
||||||
|
padding: 25mm;
|
||||||
|
box-shadow: 0 0 20px rgba(0,0,0,0.15);
|
||||||
|
color: #000;
|
||||||
|
font-family: 'Georgia', serif; /* Fonte mais séria para o documento */
|
||||||
|
font-size: 12pt;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsividade: Em celular vira coluna única */
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.ai-editor-container {
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: auto;
|
||||||
|
}
|
||||||
|
.editor-sidebar {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
.preview-area {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.paper-a4 {
|
||||||
|
width: 100%;
|
||||||
|
min-height: auto;
|
||||||
|
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 navigate = useNavigate();
|
||||||
|
|
||||||
const {getAuthorizationHeader} = useAuth()
|
const [Dict, setDict] = useState({});
|
||||||
const [Dict, setDict] = useState({})
|
// patient_id fixo do Pedro Abravanel
|
||||||
const navigate = useNavigate()
|
const [patientId, setPatientId] = useState('bf7d8323-05e1-437a-817c-f08eb5f174ef');
|
||||||
const [idUsuario, setIDusuario] = useState("")
|
const [idUsuario, setIDusuario] = useState('');
|
||||||
|
|
||||||
let authHeader = getAuthorizationHeader()
|
|
||||||
|
|
||||||
|
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)
|
const result = await UserInfos(authHeader);
|
||||||
|
|
||||||
|
const pid =
|
||||||
|
result?.patient_id ||
|
||||||
|
result?.profile?.id ||
|
||||||
|
user?.patient_id ||
|
||||||
|
user?.profile?.id ||
|
||||||
|
user?.user?.id;
|
||||||
|
|
||||||
|
if (pid) {
|
||||||
|
setPatientId(pid);
|
||||||
}
|
}
|
||||||
ColherInfoUsuario()
|
|
||||||
|
|
||||||
|
setIDusuario(result?.profile?.id || pid || '');
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Erro ao colher infos do usuário:', e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}, [])
|
ColherInfoUsuario();
|
||||||
|
}, [authHeader, user]);
|
||||||
|
|
||||||
const handleSave = (Dict) => {
|
const handleSave = (Dict) => {
|
||||||
|
// se por algum motivo não tiver, usa o fixo do Pedro
|
||||||
|
const finalPatientId = patientId || 'bf7d8323-05e1-437a-817c-f08eb5f174ef';
|
||||||
|
|
||||||
let DataAtual = dayjs()
|
const myHeaders = new Headers();
|
||||||
var myHeaders = new Headers();
|
myHeaders.append('apikey', API_KEY);
|
||||||
myHeaders.append("apikey", API_KEY);
|
myHeaders.append('Authorization', authHeader);
|
||||||
myHeaders.append("Authorization", authHeader);
|
myHeaders.append('Content-Type', 'application/json');
|
||||||
myHeaders.append("Content-Type", "application/json");
|
|
||||||
|
|
||||||
|
const raw = JSON.stringify({
|
||||||
var raw = JSON.stringify({
|
patient_id: finalPatientId, // paciente Pedro
|
||||||
"patient_id": "6e7f8829-0574-42df-9290-8dbb70f75ada",
|
doctor_id: Dict.doctor_id,
|
||||||
"doctor_id": Dict.doctor_id,
|
scheduled_at: `${Dict.dataAtendimento}T${Dict.horarioInicio}:00.000Z`,
|
||||||
"scheduled_at": `${Dict.dataAtendimento}T${Dict.horarioInicio}:00.000Z`,
|
duration_minutes: 30,
|
||||||
"duration_minutes": 30,
|
appointment_type: Dict.tipo_consulta,
|
||||||
"appointment_type": Dict.tipo_consulta,
|
patient_notes: 'Prefiro horário pela manhã',
|
||||||
|
insurance_provider: Dict.convenio,
|
||||||
"patient_notes": "Prefiro horário pela manhã",
|
status: 'confirmed',
|
||||||
"insurance_provider": Dict.convenio,
|
created_by: idUsuario || finalPatientId,
|
||||||
"status": "confirmed",
|
|
||||||
"created_by": idUsuario
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var requestOptions = {
|
const requestOptions = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: myHeaders,
|
headers: myHeaders,
|
||||||
body: raw,
|
body: raw,
|
||||||
redirect: 'follow'
|
redirect: 'follow',
|
||||||
};
|
};
|
||||||
|
|
||||||
fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments", requestOptions)
|
fetch(
|
||||||
.then(response => response.text())
|
'https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments',
|
||||||
.then(result => console.log(result))
|
requestOptions
|
||||||
.catch(error => console.log('error', error));
|
)
|
||||||
|
.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 (
|
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,34 +34,49 @@ 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) {
|
if (!authHeader) {
|
||||||
console.warn("Header de autorização não disponível.");
|
console.warn('Header de autorização não disponível.');
|
||||||
setIsLoading(false);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!patientId) {
|
||||||
|
console.warn('patientId ainda não carregado, aguardando contexto.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const myHeaders = new Headers({ "Authorization": authHeader, "apikey": API_KEY });
|
const myHeaders = new Headers({
|
||||||
|
Authorization: authHeader,
|
||||||
|
apikey: API_KEY,
|
||||||
|
});
|
||||||
const requestOptions = { method: 'GET', headers: myHeaders };
|
const requestOptions = { method: 'GET', headers: myHeaders };
|
||||||
const response = await fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?select=*,doctors(full_name)&patient_id=eq.${patientId}`, requestOptions);
|
|
||||||
|
|
||||||
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 consultasBrutas = (await response.json()) || [];
|
||||||
|
console.log('CONSULTAS BRUTAS PACIENTE:', consultasBrutas);
|
||||||
|
|
||||||
const newDict = {};
|
const newDict = {};
|
||||||
const newFila = [];
|
const newFila = [];
|
||||||
@ -65,13 +84,18 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
for (const agendamento of consultasBrutas) {
|
for (const agendamento of consultasBrutas) {
|
||||||
const agendamentoMelhorado = {
|
const agendamentoMelhorado = {
|
||||||
...agendamento,
|
...agendamento,
|
||||||
medico_nome: agendamento.doctors?.full_name || 'Médico não informado'
|
medico_nome: agendamento.doctors?.full_name || 'Médico não informado',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (agendamento.status === "requested") {
|
if (agendamento.status === 'requested') {
|
||||||
newFila.push({ agendamento: agendamentoMelhorado, Infos: agendamentoMelhorado });
|
newFila.push({
|
||||||
|
agendamento: agendamentoMelhorado,
|
||||||
|
Infos: agendamentoMelhorado,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const diaAgendamento = dayjs(agendamento.scheduled_at).format("YYYY-MM-DD");
|
const diaAgendamento = dayjs(
|
||||||
|
agendamento.scheduled_at
|
||||||
|
).format('YYYY-MM-DD');
|
||||||
if (newDict[diaAgendamento]) {
|
if (newDict[diaAgendamento]) {
|
||||||
newDict[diaAgendamento].push(agendamentoMelhorado);
|
newDict[diaAgendamento].push(agendamentoMelhorado);
|
||||||
} else {
|
} else {
|
||||||
@ -81,12 +105,13 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const key in newDict) {
|
for (const key in newDict) {
|
||||||
newDict[key].sort((a, b) => a.scheduled_at.localeCompare(b.scheduled_at));
|
newDict[key].sort((a, b) =>
|
||||||
|
a.scheduled_at.localeCompare(b.scheduled_at)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
setDictAgendamentosOrganizados(newDict);
|
setDictAgendamentosOrganizados(newDict);
|
||||||
setFilaDeEsperaData(newFila);
|
setFilaDeEsperaData(newFila);
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Falha ao buscar ou processar agendamentos:', err);
|
console.error('Falha ao buscar ou processar agendamentos:', err);
|
||||||
setDictAgendamentosOrganizados({});
|
setDictAgendamentosOrganizados({});
|
||||||
@ -96,17 +121,28 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 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
|
||||||
|
className="btns-gerenciamento-e-consulta"
|
||||||
|
style={{ display: 'flex', gap: '10px', marginBottom: '20px' }}
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
className="btn-adicionar-consulta"
|
className="btn btn-primary btn-consulta-paciente"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setPageConsulta(true);
|
setPageConsulta(true);
|
||||||
setFiladeEspera(false);
|
setFiladeEspera(false);
|
||||||
}}
|
}}
|
||||||
style={{
|
|
||||||
backgroundColor: PageNovaConsulta ? '#1d4ed8' : undefined
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<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})
|
<i className="bi bi-list-task me-1"></i> Fila de Espera ({filaEsperaData.length})
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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()) && (
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-outline-danger"
|
||||||
|
onClick={() => handleCancelClick(app.id)}
|
||||||
|
title="Cancelar Consulta"
|
||||||
|
>
|
||||||
<Trash2 size={16} />
|
<Trash2 size={16} />
|
||||||
</button>
|
</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 ? (
|
||||||
|
filaEsperaData.map((item) => (
|
||||||
<tr key={item.agendamento.id}>
|
<tr key={item.agendamento.id}>
|
||||||
<td>Dr(a). {item.Infos?.medico_nome}</td>
|
<td>Dr(a). {item.Infos?.medico_nome}</td>
|
||||||
<td>{dayjs(item.agendamento.created_at).format('DD/MM/YYYY HH:mm')}</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
|
||||||
|
).format('DD/MM/YYYY HH:mm')}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-danger"
|
||||||
|
onClick={() =>
|
||||||
|
handleCancelClick(item.agendamento.id)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<i className="bi bi-trash me-1"></i>{' '}
|
||||||
|
Cancelar
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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,
|
...prev,
|
||||||
contato: { ...prev.contato, email: value }
|
contato: {
|
||||||
|
...(prev.contato || {}),
|
||||||
|
email: value,
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
} else if (name === 'status') {
|
} else if (name === "status") {
|
||||||
setAgendamento(prev => ({
|
setAgendamento((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
status: prev.status === 'requested' ? 'confirmed' : 'requested'
|
status: prev.status === "requested" ? "confirmed" : "requested",
|
||||||
}));
|
}));
|
||||||
} else if (name === 'paciente_cpf') {
|
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(() => {
|
||||||
|
|
||||||
console.log("Horario","tessssste" )
|
|
||||||
if (agendamento?.scheduled_at) {
|
if (agendamento?.scheduled_at) {
|
||||||
setHorarioInicio(formatarHora(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,163 +172,138 @@ 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() === '') {
|
const opcoesDeHorario = slotsArray.map((item) => ({
|
||||||
setProfissionaisFiltrados([]);
|
|
||||||
setIsDropdownOpen(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const filtered = todosProfissionais.filter(p =>
|
|
||||||
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;
|
||||||
|
|
||||||
|
if (
|
||||||
|
!agendamento.doctor_id ||
|
||||||
|
!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,
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCloseModal = () => {
|
onSave?.(payload);
|
||||||
setShowSuccessModal(false);
|
setIsSubmitting(false);
|
||||||
onSave({ ...agendamento, horarioInicio: horarioInicio, status:status });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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 (<div className="form-container">
|
|
||||||
{showSuccessModal && (
|
|
||||||
<div className="modal-overlay">
|
|
||||||
<div className="modal-content">
|
|
||||||
<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}>
|
<form className="form-agendamento" onSubmit={handleSubmit}>
|
||||||
<h2 className="section-title">Informações do paciente</h2>
|
<h2 className="section-title">Informações do paciente</h2>
|
||||||
|
|
||||||
<div className="campos-informacoes-paciente" id="informacoes-paciente-linha-um">
|
<div
|
||||||
|
className="campos-informacoes-paciente"
|
||||||
|
id="informacoes-paciente-linha-um"
|
||||||
|
>
|
||||||
<div className="campo-de-input-container">
|
<div className="campo-de-input-container">
|
||||||
<div className="campo-de-input">
|
<div className="campo-de-input">
|
||||||
<label>Nome *</label>
|
<label>Nome *</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
name="paciente_nome"
|
name="paciente_nome"
|
||||||
|
value={agendamento.paciente_nome || ""}
|
||||||
placeholder="Insira o nome do paciente"
|
placeholder="Insira o nome do paciente"
|
||||||
required
|
required
|
||||||
onChange={(e) => handleSearchPaciente(e)}
|
onChange={handleSearchPaciente}
|
||||||
value={agendamento?.paciente_nome || ""}
|
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="campo-de-input">
|
||||||
|
<label>CPF do paciente</label>
|
||||||
|
<InputMask
|
||||||
|
mask="999.999.999-99"
|
||||||
|
maskChar={null}
|
||||||
|
type="text"
|
||||||
|
name="paciente_cpf"
|
||||||
|
placeholder="000.000.000-00"
|
||||||
|
value={agendamento.paciente_cpf || ""}
|
||||||
|
onChange={handleChange}
|
||||||
|
autoComplete="off"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
{isDropdownPacienteOpen && pacientesFiltrados.length > 0 && (
|
{isDropdownPacienteOpen && pacientesFiltrados.length > 0 && (
|
||||||
<div className="dropdown-pacientes">
|
<div className="dropdown-pacientes">
|
||||||
{pacientesFiltrados.map((paciente) => (
|
{pacientesFiltrados.map((paciente) => (
|
||||||
@ -279,29 +312,25 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
|||||||
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 className="campo-de-input campo-cpf">
|
|
||||||
<label>CPF do paciente</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="paciente_cpf"
|
|
||||||
placeholder="000.000.000-00"
|
|
||||||
onChange={handleChange}
|
|
||||||
value={agendamento.paciente_cpf}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="campos-informacoes-paciente" id="informacoes-paciente-linha-tres">
|
<div
|
||||||
|
className="campos-informacoes-paciente"
|
||||||
|
id="informacoes-paciente-linha-tres"
|
||||||
|
>
|
||||||
<div>
|
<div>
|
||||||
<label>Convênio</label>
|
<label>Convênio</label>
|
||||||
<select name="convenio" onChange={handleChange} value={agendamento.insurance_provider}>
|
<select
|
||||||
|
name="convenio"
|
||||||
|
onChange={handleChange}
|
||||||
|
value={agendamento.insurance_provider || "publico"}
|
||||||
|
>
|
||||||
<option value="publico">Público</option>
|
<option value="publico">Público</option>
|
||||||
<option value="unimed">Unimed</option>
|
<option value="unimed">Unimed</option>
|
||||||
<option value="bradesco_saude">Bradesco Saúde</option>
|
<option value="bradesco_saude">Bradesco Saúde</option>
|
||||||
@ -320,7 +349,7 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
|||||||
type="text"
|
type="text"
|
||||||
name="nome_medico"
|
name="nome_medico"
|
||||||
onChange={handleSearchProfissional}
|
onChange={handleSearchProfissional}
|
||||||
value={agendamento?.nome_medico || ''}
|
value={agendamento?.nome_medico || ""}
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
@ -343,7 +372,11 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
|||||||
|
|
||||||
<div className="tipo_atendimento">
|
<div className="tipo_atendimento">
|
||||||
<label>Tipo de atendimento *</label>
|
<label>Tipo de atendimento *</label>
|
||||||
<select name="tipo_atendimento" onChange={handleChange} value={agendamento.tipo_atendimento}>
|
<select
|
||||||
|
name="tipo_atendimento"
|
||||||
|
onChange={handleChange}
|
||||||
|
value={agendamento.tipo_atendimento || "presencial"}
|
||||||
|
>
|
||||||
<option value="presencial">Presencial</option>
|
<option value="presencial">Presencial</option>
|
||||||
<option value="teleconsulta">Teleconsulta</option>
|
<option value="teleconsulta">Teleconsulta</option>
|
||||||
</select>
|
</select>
|
||||||
@ -351,6 +384,7 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section id="informacoes-atendimento-segunda-linha">
|
<section id="informacoes-atendimento-segunda-linha">
|
||||||
|
<section id="informacoes-atendimento-segunda-linha-esquerda">
|
||||||
<div className="campo-informacoes-atendimento">
|
<div className="campo-informacoes-atendimento">
|
||||||
<div className="campo-de-input">
|
<div className="campo-de-input">
|
||||||
<label>Data *</label>
|
<label>Data *</label>
|
||||||
@ -358,7 +392,7 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
|||||||
type="date"
|
type="date"
|
||||||
name="dataAtendimento"
|
name="dataAtendimento"
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
value={agendamento.dataAtendimento}
|
value={agendamento.dataAtendimento || ""}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -369,13 +403,19 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
|||||||
<select
|
<select
|
||||||
id="inicio"
|
id="inicio"
|
||||||
name="inicio"
|
name="inicio"
|
||||||
required
|
|
||||||
value={horarioInicio}
|
value={horarioInicio}
|
||||||
onChange={(e) => setHorarioInicio(e.target.value)}
|
onChange={(e) => setHorarioInicio(e.target.value)}
|
||||||
|
required
|
||||||
>
|
>
|
||||||
<option value="" disabled>Selecione a hora de início</option>
|
<option value="" disabled>
|
||||||
|
Selecione a hora de início
|
||||||
|
</option>
|
||||||
{opcoesDeHorario.map((opcao, index) => (
|
{opcoesDeHorario.map((opcao, index) => (
|
||||||
<option key={index} value={opcao.value} disabled={opcao.disabled}>
|
<option
|
||||||
|
key={index}
|
||||||
|
value={opcao.value}
|
||||||
|
disabled={opcao.disabled}
|
||||||
|
>
|
||||||
{opcao.label}
|
{opcao.label}
|
||||||
{opcao.disabled && " (Indisponível)"}
|
{opcao.disabled && " (Indisponível)"}
|
||||||
</option>
|
</option>
|
||||||
@ -389,46 +429,47 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
|||||||
type="text"
|
type="text"
|
||||||
id="termino"
|
id="termino"
|
||||||
name="termino"
|
name="termino"
|
||||||
value={horarioTermino || '— —'}
|
value={horarioTermino || "— —"}
|
||||||
readOnly
|
readOnly
|
||||||
className="horario-termino-readonly"
|
className="horario-termino-readonly"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<div className="campo-de-input observacoes">
|
<section className="informacoes-atendimento-segunda-linha-direita">
|
||||||
|
<div className="campo-de-input">
|
||||||
<label>Observações</label>
|
<label>Observações</label>
|
||||||
<textarea
|
<textarea
|
||||||
name="observacoes"
|
name="observacoes"
|
||||||
rows="4"
|
rows="4"
|
||||||
cols="1"
|
cols="1"
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
value={agendamento.observacoes || ''}
|
value={agendamento.observacoes || ""}
|
||||||
/>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
</section>
|
||||||
<div className="campo-de-input-check">
|
|
||||||
<input
|
|
||||||
className="form-check-input form-custom-check"
|
|
||||||
type="checkbox"
|
|
||||||
name="status"
|
|
||||||
onChange={handleCheckbox}
|
|
||||||
checked={status === "requested"}
|
|
||||||
/>
|
|
||||||
<label className="form-check-label checkbox-label" htmlFor="status">
|
|
||||||
Adicionar à fila de espera
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="form-actions">
|
<div className="form-actions">
|
||||||
<button type="submit" className="btn-primary">Salvar agendamento</button>
|
<button
|
||||||
<button type="button" className="btn-cancel" onClick={onCancel}>Cancelar</button>
|
type="submit"
|
||||||
|
className="btn-primary"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
{isSubmitting ? "Salvando..." : "Salvar agendamento"}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn-cancel"
|
||||||
|
onClick={onCancel}
|
||||||
|
>
|
||||||
|
Cancelar
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</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;
|
||||||
@ -85,3 +92,49 @@
|
|||||||
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;
|
||||||
@ -690,3 +751,93 @@ input[name="paciente_cpf"]{
|
|||||||
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;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,19 +1,61 @@
|
|||||||
import React from 'react'
|
import React, { useState } from 'react'
|
||||||
import '../PagesMedico/styleMedico/FormNovoRelatorio.css'
|
import '../PagesMedico/styleMedico/FormNovoRelatorio.css'
|
||||||
import { useState } from 'react'
|
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
import { useAuth } from '../components/utils/AuthProvider'
|
import { useAuth } from '../components/utils/AuthProvider'
|
||||||
import { GetPatientByCPF } from '../components/utils/Functions-Endpoints/Patient'
|
import { GetPatientByCPF } from '../components/utils/Functions-Endpoints/Patient'
|
||||||
import { FormatCPF } from '../components/utils/Formatar/Format'
|
import { FormatCPF } from '../components/utils/Formatar/Format'
|
||||||
import html2pdf from 'html2pdf.js'
|
import html2pdf from 'html2pdf.js'
|
||||||
|
|
||||||
const FormRelatorio = ({onSave, DictInfo, setDictInfo }) => {
|
const FormRelatorio = ({ onSave, DictInfo, setDictInfo }) => {
|
||||||
const {getAuthorizationHeader} = useAuth()
|
const { getAuthorizationHeader } = useAuth()
|
||||||
let authHeader = getAuthorizationHeader()
|
let authHeader = getAuthorizationHeader()
|
||||||
const navigate= useNavigate()
|
const navigate = useNavigate()
|
||||||
|
|
||||||
const [showModal, setShowModal] = useState(false)
|
const [showModal, setShowModal] = useState(false)
|
||||||
|
|
||||||
|
// --- NOVO: Estado para controlar o loading da transcrição ---
|
||||||
|
const [isTranscribing, setIsTranscribing] = useState(false);
|
||||||
|
|
||||||
|
// --- NOVA FUNÇÃO: Envia o áudio e preenche o formulário ---
|
||||||
|
const handleAudioUpload = async (e) => {
|
||||||
|
const file = e.target.files[0];
|
||||||
|
if (!file) return;
|
||||||
|
|
||||||
|
setIsTranscribing(true); // Ativa o spinner
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('audio', file); // 'audio' deve ser o nome esperado no backend
|
||||||
|
|
||||||
|
try {
|
||||||
|
// ⚠️ ATENÇÃO: Substitua essa URL pela rota do seu backend que criamos
|
||||||
|
const response = await fetch('http://localhost:3001/api/transcrever-relatorio', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData,
|
||||||
|
// headers: { 'Authorization': authHeader } // Descomente se seu backend precisar de token
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error("Falha na transcrição");
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
// Atualiza o DictInfo com os dados vindos da IA
|
||||||
|
setDictInfo((prev) => ({
|
||||||
|
...prev,
|
||||||
|
exam: data.exam || prev.exam, // Preenche se a IA achou, senão mantém o antigo
|
||||||
|
diagnostico: data.diagnostico || prev.diagnostico,
|
||||||
|
conclusao: data.conclusao || prev.conclusao
|
||||||
|
}));
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Erro no upload de áudio:", error);
|
||||||
|
alert("Não foi possível gerar o relatório por áudio. Verifique o backend.");
|
||||||
|
} finally {
|
||||||
|
setIsTranscribing(false); // Desativa o spinner
|
||||||
|
e.target.value = null; // Limpa o input para permitir enviar o mesmo arquivo novamente se quiser
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
|
||||||
const BaixarPDFdoRelatorio = () => {
|
const BaixarPDFdoRelatorio = () => {
|
||||||
const elemento = document.getElementById("folhaA4"); // tua div do relatório
|
const elemento = document.getElementById("folhaA4"); // tua div do relatório
|
||||||
const opt = {
|
const opt = {
|
||||||
@ -29,7 +71,7 @@ const FormRelatorio = ({onSave, DictInfo, setDictInfo }) => {
|
|||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
const { name, value } = e.target;
|
const { name, value } = e.target;
|
||||||
console.log(name, value)
|
console.log(name, value)
|
||||||
if(name === 'paciente_cpf') {
|
if (name === 'paciente_cpf') {
|
||||||
const formattedCPF = FormatCPF(value);
|
const formattedCPF = FormatCPF(value);
|
||||||
setDictInfo((prev) => ({ ...prev, [name]: formattedCPF }));
|
setDictInfo((prev) => ({ ...prev, [name]: formattedCPF }));
|
||||||
|
|
||||||
@ -38,17 +80,17 @@ const FormRelatorio = ({onSave, DictInfo, setDictInfo }) => {
|
|||||||
if (patientData) {
|
if (patientData) {
|
||||||
setDictInfo((prev) => ({
|
setDictInfo((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
paciente_cpf:value,
|
paciente_cpf: value,
|
||||||
paciente_nome: patientData.full_name,
|
paciente_nome: patientData.full_name,
|
||||||
paciente_id: patientData.id
|
paciente_id: patientData.id
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
if(formattedCPF.length === 14){
|
if (formattedCPF.length === 14) {
|
||||||
fetchPatient();
|
fetchPatient();
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
setDictInfo((prev) => ({ ...prev, [name]: value }));
|
setDictInfo((prev) => ({ ...prev, [name]: value }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,25 +100,21 @@ const FormRelatorio = ({onSave, DictInfo, setDictInfo }) => {
|
|||||||
console.log(DictInfo)
|
console.log(DictInfo)
|
||||||
setShowModal(true)
|
setShowModal(true)
|
||||||
|
|
||||||
|
onSave({
|
||||||
onSave({
|
|
||||||
"patient_id": DictInfo.paciente_id,
|
"patient_id": DictInfo.paciente_id,
|
||||||
|
|
||||||
"exam": DictInfo.exam,
|
"exam": DictInfo.exam,
|
||||||
"diagnosis": DictInfo.diagnosis,
|
"diagnosis": DictInfo.diagnostico, // Garanta que o backend espera 'diagnosis' mas seu state usa 'diagnostico'
|
||||||
"conclusion": DictInfo.conclusao,
|
"conclusion": DictInfo.conclusao,
|
||||||
"status": "draft",
|
"status": "draft",
|
||||||
"requested_by": DictInfo.requested_by,
|
"requested_by": DictInfo.requested_by,
|
||||||
|
|
||||||
"hide_date": false,
|
"hide_date": false,
|
||||||
"hide_signature": false,
|
"hide_signature": false,
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{showModal &&(
|
{showModal && (
|
||||||
<div className="modal" style={{ display: 'block', backgroundColor: 'rgba(0,0,0,0.5)' }}>
|
<div className="modal" style={{ display: 'block', backgroundColor: 'rgba(0,0,0,0.5)' }}>
|
||||||
<div className="modal-dialog">
|
<div className="modal-dialog">
|
||||||
<div className="modal-content">
|
<div className="modal-content">
|
||||||
@ -92,12 +130,12 @@ onSave({
|
|||||||
<p>Você também pode baixa-lo agora em pdf</p>
|
<p>Você também pode baixa-lo agora em pdf</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-footer">
|
<div className="modal-footer">
|
||||||
<button className="btn btn-primary" onClick={ BaixarPDFdoRelatorio}><i className='bi bi-file-pdf-fill'></i> baixar em pdf</button>
|
<button className="btn btn-primary" onClick={BaixarPDFdoRelatorio}><i className='bi bi-file-pdf-fill'></i> baixar em pdf</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-primary"
|
className="btn btn-primary"
|
||||||
onClick={() => {setShowModal(false); navigate(('/medico/relatorios'))}}
|
onClick={() => { setShowModal(false); navigate(('/medico/relatorios')) }}
|
||||||
>
|
>
|
||||||
Fechar
|
Fechar
|
||||||
</button>
|
</button>
|
||||||
@ -110,6 +148,28 @@ onSave({
|
|||||||
|
|
||||||
<div className='card'>
|
<div className='card'>
|
||||||
|
|
||||||
|
{/* --- ÁREA DE UPLOAD DE ÁUDIO (INSERIDA AQUI) --- */}
|
||||||
|
<div className="p-3 mb-3 border-bottom bg-light">
|
||||||
|
<label className="form-label fw-bold">🎙️ Preenchimento Automático via Áudio</label>
|
||||||
|
<div className="d-flex align-items-center gap-3">
|
||||||
|
{isTranscribing ? (
|
||||||
|
<div className="d-flex align-items-center text-primary">
|
||||||
|
<div className="spinner-border spinner-border-sm me-2" role="status"></div>
|
||||||
|
<span>A IA está gerando o relatório... aguarde.</span>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
className="form-control"
|
||||||
|
accept="audio/*"
|
||||||
|
onChange={handleAudioUpload}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<small className="text-muted">Envie um áudio ditando o exame, diagnóstico e conclusão.</small>
|
||||||
|
</div>
|
||||||
|
{/* ----------------------------------------------- */}
|
||||||
|
|
||||||
<form action="" onSubmit={handleSubmit}>
|
<form action="" onSubmit={handleSubmit}>
|
||||||
<div id='primeiraLinha'>
|
<div id='primeiraLinha'>
|
||||||
|
|
||||||
@ -131,7 +191,7 @@ onSave({
|
|||||||
|
|
||||||
<div className="col-md-2 mb-3">
|
<div className="col-md-2 mb-3">
|
||||||
<label >Exame:</label>
|
<label >Exame:</label>
|
||||||
<input type="text" className="form-control" name="exam" onChange={handleChange} />
|
<input type="text" className="form-control" name="exam" onChange={handleChange} value={DictInfo.exam || ''} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -177,7 +237,8 @@ onSave({
|
|||||||
<p>Paciente: {DictInfo?.paciente_nome}</p>
|
<p>Paciente: {DictInfo?.paciente_nome}</p>
|
||||||
<p>Data de nascimento: </p>
|
<p>Data de nascimento: </p>
|
||||||
|
|
||||||
<p>Data do exame: {DictInfo.data_exam}</p>
|
{/* Corrigi de data_exam para data_exame para bater com o state */}
|
||||||
|
<p>Data do exame: {DictInfo.data_exame}</p>
|
||||||
|
|
||||||
<p>Exame: {DictInfo.exam}</p>
|
<p>Exame: {DictInfo.exam}</p>
|
||||||
|
|
||||||
@ -189,7 +250,7 @@ onSave({
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>Dr {DictInfo.requested_by}</p>
|
<p>Dr {DictInfo.requested_by}</p>
|
||||||
<p>Emitido em: 0</p>
|
<p>Emitido em: {new Date().toLocaleDateString()}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
@ -5,12 +5,21 @@
|
|||||||
"url": "/medico/agendamento"
|
"url": "/medico/agendamento"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "Relatório por Áudio",
|
||||||
|
"icon": "file-earmark-plus-fill",
|
||||||
|
"url": "/medico/novo-relatorio-audio"
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "Relatórios",
|
"name": "Relatórios",
|
||||||
"icon": "file-earmark-text-fill",
|
"icon": "file-earmark-text-fill",
|
||||||
"url": "/medico/relatorios"
|
"url": "/medico/relatorios"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "Chat com pacientes",
|
"name": "Chat com pacientes",
|
||||||
"icon": "chat-dots-fill",
|
"icon": "chat-dots-fill",
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
*,
|
||||||
|
*::before,
|
||||||
|
*::after {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||||
|
|||||||
@ -1,51 +1,60 @@
|
|||||||
import React, { useState, useMemo, useEffect } from 'react';
|
import React, { useState, useMemo, useEffect } 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 './AgendamentoCadastroManager.jsx';
|
import AgendamentoCadastroManager from "./AgendamentoCadastroManager.jsx";
|
||||||
import { GetPatientByID } from '../components/utils/Functions-Endpoints/Patient.js';
|
import { GetPatientByID } from "../components/utils/Functions-Endpoints/Patient.js";
|
||||||
import TabelaAgendamentoDia from '../components/AgendarConsulta/TabelaAgendamentoDia';
|
import TabelaAgendamentoDia from "../components/AgendarConsulta/TabelaAgendamentoDia";
|
||||||
import TabelaAgendamentoSemana from '../components/AgendarConsulta/TabelaAgendamentoSemana';
|
import TabelaAgendamentoSemana from "../components/AgendarConsulta/TabelaAgendamentoSemana";
|
||||||
import TabelaAgendamentoMes from '../components/AgendarConsulta/TabelaAgendamentoMes';
|
import TabelaAgendamentoMes from "../components/AgendarConsulta/TabelaAgendamentoMes";
|
||||||
import FormNovaConsulta from '../components/AgendarConsulta/FormNovaConsulta';
|
import FormNovaConsulta from "../components/AgendarConsulta/FormNovaConsulta";
|
||||||
import { GetAllDoctors, GetDoctorByID } from '../components/utils/Functions-Endpoints/Doctor.js';
|
import {
|
||||||
import { useAuth } from '../components/utils/AuthProvider.js';
|
GetAllDoctors,
|
||||||
import dayjs from 'dayjs';
|
GetDoctorByID,
|
||||||
import 'dayjs/locale/pt-br';
|
} from "../components/utils/Functions-Endpoints/Doctor.js";
|
||||||
import isBetween from 'dayjs/plugin/isBetween';
|
import { useAuth } from "../components/utils/AuthProvider.js";
|
||||||
import localeData from 'dayjs/plugin/localeData';
|
import dayjs from "dayjs";
|
||||||
import { Search, ChevronLeft, ChevronRight, Edit, Trash2 } from 'lucide-react';
|
import "dayjs/locale/pt-br";
|
||||||
import CalendarComponent from '../components/AgendarConsulta/CalendarComponent.jsx';
|
import isBetween from "dayjs/plugin/isBetween";
|
||||||
|
import localeData from "dayjs/plugin/localeData";
|
||||||
|
import { ChevronLeft, ChevronRight, Edit, Trash2 } from "lucide-react";
|
||||||
|
import CalendarComponent from "../components/AgendarConsulta/CalendarComponent.jsx";
|
||||||
import "./style/Agendamento.css";
|
import "./style/Agendamento.css";
|
||||||
import './style/FilaEspera.css';
|
import "./style/FilaEspera.css";
|
||||||
import Spinner from '../components/Spinner.jsx';
|
import Spinner from "../components/Spinner.jsx";
|
||||||
|
|
||||||
dayjs.locale('pt-br');
|
dayjs.locale("pt-br");
|
||||||
dayjs.extend(isBetween);
|
dayjs.extend(isBetween);
|
||||||
dayjs.extend(localeData);
|
dayjs.extend(localeData);
|
||||||
|
|
||||||
|
// Offset de horário para bater com o que o paciente marca (ajuste se precisar)
|
||||||
|
const HORARIO_OFFSET = 3; // se a diferença for 2h, troca para 2
|
||||||
|
|
||||||
const Agendamento = ({ setDictInfo }) => {
|
const Agendamento = ({ setDictInfo }) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [listaTodosAgendamentos, setListaTodosAgendamentos] = useState([]);
|
const [listaTodosAgendamentos, setListaTodosAgendamentos] = useState([]);
|
||||||
const [selectedID, setSelectedId] = useState('0');
|
const [selectedID, setSelectedId] = useState("0");
|
||||||
const [filaEsperaData, setFilaEsperaData] = useState([]);
|
const [filaEsperaData, setFilaEsperaData] = useState([]);
|
||||||
const [FiladeEspera, setFiladeEspera] = useState(false);
|
const [FiladeEspera, setFiladeEspera] = useState(false);
|
||||||
const [PageNovaConsulta, setPageConsulta] = useState(false);
|
const [PageNovaConsulta, setPageConsulta] = useState(false);
|
||||||
const [searchTerm, setSearchTerm] = useState('');
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
const { getAuthorizationHeader } = useAuth();
|
const { getAuthorizationHeader } = useAuth();
|
||||||
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 [doctorDropdownOpen, setDoctorDropdownOpen] = useState(false);
|
||||||
const [MedicoFiltrado, setMedicoFiltrado] = useState({ id: "vazio" });
|
const [MedicoFiltrado, setMedicoFiltrado] = useState({ id: "vazio" });
|
||||||
const [cacheAgendamentos, setCacheAgendamentos] = useState([]);
|
const [cacheAgendamentos, setCacheAgendamentos] = useState([]);
|
||||||
const [appointmentToEdit, setAppointmentToEdit] = useState(null);
|
const [appointmentToEdit, setAppointmentToEdit] = useState(null);
|
||||||
const [showConfirmModal, setShowConfirmModal] = useState(false);
|
const [showConfirmModal, setShowConfirmModal] = useState(false);
|
||||||
const [motivoCancelamento, setMotivoCancelamento] = useState("");
|
const [motivoCancelamento, setMotivoCancelamento] = useState("");
|
||||||
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);
|
||||||
const [waitSortDir, setWaitSortDir] = useState('asc');
|
const [waitSortDir, setWaitSortDir] = useState("asc");
|
||||||
const [waitPage, setWaitPage] = useState(1);
|
const [waitPage, setWaitPage] = useState(1);
|
||||||
const [waitPerPage, setWaitPerPage] = useState(10);
|
const [waitPerPage, setWaitPerPage] = useState(10);
|
||||||
const authHeader = getAuthorizationHeader();
|
const authHeader = getAuthorizationHeader();
|
||||||
@ -53,25 +62,31 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
const cachePacientes = useMemo(() => ({}), []);
|
const cachePacientes = useMemo(() => ({}), []);
|
||||||
const [currentDate, setCurrentDate] = useState(dayjs());
|
const [currentDate, setCurrentDate] = useState(dayjs());
|
||||||
const [selectedDay, setSelectedDay] = useState(dayjs());
|
const [selectedDay, setSelectedDay] = useState(dayjs());
|
||||||
|
|
||||||
const [editingAppointmentId, setEditingAppointmentId] = useState(null);
|
const [editingAppointmentId, setEditingAppointmentId] = useState(null);
|
||||||
|
|
||||||
const [quickJump, setQuickJump] = useState({
|
const [quickJump, setQuickJump] = useState({
|
||||||
month: currentDate.month(),
|
month: currentDate.month(),
|
||||||
year: currentDate.year()
|
year: currentDate.year(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchAppointments = async () => {
|
const fetchAppointments = async () => {
|
||||||
const myHeaders = new Headers();
|
const myHeaders = new Headers();
|
||||||
myHeaders.append("Authorization", authHeader);
|
myHeaders.append("Authorization", authHeader);
|
||||||
myHeaders.append("apikey", API_KEY);
|
myHeaders.append("apikey", API_KEY);
|
||||||
const requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' };
|
const requestOptions = {
|
||||||
|
method: "GET",
|
||||||
|
headers: myHeaders,
|
||||||
|
redirect: "follow",
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
const res = await fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?select=*", requestOptions);
|
const res = await fetch(
|
||||||
|
"https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?select=*",
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
setListaTodosAgendamentos(data);
|
setListaTodosAgendamentos(data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Erro ao buscar agendamentos', err);
|
console.error("Erro ao buscar agendamentos", err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -81,19 +96,26 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
myHeaders.append("apikey", API_KEY);
|
myHeaders.append("apikey", API_KEY);
|
||||||
myHeaders.append("Content-Type", "application/json");
|
myHeaders.append("Content-Type", "application/json");
|
||||||
myHeaders.append("Prefer", "return=representation");
|
myHeaders.append("Prefer", "return=representation");
|
||||||
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) {
|
if (response.ok) {
|
||||||
await fetchAppointments();
|
await fetchAppointments();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
console.error('Erro ao atualizar agendamento:', await response.text());
|
console.error("Erro ao atualizar agendamento:", await response.text());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erro de rede/servidor:', error);
|
console.error("Erro de rede/servidor:", error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -103,13 +125,13 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
const success = await updateAppointmentStatus(id, {
|
const success = await updateAppointmentStatus(id, {
|
||||||
status: "cancelled",
|
status: "cancelled",
|
||||||
cancellation_reason: motivoCancelamento,
|
cancellation_reason: motivoCancelamento,
|
||||||
updated_at: new Date().toISOString()
|
updated_at: new Date().toISOString(),
|
||||||
});
|
});
|
||||||
setShowSpinner(false);
|
setShowSpinner(false);
|
||||||
if (success) {
|
if (success) {
|
||||||
setShowDeleteModal(false);
|
setShowDeleteModal(false);
|
||||||
setMotivoCancelamento("");
|
setMotivoCancelamento("");
|
||||||
setSelectedId('0');
|
setSelectedId("0");
|
||||||
} else {
|
} else {
|
||||||
alert("Falha ao cancelar a consulta.");
|
alert("Falha ao cancelar a consulta.");
|
||||||
}
|
}
|
||||||
@ -120,25 +142,25 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
const success = await updateAppointmentStatus(id, {
|
const success = await updateAppointmentStatus(id, {
|
||||||
status: "agendado",
|
status: "agendado",
|
||||||
cancellation_reason: null,
|
cancellation_reason: null,
|
||||||
updated_at: new Date().toISOString()
|
updated_at: new Date().toISOString(),
|
||||||
});
|
});
|
||||||
setShowSpinner(false);
|
setShowSpinner(false);
|
||||||
if (success) {
|
if (success) {
|
||||||
setShowConfirmModal(false);
|
setShowConfirmModal(false);
|
||||||
setSelectedId('0');
|
setSelectedId("0");
|
||||||
} else {
|
} else {
|
||||||
alert("Falha ao reverter o cancelamento.");
|
alert("Falha ao reverter o cancelamento.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleQuickJumpChange = (type, value) => {
|
const handleQuickJumpChange = (type, value) => {
|
||||||
setQuickJump(prev => ({ ...prev, [type]: Number(value) }));
|
setQuickJump((prev) => ({ ...prev, [type]: Number(value) }));
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setQuickJump({
|
setQuickJump({
|
||||||
month: currentDate.month(),
|
month: currentDate.month(),
|
||||||
year: currentDate.year()
|
year: currentDate.year(),
|
||||||
});
|
});
|
||||||
}, [currentDate]);
|
}, [currentDate]);
|
||||||
|
|
||||||
@ -149,7 +171,10 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!listaTodosAgendamentos.length) { setShowSpinner(false); return; }
|
if (!listaTodosAgendamentos.length) {
|
||||||
|
setShowSpinner(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
setShowSpinner(true);
|
setShowSpinner(true);
|
||||||
const fetchDados = async () => {
|
const fetchDados = async () => {
|
||||||
const newDict = {};
|
const newDict = {};
|
||||||
@ -157,10 +182,14 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
for (const agendamento of listaTodosAgendamentos) {
|
for (const agendamento of listaTodosAgendamentos) {
|
||||||
if (!agendamento.doctor_id || !agendamento.patient_id) continue;
|
if (!agendamento.doctor_id || !agendamento.patient_id) continue;
|
||||||
if (!cacheMedicos[agendamento.doctor_id]) {
|
if (!cacheMedicos[agendamento.doctor_id]) {
|
||||||
cacheMedicos[agendamento.doctor_id] = (await GetDoctorByID(agendamento.doctor_id, authHeader))[0];
|
cacheMedicos[agendamento.doctor_id] = (
|
||||||
|
await GetDoctorByID(agendamento.doctor_id, authHeader)
|
||||||
|
)[0];
|
||||||
}
|
}
|
||||||
if (!cachePacientes[agendamento.patient_id]) {
|
if (!cachePacientes[agendamento.patient_id]) {
|
||||||
cachePacientes[agendamento.patient_id] = (await GetPatientByID(agendamento.patient_id, authHeader))[0];
|
cachePacientes[agendamento.patient_id] = (
|
||||||
|
await GetPatientByID(agendamento.patient_id, authHeader)
|
||||||
|
)[0];
|
||||||
}
|
}
|
||||||
const medico = cacheMedicos[agendamento.doctor_id];
|
const medico = cacheMedicos[agendamento.doctor_id];
|
||||||
const paciente = cachePacientes[agendamento.patient_id];
|
const paciente = cachePacientes[agendamento.patient_id];
|
||||||
@ -169,13 +198,18 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
...agendamento,
|
...agendamento,
|
||||||
medico_nome: medico?.full_name,
|
medico_nome: medico?.full_name,
|
||||||
paciente_nome: paciente?.full_name,
|
paciente_nome: paciente?.full_name,
|
||||||
paciente_cpf: paciente?.cpf
|
paciente_cpf: paciente?.cpf,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (agendamento.status === "requested") {
|
if (agendamento.status === "requested") {
|
||||||
newFila.push({ agendamento: agendamentoMelhorado, Infos: agendamentoMelhorado });
|
newFila.push({
|
||||||
|
agendamento: agendamentoMelhorado,
|
||||||
|
Infos: agendamentoMelhorado,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const DiaAgendamento = dayjs(agendamento.scheduled_at).format("YYYY-MM-DD");
|
const DiaAgendamento = dayjs(agendamento.scheduled_at).format(
|
||||||
|
"YYYY-MM-DD"
|
||||||
|
);
|
||||||
if (newDict[DiaAgendamento]) {
|
if (newDict[DiaAgendamento]) {
|
||||||
newDict[DiaAgendamento].push(agendamentoMelhorado);
|
newDict[DiaAgendamento].push(agendamentoMelhorado);
|
||||||
} else {
|
} else {
|
||||||
@ -184,7 +218,9 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const key in newDict) {
|
for (const key in newDict) {
|
||||||
newDict[key].sort((a, b) => a.scheduled_at.localeCompare(b.scheduled_at));
|
newDict[key].sort((a, b) =>
|
||||||
|
a.scheduled_at.localeCompare(b.scheduled_at)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
setAgendamentosOrganizados(newDict);
|
setAgendamentosOrganizados(newDict);
|
||||||
setFilaEsperaData(newFila);
|
setFilaEsperaData(newFila);
|
||||||
@ -195,44 +231,59 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchAppointments();
|
fetchAppointments();
|
||||||
GetAllDoctors(authHeader).then(docs =>
|
GetAllDoctors(authHeader).then((docs) =>
|
||||||
setListaDeMedicos(docs.map(d => ({ nomeMedico: d.full_name, idMedico: d.id })))
|
setListaDeMedicos(
|
||||||
|
docs.map((d) => ({ nomeMedico: d.full_name, idMedico: d.id }))
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}, [authHeader]);
|
}, [authHeader]);
|
||||||
|
|
||||||
const handleSearchMedicos = (term) => { };
|
const handleSearchMedicos = (term) => {};
|
||||||
|
|
||||||
const filaEsperaFiltrada = useMemo(() => {
|
const filaEsperaFiltrada = useMemo(() => {
|
||||||
if (!waitlistSearch.trim()) return filaEsperaData;
|
if (!waitlistSearch.trim()) return filaEsperaData;
|
||||||
const term = waitlistSearch.toLowerCase();
|
const term = waitlistSearch.toLowerCase();
|
||||||
return filaEsperaData.filter(item =>
|
return filaEsperaData.filter(
|
||||||
(item?.Infos?.paciente_nome?.toLowerCase() || '').includes(term) ||
|
(item) =>
|
||||||
(item?.Infos?.paciente_cpf?.toLowerCase() || '').includes(term) ||
|
(item?.Infos?.paciente_nome?.toLowerCase() || "").includes(term) ||
|
||||||
(item?.Infos?.nome_medico?.toLowerCase() || '').includes(term)
|
(item?.Infos?.paciente_cpf?.toLowerCase() || "").includes(term) ||
|
||||||
|
(item?.Infos?.nome_medico?.toLowerCase() || "").includes(term)
|
||||||
);
|
);
|
||||||
}, [waitlistSearch, filaEsperaData]);
|
}, [waitlistSearch, filaEsperaData]);
|
||||||
|
|
||||||
const applySortingWaitlist = (arr) => {
|
const applySortingWaitlist = (arr) => {
|
||||||
if (!Array.isArray(arr) || !waitSortKey) return arr;
|
if (!Array.isArray(arr) || !waitSortKey) return arr;
|
||||||
const copy = [...arr];
|
const copy = [...arr];
|
||||||
if (waitSortKey === 'paciente') {
|
if (waitSortKey === "paciente") {
|
||||||
copy.sort((a, b) => (a?.Infos?.paciente_nome || '').localeCompare((b?.Infos?.paciente_nome || '')));
|
|
||||||
} else if (waitSortKey === 'medico') {
|
|
||||||
copy.sort((a, b) => (a?.Infos?.nome_medico || '').localeCompare((b?.Infos?.nome_medico || '')));
|
|
||||||
} else if (waitSortKey === 'data') {
|
|
||||||
copy.sort((a, b) =>
|
copy.sort((a, b) =>
|
||||||
new Date(a?.agendamento?.scheduled_at || 0) - new Date(b?.agendamento?.scheduled_at || 0)
|
(a?.Infos?.paciente_nome || "").localeCompare(
|
||||||
|
b?.Infos?.paciente_nome || ""
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (waitSortKey === "medico") {
|
||||||
|
copy.sort((a, b) =>
|
||||||
|
(a?.Infos?.nome_medico || "").localeCompare(b?.Infos?.nome_medico || "")
|
||||||
|
);
|
||||||
|
} else if (waitSortKey === "data") {
|
||||||
|
copy.sort(
|
||||||
|
(a, b) =>
|
||||||
|
new Date(a?.agendamento?.scheduled_at || 0) -
|
||||||
|
new Date(b?.agendamento?.scheduled_at || 0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (waitSortDir === 'desc') copy.reverse();
|
if (waitSortDir === "desc") copy.reverse();
|
||||||
return copy;
|
return copy;
|
||||||
};
|
};
|
||||||
|
|
||||||
const filaEsperaOrdenada = applySortingWaitlist(filaEsperaFiltrada);
|
const filaEsperaOrdenada = applySortingWaitlist(filaEsperaFiltrada);
|
||||||
const waitTotalPages = Math.ceil(filaEsperaOrdenada.length / waitPerPage) || 1;
|
const waitTotalPages =
|
||||||
|
Math.ceil(filaEsperaOrdenada.length / waitPerPage) || 1;
|
||||||
const waitIndiceInicial = (waitPage - 1) * waitPerPage;
|
const waitIndiceInicial = (waitPage - 1) * waitPerPage;
|
||||||
const waitIndiceFinal = waitIndiceInicial + waitPerPage;
|
const waitIndiceFinal = waitIndiceInicial + waitPerPage;
|
||||||
const filaEsperaPaginada = filaEsperaOrdenada.slice(waitIndiceInicial, waitIndiceFinal);
|
const filaEsperaPaginada = filaEsperaOrdenada.slice(
|
||||||
|
waitIndiceInicial,
|
||||||
|
waitIndiceFinal
|
||||||
|
);
|
||||||
|
|
||||||
const gerarNumerosWaitPages = () => {
|
const gerarNumerosWaitPages = () => {
|
||||||
const paginas = [];
|
const paginas = [];
|
||||||
@ -240,34 +291,49 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
let inicio = Math.max(1, waitPage - Math.floor(paginasParaMostrar / 2));
|
let inicio = Math.max(1, waitPage - Math.floor(paginasParaMostrar / 2));
|
||||||
let fim = Math.min(waitTotalPages, inicio + paginasParaMostrar - 1);
|
let fim = Math.min(waitTotalPages, inicio + paginasParaMostrar - 1);
|
||||||
inicio = Math.max(1, fim - paginasParaMostrar + 1);
|
inicio = Math.max(1, fim - paginasParaMostrar + 1);
|
||||||
for (let i = inicio; i <= fim; i++) { paginas.push(i); }
|
for (let i = inicio; i <= fim; i++) {
|
||||||
|
paginas.push(i);
|
||||||
|
}
|
||||||
return paginas;
|
return paginas;
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => { setWaitPage(1); }, [waitlistSearch, waitSortKey, waitSortDir]);
|
useEffect(() => {
|
||||||
|
setWaitPage(1);
|
||||||
|
}, [waitlistSearch, waitSortKey, waitSortDir]);
|
||||||
|
|
||||||
const generateDateGrid = () => {
|
const generateDateGrid = () => {
|
||||||
const grid = [];
|
const grid = [];
|
||||||
const startOfMonth = currentDate.startOf('month');
|
const startOfMonth = currentDate.startOf("month");
|
||||||
let currentDay = startOfMonth.subtract(startOfMonth.day(), 'day');
|
let currentDay = startOfMonth.subtract(startOfMonth.day(), "day");
|
||||||
for (let i = 0; i < 42; i++) {
|
for (let i = 0; i < 42; i++) {
|
||||||
grid.push(currentDay);
|
grid.push(currentDay);
|
||||||
currentDay = currentDay.add(1, 'day');
|
currentDay = currentDay.add(1, "day");
|
||||||
}
|
}
|
||||||
return grid;
|
return grid;
|
||||||
};
|
};
|
||||||
|
|
||||||
const dateGrid = useMemo(() => generateDateGrid(), [currentDate]);
|
const dateGrid = useMemo(() => generateDateGrid(), [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);
|
||||||
|
|
||||||
const DeleteModal = () => (
|
const DeleteModal = () => (
|
||||||
<div className="modal fade show" style={{ display: "block", backgroundColor: "rgba(0,0,0,0.5)" }} tabIndex="-1">
|
<div
|
||||||
|
className="modal fade show"
|
||||||
|
style={{ display: "block", backgroundColor: "rgba(0,0,0,0.5)" }}
|
||||||
|
tabIndex="-1"
|
||||||
|
>
|
||||||
<div className="modal-dialog modal-dialog-centered">
|
<div className="modal-dialog modal-dialog-centered">
|
||||||
<div className="modal-content">
|
<div className="modal-content">
|
||||||
<div className="modal-header" style={{ backgroundColor: '#f8d7da', color: '#721c24' }}>
|
<div
|
||||||
|
className="modal-header"
|
||||||
|
style={{ backgroundColor: "#f8d7da", color: "#721c24" }}
|
||||||
|
>
|
||||||
<h5 className="modal-title">Confirmação de Cancelamento</h5>
|
<h5 className="modal-title">Confirmação de Cancelamento</h5>
|
||||||
<button type="button" className="btn-close" onClick={() => setShowDeleteModal(false)}></button>
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn-close"
|
||||||
|
onClick={() => setShowDeleteModal(false)}
|
||||||
|
></button>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<p>Qual o motivo do cancelamento?</p>
|
<p>Qual o motivo do cancelamento?</p>
|
||||||
@ -282,7 +348,10 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-secondary"
|
className="btn btn-secondary"
|
||||||
onClick={() => { setShowDeleteModal(false); setMotivoCancelamento(""); }}
|
onClick={() => {
|
||||||
|
setShowDeleteModal(false);
|
||||||
|
setMotivoCancelamento("");
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Cancelar
|
Cancelar
|
||||||
</button>
|
</button>
|
||||||
@ -300,16 +369,29 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const ConfirmEditModal = () => (
|
const ConfirmEditModal = () => (
|
||||||
<div className="modal fade show" style={{ display: "block", backgroundColor: "rgba(0,0,0,0.5)" }} tabIndex="-1">
|
<div
|
||||||
|
className="modal fade show"
|
||||||
|
style={{ display: "block", backgroundColor: "rgba(0,0,0,0.5)" }}
|
||||||
|
tabIndex="-1"
|
||||||
|
>
|
||||||
<div className="modal-dialog modal-dialog-centered">
|
<div className="modal-dialog modal-dialog-centered">
|
||||||
<div className="modal-content">
|
<div className="modal-content">
|
||||||
<div className="modal-header" style={{ backgroundColor: '#d4edda', color: '#155724' }}>
|
<div
|
||||||
|
className="modal-header"
|
||||||
|
style={{ backgroundColor: "#d4edda", color: "#155724" }}
|
||||||
|
>
|
||||||
<h5 className="modal-title">Confirmação de edição</h5>
|
<h5 className="modal-title">Confirmação de edição</h5>
|
||||||
<button type="button" className="btn-close" onClick={() => setShowConfirmModal(false)}></button>
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn-close"
|
||||||
|
onClick={() => setShowConfirmModal(false)}
|
||||||
|
></button>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<p>Tem certeza que deseja retirar o cancelamento?</p>
|
<p>Tem certeza que deseja retirar o cancelamento?</p>
|
||||||
<small className="text-muted">Isso reverterá o status do agendamento para Agendado.</small>
|
<small className="text-muted">
|
||||||
|
Isso reverterá o status do agendamento para Agendado.
|
||||||
|
</small>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-footer justify-content-center">
|
<div className="modal-footer justify-content-center">
|
||||||
<button
|
<button
|
||||||
@ -324,7 +406,12 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
className="btn btn-success"
|
className="btn btn-success"
|
||||||
onClick={() => confirmConsulta(selectedID)}
|
onClick={() => confirmConsulta(selectedID)}
|
||||||
>
|
>
|
||||||
<Trash2 size={16} className="me-1" style={{ transform: 'rotate(45deg)' }} /> Confirmar
|
<Trash2
|
||||||
|
size={16}
|
||||||
|
className="me-1"
|
||||||
|
style={{ transform: "rotate(45deg)" }}
|
||||||
|
/>{" "}
|
||||||
|
Confirmar
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -337,53 +424,28 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
<h1>Agendar nova consulta</h1>
|
<h1>Agendar nova consulta</h1>
|
||||||
|
|
||||||
{!PageNovaConsulta ? (
|
{!PageNovaConsulta ? (
|
||||||
<div className='atendimento-eprocura'>
|
<div className="atendimento-eprocura">
|
||||||
<div className='unidade-selecionarprofissional'>
|
<div className="container-btns-agenda-fila_esepera">
|
||||||
<div className='busca-atendimento-container'>
|
|
||||||
<div className='input-e-dropdown-wrapper'>
|
|
||||||
<div className='busca-atendimento'>
|
|
||||||
<div className='mb-5'>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
placeholder="Filtrar atendimento do medico..."
|
|
||||||
value={searchTermDoctor}
|
|
||||||
onChange={(e) => handleSearchMedicos(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{searchTermDoctor && FiltredTodosMedicos.length > 0 && (
|
|
||||||
<div className='dropdown-medicos'>
|
|
||||||
{FiltredTodosMedicos.map((medico) => (
|
|
||||||
<div
|
|
||||||
key={medico.idMedico}
|
|
||||||
className='dropdown-item'
|
|
||||||
onClick={() => {
|
|
||||||
setSearchTermDoctor(medico.nomeMedico);
|
|
||||||
setFiltredTodosMedicos([]);
|
|
||||||
setMedicoFiltrado(medico);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<p>{medico.nomeMedico}</p>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* ABA + BOTÕES NA MESMA BARRA */}
|
|
||||||
<div className='container-btns-agenda-fila_esepera'>
|
|
||||||
<div className="tabs-agenda-fila">
|
<div className="tabs-agenda-fila">
|
||||||
<button
|
<button
|
||||||
className={`btn-agenda ${!FiladeEspera ? "opc-agenda-ativo" : ""}`}
|
className={`btn-agenda ${
|
||||||
onClick={() => { setFiladeEspera(false); setSearchTerm(''); }}
|
!FiladeEspera ? "opc-agenda-ativo" : ""
|
||||||
|
}`}
|
||||||
|
onClick={() => {
|
||||||
|
setFiladeEspera(false);
|
||||||
|
setSearchTerm("");
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Agenda
|
Agenda
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`btn-fila-espera ${FiladeEspera ? "opc-filaespera-ativo" : ""}`}
|
className={`btn-fila-espera ${
|
||||||
onClick={() => { setFiladeEspera(true); setSearchTerm(''); }}
|
FiladeEspera ? "opc-filaespera-ativo" : ""
|
||||||
|
}`}
|
||||||
|
onClick={() => {
|
||||||
|
setFiladeEspera(true);
|
||||||
|
setSearchTerm("");
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Fila de espera
|
Fila de espera
|
||||||
</button>
|
</button>
|
||||||
@ -407,45 +469,87 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
<i className="bi bi-gear-fill me-1"></i> Gerenciar Exceções
|
<i className="bi bi-gear-fill me-1"></i> Gerenciar Exceções
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className='manage-button btn'
|
className="manage-button btn"
|
||||||
onClick={() => navigate('/secretaria/disponibilidade')}
|
onClick={() => navigate("/secretaria/disponibilidade")}
|
||||||
>
|
>
|
||||||
<i className="bi bi-gear-fill me-1"></i> Mudar Disponibilidade
|
<i className="bi bi-gear-fill me-1"></i> Mudar Disponibilidade
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section className='calendario-ou-filaespera'>
|
<section className="calendario-ou-filaespera">
|
||||||
{FiladeEspera === false ? (
|
{FiladeEspera === false ? (
|
||||||
<div className="calendar-wrapper">
|
<div className="calendar-wrapper">
|
||||||
<div className="calendar-info-panel">
|
<div className="calendar-info-panel">
|
||||||
<div className="info-date-display">
|
<div className="info-date-display">
|
||||||
<span>{selectedDay.format('MMM')}</span>
|
<span>{selectedDay.format("MMM")}</span>
|
||||||
<strong>{selectedDay.format('DD')}</strong>
|
<strong>{selectedDay.format("DD")}</strong>
|
||||||
</div>
|
</div>
|
||||||
<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>
|
||||||
|
|
||||||
|
<h4 className="subtitle-consultas">
|
||||||
|
Consultas para {selectedDay.format("DD/MM")}
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div className="appointments-list">
|
<div className="appointments-list">
|
||||||
<h4>Consultas para {selectedDay.format('DD/MM')}</h4>
|
|
||||||
{showSpinner ? (
|
{showSpinner ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : (DictAgendamentosOrganizados[selectedDay.format('YYYY-MM-DD')]?.length > 0) ? (
|
) : (
|
||||||
DictAgendamentosOrganizados[selectedDay.format('YYYY-MM-DD')].map(app => (
|
(() => {
|
||||||
<div key={app.id} className="appointment-item" data-status={app.status}>
|
const allApps =
|
||||||
|
DictAgendamentosOrganizados[
|
||||||
|
selectedDay.format("YYYY-MM-DD")
|
||||||
|
] || [];
|
||||||
|
const termDoc = searchTermDoctor.toLowerCase();
|
||||||
|
const filtered = allApps.filter((app) =>
|
||||||
|
!termDoc
|
||||||
|
? true
|
||||||
|
: (app.medico_nome || "")
|
||||||
|
.toLowerCase()
|
||||||
|
.startsWith(termDoc)
|
||||||
|
);
|
||||||
|
|
||||||
|
return filtered.length > 0 ? (
|
||||||
|
filtered.map((app) => (
|
||||||
|
<div
|
||||||
|
key={app.id}
|
||||||
|
className="appointment-item"
|
||||||
|
data-status={app.status}
|
||||||
|
>
|
||||||
<div className="item-time">
|
<div className="item-time">
|
||||||
{dayjs(app.scheduled_at).format('HH:mm')}
|
{dayjs(app.scheduled_at)
|
||||||
|
.add(HORARIO_OFFSET, "hour")
|
||||||
|
.format("HH:mm")}
|
||||||
</div>
|
</div>
|
||||||
<div className="item-details">
|
<div className="item-details">
|
||||||
<span>{app.paciente_nome}</span>
|
<span>{app.paciente_nome}</span>
|
||||||
<small>Dr(a). {app.medico_nome}</small>
|
<small>Dr(a). {app.medico_nome}</small>
|
||||||
</div>
|
</div>
|
||||||
<div className="appointment-actions">
|
<div className="appointment-actions">
|
||||||
{app.status === 'cancelled' ? (
|
{app.status === "cancelled" ? (
|
||||||
<button
|
<button
|
||||||
className="btn-action btn-edit"
|
className="btn-action btn-edit"
|
||||||
onClick={() => { setSelectedId(app.id); setShowConfirmModal(true); }}
|
onClick={() => {
|
||||||
|
setSelectedId(app.id);
|
||||||
|
setShowConfirmModal(true);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Edit size={16} />
|
<Edit size={16} />
|
||||||
</button>
|
</button>
|
||||||
@ -463,7 +567,10 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className="btn-action btn-delete"
|
className="btn-action btn-delete"
|
||||||
onClick={() => { setSelectedId(app.id); setShowDeleteModal(true); }}
|
onClick={() => {
|
||||||
|
setSelectedId(app.id);
|
||||||
|
setShowDeleteModal(true);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Trash2 size={16} />
|
<Trash2 size={16} />
|
||||||
</button>
|
</button>
|
||||||
@ -476,24 +583,90 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
<div className="no-appointments-info">
|
<div className="no-appointments-info">
|
||||||
<p>Nenhuma consulta agendada.</p>
|
<p>Nenhuma consulta agendada.</p>
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
|
})()
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="calendar-main">
|
||||||
|
<div className="calendar-header-filter">
|
||||||
|
<div className="position-relative">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
placeholder="Filtrar atendimento do médico"
|
||||||
|
value={searchTermDoctor}
|
||||||
|
onChange={(e) => {
|
||||||
|
setSearchTermDoctor(e.target.value);
|
||||||
|
setDoctorDropdownOpen(true);
|
||||||
|
}}
|
||||||
|
onFocus={() => {
|
||||||
|
if (searchTermDoctor.trim())
|
||||||
|
setDoctorDropdownOpen(true);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{doctorDropdownOpen && searchTermDoctor.trim() && (
|
||||||
|
<div
|
||||||
|
className="doctor-suggestions"
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
top: "100%",
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
zIndex: 10,
|
||||||
|
backgroundColor: "white",
|
||||||
|
border: "1px solid #ced4da",
|
||||||
|
borderTop: "none",
|
||||||
|
maxHeight: "250px",
|
||||||
|
overflowY: "auto",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{ListaDeMedicos.filter((m) => {
|
||||||
|
const nome = (m.nomeMedico || "").toLowerCase();
|
||||||
|
const term = searchTermDoctor.toLowerCase();
|
||||||
|
return nome.startsWith(term);
|
||||||
|
})
|
||||||
|
.slice(0, 20)
|
||||||
|
.map((m) => (
|
||||||
|
<button
|
||||||
|
key={m.idMedico}
|
||||||
|
type="button"
|
||||||
|
className="w-100 text-start px-3 py-1"
|
||||||
|
style={{
|
||||||
|
border: "none",
|
||||||
|
background: "white",
|
||||||
|
fontSize: "0.9rem",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
setSearchTermDoctor(m.nomeMedico);
|
||||||
|
setDoctorDropdownOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{m.nomeMedico}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="calendar-main">
|
|
||||||
<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 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
|
||||||
|
className="quick-jump-controls"
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
gap: "5px",
|
||||||
|
marginTop: "10px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
<select
|
<select
|
||||||
value={quickJump.month}
|
value={quickJump.month}
|
||||||
onChange={(e) => handleQuickJumpChange('month', e.target.value)}
|
onChange={(e) =>
|
||||||
|
handleQuickJumpChange("month", e.target.value)
|
||||||
|
}
|
||||||
className="form-select form-select-sm w-auto"
|
className="form-select form-select-sm w-auto"
|
||||||
>
|
>
|
||||||
{dayjs.months().map((month, index) => (
|
{dayjs.months().map((month, index) => (
|
||||||
@ -504,17 +677,27 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
</select>
|
</select>
|
||||||
<select
|
<select
|
||||||
value={quickJump.year}
|
value={quickJump.year}
|
||||||
onChange={(e) => handleQuickJumpChange('year', e.target.value)}
|
onChange={(e) =>
|
||||||
|
handleQuickJumpChange("year", e.target.value)
|
||||||
|
}
|
||||||
className="form-select form-select-sm w-auto"
|
className="form-select form-select-sm w-auto"
|
||||||
>
|
>
|
||||||
{Array.from({ length: 11 }, (_, i) => dayjs().year() - 5 + i).map(year => (
|
{Array.from(
|
||||||
<option key={year} value={year}>{year}</option>
|
{ length: 11 },
|
||||||
|
(_, i) => dayjs().year() - 5 + i
|
||||||
|
).map((year) => (
|
||||||
|
<option key={year} value={year}>
|
||||||
|
{year}
|
||||||
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-outline-primary"
|
className="btn btn-sm btn-outline-primary"
|
||||||
onClick={applyQuickJump}
|
onClick={applyQuickJump}
|
||||||
disabled={quickJump.month === currentDate.month() && quickJump.year === currentDate.year()}
|
disabled={
|
||||||
|
quickJump.month === currentDate.month() &&
|
||||||
|
quickJump.year === currentDate.year()
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Ir
|
Ir
|
||||||
</button>
|
</button>
|
||||||
@ -522,28 +705,63 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="nav-buttons">
|
<div className="nav-buttons">
|
||||||
<button onClick={() => { setCurrentDate(currentDate.subtract(1, 'month')); setSelectedDay(currentDate.subtract(1, 'month')); }}>
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
const newDate = currentDate.subtract(1, "month");
|
||||||
|
setCurrentDate(newDate);
|
||||||
|
setSelectedDay(newDate);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<ChevronLeft size={20} />
|
<ChevronLeft size={20} />
|
||||||
</button>
|
</button>
|
||||||
<button onClick={() => { setCurrentDate(dayjs()); setSelectedDay(dayjs()); }}>
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
const today = dayjs();
|
||||||
|
setCurrentDate(today);
|
||||||
|
setSelectedDay(today);
|
||||||
|
}}
|
||||||
|
>
|
||||||
Hoje
|
Hoje
|
||||||
</button>
|
</button>
|
||||||
<button onClick={() => { setCurrentDate(currentDate.add(1, 'month')); setSelectedDay(currentDate.add(1, 'month')); }}>
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
const newDate = currentDate.add(1, "month");
|
||||||
|
setCurrentDate(newDate);
|
||||||
|
setSelectedDay(newDate);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<ChevronRight size={20} />
|
<ChevronRight size={20} />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="calendar-grid-scroll-wrapper">
|
||||||
|
<div className="calendar-grid-scrollable">
|
||||||
<div className="calendar-grid">
|
<div className="calendar-grid">
|
||||||
{weekDays.map(day => (
|
{weekDays.map((day) => (
|
||||||
<div key={day} className="day-header">{day}</div>
|
<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 dayKey = day.format("YYYY-MM-DD");
|
||||||
|
const appointmentsOnDay =
|
||||||
|
DictAgendamentosOrganizados[dayKey] || [];
|
||||||
|
const termDoc = searchTermDoctor.toLowerCase();
|
||||||
|
const filteredAppointments =
|
||||||
|
appointmentsOnDay.filter((app) =>
|
||||||
|
!termDoc
|
||||||
|
? true
|
||||||
|
: (app.medico_nome || "")
|
||||||
|
.toLowerCase()
|
||||||
|
.startsWith(termDoc)
|
||||||
|
);
|
||||||
const cellClasses = `day-cell ${
|
const cellClasses = `day-cell ${
|
||||||
day.isSame(currentDate, 'month') ? 'current-month' : 'other-month'
|
day.isSame(currentDate, "month")
|
||||||
} ${day.isSame(dayjs(), 'day') ? 'today' : ''} ${
|
? "current-month"
|
||||||
day.isSame(selectedDay, 'day') ? 'selected' : ''
|
: "other-month"
|
||||||
|
} ${day.isSame(dayjs(), "day") ? "today" : ""} ${
|
||||||
|
day.isSame(selectedDay, "day") ? "selected" : ""
|
||||||
}`;
|
}`;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -551,9 +769,11 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
className={cellClasses}
|
className={cellClasses}
|
||||||
onClick={() => handleDateClick(day)}
|
onClick={() => handleDateClick(day)}
|
||||||
>
|
>
|
||||||
<span>{day.format('D')}</span>
|
<span>{day.format("D")}</span>
|
||||||
{appointmentsOnDay.length > 0 && (
|
{filteredAppointments.length > 0 && (
|
||||||
<div className="appointments-indicator">{appointmentsOnDay.length}</div>
|
<div className="appointments-indicator">
|
||||||
|
{filteredAppointments.length}
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -561,6 +781,13 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="d-md-none scroll-hint">
|
||||||
|
<i className="bi bi-arrow-left-right"></i>
|
||||||
|
<span>Arraste para ver mais dias</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="page-content table-paciente-container">
|
<div className="page-content table-paciente-container">
|
||||||
<section className="row">
|
<section className="row">
|
||||||
@ -574,6 +801,7 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
<h5 className="mb-3">
|
<h5 className="mb-3">
|
||||||
<i className="bi bi-funnel-fill me-2 text-primary"></i> Filtros
|
<i className="bi bi-funnel-fill me-2 text-primary"></i> Filtros
|
||||||
</h5>
|
</h5>
|
||||||
|
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@ -586,23 +814,21 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
Digite o nome do paciente, CPF ou nome do médico
|
Digite o nome do paciente, CPF ou nome do médico
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="d-flex flex-wrap align-items-center gap-2 mb-3">
|
<div className="d-flex flex-wrap align-items-center gap-2 mb-3">
|
||||||
<div className="d-flex align-items-center gap-2">
|
<div className="d-flex align-items-center gap-2">
|
||||||
<span className="me-2 text-muted small">Ordenar por:</span>
|
<span className="me-2 text-muted small">Ordenar por:</span>
|
||||||
{(() => {
|
|
||||||
const sortValue = waitSortKey ? `${waitSortKey}-${waitSortDir}` : '';
|
|
||||||
return (
|
|
||||||
<select
|
<select
|
||||||
className="form-select compact-select sort-select w-auto"
|
className="form-select compact-select sort-select w-auto"
|
||||||
value={sortValue}
|
value={waitSortKey ? `${waitSortKey}-${waitSortDir}` : ""}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const v = e.target.value;
|
const v = e.target.value;
|
||||||
if (!v) {
|
if (!v) {
|
||||||
setWaitSortKey(null);
|
setWaitSortKey(null);
|
||||||
setWaitSortDir('asc');
|
setWaitSortDir("asc");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const [k, d] = v.split('-');
|
const [k, d] = v.split("-");
|
||||||
setWaitSortKey(k);
|
setWaitSortKey(k);
|
||||||
setWaitSortDir(d);
|
setWaitSortDir(d);
|
||||||
}}
|
}}
|
||||||
@ -615,10 +841,9 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
<option value="data-asc">Data (mais antiga)</option>
|
<option value="data-asc">Data (mais antiga)</option>
|
||||||
<option value="data-desc">Data (mais recente)</option>
|
<option value="data-desc">Data (mais recente)</option>
|
||||||
</select>
|
</select>
|
||||||
);
|
|
||||||
})()}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-3">
|
<div className="mt-3">
|
||||||
<div className="contador-pacientes">
|
<div className="contador-pacientes">
|
||||||
{filaEsperaFiltrada.length} DE {filaEsperaData.length} SOLICITAÇÕES ENCONTRADAS
|
{filaEsperaFiltrada.length} DE {filaEsperaData.length} SOLICITAÇÕES ENCONTRADAS
|
||||||
@ -643,12 +868,17 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
<tr key={index}>
|
<tr key={index}>
|
||||||
<td>{item?.Infos?.paciente_nome}</td>
|
<td>{item?.Infos?.paciente_nome}</td>
|
||||||
<td>{item?.Infos?.paciente_cpf}</td>
|
<td>{item?.Infos?.paciente_cpf}</td>
|
||||||
<td>{item?.Infos?.nome_medico}</td>
|
<td>{item?.Infos?.medico_nome}</td>
|
||||||
<td>{dayjs(item.agendamento.scheduled_at).format('DD/MM/YYYY')}</td>
|
<td>
|
||||||
|
{dayjs(item.agendamento.scheduled_at).format("DD/MM/YYYY")}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-delete"
|
className="btn btn-sm btn-delete"
|
||||||
onClick={() => { setSelectedId(item.agendamento.id); setShowDeleteModal(true); }}
|
onClick={() => {
|
||||||
|
setSelectedId(item.agendamento.id);
|
||||||
|
setShowDeleteModal(true);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<i className="bi bi-trash me-1"></i> Excluir
|
<i className="bi bi-trash me-1"></i> Excluir
|
||||||
</button>
|
</button>
|
||||||
@ -692,24 +922,30 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
<option value={50}>50</option>
|
<option value={50}>50</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="d-flex align-items-center">
|
<div className="d-flex align-items-center">
|
||||||
<span className="me-3 text-muted">
|
<span className="me-3 text-muted">
|
||||||
Página {waitPage} de {waitTotalPages} • Mostrando {waitIndiceInicial + 1}-{Math.min(waitIndiceFinal, filaEsperaFiltrada.length)} de {filaEsperaFiltrada.length}
|
Página {waitPage} de {waitTotalPages} • Mostrando{" "}
|
||||||
|
{waitIndiceInicial + 1}-
|
||||||
|
{Math.min(waitIndiceFinal, filaEsperaFiltrada.length)} de{" "}
|
||||||
|
{filaEsperaFiltrada.length}
|
||||||
</span>
|
</span>
|
||||||
<nav>
|
<nav>
|
||||||
<ul className="pagination pagination-sm mb-0">
|
<ul className="pagination pagination-sm mb-0">
|
||||||
<li className={`page-item ${waitPage === 1 ? 'disabled' : ''}`}>
|
<li className={`page-item ${waitPage === 1 ? "disabled" : ""}`}>
|
||||||
<button
|
<button
|
||||||
className="page-link"
|
className="page-link"
|
||||||
onClick={() => setWaitPage(p => Math.max(1, p - 1))}
|
onClick={() => setWaitPage((p) => Math.max(1, p - 1))}
|
||||||
>
|
>
|
||||||
<i className="bi bi-chevron-left"></i>
|
<i className="bi bi-chevron-left"></i>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
{gerarNumerosWaitPages().map(pagina => (
|
{gerarNumerosWaitPages().map((pagina) => (
|
||||||
<li
|
<li
|
||||||
key={pagina}
|
key={pagina}
|
||||||
className={`page-item ${pagina === waitPage ? 'active' : ''}`}
|
className={`page-item ${
|
||||||
|
pagina === waitPage ? "active" : ""
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
className="page-link"
|
className="page-link"
|
||||||
@ -719,10 +955,16 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
<li className={`page-item ${waitPage === waitTotalPages ? 'disabled' : ''}`}>
|
<li
|
||||||
|
className={`page-item ${
|
||||||
|
waitPage === waitTotalPages ? "disabled" : ""
|
||||||
|
}`}
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
className="page-link"
|
className="page-link"
|
||||||
onClick={() => setWaitPage(p => Math.min(waitTotalPages, p + 1))}
|
onClick={() =>
|
||||||
|
setWaitPage((p) => Math.min(waitTotalPages, p + 1))
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<i className="bi bi-chevron-right"></i>
|
<i className="bi bi-chevron-right"></i>
|
||||||
</button>
|
</button>
|
||||||
@ -744,8 +986,11 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
) : (
|
) : (
|
||||||
<AgendamentoCadastroManager
|
<AgendamentoCadastroManager
|
||||||
setPageConsulta={setPageConsulta}
|
setPageConsulta={setPageConsulta}
|
||||||
agendamentoInicial={appointmentToEdit}
|
Dict={appointmentToEdit}
|
||||||
setEditingAppointmentId={setEditingAppointmentId}
|
onSaved={() => {
|
||||||
|
fetchAppointments(); // recarrega os agendamentos do médico
|
||||||
|
setPageConsulta(false);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@ -4,173 +4,92 @@ 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: 'agendado' });
|
const [agendamento, setAgendamento] = useState({ status: 'confirmed' });
|
||||||
const [idUsuario, setIDusuario] = useState('0');
|
const [idUsuario, setIDusuario] = useState('0');
|
||||||
const [isEditMode, setIsEditMode] = useState(false);
|
|
||||||
|
|
||||||
let authHeader = getAuthorizationHeader();
|
// patient_id do paciente logado (ou fallback para o Pedro)
|
||||||
|
|
||||||
|
const patientId = 'bf7d8323-05e1-437a-817c-f08eb5f174ef';
|
||||||
|
|
||||||
|
const authHeader = getAuthorizationHeader();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!Dict) {
|
||||||
|
setAgendamento({ status: 'confirmed' });
|
||||||
if (agendamentoInicial && agendamentoInicial.id) {
|
|
||||||
|
|
||||||
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 {
|
} else {
|
||||||
|
setAgendamento(Dict);
|
||||||
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 ColherInfoUsuario = async () => {
|
||||||
|
try {
|
||||||
const result = await UserInfos(authHeader);
|
const result = await UserInfos(authHeader);
|
||||||
setIDusuario(result?.profile?.id);
|
setIDusuario(result?.profile?.id);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Erro ao buscar infos do usuário:', e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (authHeader) {
|
||||||
ColherInfoUsuario();
|
ColherInfoUsuario();
|
||||||
|
}
|
||||||
|
}, [Dict, authHeader]);
|
||||||
|
|
||||||
|
const handleSave = async (DictForm) => {
|
||||||
|
if (!authHeader) {
|
||||||
|
alert('Sem autorização. Faça login novamente.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}, [agendamentoInicial, authHeader]);
|
const myHeaders = new Headers();
|
||||||
const handleSave = async (Dict) => {
|
myHeaders.append('apikey', API_KEY);
|
||||||
var myHeaders = new Headers();
|
myHeaders.append('Authorization', authHeader);
|
||||||
myHeaders.append("apikey", API_KEY);
|
myHeaders.append('Content-Type', 'application/json');
|
||||||
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(),
|
|
||||||
|
|
||||||
|
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(),
|
||||||
});
|
});
|
||||||
|
|
||||||
var requestOptions = {
|
const requestOptions = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: myHeaders,
|
headers: myHeaders,
|
||||||
body: raw,
|
body: raw,
|
||||||
redirect: 'follow'
|
redirect: 'follow',
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments", requestOptions);
|
const response = await fetch(
|
||||||
|
'https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments',
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
toast.success("Agendamento criado com sucesso! ✅");
|
if (onSaved) onSaved(); // pai recarrega e fecha
|
||||||
setPageConsulta(false);
|
else setPageConsulta(false);
|
||||||
} else {
|
} else {
|
||||||
const errorText = await response.text();
|
console.error('Erro ao criar agendamento:', await response.text());
|
||||||
console.error('Erro ao cadastrar agendamento:', errorText);
|
alert('Falha ao criar agendamento.');
|
||||||
toast.error(`Falha ao criar agendamento: ${JSON.parse(errorText)?.message || 'Erro desconhecido'}`);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erro de rede:', error);
|
console.error('Erro de rede:', error);
|
||||||
toast.error("Erro de rede ao salvar. ❌");
|
alert('Erro de rede ao salvar agendamento.');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{}
|
|
||||||
<FormNovaConsulta
|
<FormNovaConsulta
|
||||||
onSave={handleFormSubmit}
|
onSave={handleSave}
|
||||||
agendamento={agendamento}
|
agendamento={agendamento}
|
||||||
setAgendamento={setAgendamento}
|
setAgendamento={setAgendamento}
|
||||||
onCancel={() => setPageConsulta(false)}
|
onCancel={() => setPageConsulta(false)}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { useState, useEffect, useMemo, useCallback } from "react";
|
import React, { useState, useEffect, useMemo, useCallback } from "react";
|
||||||
import './style/FinanceiroDashboard.css';
|
import "./style/FinanceiroDashboard.css";
|
||||||
|
|
||||||
const CONVENIOS_LIST = [
|
const CONVENIOS_LIST = [
|
||||||
"Particular",
|
"Particular",
|
||||||
@ -8,7 +8,7 @@ const CONVENIOS_LIST = [
|
|||||||
"SulAmérica",
|
"SulAmérica",
|
||||||
"Unimed",
|
"Unimed",
|
||||||
"Cassio",
|
"Cassio",
|
||||||
"Outro"
|
"Outro",
|
||||||
];
|
];
|
||||||
|
|
||||||
function CurrencyInput({ value, onChange, label, id }) {
|
function CurrencyInput({ value, onChange, label, id }) {
|
||||||
@ -17,22 +17,25 @@ function CurrencyInput({ value, onChange, label, id }) {
|
|||||||
|
|
||||||
let stringValue = String(numericValue);
|
let stringValue = String(numericValue);
|
||||||
while (stringValue.length < 3) {
|
while (stringValue.length < 3) {
|
||||||
stringValue = '0' + stringValue;
|
stringValue = "0" + stringValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const integerPart = stringValue.slice(0, -2);
|
const integerPart = stringValue.slice(0, -2);
|
||||||
const decimalPart = stringValue.slice(-2);
|
const decimalPart = stringValue.slice(-2);
|
||||||
|
|
||||||
const formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, '.');
|
const formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||||
|
|
||||||
return `R$ ${formattedInteger},${decimalPart}`;
|
return `R$ ${formattedInteger},${decimalPart}`;
|
||||||
}, [value]);
|
}, [value]);
|
||||||
|
|
||||||
const handleKeyDown = useCallback((e) => {
|
const handleKeyDown = useCallback(
|
||||||
|
(e) => {
|
||||||
const key = e.key;
|
const key = e.key;
|
||||||
|
|
||||||
if (['Backspace', 'Delete', 'ArrowLeft', 'ArrowRight', 'Tab'].includes(key)) {
|
if (
|
||||||
if (key === 'Backspace' || key === 'Delete') {
|
["Backspace", "Delete", "ArrowLeft", "ArrowRight", "Tab"].includes(key)
|
||||||
|
) {
|
||||||
|
if (key === "Backspace" || key === "Delete") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const numericValue = value || 0;
|
const numericValue = value || 0;
|
||||||
let newValueString = String(numericValue);
|
let newValueString = String(numericValue);
|
||||||
@ -63,7 +66,9 @@ function CurrencyInput({ value, onChange, label, id }) {
|
|||||||
const newNumericValue = parseInt(newValueString);
|
const newNumericValue = parseInt(newValueString);
|
||||||
|
|
||||||
onChange(newNumericValue);
|
onChange(newNumericValue);
|
||||||
}, [value, onChange]);
|
},
|
||||||
|
[value, onChange]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
@ -91,7 +96,7 @@ function mockFetchPagamentos() {
|
|||||||
data_vencimento: "2025-09-30",
|
data_vencimento: "2025-09-30",
|
||||||
status: "pendente",
|
status: "pendente",
|
||||||
desconto: 0,
|
desconto: 0,
|
||||||
observacoes: "Pagamento parcelado em 2x"
|
observacoes: "Pagamento parcelado em 2x",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "PAY-002",
|
id: "PAY-002",
|
||||||
@ -101,7 +106,7 @@ function mockFetchPagamentos() {
|
|||||||
data_vencimento: "2025-09-15",
|
data_vencimento: "2025-09-15",
|
||||||
status: "pago",
|
status: "pago",
|
||||||
desconto: 1000,
|
desconto: 1000,
|
||||||
observacoes: ""
|
observacoes: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "PAY-003",
|
id: "PAY-003",
|
||||||
@ -111,7 +116,7 @@ function mockFetchPagamentos() {
|
|||||||
data_vencimento: "2025-09-20",
|
data_vencimento: "2025-09-20",
|
||||||
status: "vencido",
|
status: "vencido",
|
||||||
desconto: 0,
|
desconto: 0,
|
||||||
observacoes: "Não respondeu ao contato"
|
observacoes: "Não respondeu ao contato",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "PAY-004",
|
id: "PAY-004",
|
||||||
@ -121,8 +126,8 @@ function mockFetchPagamentos() {
|
|||||||
data_vencimento: "2025-09-29",
|
data_vencimento: "2025-09-29",
|
||||||
status: "pago",
|
status: "pago",
|
||||||
desconto: 500,
|
desconto: 500,
|
||||||
observacoes: "Desconto por pagamento adiantado"
|
observacoes: "Desconto por pagamento adiantado",
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +137,11 @@ export default function FinanceiroDashboard() {
|
|||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
const [filtroStatus, setFiltroStatus] = useState("Todos");
|
const [filtroStatus, setFiltroStatus] = useState("Todos");
|
||||||
const [novoPagamento, setNovoPagamento] = useState(false);
|
const [novoPagamento, setNovoPagamento] = useState(false);
|
||||||
const [summary, setSummary] = useState({ totalRecebido: 0, totalAReceber: 0, totalDescontos: 0 });
|
const [summary, setSummary] = useState({
|
||||||
|
totalRecebido: 0,
|
||||||
|
totalAReceber: 0,
|
||||||
|
totalDescontos: 0,
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const data = mockFetchPagamentos();
|
const data = mockFetchPagamentos();
|
||||||
@ -141,7 +150,13 @@ export default function FinanceiroDashboard() {
|
|||||||
|
|
||||||
function formatCurrency(centavos) {
|
function formatCurrency(centavos) {
|
||||||
const valorEmReais = centavos / 100;
|
const valorEmReais = centavos / 100;
|
||||||
return "R$ " + valorEmReais.toFixed(2).replace(".", ",").replace(/\B(?=(\d{3})+(?!\d))/g, '.');
|
return (
|
||||||
|
"R$ " +
|
||||||
|
valorEmReais
|
||||||
|
.toFixed(2)
|
||||||
|
.replace(".", ",")
|
||||||
|
.replace(/\B(?=(\d{3})+(?!\d))/g, ".")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValorLiquido(valor, desconto) {
|
function getValorLiquido(valor, desconto) {
|
||||||
@ -149,10 +164,11 @@ export default function FinanceiroDashboard() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const filteredPagamentos = useMemo(() => {
|
const filteredPagamentos = useMemo(() => {
|
||||||
return pagamentos.filter(p => {
|
return pagamentos.filter((p) => {
|
||||||
const q = query.toLowerCase();
|
const q = query.toLowerCase();
|
||||||
const statusOk = filtroStatus === "Todos" || p.status === filtroStatus;
|
const statusOk = filtroStatus === "Todos" || p.status === filtroStatus;
|
||||||
const buscaOk = p.paciente.nome.toLowerCase().includes(q) ||
|
const buscaOk =
|
||||||
|
p.paciente.nome.toLowerCase().includes(q) ||
|
||||||
p.id.toLowerCase().includes(q);
|
p.id.toLowerCase().includes(q);
|
||||||
return statusOk && buscaOk;
|
return statusOk && buscaOk;
|
||||||
});
|
});
|
||||||
@ -163,9 +179,9 @@ export default function FinanceiroDashboard() {
|
|||||||
let aReceber = 0;
|
let aReceber = 0;
|
||||||
let descontos = 0;
|
let descontos = 0;
|
||||||
|
|
||||||
filteredPagamentos.forEach(p => {
|
filteredPagamentos.forEach((p) => {
|
||||||
const valorLiquido = getValorLiquido(p.valor, p.desconto);
|
const valorLiquido = getValorLiquido(p.valor, p.desconto);
|
||||||
if (p.status === 'pago') {
|
if (p.status === "pago") {
|
||||||
recebido += valorLiquido;
|
recebido += valorLiquido;
|
||||||
descontos += p.desconto;
|
descontos += p.desconto;
|
||||||
} else {
|
} else {
|
||||||
@ -176,29 +192,37 @@ export default function FinanceiroDashboard() {
|
|||||||
setSummary({
|
setSummary({
|
||||||
totalRecebido: recebido,
|
totalRecebido: recebido,
|
||||||
totalAReceber: aReceber,
|
totalAReceber: aReceber,
|
||||||
totalDescontos: descontos
|
totalDescontos: descontos,
|
||||||
});
|
});
|
||||||
}, [filteredPagamentos]);
|
}, [filteredPagamentos]);
|
||||||
|
|
||||||
function handleDelete(id) {
|
function handleDelete(id) {
|
||||||
if (window.confirm("Tem certeza que deseja excluir este pagamento?")) {
|
if (window.confirm("Tem certeza que deseja excluir este pagamento?")) {
|
||||||
setPagamentos(prev => prev.filter(p => p.id !== id));
|
setPagamentos((prev) => prev.filter((p) => p.id !== id));
|
||||||
setModalPagamento(null);
|
setModalPagamento(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSave(pagamento) {
|
function handleSave(pagamento) {
|
||||||
if (!pagamento.paciente.nome || !pagamento.valor || !pagamento.data_vencimento || !pagamento.paciente.convenio) {
|
if (
|
||||||
|
!pagamento.paciente.nome ||
|
||||||
|
!pagamento.valor ||
|
||||||
|
!pagamento.data_vencimento ||
|
||||||
|
!pagamento.paciente.convenio
|
||||||
|
) {
|
||||||
alert("Preencha Paciente, Convênio, Valor e Data de Vencimento.");
|
alert("Preencha Paciente, Convênio, Valor e Data de Vencimento.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (novoPagamento) {
|
if (novoPagamento) {
|
||||||
const newId = "PAY-" + (pagamentos.length + 1).toString().padStart(3, "0");
|
const newId =
|
||||||
|
"PAY-" + (pagamentos.length + 1).toString().padStart(3, "0");
|
||||||
pagamento.id = newId;
|
pagamento.id = newId;
|
||||||
setPagamentos(prev => [...prev, pagamento]);
|
setPagamentos((prev) => [...prev, pagamento]);
|
||||||
} else {
|
} else {
|
||||||
setPagamentos(prev => prev.map(p => p.id === pagamento.id ? pagamento : p));
|
setPagamentos((prev) =>
|
||||||
|
prev.map((p) => (p.id === pagamento.id ? pagamento : p))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
setModalPagamento(null);
|
setModalPagamento(null);
|
||||||
setNovoPagamento(false);
|
setNovoPagamento(false);
|
||||||
@ -229,15 +253,19 @@ export default function FinanceiroDashboard() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="list-page-card">
|
<div className="list-page-card">
|
||||||
<div style={{ display:"flex", gap:12, marginBottom:20 }}>
|
<div style={{ display: "flex", gap: 12, marginBottom: 20 }}>
|
||||||
<input
|
<input
|
||||||
className="input-field"
|
className="input-field"
|
||||||
placeholder="Buscar paciente"
|
placeholder="Buscar paciente"
|
||||||
value={query}
|
value={query}
|
||||||
onChange={e => setQuery(e.target.value)}
|
onChange={(e) => setQuery(e.target.value)}
|
||||||
style={{ flexGrow: 1 }}
|
style={{ flexGrow: 1 }}
|
||||||
/>
|
/>
|
||||||
<select className="select-field" value={filtroStatus} onChange={e => setFiltroStatus(e.target.value)}>
|
<select
|
||||||
|
className="select-field"
|
||||||
|
value={filtroStatus}
|
||||||
|
onChange={(e) => setFiltroStatus(e.target.value)}
|
||||||
|
>
|
||||||
<option value="Todos">Todos</option>
|
<option value="Todos">Todos</option>
|
||||||
<option value="pago">Pago</option>
|
<option value="pago">Pago</option>
|
||||||
<option value="pendente">Pendente</option>
|
<option value="pendente">Pendente</option>
|
||||||
@ -247,13 +275,13 @@ export default function FinanceiroDashboard() {
|
|||||||
className="btn btn-primary"
|
className="btn btn-primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setModalPagamento({
|
setModalPagamento({
|
||||||
paciente: { nome:"", convenio: CONVENIOS_LIST[0] },
|
paciente: { nome: "", convenio: CONVENIOS_LIST[0] },
|
||||||
valor:0,
|
valor: 0,
|
||||||
forma_pagamento:"Dinheiro",
|
forma_pagamento: "Dinheiro",
|
||||||
data_vencimento: new Date().toISOString().split('T')[0],
|
data_vencimento: new Date().toISOString().split("T")[0],
|
||||||
status:"pendente",
|
status: "pendente",
|
||||||
desconto:0,
|
desconto: 0,
|
||||||
observacoes:""
|
observacoes: "",
|
||||||
});
|
});
|
||||||
setNovoPagamento(true);
|
setNovoPagamento(true);
|
||||||
}}
|
}}
|
||||||
@ -281,23 +309,32 @@ export default function FinanceiroDashboard() {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{filteredPagamentos.map(p => (
|
{filteredPagamentos.map((p) => (
|
||||||
<tr key={p.id}>
|
<tr key={p.id}>
|
||||||
<td style={{ fontWeight: 600 }}>{p.paciente.nome}</td>
|
<td style={{ fontWeight: 600 }}>{p.paciente.nome}</td>
|
||||||
<td>{p.paciente.convenio}</td>
|
<td>{p.paciente.convenio}</td>
|
||||||
<td>{formatCurrency(p.valor)}</td>
|
<td>{formatCurrency(p.valor)}</td>
|
||||||
<td>{formatCurrency(p.desconto)}</td>
|
<td>{formatCurrency(p.desconto)}</td>
|
||||||
<td style={{ fontWeight: 600 }}>{formatCurrency(getValorLiquido(p.valor, p.desconto))}</td>
|
<td style={{ fontWeight: 600 }}>
|
||||||
|
{formatCurrency(getValorLiquido(p.valor, p.desconto))}
|
||||||
|
</td>
|
||||||
<td>{p.forma_pagamento}</td>
|
<td>{p.forma_pagamento}</td>
|
||||||
<td>{p.data_vencimento.split('-').reverse().join('/')}</td>
|
<td>{p.data_vencimento.split("-").reverse().join("/")}</td>
|
||||||
<td><span className={`badge ${p.status}`}>{p.status.toUpperCase()}</span></td>
|
<td>
|
||||||
|
<span className={`badge ${p.status}`}>
|
||||||
|
{p.status.toUpperCase()}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div className="action-group">
|
<div className="action-group">
|
||||||
<button
|
<button
|
||||||
className="btn-view"
|
className="btn-view"
|
||||||
onClick={() => { setModalPagamento({...p}); setNovoPagamento(false); }}
|
onClick={() => {
|
||||||
|
setModalPagamento({ ...p });
|
||||||
|
setNovoPagamento(false);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<i className="bi bi-eye me-1"></i> Ver / Editar
|
<i className="bi bi-eye me-1"></i> Ver Detalhes
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className="btn-delete"
|
className="btn-delete"
|
||||||
@ -316,11 +353,20 @@ export default function FinanceiroDashboard() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{modalPagamento && (
|
{modalPagamento && (
|
||||||
<div className="modal" onClick={(e) => e.target.classList.contains('modal') && closeModal()}>
|
<div
|
||||||
|
className="modal"
|
||||||
|
onClick={(e) => e.target.classList.contains("modal") && closeModal()}
|
||||||
|
>
|
||||||
<div className="modal-card">
|
<div className="modal-card">
|
||||||
<div className="modal-header">
|
<div className="modal-header">
|
||||||
<h2>{novoPagamento ? "Adicionar Pagamento" : `Editar Pagamento - ${modalPagamento.paciente.nome}`}</h2>
|
<h2>
|
||||||
<button className="close-btn" onClick={closeModal}>×</button>
|
{novoPagamento
|
||||||
|
? "Adicionar Pagamento"
|
||||||
|
: `Editar Pagamento - ${modalPagamento.paciente.nome}`}
|
||||||
|
</h2>
|
||||||
|
<button className="close-btn" onClick={closeModal}>
|
||||||
|
×
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
@ -330,7 +376,15 @@ export default function FinanceiroDashboard() {
|
|||||||
id="paciente_nome"
|
id="paciente_nome"
|
||||||
className="input-field"
|
className="input-field"
|
||||||
value={modalPagamento.paciente.nome}
|
value={modalPagamento.paciente.nome}
|
||||||
onChange={e => setModalPagamento({...modalPagamento, paciente:{...modalPagamento.paciente, nome:e.target.value}})}
|
onChange={(e) =>
|
||||||
|
setModalPagamento({
|
||||||
|
...modalPagamento,
|
||||||
|
paciente: {
|
||||||
|
...modalPagamento.paciente,
|
||||||
|
nome: e.target.value,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -340,11 +394,21 @@ export default function FinanceiroDashboard() {
|
|||||||
id="convenio"
|
id="convenio"
|
||||||
className="select-field"
|
className="select-field"
|
||||||
value={modalPagamento.paciente.convenio}
|
value={modalPagamento.paciente.convenio}
|
||||||
onChange={e => setModalPagamento({...modalPagamento, paciente:{...modalPagamento.paciente, convenio:e.target.value}})}
|
onChange={(e) =>
|
||||||
|
setModalPagamento({
|
||||||
|
...modalPagamento,
|
||||||
|
paciente: {
|
||||||
|
...modalPagamento.paciente,
|
||||||
|
convenio: e.target.value,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<option value="">Selecione</option>
|
<option value="">Selecione</option>
|
||||||
{CONVENIOS_LIST.map(conv => (
|
{CONVENIOS_LIST.map((conv) => (
|
||||||
<option key={conv} value={conv}>{conv}</option>
|
<option key={conv} value={conv}>
|
||||||
|
{conv}
|
||||||
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -352,14 +416,18 @@ export default function FinanceiroDashboard() {
|
|||||||
id="valor"
|
id="valor"
|
||||||
label="Valor da consulta (R$)"
|
label="Valor da consulta (R$)"
|
||||||
value={modalPagamento.valor}
|
value={modalPagamento.valor}
|
||||||
onChange={newValue => setModalPagamento({...modalPagamento, valor: newValue})}
|
onChange={(newValue) =>
|
||||||
|
setModalPagamento({ ...modalPagamento, valor: newValue })
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<CurrencyInput
|
<CurrencyInput
|
||||||
id="desconto"
|
id="desconto"
|
||||||
label="Desconto aplicado (R$)"
|
label="Desconto aplicado (R$)"
|
||||||
value={modalPagamento.desconto}
|
value={modalPagamento.desconto}
|
||||||
onChange={newValue => setModalPagamento({...modalPagamento, desconto: newValue})}
|
onChange={(newValue) =>
|
||||||
|
setModalPagamento({ ...modalPagamento, desconto: newValue })
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
@ -368,7 +436,12 @@ export default function FinanceiroDashboard() {
|
|||||||
id="forma"
|
id="forma"
|
||||||
className="select-field"
|
className="select-field"
|
||||||
value={modalPagamento.forma_pagamento}
|
value={modalPagamento.forma_pagamento}
|
||||||
onChange={e => setModalPagamento({...modalPagamento, forma_pagamento:e.target.value})}
|
onChange={(e) =>
|
||||||
|
setModalPagamento({
|
||||||
|
...modalPagamento,
|
||||||
|
forma_pagamento: e.target.value,
|
||||||
|
})
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<option>Dinheiro</option>
|
<option>Dinheiro</option>
|
||||||
<option>Cartão</option>
|
<option>Cartão</option>
|
||||||
@ -384,7 +457,12 @@ export default function FinanceiroDashboard() {
|
|||||||
className="input-field"
|
className="input-field"
|
||||||
type="date"
|
type="date"
|
||||||
value={modalPagamento.data_vencimento}
|
value={modalPagamento.data_vencimento}
|
||||||
onChange={e => setModalPagamento({...modalPagamento, data_vencimento:e.target.value})}
|
onChange={(e) =>
|
||||||
|
setModalPagamento({
|
||||||
|
...modalPagamento,
|
||||||
|
data_vencimento: e.target.value,
|
||||||
|
})
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -394,7 +472,12 @@ export default function FinanceiroDashboard() {
|
|||||||
id="status"
|
id="status"
|
||||||
className="select-field"
|
className="select-field"
|
||||||
value={modalPagamento.status}
|
value={modalPagamento.status}
|
||||||
onChange={e => setModalPagamento({...modalPagamento, status:e.target.value})}
|
onChange={(e) =>
|
||||||
|
setModalPagamento({
|
||||||
|
...modalPagamento,
|
||||||
|
status: e.target.value,
|
||||||
|
})
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<option value="pago">Pago</option>
|
<option value="pago">Pago</option>
|
||||||
<option value="pendente">Pendente</option>
|
<option value="pendente">Pendente</option>
|
||||||
@ -409,24 +492,28 @@ export default function FinanceiroDashboard() {
|
|||||||
className="input-field"
|
className="input-field"
|
||||||
rows={3}
|
rows={3}
|
||||||
value={modalPagamento.observacoes}
|
value={modalPagamento.observacoes}
|
||||||
onChange={e => setModalPagamento({...modalPagamento, observacoes:e.target.value})}
|
onChange={(e) =>
|
||||||
|
setModalPagamento({
|
||||||
|
...modalPagamento,
|
||||||
|
observacoes: e.target.value,
|
||||||
|
})
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="modal-footer">
|
<div className="modal-footer">
|
||||||
<button className="btn-view" onClick={() => handleSave(modalPagamento)}>
|
<button
|
||||||
|
className="btn-view"
|
||||||
|
onClick={() => handleSave(modalPagamento)}
|
||||||
|
>
|
||||||
<i className="bi bi-check-circle me-1"></i> Salvar
|
<i className="bi bi-check-circle me-1"></i> Salvar
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button className="btn-delete" onClick={closeModal}>
|
||||||
className="btn-delete"
|
|
||||||
onClick={closeModal}
|
|
||||||
>
|
|
||||||
<i className="bi bi-x-circle me-1"></i> Cancelar
|
<i className="bi bi-x-circle me-1"></i> Cancelar
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,9 +1,15 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from "react";
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from "react-router-dom";
|
||||||
import { FaCalendarAlt, FaCalendarCheck, FaFileAlt, FaUserMd, FaClock } from 'react-icons/fa';
|
import {
|
||||||
import { useAuth } from '../components/utils/AuthProvider';
|
FaCalendarAlt,
|
||||||
import API_KEY from '../components/utils/apiKeys';
|
FaCalendarCheck,
|
||||||
import './style/inicioPaciente.css';
|
FaFileAlt,
|
||||||
|
FaUserMd,
|
||||||
|
FaClock,
|
||||||
|
} from "react-icons/fa";
|
||||||
|
import { useAuth } from "../components/utils/AuthProvider";
|
||||||
|
import API_KEY from "../components/utils/apiKeys";
|
||||||
|
import "./style/inicioPaciente.css";
|
||||||
|
|
||||||
function InicioPaciente() {
|
function InicioPaciente() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@ -15,7 +21,8 @@ function InicioPaciente() {
|
|||||||
const [pacienteId, setPacienteId] = useState(null);
|
const [pacienteId, setPacienteId] = useState(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const userId = localStorage.getItem('user_id') || localStorage.getItem('patient_id');
|
const userId =
|
||||||
|
localStorage.getItem("user_id") || localStorage.getItem("patient_id");
|
||||||
setPacienteId(userId);
|
setPacienteId(userId);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -29,22 +36,25 @@ function InicioPaciente() {
|
|||||||
myHeaders.append("Authorization", authHeader);
|
myHeaders.append("Authorization", authHeader);
|
||||||
|
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
method: 'GET',
|
method: "GET",
|
||||||
headers: myHeaders,
|
headers: myHeaders,
|
||||||
redirect: 'follow'
|
redirect: "follow",
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/doctors", requestOptions);
|
const response = await fetch(
|
||||||
|
"https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/doctors",
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setMedicos(data);
|
setMedicos(data);
|
||||||
console.log(' Médicos carregados:', data.length);
|
console.log(" Médicos carregados:", data.length);
|
||||||
} else {
|
} else {
|
||||||
console.error(' Erro ao buscar médicos:', response.status);
|
console.error(" Erro ao buscar médicos:", response.status);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(' Erro ao buscar médicos:', error);
|
console.error(" Erro ao buscar médicos:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -57,23 +67,26 @@ function InicioPaciente() {
|
|||||||
myHeaders.append("Authorization", authHeader);
|
myHeaders.append("Authorization", authHeader);
|
||||||
|
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
method: 'GET',
|
method: "GET",
|
||||||
headers: myHeaders,
|
headers: myHeaders,
|
||||||
redirect: 'follow'
|
redirect: "follow",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Buscar todos os agendamentos (depois filtraremos pelo paciente)
|
// Buscar todos os agendamentos (depois filtraremos pelo paciente)
|
||||||
const response = await fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments", requestOptions);
|
const response = await fetch(
|
||||||
|
"https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments",
|
||||||
|
requestOptions
|
||||||
|
);
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setAgendamentos(data);
|
setAgendamentos(data);
|
||||||
console.log(' Agendamentos carregados:', data.length);
|
console.log(" Agendamentos carregados:", data.length);
|
||||||
} else {
|
} else {
|
||||||
console.error(' Erro ao buscar agendamentos:', response.status);
|
console.error(" Erro ao buscar agendamentos:", response.status);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(' Erro ao buscar agendamentos:', error);
|
console.error(" Erro ao buscar agendamentos:", error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@ -87,44 +100,50 @@ function InicioPaciente() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (agendamentos.length > 0 && medicos.length > 0) {
|
if (agendamentos.length > 0 && medicos.length > 0) {
|
||||||
const agendamentosComNomes = agendamentos.map(agendamento => {
|
const agendamentosComNomes = agendamentos.map((agendamento) => {
|
||||||
const medico = medicos.find(m => m.id === agendamento.doctor_id);
|
const medico = medicos.find((m) => m.id === agendamento.doctor_id);
|
||||||
return {
|
return {
|
||||||
...agendamento,
|
...agendamento,
|
||||||
nomeMedico: medico?.full_name || 'Médico não encontrado',
|
nomeMedico: medico?.full_name || "Médico não encontrado",
|
||||||
especialidadeMedico: medico?.specialty || ''
|
especialidadeMedico: medico?.specialty || "",
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
setAgendamentosComMedicos(agendamentosComNomes);
|
setAgendamentosComMedicos(agendamentosComNomes);
|
||||||
}
|
}
|
||||||
}, [agendamentos, medicos]);
|
}, [agendamentos, medicos]);
|
||||||
|
|
||||||
const meusAgendamentos = agendamentosComMedicos.filter(a =>
|
const meusAgendamentos = agendamentosComMedicos.filter((a) =>
|
||||||
pacienteId ? a.patient_id === pacienteId : true
|
pacienteId ? a.patient_id === pacienteId : true
|
||||||
);
|
);
|
||||||
|
|
||||||
const hoje = new Date();
|
const hoje = new Date();
|
||||||
hoje.setHours(0, 0, 0, 0);
|
hoje.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
const agendamentosFuturos = meusAgendamentos.filter(a => {
|
const agendamentosFuturos = meusAgendamentos
|
||||||
|
.filter((a) => {
|
||||||
if (!a.scheduled_at) return false;
|
if (!a.scheduled_at) return false;
|
||||||
const dataAgendamento = new Date(a.scheduled_at);
|
const dataAgendamento = new Date(a.scheduled_at);
|
||||||
return dataAgendamento >= hoje && a.status !== 'cancelled' && a.status !== 'completed';
|
return (
|
||||||
}).sort((a, b) => new Date(a.scheduled_at) - new Date(b.scheduled_at));
|
dataAgendamento >= hoje &&
|
||||||
|
a.status !== "cancelled" &&
|
||||||
|
a.status !== "completed"
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.sort((a, b) => new Date(a.scheduled_at) - new Date(b.scheduled_at));
|
||||||
|
|
||||||
const proximasConsultas = agendamentosFuturos.length;
|
const proximasConsultas = agendamentosFuturos.length;
|
||||||
const consultasHoje = agendamentosFuturos.filter(a => {
|
const consultasHoje = agendamentosFuturos.filter((a) => {
|
||||||
const dataAgendamento = new Date(a.scheduled_at);
|
const dataAgendamento = new Date(a.scheduled_at);
|
||||||
dataAgendamento.setHours(0, 0, 0, 0);
|
dataAgendamento.setHours(0, 0, 0, 0);
|
||||||
return dataAgendamento.getTime() === hoje.getTime();
|
return dataAgendamento.getTime() === hoje.getTime();
|
||||||
}).length;
|
}).length;
|
||||||
|
|
||||||
const consultasPendentes = meusAgendamentos.filter(a =>
|
const consultasPendentes = meusAgendamentos.filter(
|
||||||
a.status === 'pending' || a.status === 'requested'
|
(a) => a.status === "pending" || a.status === "requested"
|
||||||
).length;
|
).length;
|
||||||
|
|
||||||
const historicoConsultas = meusAgendamentos.filter(a =>
|
const historicoConsultas = meusAgendamentos.filter(
|
||||||
a.status === 'completed'
|
(a) => a.status === "completed"
|
||||||
).length;
|
).length;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -158,7 +177,9 @@ function InicioPaciente() {
|
|||||||
<div className="stat-paciente-card">
|
<div className="stat-paciente-card">
|
||||||
<div className="stat-paciente-info">
|
<div className="stat-paciente-info">
|
||||||
<span className="stat-paciente-label">Aguardando</span>
|
<span className="stat-paciente-label">Aguardando</span>
|
||||||
<span className="stat-paciente-value">{loading ? '...' : consultasPendentes}</span>
|
<span className="stat-paciente-value">
|
||||||
|
{loading ? "..." : consultasPendentes}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="stat-paciente-icon-wrapper purple">
|
<div className="stat-paciente-icon-wrapper purple">
|
||||||
<FaClock className="stat-paciente-icon" />
|
<FaClock className="stat-paciente-icon" />
|
||||||
@ -179,27 +200,42 @@ function InicioPaciente() {
|
|||||||
<div className="quick-actions-paciente">
|
<div className="quick-actions-paciente">
|
||||||
<h2>Acesso Rápido</h2>
|
<h2>Acesso Rápido</h2>
|
||||||
<div className="actions-paciente-grid">
|
<div className="actions-paciente-grid">
|
||||||
<div className="action-paciente-button" onClick={() => navigate('/paciente/agendamento')}>
|
<div
|
||||||
|
className="action-paciente-button"
|
||||||
|
onClick={() => navigate("/paciente/agendamento")}
|
||||||
|
>
|
||||||
<FaCalendarCheck className="action-paciente-icon" />
|
<FaCalendarCheck className="action-paciente-icon" />
|
||||||
<div className="action-paciente-info">
|
<div className="action-paciente-info">
|
||||||
<span className="action-paciente-title">Minhas Consultas</span>
|
<span className="action-paciente-title">Minhas Consultas</span>
|
||||||
<span className="action-paciente-desc">Ver todos os agendamentos</span>
|
<span className="action-paciente-desc">
|
||||||
|
Ver todos os agendamentos
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="action-paciente-button" onClick={() => navigate('/paciente/laudo')}>
|
<div
|
||||||
|
className="action-paciente-button"
|
||||||
|
onClick={() => navigate("/paciente/laudo")}
|
||||||
|
>
|
||||||
<FaFileAlt className="action-paciente-icon" />
|
<FaFileAlt className="action-paciente-icon" />
|
||||||
<div className="action-paciente-info">
|
<div className="action-paciente-info">
|
||||||
<span className="action-paciente-title">Meus Laudos</span>
|
<span className="action-paciente-title">Meus Laudos</span>
|
||||||
<span className="action-paciente-desc">Acessar documentos médicos</span>
|
<span className="action-paciente-desc">
|
||||||
|
Acessar documentos médicos
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="action-paciente-button" onClick={() => navigate('/paciente/agendamento')}>
|
<div
|
||||||
|
className="action-paciente-button"
|
||||||
|
onClick={() => navigate("/paciente/agendamento")}
|
||||||
|
>
|
||||||
<FaUserMd className="action-paciente-icon" />
|
<FaUserMd className="action-paciente-icon" />
|
||||||
<div className="action-paciente-info">
|
<div className="action-paciente-info">
|
||||||
<span className="action-paciente-title">Meus Médicos</span>
|
<span className="action-paciente-title">Meus Médicos</span>
|
||||||
<span className="action-paciente-desc">Ver histórico de atendimentos</span>
|
<span className="action-paciente-desc">
|
||||||
|
Ver histórico de atendimentos
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -213,22 +249,28 @@ function InicioPaciente() {
|
|||||||
</div>
|
</div>
|
||||||
) : agendamentosFuturos.length > 0 ? (
|
) : agendamentosFuturos.length > 0 ? (
|
||||||
<div className="consultas-paciente-list">
|
<div className="consultas-paciente-list">
|
||||||
{agendamentosFuturos.slice(0, 3).map(agendamento => (
|
{agendamentosFuturos.slice(0, 3).map((agendamento) => (
|
||||||
<div key={agendamento.id} className="consulta-paciente-item">
|
<div key={agendamento.id} className="consulta-paciente-item">
|
||||||
<div className="consulta-paciente-info">
|
<div className="consulta-paciente-info">
|
||||||
<div className="consulta-paciente-time-date">
|
<div className="consulta-paciente-time-date">
|
||||||
<p className="consulta-paciente-hora">
|
<p className="consulta-paciente-hora">
|
||||||
{new Date(agendamento.scheduled_at).toLocaleTimeString('pt-BR', {
|
{new Date(agendamento.scheduled_at).toLocaleTimeString(
|
||||||
hour: '2-digit',
|
"pt-BR",
|
||||||
minute: '2-digit'
|
{
|
||||||
})}
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
}
|
||||||
|
)}
|
||||||
</p>
|
</p>
|
||||||
<p className="consulta-paciente-data">
|
<p className="consulta-paciente-data">
|
||||||
{new Date(agendamento.scheduled_at).toLocaleDateString('pt-BR', {
|
{new Date(agendamento.scheduled_at).toLocaleDateString(
|
||||||
day: '2-digit',
|
"pt-BR",
|
||||||
month: 'short',
|
{
|
||||||
year: 'numeric'
|
day: "2-digit",
|
||||||
})}
|
month: "short",
|
||||||
|
year: "numeric",
|
||||||
|
}
|
||||||
|
)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="consulta-paciente-detalhes">
|
<div className="consulta-paciente-detalhes">
|
||||||
@ -242,16 +284,25 @@ function InicioPaciente() {
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<span className={`consulta-paciente-status status-${agendamento.status}`}>
|
<span
|
||||||
{agendamento.status === 'scheduled' ? 'Confirmado' :
|
className={`consulta-paciente-status status-${agendamento.status}`}
|
||||||
agendamento.status === 'pending' ? 'Aguardando' :
|
>
|
||||||
agendamento.status === 'requested' ? 'Solicitado' : agendamento.status}
|
{agendamento.status === "scheduled"
|
||||||
|
? "Confirmado"
|
||||||
|
: agendamento.status === "pending"
|
||||||
|
? "Aguardando"
|
||||||
|
: agendamento.status === "requested"
|
||||||
|
? "Solicitado"
|
||||||
|
: agendamento.status}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{agendamentosFuturos.length > 3 && (
|
{agendamentosFuturos.length > 3 && (
|
||||||
<button className="view-all-paciente-button" onClick={() => navigate('/paciente/agendamento')}>
|
<button
|
||||||
|
className="view-all-paciente-button"
|
||||||
|
onClick={() => navigate("/paciente/agendamento")}
|
||||||
|
>
|
||||||
Ver todas as consultas
|
Ver todas as consultas
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
@ -260,7 +311,10 @@ function InicioPaciente() {
|
|||||||
<div className="no-consultas-content">
|
<div className="no-consultas-content">
|
||||||
<FaCalendarCheck className="no-consultas-icon" />
|
<FaCalendarCheck className="no-consultas-icon" />
|
||||||
<p>Você não tem consultas agendadas</p>
|
<p>Você não tem consultas agendadas</p>
|
||||||
<button className="agendar-paciente-button" onClick={() => navigate('/paciente/agendamento/criar')}>
|
<button
|
||||||
|
className="agendar-paciente-button"
|
||||||
|
onClick={() => navigate("/paciente/agendamento/criar")}
|
||||||
|
>
|
||||||
Agendar Consulta
|
Agendar Consulta
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
|
.calendar-grid {
|
||||||
|
min-width: 400px;
|
||||||
|
grid-template-columns: repeat(7, 1fr);
|
||||||
|
}
|
||||||
|
.day-cell {
|
||||||
|
min-height: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.table-wrapper {
|
||||||
|
overflow-x: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
border: 1px solid #E2E8F0;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border: none;
|
margin-bottom: 16px;
|
||||||
font-weight: 600;
|
}
|
||||||
font-size: 1rem;
|
|
||||||
display: flex;
|
table {
|
||||||
align-items: center;
|
min-width: 600px;
|
||||||
gap: 8px;
|
font-size: 0.875rem;
|
||||||
cursor: pointer;
|
}
|
||||||
transition: background 0.2s;
|
|
||||||
|
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,
|
||||||
.calendar-wrapper {
|
aproxima só o conteúdo dessa área também */
|
||||||
margin-top: 0;
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 2) sempre cria um espaçamento logo DEPOIS das abas,
|
||||||
|
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;
|
||||||
@ -186,9 +192,9 @@ html[data-bs-theme="dark"] .btn-delete {
|
|||||||
/* Badges de status */
|
/* Badges de status */
|
||||||
.badge {
|
.badge {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 4px 10px;
|
padding: 8px 18px !important;
|
||||||
border-radius: 9999px;
|
border-radius: 9999px;
|
||||||
font-size: 12px;
|
font-size: 14px !important;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
@ -228,11 +234,17 @@ html[data-bs-theme="dark"] .btn-delete {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 550px;
|
max-width: 550px;
|
||||||
max-height: 85vh;
|
max-height: 85vh;
|
||||||
overflow-y: auto;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
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;
|
||||||
@ -243,7 +255,7 @@ html[data-bs-theme="dark"] .btn-delete {
|
|||||||
.modal-header h2 {
|
.modal-header h2 {
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: #1f2937;
|
color: #fff;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,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);
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
/* Estatísticas - Paciente */
|
/* Estatísticas - Paciente */
|
||||||
.stats-paciente-grid {
|
.stats-paciente-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||||
gap: 1.5rem;
|
gap: 1.5rem;
|
||||||
margin-bottom: 2.5rem;
|
margin-bottom: 2.5rem;
|
||||||
}
|
}
|
||||||
@ -81,10 +81,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Cores dos ícones - Paciente */
|
/* Cores dos ícones - Paciente */
|
||||||
.stat-paciente-icon-wrapper.blue { background-color: #5d5dff; }
|
.stat-paciente-icon-wrapper.blue { background-color: #051AFF; }
|
||||||
.stat-paciente-icon-wrapper.green { background-color: #30d158; }
|
.stat-paciente-icon-wrapper.green { background-color: #5F5DF2; }
|
||||||
.stat-paciente-icon-wrapper.purple { background-color: #a272ff; }
|
.stat-paciente-icon-wrapper.purple { background-color: #a272ff; }
|
||||||
.stat-paciente-icon-wrapper.orange { background-color: #f1952e; }
|
.stat-paciente-icon-wrapper.orange { background-color: #0065FF; }
|
||||||
|
|
||||||
/* Ações Rápidas - Paciente */
|
/* Ações Rápidas - Paciente */
|
||||||
.quick-actions-paciente h2 {
|
.quick-actions-paciente h2 {
|
||||||
@ -432,14 +432,6 @@ html[data-bs-theme="dark"] .view-all-paciente-button:hover {
|
|||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stats-paciente-grid {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
.actions-paciente-grid {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
.consulta-paciente-info {
|
.consulta-paciente-info {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import Chat from "../../PagesMedico/Chat";
|
|||||||
import DoctorItems from "../../data/sidebar-items-medico.json";
|
import DoctorItems from "../../data/sidebar-items-medico.json";
|
||||||
import FormNovoRelatorio from "../../PagesMedico/FormNovoRelatorio";
|
import FormNovoRelatorio from "../../PagesMedico/FormNovoRelatorio";
|
||||||
import EditPageRelatorio from "../../PagesMedico/EditPageRelatorio";
|
import EditPageRelatorio from "../../PagesMedico/EditPageRelatorio";
|
||||||
|
import NovoRelatorioAudio from "../../PagesMedico/NovoRelatorioAudio";
|
||||||
import BotaoVideoChamada from '../../components/BotaoVideoChamada';
|
import BotaoVideoChamada from '../../components/BotaoVideoChamada';
|
||||||
|
|
||||||
import DoctorAgendamentoEditPage from "../../PagesMedico/DoctorAgendamentoEditPage";
|
import DoctorAgendamentoEditPage from "../../PagesMedico/DoctorAgendamentoEditPage";
|
||||||
@ -25,6 +26,8 @@ function PerfilMedico() {
|
|||||||
<div id="main">
|
<div id="main">
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<DoctorRelatorioManager />} />
|
<Route path="/" element={<DoctorRelatorioManager />} />
|
||||||
|
<Route path="/novo-relatorio" element={<FormNovoRelatorio />} />
|
||||||
|
<Route path="/novo-relatorio-audio" element={<NovoRelatorioAudio />} />
|
||||||
<Route path="/relatorios/criar" element={<FormNovoRelatorio />} />
|
<Route path="/relatorios/criar" element={<FormNovoRelatorio />} />
|
||||||
<Route path="/relatorios/:id/edit" element={<EditPageRelatorio />} />
|
<Route path="/relatorios/:id/edit" element={<EditPageRelatorio />} />
|
||||||
<Route path="/prontuario" element={<Prontuario />} />
|
<Route path="/prontuario" element={<Prontuario />} />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user