Compare commits
2 Commits
7557aa28ea
...
0b5ae1f2cb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b5ae1f2cb | ||
|
|
cbfca9d6b4 |
@ -5,7 +5,7 @@ import API_KEY from '../components/utils/apiKeys'
|
||||
import { useAuth } from '../components/utils/AuthProvider'
|
||||
import { UserInfos } from '../components/utils/Functions-Endpoints/General'
|
||||
|
||||
const DoctorAgendamentoEditPage = ({DictInfo}) => {
|
||||
const DoctorAgendamentoEditPage = ({DictInfo, setDictInfo}) => {
|
||||
|
||||
const {getAuthorizationHeader} = useAuth();
|
||||
|
||||
@ -17,14 +17,15 @@ const DoctorAgendamentoEditPage = ({DictInfo}) => {
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
//console.log(DictInfo.scheduled_at.split("T")[0])
|
||||
setDictInfo({...DictInfo, dataAtendimento:DictInfo?.scheduled_at?.split("T")[0]})
|
||||
|
||||
const fetchUserInfo = async () => {
|
||||
const InfosUser = await UserInfos(authHeader)
|
||||
console.log("Informações", InfosUser)
|
||||
setIdUsuario(InfosUser.id)
|
||||
}
|
||||
|
||||
setConsultaToPUT(DictInfo)
|
||||
|
||||
fetchUserInfo()
|
||||
|
||||
|
||||
@ -70,7 +71,7 @@ const DoctorAgendamentoEditPage = ({DictInfo}) => {
|
||||
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(result => console.log(result))
|
||||
.catch(error => console.log('error', error));
|
||||
@ -81,7 +82,7 @@ const DoctorAgendamentoEditPage = ({DictInfo}) => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<FormNovaConsulta agendamento={consultaToPut} setAgendamento={setConsultaToPUT} onSave={handleSave}/>
|
||||
<FormNovaConsulta agendamento={DictInfo} setAgendamento={setDictInfo} onSave={handleSave}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@ -441,6 +441,8 @@ const confirmConsulta = (selectedPatientId) => {
|
||||
type="button"
|
||||
className="btn btn-danger"
|
||||
onClick={() => {
|
||||
|
||||
deleteConsulta(selectedID)
|
||||
setShowDeleteModal(false)
|
||||
let lista_cores = coresConsultas
|
||||
|
||||
|
||||
@ -13,7 +13,6 @@ const CardConsultaPaciente = ({consulta, setConsulta, setSelectedId, setShowDel
|
||||
const authHeader = getAuthorizationHeader()
|
||||
|
||||
|
||||
|
||||
|
||||
const ids = useMemo(() => {
|
||||
return {
|
||||
@ -45,9 +44,6 @@ const CardConsultaPaciente = ({consulta, setConsulta, setSelectedId, setShowDel
|
||||
}, [ids, authHeader]);
|
||||
|
||||
|
||||
|
||||
console.log(consulta, "dento do card")
|
||||
|
||||
let horario = consulta.scheduled_at.split("T")[1]
|
||||
let Data = consulta.scheduled_at.split("T")[0]
|
||||
|
||||
|
||||
@ -30,14 +30,16 @@ const ConsultaCadastroManager = () => {
|
||||
}, [])
|
||||
|
||||
const handleSave = (Dict) => {
|
||||
|
||||
let DataAtual = dayjs()
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append("apikey", API_KEY);
|
||||
myHeaders.append("Authorization", authHeader);
|
||||
myHeaders.append("Content-Type", "application/json");
|
||||
|
||||
|
||||
var raw = JSON.stringify({
|
||||
"patient_id": Dict.patient_id,
|
||||
"patient_id": "6e7f8829-0574-42df-9290-8dbb70f75ada",
|
||||
"doctor_id": Dict.doctor_id,
|
||||
"scheduled_at": `${Dict.dataAtendimento}T${Dict.horarioInicio}:00.000Z`,
|
||||
"duration_minutes": 30,
|
||||
|
||||
@ -169,7 +169,7 @@ const formatarHora = (datetimeString) => {
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
alert("Agendamento salvo!");
|
||||
navigate("/paciente/agendamento")
|
||||
|
||||
onSave({...agendamento, horarioInicio:horarioInicio})
|
||||
};
|
||||
|
||||
|
||||
@ -15,19 +15,16 @@ const CardConsulta = ( {DadosConsulta, TabelaAgendamento, setShowDeleteModal, se
|
||||
|
||||
const [decidirBotton, setDecidirBotton] = useState("")
|
||||
|
||||
console.log(DadosConsulta, "NOME DO PACIENTE"
|
||||
|
||||
)
|
||||
|
||||
const ids = useMemo(() => {
|
||||
/* const ids = useMemo(() => {
|
||||
return {
|
||||
doctor_id: DadosConsulta?.doctor_id,
|
||||
patient_id: DadosConsulta?.patient_id,
|
||||
status: DadosConsulta?.status
|
||||
};
|
||||
}, [DadosConsulta]);
|
||||
|
||||
|
||||
*/
|
||||
/*
|
||||
useEffect(() => {
|
||||
const BuscarMedicoEPaciente = async () => {
|
||||
if (!ids.doctor_id || !ids.patient_id || ids.status === 'nada') return;
|
||||
@ -46,16 +43,15 @@ const CardConsulta = ( {DadosConsulta, TabelaAgendamento, setShowDeleteModal, se
|
||||
};
|
||||
|
||||
BuscarMedicoEPaciente();
|
||||
}, [ids, authHeader]);
|
||||
}, [ids, authHeader]);*/
|
||||
|
||||
let nameArrayPaciente = DadosConsulta?.medico_nome?.split(' ')
|
||||
let nameArrayMedico = DadosConsulta?.paciente_nome?.split(' ')
|
||||
let nameArrayPaciente = DadosConsulta?.paciente_nome?.split(' ')
|
||||
let nameArrayMedico = DadosConsulta?.medico_nome?.split(' ')
|
||||
let indice_cor = listaConsultasID.indexOf(DadosConsulta.id)
|
||||
|
||||
|
||||
return (
|
||||
<div className={`container-cardconsulta container-cardconsulta-${TabelaAgendamento} ` }>
|
||||
|
||||
|
||||
{DadosConsulta.id?
|
||||
|
||||
@ -82,7 +78,7 @@ const CardConsulta = ( {DadosConsulta, TabelaAgendamento, setShowDeleteModal, se
|
||||
onClick={() => {navigate(`edit`)
|
||||
|
||||
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
|
||||
useEffect(() => {
|
||||
console.log("Horario", )
|
||||
console.log("Horario","tessssste" )
|
||||
if (agendamento?.scheduled_at) {
|
||||
setHorarioInicio(formatarHora(agendamento.scheduled_at));
|
||||
}
|
||||
@ -303,7 +303,7 @@ const handleSubmit = (e) => {
|
||||
<select
|
||||
id="inicio"
|
||||
name="inicio"
|
||||
required
|
||||
|
||||
value={horarioInicio}
|
||||
onChange={(e) => setHorarioInicio(e.target.value)}
|
||||
>
|
||||
|
||||
@ -51,11 +51,7 @@ const Agendamento = ({setDictInfo}) => {
|
||||
const [cacheAgendamentos, setCacheAgendamentos] = useState([])
|
||||
|
||||
const [showConfirmModal, setShowConfirmModal] = useState(false)
|
||||
|
||||
const [motivoCancelamento, setMotivoCancelamento] = useState("")
|
||||
|
||||
const [corModal, setCorModal] = useState("")
|
||||
|
||||
const [motivoCancelamento, setMotivoCancelamento] = useState("")
|
||||
|
||||
const [listaConsultasID, setListaConsultaID] = useState([])
|
||||
const [coresConsultas,setCoresConsultas] = useState([])
|
||||
@ -76,7 +72,7 @@ console.log("recarregando")
|
||||
|
||||
const fetchDados = async () => {
|
||||
for (const agendamento of listaTodosAgendamentos) {
|
||||
if (agendamento.status === "requested") {
|
||||
|
||||
// Cache de médico e paciente
|
||||
if (!cacheMedicos[agendamento.doctor_id]) {
|
||||
cacheMedicos[agendamento.doctor_id] = await GetDoctorByID(agendamento.doctor_id, authHeader);
|
||||
@ -88,6 +84,7 @@ console.log("recarregando")
|
||||
const medico = cacheMedicos[agendamento.doctor_id];
|
||||
const paciente = cachePacientes[agendamento.patient_id];
|
||||
|
||||
if (agendamento.status === "requested") {
|
||||
ListaFilaDeEspera.push({
|
||||
agendamento,
|
||||
Infos: {
|
||||
@ -96,15 +93,22 @@ console.log("recarregando")
|
||||
patient_id: paciente[0]?.id,
|
||||
paciente_nome: paciente[0]?.full_name,
|
||||
paciente_cpf: paciente[0]?.cpf,
|
||||
|
||||
},
|
||||
});
|
||||
} else {
|
||||
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) {
|
||||
DictAgendamentosOrganizados[DiaAgendamento].push(agendamento);
|
||||
DictAgendamentosOrganizados[DiaAgendamento].push(agendamentoMelhorado);
|
||||
} else {
|
||||
DictAgendamentosOrganizados[DiaAgendamento] = [agendamento];
|
||||
DictAgendamentosOrganizados[DiaAgendamento] = [agendamentoMelhorado];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,12 +16,12 @@ const AgendamentoEditPage = ({setDictInfo, DictInfo}) => {
|
||||
|
||||
let id = params.id
|
||||
|
||||
console.log(DictInfo, "DENTRO DO EDITAR")
|
||||
|
||||
|
||||
//console.log(DictInfo, 'aqui')
|
||||
|
||||
useEffect(() => {
|
||||
setDictInfo({...DictInfo, dataAtendimento:DictInfo.scheduled_at.split("T")[0]})
|
||||
setDictInfo({...DictInfo, dataAtendimento:DictInfo.scheduled_at.split("T")[0]})
|
||||
|
||||
const ColherInfoUsuario =async () => {
|
||||
const result = await UserInfos(authHeader)
|
||||
@ -51,9 +51,7 @@ const AgendamentoEditPage = ({setDictInfo, DictInfo}) => {
|
||||
"doctor_id": DictParaPatch.doctor_id,
|
||||
|
||||
"duration_minutes": 30,
|
||||
|
||||
"chief_complaint": "Dor de cabeça há 3 ",
|
||||
|
||||
"created_by": idUsuario,
|
||||
|
||||
"scheduled_at": `${DictParaPatch.dataAtendimento}T${DictParaPatch.horarioInicio}:00.000Z`,
|
||||
|
||||
@ -30,7 +30,7 @@ function PerfilMedico() {
|
||||
<Route path="/prontuario" element={<Prontuario />} />
|
||||
<Route path="/relatorios" element={<DoctorRelatorioManager />} />
|
||||
<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 />} />
|
||||
</Routes>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user