forked from RiseUP/riseup-squad23
Melhorias no agendamento
This commit is contained in:
parent
38ebb5f7f3
commit
b0306125ae
@ -15,14 +15,14 @@ const ConsultaEditPage = ({dadosConsulta}) => {
|
||||
|
||||
const [idUsuario, setIDusuario] = useState("6e7f8829-0574-42df-9290-8dbb70f75ada")
|
||||
|
||||
const [DictInfo, setDictInfo] = useState({})
|
||||
const [DictInfo, setDict] = useState({})
|
||||
|
||||
const [Medico, setMedico] = useState({})
|
||||
|
||||
const [Paciente, setPaciente] = useState([])
|
||||
|
||||
useEffect(() => {
|
||||
setDictInfo({...dadosConsulta})
|
||||
setDict({...dadosConsulta})
|
||||
|
||||
const fetchMedicoePaciente = async () => {
|
||||
console.log(dadosConsulta.doctor_id)
|
||||
@ -52,7 +52,7 @@ const ConsultaEditPage = ({dadosConsulta}) => {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
setDictInfo({...DictInfo, medico_nome:Medico?.full_name, dataAtendimento:dadosConsulta.scheduled_at?.split("T")[0]})
|
||||
setDict({...DictInfo, medico_nome:Medico?.full_name, dataAtendimento:dadosConsulta.scheduled_at?.split("T")[0]})
|
||||
}, [Medico])
|
||||
|
||||
|
||||
@ -104,7 +104,7 @@ const ConsultaEditPage = ({dadosConsulta}) => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<FormConsultaPaciente agendamento={DictInfo} setAgendamento={setDictInfo} onSave={handleSave}/>
|
||||
<FormConsultaPaciente agendamento={DictInfo} setAgendamento={setDict} onSave={handleSave}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@ -7,8 +7,6 @@ import "./style/card-consulta.css"
|
||||
const CardConsulta = ( {DadosConsulta, TabelaAgendamento, setShowDeleteModal, setDictInfo, setSelectedId} ) => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
console.log(DadosConsulta, "AQUIIII")
|
||||
|
||||
const {getAuthorizationHeader} = useAuth()
|
||||
const authHeader = getAuthorizationHeader()
|
||||
const [Paciente, setPaciente] = useState()
|
||||
|
||||
@ -75,7 +75,8 @@ const TabelaAgendamentoSemana = ({ agendamentos, ListarDiasdoMes, setShowDeleteM
|
||||
|
||||
useEffect(() => {
|
||||
setSemanasOrganizadas(OrganizarAgendamentosSemanais);
|
||||
// NOTA: Ao carregar, o Indice é 0, que é a primeira semana.
|
||||
|
||||
//console.log(semanasOrganizadas, `aqui`)
|
||||
}, [OrganizarAgendamentosSemanais])
|
||||
|
||||
// --- NOVAS FUNÇÕES DE NAVEGAÇÃO ---
|
||||
@ -156,10 +157,22 @@ const TabelaAgendamentoSemana = ({ agendamentos, ListarDiasdoMes, setShowDeleteM
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{indicesDeLinha.map((indiceLinha) => (
|
||||
{indicesDeLinha.map((indiceLinha) => {
|
||||
|
||||
let schedulet_at = semanaParaRenderizar.segunda[indiceLinha].scheduled_at.split("T")
|
||||
|
||||
let horario = schedulet_at[1].split(":")
|
||||
|
||||
console.log(horario)
|
||||
|
||||
return(
|
||||
<tr key={indiceLinha}>
|
||||
{/* Célula para Horário (Pode ser ajustado para mostrar o horário real) */}
|
||||
<td></td>
|
||||
<td>
|
||||
|
||||
<p className='horario-texto'> {`${horario[0]}:${horario[1]}`} </p>
|
||||
|
||||
</td>
|
||||
|
||||
{/* Mapeamento de COLUNAS (dias) */}
|
||||
<td>
|
||||
@ -193,7 +206,7 @@ const TabelaAgendamentoSemana = ({ agendamentos, ListarDiasdoMes, setShowDeleteM
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
)})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@ -1,15 +1,6 @@
|
||||
<<<<<<< HEAD
|
||||
import API_KEY from "../apiKeys";
|
||||
|
||||
|
||||
|
||||
const GetDoctorByID = async (ID,authHeader) => {
|
||||
|
||||
=======
|
||||
import API_KEY from '../apiKeys';
|
||||
|
||||
const GetDoctorByID = async (ID, authHeader) => {
|
||||
>>>>>>> perfillogin
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append('apikey', API_KEY);
|
||||
if (authHeader) myHeaders.append('Authorization', authHeader);
|
||||
@ -20,19 +11,7 @@ const GetDoctorByID = async (ID, authHeader) => {
|
||||
return DictMedico;
|
||||
};
|
||||
|
||||
const GetAllDoctors = async (authHeader) => {
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append('apikey', API_KEY);
|
||||
if (authHeader) myHeaders.append('Authorization', authHeader);
|
||||
|
||||
const requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' };
|
||||
const res = await fetch('https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/doctors?select=id,full_name,crm&limit=500', requestOptions);
|
||||
const DictMedicos = await res.json();
|
||||
return DictMedicos;
|
||||
};
|
||||
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
|
||||
const GetAllDoctors = async (authHeader) => {
|
||||
var myHeaders = new Headers();
|
||||
@ -67,6 +46,3 @@ const GetDoctorByName = async (nome, authHeader) => {
|
||||
}
|
||||
|
||||
export {GetDoctorByID, GetDoctorByName, GetAllDoctors}
|
||||
=======
|
||||
export { GetDoctorByID, GetAllDoctors };
|
||||
>>>>>>> perfillogin
|
||||
|
||||
@ -155,19 +155,25 @@ const Agendamento = ({setDictInfo}) => {
|
||||
}, [FiltredTodosMedicos]);
|
||||
|
||||
const deleteConsulta = (selectedPatientId) => {
|
||||
console.log("tentando apagar")
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append("Authorization", authHeader);
|
||||
myHeaders.append("apikey", API_KEY)
|
||||
myHeaders.append("Content-Type", "application/json");
|
||||
myHeaders.append('apikey', API_KEY)
|
||||
myHeaders.append("authorization", authHeader)
|
||||
|
||||
var requestOptions = {
|
||||
method: 'DELETE',
|
||||
redirect: 'follow',
|
||||
headers: myHeaders
|
||||
};
|
||||
|
||||
fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?id=eq.${selectedPatientId}`, requestOptions)
|
||||
.then(response => response.json())
|
||||
var raw = JSON.stringify({ "status":"cancelled"
|
||||
});
|
||||
|
||||
|
||||
var requestOptions = {
|
||||
method: 'PATCH',
|
||||
headers: myHeaders,
|
||||
body: raw,
|
||||
redirect: 'follow'
|
||||
};
|
||||
|
||||
fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?id=eq.${selectedPatientId}`, requestOptions)
|
||||
.then(response => {if(response.status !== 200)(console.log(response))})
|
||||
.then(result => console.log(result))
|
||||
.catch(error => console.log('error', error));
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user