Bug concertado nos agendamentos dos perfis
This commit is contained in:
parent
7557aa28ea
commit
cbfca9d6b4
@ -5,7 +5,7 @@ import API_KEY from '../components/utils/apiKeys'
|
|||||||
import { useAuth } from '../components/utils/AuthProvider'
|
import { useAuth } from '../components/utils/AuthProvider'
|
||||||
import { UserInfos } from '../components/utils/Functions-Endpoints/General'
|
import { UserInfos } from '../components/utils/Functions-Endpoints/General'
|
||||||
|
|
||||||
const DoctorAgendamentoEditPage = ({DictInfo}) => {
|
const DoctorAgendamentoEditPage = ({DictInfo, setDictInfo}) => {
|
||||||
|
|
||||||
const {getAuthorizationHeader} = useAuth();
|
const {getAuthorizationHeader} = useAuth();
|
||||||
|
|
||||||
@ -17,14 +17,15 @@ const DoctorAgendamentoEditPage = ({DictInfo}) => {
|
|||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
//console.log(DictInfo.scheduled_at.split("T")[0])
|
||||||
|
setDictInfo({...DictInfo, dataAtendimento:DictInfo?.scheduled_at?.split("T")[0]})
|
||||||
|
|
||||||
const fetchUserInfo = async () => {
|
const fetchUserInfo = async () => {
|
||||||
const InfosUser = await UserInfos(authHeader)
|
const InfosUser = await UserInfos(authHeader)
|
||||||
console.log("Informações", InfosUser)
|
console.log("Informações", InfosUser)
|
||||||
setIdUsuario(InfosUser.id)
|
setIdUsuario(InfosUser.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
setConsultaToPUT(DictInfo)
|
|
||||||
|
|
||||||
fetchUserInfo()
|
fetchUserInfo()
|
||||||
|
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ const DoctorAgendamentoEditPage = ({DictInfo}) => {
|
|||||||
redirect: 'follow'
|
redirect: 'follow'
|
||||||
};
|
};
|
||||||
|
|
||||||
fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?id=eq.${consultaToPut.id}`, requestOptions)
|
fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?id=eq.${DictInfo.id}`, requestOptions)
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(result => console.log(result))
|
.then(result => console.log(result))
|
||||||
.catch(error => console.log('error', error));
|
.catch(error => console.log('error', error));
|
||||||
@ -81,7 +82,7 @@ const DoctorAgendamentoEditPage = ({DictInfo}) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<FormNovaConsulta agendamento={consultaToPut} setAgendamento={setConsultaToPUT} onSave={handleSave}/>
|
<FormNovaConsulta agendamento={DictInfo} setAgendamento={setDictInfo} onSave={handleSave}/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -441,6 +441,8 @@ const confirmConsulta = (selectedPatientId) => {
|
|||||||
type="button"
|
type="button"
|
||||||
className="btn btn-danger"
|
className="btn btn-danger"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
||||||
|
deleteConsulta(selectedID)
|
||||||
setShowDeleteModal(false)
|
setShowDeleteModal(false)
|
||||||
let lista_cores = coresConsultas
|
let lista_cores = coresConsultas
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,6 @@ const CardConsultaPaciente = ({consulta, setConsulta, setSelectedId, setShowDel
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const ids = useMemo(() => {
|
const ids = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
doctor_id: consulta?.doctor_id,
|
doctor_id: consulta?.doctor_id,
|
||||||
@ -45,9 +44,6 @@ const CardConsultaPaciente = ({consulta, setConsulta, setSelectedId, setShowDel
|
|||||||
}, [ids, authHeader]);
|
}, [ids, authHeader]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
console.log(consulta, "dento do card")
|
|
||||||
|
|
||||||
let horario = consulta.scheduled_at.split("T")[1]
|
let horario = consulta.scheduled_at.split("T")[1]
|
||||||
let Data = consulta.scheduled_at.split("T")[0]
|
let Data = consulta.scheduled_at.split("T")[0]
|
||||||
|
|
||||||
|
|||||||
@ -30,14 +30,16 @@ const ConsultaCadastroManager = () => {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleSave = (Dict) => {
|
const handleSave = (Dict) => {
|
||||||
|
|
||||||
let DataAtual = dayjs()
|
let DataAtual = dayjs()
|
||||||
var 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");
|
||||||
|
|
||||||
|
|
||||||
var raw = JSON.stringify({
|
var raw = JSON.stringify({
|
||||||
"patient_id": Dict.patient_id,
|
"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,
|
||||||
|
|||||||
@ -169,7 +169,7 @@ const formatarHora = (datetimeString) => {
|
|||||||
const handleSubmit = (e) => {
|
const handleSubmit = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
alert("Agendamento salvo!");
|
alert("Agendamento salvo!");
|
||||||
navigate("/paciente/agendamento")
|
|
||||||
onSave({...agendamento, horarioInicio:horarioInicio})
|
onSave({...agendamento, horarioInicio:horarioInicio})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -15,19 +15,16 @@ const CardConsulta = ( {DadosConsulta, TabelaAgendamento, setShowDeleteModal, se
|
|||||||
|
|
||||||
const [decidirBotton, setDecidirBotton] = useState("")
|
const [decidirBotton, setDecidirBotton] = useState("")
|
||||||
|
|
||||||
console.log(DadosConsulta, "NOME DO PACIENTE"
|
|
||||||
|
|
||||||
)
|
/* const ids = useMemo(() => {
|
||||||
|
|
||||||
const ids = useMemo(() => {
|
|
||||||
return {
|
return {
|
||||||
doctor_id: DadosConsulta?.doctor_id,
|
doctor_id: DadosConsulta?.doctor_id,
|
||||||
patient_id: DadosConsulta?.patient_id,
|
patient_id: DadosConsulta?.patient_id,
|
||||||
status: DadosConsulta?.status
|
status: DadosConsulta?.status
|
||||||
};
|
};
|
||||||
}, [DadosConsulta]);
|
}, [DadosConsulta]);
|
||||||
|
*/
|
||||||
|
/*
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const BuscarMedicoEPaciente = async () => {
|
const BuscarMedicoEPaciente = async () => {
|
||||||
if (!ids.doctor_id || !ids.patient_id || ids.status === 'nada') return;
|
if (!ids.doctor_id || !ids.patient_id || ids.status === 'nada') return;
|
||||||
@ -46,10 +43,10 @@ const CardConsulta = ( {DadosConsulta, TabelaAgendamento, setShowDeleteModal, se
|
|||||||
};
|
};
|
||||||
|
|
||||||
BuscarMedicoEPaciente();
|
BuscarMedicoEPaciente();
|
||||||
}, [ids, authHeader]);
|
}, [ids, authHeader]);*/
|
||||||
|
|
||||||
let nameArrayPaciente = DadosConsulta?.medico_nome?.split(' ')
|
let nameArrayPaciente = DadosConsulta?.paciente_nome?.split(' ')
|
||||||
let nameArrayMedico = DadosConsulta?.paciente_nome?.split(' ')
|
let nameArrayMedico = DadosConsulta?.medico_nome?.split(' ')
|
||||||
let indice_cor = listaConsultasID.indexOf(DadosConsulta.id)
|
let indice_cor = listaConsultasID.indexOf(DadosConsulta.id)
|
||||||
|
|
||||||
|
|
||||||
@ -82,7 +79,7 @@ const CardConsulta = ( {DadosConsulta, TabelaAgendamento, setShowDeleteModal, se
|
|||||||
onClick={() => {navigate(`edit`)
|
onClick={() => {navigate(`edit`)
|
||||||
|
|
||||||
console.log(DadosConsulta)
|
console.log(DadosConsulta)
|
||||||
setDictInfo({...DadosConsulta,paciente_cpf:"", paciente_nome:DadosConsulta?.paciente_nome, nome_medico:DadosConsulta?.medico_nome})
|
setDictInfo({...DadosConsulta,paciente_cpf:DadosConsulta?.paciente_cpf, paciente_nome:DadosConsulta?.paciente_nome, nome_medico:DadosConsulta?.nome_medico})
|
||||||
}}
|
}}
|
||||||
|
|
||||||
>
|
>
|
||||||
|
|||||||
@ -89,7 +89,7 @@ const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
|||||||
|
|
||||||
// Se estiver na página de edição esse useEffect pega o horario de inicio para coloca-lo no horarioInicio
|
// Se estiver na página de edição esse useEffect pega o horario de inicio para coloca-lo no horarioInicio
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log("Horario", )
|
console.log("Horario","tessssste" )
|
||||||
if (agendamento?.scheduled_at) {
|
if (agendamento?.scheduled_at) {
|
||||||
setHorarioInicio(formatarHora(agendamento.scheduled_at));
|
setHorarioInicio(formatarHora(agendamento.scheduled_at));
|
||||||
}
|
}
|
||||||
@ -303,7 +303,7 @@ const handleSubmit = (e) => {
|
|||||||
<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)}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -51,12 +51,8 @@ const Agendamento = ({setDictInfo}) => {
|
|||||||
const [cacheAgendamentos, setCacheAgendamentos] = useState([])
|
const [cacheAgendamentos, setCacheAgendamentos] = useState([])
|
||||||
|
|
||||||
const [showConfirmModal, setShowConfirmModal] = useState(false)
|
const [showConfirmModal, setShowConfirmModal] = useState(false)
|
||||||
|
|
||||||
const [motivoCancelamento, setMotivoCancelamento] = useState("")
|
const [motivoCancelamento, setMotivoCancelamento] = useState("")
|
||||||
|
|
||||||
const [corModal, setCorModal] = useState("")
|
|
||||||
|
|
||||||
|
|
||||||
const [listaConsultasID, setListaConsultaID] = useState([])
|
const [listaConsultasID, setListaConsultaID] = useState([])
|
||||||
const [coresConsultas,setCoresConsultas] = useState([])
|
const [coresConsultas,setCoresConsultas] = useState([])
|
||||||
|
|
||||||
@ -76,7 +72,7 @@ console.log("recarregando")
|
|||||||
|
|
||||||
const fetchDados = async () => {
|
const fetchDados = async () => {
|
||||||
for (const agendamento of listaTodosAgendamentos) {
|
for (const agendamento of listaTodosAgendamentos) {
|
||||||
if (agendamento.status === "requested") {
|
|
||||||
// Cache de médico e paciente
|
// Cache de médico e paciente
|
||||||
if (!cacheMedicos[agendamento.doctor_id]) {
|
if (!cacheMedicos[agendamento.doctor_id]) {
|
||||||
cacheMedicos[agendamento.doctor_id] = await GetDoctorByID(agendamento.doctor_id, authHeader);
|
cacheMedicos[agendamento.doctor_id] = await GetDoctorByID(agendamento.doctor_id, authHeader);
|
||||||
@ -88,6 +84,7 @@ console.log("recarregando")
|
|||||||
const medico = cacheMedicos[agendamento.doctor_id];
|
const medico = cacheMedicos[agendamento.doctor_id];
|
||||||
const paciente = cachePacientes[agendamento.patient_id];
|
const paciente = cachePacientes[agendamento.patient_id];
|
||||||
|
|
||||||
|
if (agendamento.status === "requested") {
|
||||||
ListaFilaDeEspera.push({
|
ListaFilaDeEspera.push({
|
||||||
agendamento,
|
agendamento,
|
||||||
Infos: {
|
Infos: {
|
||||||
@ -96,15 +93,22 @@ console.log("recarregando")
|
|||||||
patient_id: paciente[0]?.id,
|
patient_id: paciente[0]?.id,
|
||||||
paciente_nome: paciente[0]?.full_name,
|
paciente_nome: paciente[0]?.full_name,
|
||||||
paciente_cpf: paciente[0]?.cpf,
|
paciente_cpf: paciente[0]?.cpf,
|
||||||
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const DiaAgendamento = agendamento.scheduled_at.split("T")[0];
|
const DiaAgendamento = agendamento.scheduled_at.split("T")[0];
|
||||||
|
|
||||||
|
let agendamentoMelhorado = {...agendamento, medico_nome: medico[0]?.full_name,
|
||||||
|
doctor_id: medico[0]?.id,
|
||||||
|
patient_id: paciente[0]?.id,
|
||||||
|
paciente_nome: paciente[0]?.full_name,
|
||||||
|
paciente_cpf: paciente[0]?.cpf, }
|
||||||
|
|
||||||
if (DiaAgendamento in DictAgendamentosOrganizados) {
|
if (DiaAgendamento in DictAgendamentosOrganizados) {
|
||||||
DictAgendamentosOrganizados[DiaAgendamento].push(agendamento);
|
DictAgendamentosOrganizados[DiaAgendamento].push(agendamentoMelhorado);
|
||||||
} else {
|
} else {
|
||||||
DictAgendamentosOrganizados[DiaAgendamento] = [agendamento];
|
DictAgendamentosOrganizados[DiaAgendamento] = [agendamentoMelhorado];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ const AgendamentoEditPage = ({setDictInfo, DictInfo}) => {
|
|||||||
|
|
||||||
let id = params.id
|
let id = params.id
|
||||||
|
|
||||||
console.log(DictInfo, "DENTRO DO EDITAR")
|
|
||||||
|
|
||||||
//console.log(DictInfo, 'aqui')
|
//console.log(DictInfo, 'aqui')
|
||||||
|
|
||||||
@ -51,9 +51,7 @@ const AgendamentoEditPage = ({setDictInfo, DictInfo}) => {
|
|||||||
"doctor_id": DictParaPatch.doctor_id,
|
"doctor_id": DictParaPatch.doctor_id,
|
||||||
|
|
||||||
"duration_minutes": 30,
|
"duration_minutes": 30,
|
||||||
|
|
||||||
"chief_complaint": "Dor de cabeça há 3 ",
|
"chief_complaint": "Dor de cabeça há 3 ",
|
||||||
|
|
||||||
"created_by": idUsuario,
|
"created_by": idUsuario,
|
||||||
|
|
||||||
"scheduled_at": `${DictParaPatch.dataAtendimento}T${DictParaPatch.horarioInicio}:00.000Z`,
|
"scheduled_at": `${DictParaPatch.dataAtendimento}T${DictParaPatch.horarioInicio}:00.000Z`,
|
||||||
|
|||||||
@ -30,7 +30,7 @@ function PerfilMedico() {
|
|||||||
<Route path="/prontuario" element={<Prontuario />} />
|
<Route path="/prontuario" element={<Prontuario />} />
|
||||||
<Route path="/relatorios" element={<DoctorRelatorioManager />} />
|
<Route path="/relatorios" element={<DoctorRelatorioManager />} />
|
||||||
<Route path="/agendamento" element={<DoctorAgendamentoManager setDictInfo={setDictInfo}/>} />
|
<Route path="/agendamento" element={<DoctorAgendamentoManager setDictInfo={setDictInfo}/>} />
|
||||||
<Route path="/agendamento/edit" element={<DoctorAgendamentoEditPage DictInfo={dictInfo}/>} />
|
<Route path="/agendamento/edit" element={<DoctorAgendamentoEditPage DictInfo={dictInfo} setDictInfo={setDictInfo}/>} />
|
||||||
<Route path="/chat" element={<Chat />} />
|
<Route path="/chat" element={<Chat />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user