forked from RiseUP/riseup-squad23
Merge com melhorias agendamentos
This commit is contained in:
commit
8f7fef3b8d
@ -4,7 +4,7 @@ import { useAuth } from '../utils/AuthProvider';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
const CardConsulta = ( {DadosConsulta, TabelaAgendamento, setShowDeleteModal} ) => {
|
||||
const CardConsulta = ( {DadosConsulta, TabelaAgendamento, setShowDeleteModal, setDictInfo, setSelectedId} ) => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const {getAuthorizationHeader} = useAuth()
|
||||
@ -45,6 +45,7 @@ const CardConsulta = ( {DadosConsulta, TabelaAgendamento, setShowDeleteModal} )
|
||||
|
||||
let nameArrayMedico = Medico?.full_name.split(' ')
|
||||
|
||||
console.log(DadosConsulta.status)
|
||||
|
||||
return (
|
||||
<div className={`container-cardconsulta-${TabelaAgendamento}`}>
|
||||
@ -67,9 +68,14 @@ const CardConsulta = ( {DadosConsulta, TabelaAgendamento, setShowDeleteModal} )
|
||||
<div className='container-botons'>
|
||||
<button className="btn btn-sm btn-edit-custom"
|
||||
|
||||
onClick={() => {navigate(`${DadosConsulta.id}/edit`)}}
|
||||
onClick={() => {navigate(`2/edit`)
|
||||
setDictInfo({agendamento:DadosConsulta, Infos:{paciente_cpf:Paciente.cpf, paciente_nome:Paciente.full_name}})
|
||||
|
||||
|
||||
}}
|
||||
|
||||
>
|
||||
<i className="bi bi-pencil me-1"></i> Editar
|
||||
<i className="bi bi-pencil me-1"></i>
|
||||
</button>
|
||||
|
||||
|
||||
@ -78,11 +84,11 @@ const CardConsulta = ( {DadosConsulta, TabelaAgendamento, setShowDeleteModal} )
|
||||
className="btn btn-sm btn-delete-custom"
|
||||
onClick={() => {
|
||||
console.log(DadosConsulta.id)
|
||||
//setSelectedPatientId(DadosConsulta.id);
|
||||
setSelectedId(DadosConsulta.id);
|
||||
setShowDeleteModal(true);
|
||||
}}
|
||||
>
|
||||
<i className="bi bi-trash me-1"></i> Excluir
|
||||
<i className="bi bi-trash me-1"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
@ -2,32 +2,33 @@ import InputMask from "react-input-mask";
|
||||
import "./style/formagendamentos.css";
|
||||
import { useState, useEffect } from "react";
|
||||
import { GetPatientByCPF } from "../utils/Functions-Endpoints/Patient";
|
||||
import { GetDoctorByName } from "../utils/Functions-Endpoints/Doctor";
|
||||
import { GetDoctorByName, GetAllDoctors } from "../utils/Functions-Endpoints/Doctor";
|
||||
import { useAuth } from "../utils/AuthProvider";
|
||||
import API_KEY from "../utils/apiKeys";
|
||||
|
||||
const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) => {
|
||||
const {getAuthorizationHeader} = useAuth()
|
||||
|
||||
console.log(agendamento, 'aqui2')
|
||||
|
||||
const [selectedFile, setSelectedFile] = useState(null);
|
||||
const [anexos, setAnexos] = useState([]);
|
||||
const [loadingAnexos, setLoadingAnexos] = useState(false);
|
||||
|
||||
|
||||
const [acessibilidade, setAcessibilidade] = useState({cadeirante:false,idoso:false,gravida:false,bebe:false, autista:false })
|
||||
|
||||
|
||||
const [todosProfissionais, setTodosProfissionais] = useState([])
|
||||
const [profissionaisFiltrados, setProfissionaisFiltrados] = useState([]);
|
||||
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
||||
|
||||
|
||||
const [horarioInicio, setHorarioInicio] = useState('');
|
||||
const [horarioTermino, setHorarioTermino] = useState('');
|
||||
|
||||
const [horariosDisponiveis, sethorariosDisponiveis] = useState([])
|
||||
|
||||
let authHeader = getAuthorizationHeader()
|
||||
|
||||
|
||||
const handleclickAcessibilidade = (id) => {
|
||||
let resultado = acessibilidade[id]
|
||||
|
||||
if(resultado === false){ setAcessibilidade({...acessibilidade, [id]:true}); console.log('mudou')}
|
||||
|
||||
else if(resultado === true){ setAcessibilidade({...acessibilidade, [id]:false})}
|
||||
console.log(id)
|
||||
}
|
||||
|
||||
|
||||
const FormatCPF = (valor) => {
|
||||
const digits = String(valor).replace(/\D/g, '').slice(0, 11);
|
||||
return digits
|
||||
@ -39,15 +40,29 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
||||
|
||||
|
||||
const handleChange = (e) => {
|
||||
|
||||
const {value, name} = e.target;
|
||||
console.log(value, name, agendamento)
|
||||
|
||||
if(name === 'email'){
|
||||
setAgendamento({...agendamento, contato:{
|
||||
...agendamento.contato,
|
||||
email:value
|
||||
}})
|
||||
}})}
|
||||
else if(name === 'status'){
|
||||
if(agendamento.status==='requested'){
|
||||
setAgendamento((prev) => ({
|
||||
...prev,
|
||||
status:'confirmed',
|
||||
}));
|
||||
}else if(agendamento.status === 'confirmed'){
|
||||
console.log(value)
|
||||
setAgendamento((prev) => ({
|
||||
...prev,
|
||||
status:'requested',
|
||||
}));
|
||||
}}
|
||||
|
||||
}else if(name === 'cpf'){
|
||||
else if(name === 'paciente_cpf'){
|
||||
|
||||
let cpfFormatted = FormatCPF(value)
|
||||
const fetchPatient = async () => {
|
||||
@ -55,7 +70,7 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
||||
if (patientData) {
|
||||
setAgendamento((prev) => ({
|
||||
...prev,
|
||||
nome: patientData.full_name,
|
||||
pacinte_nome: patientData.full_name,
|
||||
patient_id: patientData.id
|
||||
}));
|
||||
}}
|
||||
@ -63,28 +78,97 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
||||
fetchPatient()
|
||||
}else if(name==='convenio'){
|
||||
setAgendamento({...agendamento,insurance_provider:value})
|
||||
}else if(name ==='profissional'){
|
||||
|
||||
|
||||
const fetchDoctor = async () => {
|
||||
let DoctorData = await GetDoctorByName(value, authHeader)
|
||||
if(DoctorData){
|
||||
setAgendamento((prev) => ({
|
||||
...prev,
|
||||
doctor_id:DoctorData.id
|
||||
}))
|
||||
}}
|
||||
fetchDoctor()
|
||||
}
|
||||
else{
|
||||
setAgendamento({...agendamento,[name]:value})
|
||||
}
|
||||
}
|
||||
|
||||
const handleSubmit = (e) => {
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const ChamarMedicos = async () => {
|
||||
const Medicos = await GetAllDoctors(authHeader)
|
||||
setTodosProfissionais(Medicos)
|
||||
}
|
||||
ChamarMedicos();
|
||||
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append("Content-Type", "application/json");
|
||||
myHeaders.append("apikey", API_KEY)
|
||||
myHeaders.append("Authorization", `Bearer ${authHeader.split(' ')[1]}`);
|
||||
|
||||
var raw = JSON.stringify({
|
||||
"doctor_id": agendamento.doctor_id,
|
||||
"start_date": agendamento.dataAtendimento,
|
||||
"end_date": `${agendamento.dataAtendimento}T23:59:59.999Z`,
|
||||
|
||||
});
|
||||
|
||||
var requestOptions = {
|
||||
method: 'POST',
|
||||
headers: myHeaders,
|
||||
body: raw,
|
||||
redirect: 'follow'
|
||||
};
|
||||
|
||||
fetch("https://yuanqfswhberkoevtmfr.supabase.co/functions/v1/get-available-slots", requestOptions)
|
||||
.then(response => response.json())
|
||||
.then(result => {console.log(result); sethorariosDisponiveis(result)})
|
||||
.catch(error => console.log('error', error));
|
||||
|
||||
}, [agendamento.dataAtendimento, agendamento.doctor_id])
|
||||
|
||||
|
||||
// FUNÇÃO DE BUSCA E FILTRAGEM
|
||||
const handleSearchProfissional = (e) => {
|
||||
const term = e.target.value;
|
||||
handleChange(e);
|
||||
// 2. Lógica de filtragem:
|
||||
if (term.trim() === '') {
|
||||
setProfissionaisFiltrados([]);
|
||||
setIsDropdownOpen(false);
|
||||
return;
|
||||
}
|
||||
// Adapte o nome da propriedade (ex: 'nome', 'full_name')
|
||||
const filtered = todosProfissionais.filter(p =>
|
||||
p.full_name.toLowerCase().includes(term.toLowerCase())
|
||||
);
|
||||
|
||||
setProfissionaisFiltrados(filtered);
|
||||
setIsDropdownOpen(filtered.length > 0); // Abre se houver resultados
|
||||
};
|
||||
|
||||
|
||||
// FUNÇÃO PARA SELECIONAR UM ITEM DO DROPDOWN
|
||||
const handleSelectProfissional = async (profissional) => {
|
||||
setAgendamento(prev => ({
|
||||
...prev,
|
||||
doctor_id: profissional.id,
|
||||
medico_nome: profissional.full_name
|
||||
}));
|
||||
// 2. Fecha o dropdown
|
||||
setProfissionaisFiltrados([]);
|
||||
setIsDropdownOpen(false);
|
||||
};
|
||||
|
||||
|
||||
const formatarHora = (datetimeString) => {
|
||||
return datetimeString.substring(11, 16);
|
||||
};
|
||||
|
||||
const opcoesDeHorario = horariosDisponiveis?.slots?.map(item => ({
|
||||
|
||||
value: formatarHora(item.datetime),
|
||||
label: formatarHora(item.datetime),
|
||||
disabled: !item.available
|
||||
}));
|
||||
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
alert("Agendamento salvo!");
|
||||
onSave(agendamento)
|
||||
onSave({...agendamento, horarioInicio:horarioInicio})
|
||||
};
|
||||
|
||||
return (
|
||||
@ -95,26 +179,21 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
||||
<h2 className="section-title">Informações do paciente</h2>
|
||||
|
||||
<div className="campos-informacoes-paciente" id="informacoes-paciente-linha-um">
|
||||
<div className="campo-de-input">
|
||||
<label>Nome *</label>
|
||||
<input type="text" name="nome" value={agendamento.nome} placeholder="Insira o nome do paciente" required onChange={handleChange} />
|
||||
</div>
|
||||
|
||||
<div className="campo-de-input">
|
||||
<label>CPF do paciente</label>
|
||||
|
||||
<input type="text" name="cpf" placeholder="000.000.000-00" onChange={handleChange} value={agendamento.cpf}/>
|
||||
<input type="text" name="paciente_cpf" placeholder="000.000.000-00" onChange={handleChange} value={agendamento.paciente_cpf}/>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div className="campos-informacoes-paciente" id="informacoes-paciente-linha-tres">
|
||||
|
||||
<div className="campo-de-input">
|
||||
<label>Nome *</label>
|
||||
<input type="text" name="paciente_nome" value={agendamento.paciente_nome} placeholder="Insira o nome do paciente" required onChange={handleChange} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="campos-informacoes-paciente" id="informacoes-paciente-linha-tres">
|
||||
|
||||
<div >
|
||||
<label>Convênio</label>
|
||||
<select name="convenio" onChange={handleChange}>
|
||||
<option value="publico">Público</option>
|
||||
@ -126,71 +205,53 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
||||
|
||||
</div>
|
||||
|
||||
<h3 className="section-subtitle">Informações adicionais</h3>
|
||||
|
||||
<label htmlFor="anexo-input" className="btn btn-secondary">Adicionar Anexo</label>
|
||||
<input
|
||||
type="file"
|
||||
id="anexo-input"
|
||||
className="d-none"
|
||||
onChange={(e) => setSelectedFile(e.target.files[0])}
|
||||
/>
|
||||
{selectedFile && (
|
||||
<button type="button" className="btn btn-primary ms-2" >
|
||||
Enviar
|
||||
</button>
|
||||
)}
|
||||
<div className="anexos-list">
|
||||
{loadingAnexos ? (
|
||||
<p>Carregando anexos...</p>
|
||||
) : (
|
||||
anexos.map((anexo, index) => (
|
||||
<div key={index} className="anexo-item">
|
||||
<span>{anexo.nome || anexo.fileName}</span>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
<h2 className="section-title">Informações do atendimento</h2>
|
||||
|
||||
|
||||
<div className="icons-container">
|
||||
|
||||
<div className={`icons-div ${ acessibilidade.cadeirante === true ? 'acessibilidade-ativado' : ''} `} id='cadeirante' onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
||||
|
||||
<span className="material-symbols-outlined icon">accessible</span>
|
||||
</div>
|
||||
|
||||
<div className={`icons-div ${acessibilidade.idoso === true ? 'acessibilidade-ativado' : ''}`} id="idoso" onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
||||
<span className="material-symbols-outlined icon">elderly</span>
|
||||
</div>
|
||||
|
||||
<div className={`icons-div ${acessibilidade.gravida === true ? 'acessibilidade-ativado' : ''}`} id="gravida" onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
||||
<span className="material-symbols-outlined icon">pregnant_woman</span>
|
||||
</div>
|
||||
|
||||
<div className={`icons-div ${acessibilidade.bebe === true ? 'acessibilidade-ativado' : ''}`} id="bebe" onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-baby-icon lucide-baby"><path d="M10 16c.5.3 1.2.5 2 .5s1.5-.2 2-.5"/><path d="M15 12h.01"/><path d="M19.38 6.813A9 9 0 0 1 20.8 10.2a2 2 0 0 1 0 3.6 9 9 0 0 1-17.6 0 2 2 0 0 1 0-3.6A9 9 0 0 1 12 3c2 0 3.5 1.1 3.5 2.5s-.9 2.5-2 2.5c-.8 0-1.5-.4-1.5-1"/><path d="M9 12h.01"/></svg>
|
||||
|
||||
</div>
|
||||
|
||||
<div className={`icons-div ${acessibilidade.autista === true ? 'acessibilidade-ativado' : ''}`} id="autista" onClick={(e) => handleclickAcessibilidade(e.currentTarget.id)}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.75" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-puzzle-icon lucide-puzzle"><path d="M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z"/></svg>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div className="campo-informacoes-atendimento">
|
||||
|
||||
<div className="campo-de-input-container"> {/* NOVO CONTAINER PAI */}
|
||||
<div className="campo-de-input">
|
||||
<label>Nome do profissional *</label>
|
||||
<input type="text" name="profissional" onChange={handleChange} value={agendamento.nome_medico}required />
|
||||
<input
|
||||
type="text"
|
||||
name="medico_nome" // Use o nome correto da propriedade no estado `agendamento`
|
||||
onChange={handleSearchProfissional}
|
||||
value={agendamento.medico_nome}
|
||||
autoComplete="off" // Ajuda a evitar o autocomplete nativo do navegador
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* DROPDOWN - RENDERIZAÇÃO CONDICIONAL */}
|
||||
{isDropdownOpen && profissionaisFiltrados.length > 0 && (
|
||||
<div className='dropdown-profissionais'>
|
||||
{profissionaisFiltrados.map((profissional) => (
|
||||
<div
|
||||
key={profissional.id} // Use o ID do profissional
|
||||
className='dropdown-item'
|
||||
onClick={() => handleSelectProfissional(profissional)}
|
||||
>
|
||||
{profissional.full_name}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="campo-de-input">
|
||||
<div className="tipo_atendimento">
|
||||
<label>Tipo de atendimento *</label>
|
||||
<input type="text" name="tipoAtendimento" required />
|
||||
<select onChange={handleChange} name="tipo_atendimento" >
|
||||
<option value="presencial" selected>Presencial</option>
|
||||
<option value="teleconsulta">Teleconsulta</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div className="form-check ">
|
||||
<input className="form-check-input checkbox-cstom" type="checkbox" name="status" onChange={handleChange} />
|
||||
<label className="form-check-label checkbox-label" htmlFor="vip">
|
||||
Fila de espera
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -211,30 +272,68 @@ const FormNovaConsulta = ({ onCancel, onSave, setAgendamento, agendamento }) =>
|
||||
|
||||
<div className="campo-de-input">
|
||||
<label>Data *</label>
|
||||
<input type="date" name="dataAtendimento" required />
|
||||
<input type="date" name="dataAtendimento" onChange={handleChange} required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="campo-informacoes-atendimento">
|
||||
|
||||
<div className="row">
|
||||
<div className="campo-de-input">
|
||||
<label>Início *</label>
|
||||
<input type="time" name="inicio" required />
|
||||
<label htmlFor="inicio">Início *</label>
|
||||
<select
|
||||
id="inicio"
|
||||
name="inicio"
|
||||
required
|
||||
value={horarioInicio}
|
||||
onChange={(e) => setHorarioInicio(e.target.value)}
|
||||
>
|
||||
<option value="" disabled>Selecione a hora de início</option>
|
||||
{opcoesDeHorario?.map((opcao, index) => (
|
||||
<option
|
||||
key={index}
|
||||
value={opcao.value}
|
||||
disabled={opcao.disabled}
|
||||
>
|
||||
{opcao.label}
|
||||
{opcao.disabled && " (Indisponível)"}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div className="campo-de-input">
|
||||
<label>Término *</label>
|
||||
<input type="time" name="termino" required />
|
||||
<div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{/* Dropdown de Término */}
|
||||
<div className="campo-de-input">
|
||||
<label>Profissional solicitante</label>
|
||||
<select name="solicitante">
|
||||
<option value="" disabled invisible selected>Selecione o solicitante</option>
|
||||
<option value="secretaria">Secretária</option>
|
||||
<option value="medico">Médico</option>
|
||||
<label htmlFor="termino">Término *</label>
|
||||
<select
|
||||
id="termino"
|
||||
name="termino"
|
||||
required
|
||||
value={horarioTermino}
|
||||
onChange={(e) => setHorarioTermino(e.target.value)}
|
||||
>
|
||||
<option value="" disabled>Selecione a hora de término</option>
|
||||
{opcoesDeHorario?.map((opcao, index) => (
|
||||
<option
|
||||
key={index}
|
||||
value={opcao.value}
|
||||
disabled={opcao.disabled}
|
||||
>
|
||||
{opcao.label}
|
||||
{opcao.disabled && " (Indisponível)"}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
<section className="informacoes-atendimento-segunda-linha-direita">
|
||||
|
||||
@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
|
||||
import CardConsulta from './CardConsulta';
|
||||
import "./style/styleTabelas/tabeladia.css";
|
||||
|
||||
const TabelaAgendamentoDia = ({ handleClickAgendamento, agendamentos, setShowDeleteModal }) => {
|
||||
const TabelaAgendamentoDia = ({ handleClickAgendamento, agendamentos, setShowDeleteModal, setDictInfo, setSelectedId }) => {
|
||||
const [indiceAcesso, setIndiceAcesso] = useState(0)
|
||||
const [Dia, setDia] = useState()
|
||||
const agendamentosDoDia = agendamentos?.semana1?.segunda || [];
|
||||
@ -24,7 +24,9 @@ const TabelaAgendamentoDia = ({ handleClickAgendamento, agendamentos, setShowDel
|
||||
<div>
|
||||
<div id='tabela-seletor-container'>
|
||||
<button onClick={() => {if(indiceAcesso === 0)return; else(setIndiceAcesso(indiceAcesso - 1))}}> <i className="bi bi-chevron-compact-left"></i></button>
|
||||
<p>{Dia}</p>
|
||||
|
||||
|
||||
<p>{Dia ? `${Dia?.split('-')[2]}/${Dia?.split('-')[1]}/${Dia?.split('-')[0]}`: ''}</p>
|
||||
<button onClick={() => {if(ListaDiasComAgendamentos.length - 1 === indiceAcesso)return; else(setIndiceAcesso(indiceAcesso + 1))}}> <i className="bi bi-chevron-compact-right"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
@ -37,16 +39,21 @@ const TabelaAgendamentoDia = ({ handleClickAgendamento, agendamentos, setShowDel
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{agendamentos[Dia]?.map((agendamento, index) => (
|
||||
{agendamentos[Dia]?.map((agendamento, index) => {
|
||||
|
||||
let Data =agendamento.scheduled_at.split("T")
|
||||
let horario = Data[1].split(':')
|
||||
return(
|
||||
<tr key={index}>
|
||||
<td><p>{agendamento.horario}</p></td>
|
||||
|
||||
<td><p>{`${horario[0]}:${horario[1]}`}</p></td>
|
||||
<td className='mostrar-horario'>
|
||||
<div onClick={() => handleClickAgendamento(agendamento)}>
|
||||
<CardConsulta DadosConsulta={agendamento} TabelaAgendamento={'dia'} setShowDeleteModal={setShowDeleteModal} />
|
||||
<CardConsulta DadosConsulta={agendamento} TabelaAgendamento={'dia'} setShowDeleteModal={setShowDeleteModal} setDictInfo={setDictInfo} setSelectedId={setSelectedId}/>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
)})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@ -6,7 +6,7 @@ import "./style/styleTabelas/tabelames.css";
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
const TabelaAgendamentoMes = ({ ListarDiasdoMes, agendamentos }) => {
|
||||
const TabelaAgendamentoMes = ({ ListarDiasdoMes, agendamentos, setShowDeleteModal, setSelectedId ,setDictInfo }) => {
|
||||
|
||||
const dataHoje = dayjs();
|
||||
const AnoAtual = dataHoje.year();
|
||||
@ -88,8 +88,6 @@ const TabelaAgendamentoMes = ({ ListarDiasdoMes, agendamentos }) => {
|
||||
|
||||
useEffect(() => {
|
||||
console.log(OrganizarAgendamentosMensais)
|
||||
|
||||
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
@ -185,11 +183,11 @@ const TabelaAgendamentoMes = ({ ListarDiasdoMes, agendamentos }) => {
|
||||
<table className='tabelamensal'>
|
||||
<thead>
|
||||
<tr>
|
||||
<td className='cabecalho-tabela'>Seg</td>
|
||||
<th>Ter</th>
|
||||
<th>Qua</th>
|
||||
<th>Qui</th>
|
||||
<th>Sex</th>
|
||||
<th className='cabecalho-tabela'>Segunda</th>
|
||||
<th>Terça</th>
|
||||
<th>Quarta</th>
|
||||
<th>Quinta</th>
|
||||
<th>Sexta</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -204,9 +202,9 @@ const TabelaAgendamentoMes = ({ ListarDiasdoMes, agendamentos }) => {
|
||||
{
|
||||
semana && typeof semana === "object" && Object.keys(semana).map((dia) => (
|
||||
<td key={dia} >
|
||||
<CardConsulta DadosConsulta={((semana[dia]|| [])[0]) || {status:'vazio'}}/>
|
||||
<CardConsulta DadosConsulta={((semana[dia]|| [])[1]) || {status:'vazio'}}/>
|
||||
<CardConsulta DadosConsulta={((semana[dia]|| [])[2]) || {status:'vazio'}}/>
|
||||
<CardConsulta DadosConsulta={((semana[dia]|| [])[0]) || {status:'vazio'}} setShowDeleteModal={setShowDeleteModal} setSelectedId={setSelectedId} setDictInfo={setDictInfo}/>
|
||||
<CardConsulta DadosConsulta={((semana[dia]|| [])[1]) || {status:'vazio'}} setShowDeleteModal={setShowDeleteModal} setSelectedId={setSelectedId} setDictInfo={setDictInfo}/>
|
||||
<CardConsulta DadosConsulta={((semana[dia]|| [])[2]) || {status:'vazio'}} setShowDeleteModal={setShowDeleteModal} setSelectedId={setSelectedId} setDictInfo={setDictInfo}/>
|
||||
{semana[dia].length > 3 ? (
|
||||
<div>
|
||||
<p>{` +${semana[dia].length - 2}`}</p>
|
||||
|
||||
@ -6,7 +6,7 @@ import { useEffect, useState, useMemo } from 'react';
|
||||
import weekOfYear from 'dayjs/plugin/weekOfYear'
|
||||
dayjs.extend(weekOfYear)
|
||||
|
||||
const TabelaAgendamentoSemana = ({ agendamentos, ListarDiasdoMes }) => {
|
||||
const TabelaAgendamentoSemana = ({ agendamentos, ListarDiasdoMes, setShowDeleteModal ,setSelectedId ,setDictInfo}) => {
|
||||
|
||||
// Armazena o objeto COMPLETO das semanas organizadas
|
||||
const [semanasOrganizadas, setSemanasOrganizadas] = useState({});
|
||||
@ -164,31 +164,31 @@ const TabelaAgendamentoSemana = ({ agendamentos, ListarDiasdoMes }) => {
|
||||
{/* Mapeamento de COLUNAS (dias) */}
|
||||
<td>
|
||||
{semanaParaRenderizar.segunda[indiceLinha]
|
||||
? <CardConsulta DadosConsulta={semanaParaRenderizar.segunda[indiceLinha]} />
|
||||
? <CardConsulta DadosConsulta={semanaParaRenderizar.segunda[indiceLinha]} setShowDeleteModal={setShowDeleteModal} setSelectedId={setSelectedId} setDictInfo={setDictInfo} />
|
||||
: null
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
{semanaParaRenderizar.terça[indiceLinha]
|
||||
? <CardConsulta DadosConsulta={semanaParaRenderizar.terça[indiceLinha]} />
|
||||
? <CardConsulta DadosConsulta={semanaParaRenderizar.terça[indiceLinha]} setShowDeleteModal={setShowDeleteModal} setSelectedId={setSelectedId} setDictInfo={setDictInfo}/>
|
||||
: null
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
{semanaParaRenderizar.quarta[indiceLinha]
|
||||
? <CardConsulta DadosConsulta={semanaParaRenderizar.quarta[indiceLinha]} />
|
||||
? <CardConsulta DadosConsulta={semanaParaRenderizar.quarta[indiceLinha]} setShowDeleteModal={setShowDeleteModal} setSelectedId={setSelectedId} setDictInfo={setDictInfo}/>
|
||||
: null
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
{semanaParaRenderizar.quinta[indiceLinha]
|
||||
? <CardConsulta DadosConsulta={semanaParaRenderizar.quinta[indiceLinha]} />
|
||||
? <CardConsulta DadosConsulta={semanaParaRenderizar.quinta[indiceLinha]} setShowDeleteModal={setShowDeleteModal} setSelectedId={setSelectedId} setDictInfo={setDictInfo} />
|
||||
: null
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
{semanaParaRenderizar.sexta[indiceLinha]
|
||||
? <CardConsulta DadosConsulta={semanaParaRenderizar.sexta[indiceLinha]} />
|
||||
? <CardConsulta DadosConsulta={semanaParaRenderizar.sexta[indiceLinha]} setShowDeleteModal={setShowDeleteModal} setSelectedId={setSelectedId} setDictInfo={setDictInfo} />
|
||||
: null
|
||||
}
|
||||
</td>
|
||||
|
||||
@ -304,3 +304,89 @@ html[data-bs-theme="dark"] .icon,
|
||||
html[data-bs-theme="dark"] svg {
|
||||
color: #e0e0e0 !important;
|
||||
}
|
||||
|
||||
/* CONTAINER PAI - ESSENCIAL PARA POSICIONAMENTO */
|
||||
.campo-de-input-container {
|
||||
position: relative; /* Define o contexto para o dropdown */
|
||||
/* ... outros estilos de layout (display, margin, etc.) ... */
|
||||
}
|
||||
|
||||
/* ESTILO DA LISTA DROPDOWN */
|
||||
.dropdown-profissionais {
|
||||
position: absolute; /* Flutua em relação ao pai (.campo-de-input-container) */
|
||||
top: 100%; /* Começa logo abaixo do input */
|
||||
left: 0;
|
||||
width: 100%; /* Ocupa toda a largura do container pai */
|
||||
|
||||
/* Estilos visuais */
|
||||
background-color: white;
|
||||
border: 1px solid #ccc;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
z-index: 100; /* Alto z-index para garantir que fique acima de outros elementos */
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* ESTILO DE CADA ITEM DO DROPDOWN */
|
||||
.dropdown-item {
|
||||
padding: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dropdown-item:hover {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.tipo_atendimento{
|
||||
margin-left: 3rem;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 1. Estilização Básica e Tamanho (Estado Padrão - Antes de Clicar) */
|
||||
.checkbox-customs {
|
||||
/* Remove a aparência padrão do navegador/Bootstrap */
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
|
||||
/* Define o tamanho desejado */
|
||||
width: 1.2rem; /* Ajuste conforme o seu gosto (ex: 1.2rem = 19.2px) */
|
||||
height: 1.2rem;
|
||||
|
||||
/* Define o visual "branco com borda preta" */
|
||||
background-color: #fff; /* Fundo branco */
|
||||
border: 1px solid #000; /* Borda preta de 1px */
|
||||
border-radius: 0.25rem; /* Borda levemente arredondada (opcional, imita Bootstrap) */
|
||||
|
||||
/* Centraliza o 'check' (quando aparecer) */
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
cursor: pointer; /* Indica que é clicável */
|
||||
|
||||
/* Adiciona a transição suave */
|
||||
transition: all 0.5s ease; /* Transição em 0.5 segundos para todas as propriedades */
|
||||
}
|
||||
|
||||
/* 2. Estilização no Estado Clicado (:checked) */
|
||||
.checkbox-customs:checked {
|
||||
/* Quando clicado, mantém o fundo branco (se quiser mudar, altere aqui) */
|
||||
background-color: #fff;
|
||||
|
||||
/* Se você quiser que a borda mude de cor ao clicar, altere aqui. */
|
||||
/* border-color: #007bff; */ /* Exemplo: borda azul */
|
||||
}
|
||||
|
||||
/* 3. Ocultar o 'Check' Padrão e Criar um Check Customizado */
|
||||
/* O Bootstrap/Navegador insere um ícone de 'check'. Vamos controlá-lo com background-image. */
|
||||
.checkbox-customs:checked {
|
||||
/* Este código do Bootstrap usa um SVG para o ícone de 'check' */
|
||||
/* Aqui, estamos forçando o ícone de 'check' a ser preto para combinar com a borda preta. */
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e");
|
||||
|
||||
/* Garante que o ícone fique centralizado e preencha o espaço */
|
||||
background-size: 100% 100%;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
@ -18,7 +18,7 @@
|
||||
/* Cabeçalho */
|
||||
.tabelamensal thead th {
|
||||
background-color: #0078d7;
|
||||
color: #0078d7;
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
border-bottom: 2px solid #0078d7; /* borda inferior mais forte no cabeçalho */
|
||||
}
|
||||
|
||||
@ -6,8 +6,8 @@ import TabelaAgendamentoDia from '../components/AgendarConsulta/TabelaAgendament
|
||||
import TabelaAgendamentoSemana from '../components/AgendarConsulta/TabelaAgendamentoSemana';
|
||||
import TabelaAgendamentoMes from '../components/AgendarConsulta/TabelaAgendamentoMes';
|
||||
import FormNovaConsulta from '../components/AgendarConsulta/FormNovaConsulta';
|
||||
|
||||
import { GetAllDoctors } from '../components/utils/Functions-Endpoints/Doctor.js';
|
||||
import { GetPatientByID } from '../components/utils/Functions-Endpoints/Patient.js';
|
||||
import { GetAllDoctors, GetDoctorByID } from '../components/utils/Functions-Endpoints/Doctor.js';
|
||||
|
||||
import { useAuth } from '../components/utils/AuthProvider.js';
|
||||
// ✨ NOVO: Caminho de importação corrigido com base na sua estrutura de pastas
|
||||
@ -21,9 +21,11 @@ import { Search } from 'lucide-react';
|
||||
|
||||
|
||||
|
||||
const Agendamento = () => {
|
||||
const Agendamento = ({setDictInfo}) => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [selectedID, setSelectedId] = useState('0')
|
||||
const [filaEsperaData, setfilaEsperaData] = useState([])
|
||||
const [FiladeEspera, setFiladeEspera] = useState(false);
|
||||
const [tabela, setTabela] = useState('diario');
|
||||
const [PageNovaConsulta, setPageConsulta] = useState(false);
|
||||
@ -42,29 +44,79 @@ const Agendamento = () => {
|
||||
|
||||
let authHeader = getAuthorizationHeader()
|
||||
|
||||
const FiltrarAgendamentos = (listaTodosAgendamentos) => {
|
||||
let DictAgendamentosOrganizados = {};
|
||||
const FiltrarAgendamentos = async (listaTodosAgendamentos) => {
|
||||
const ConfigurarFiladeEspera = async (patient_id, doctor_id, agendamento) => {
|
||||
// Assumindo que GetDoctorByID e GetPatientByID estão definidos no seu escopo
|
||||
let medico = await GetDoctorByID(doctor_id, authHeader);
|
||||
let paciente = await GetPatientByID(patient_id, authHeader);
|
||||
|
||||
for (let i = 0; i < listaTodosAgendamentos.length; i++) {
|
||||
const agendamento = listaTodosAgendamentos[i];
|
||||
let dicionario = {
|
||||
agendamento: agendamento,
|
||||
Infos: {
|
||||
nome_nedico: medico.full_name,
|
||||
doctor_id: medico.id,
|
||||
patient_id: paciente[0].id,
|
||||
paciente_nome: paciente[0].full_name,
|
||||
paciente_cpf: paciente[0].cpf
|
||||
}
|
||||
};
|
||||
return dicionario;
|
||||
};
|
||||
|
||||
let DictAgendamentosOrganizados = {};
|
||||
let ListaFilaDeEspera = [];
|
||||
|
||||
// 1. Agrupamento (igual ao seu código original)
|
||||
for (const agendamento of listaTodosAgendamentos) {
|
||||
if (agendamento.status === 'requested') {
|
||||
// Recomenda-se usar Promise.all para melhorar a performance
|
||||
// mas, para manter a estrutura, mantemos o await no loop.
|
||||
let v = await ConfigurarFiladeEspera(agendamento.patient_id, agendamento.doctor_id, agendamento);
|
||||
ListaFilaDeEspera.push(v);
|
||||
} else {
|
||||
const DiaAgendamento = agendamento.scheduled_at.split("T")[0];
|
||||
|
||||
//console.log(DictAgendamentosOrganizados)
|
||||
|
||||
if (DiaAgendamento in DictAgendamentosOrganizados) {
|
||||
// já existe a data → adiciona na lista
|
||||
DictAgendamentosOrganizados[DiaAgendamento].push(agendamento);
|
||||
} else {
|
||||
// não existe → cria nova key com uma lista
|
||||
DictAgendamentosOrganizados[DiaAgendamento] = [agendamento];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setAgendamentosOrganizados(DictAgendamentosOrganizados);
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// 2. Ordenação Interna: Ordenar os agendamentos por HORÁRIO (do menor para o maior)
|
||||
for (const DiaAgendamento in DictAgendamentosOrganizados) {
|
||||
DictAgendamentosOrganizados[DiaAgendamento].sort((a, b) => {
|
||||
// Compara as strings de data/hora (ISO 8601) diretamente,
|
||||
// que funcionam para ordenação cronológica.
|
||||
if (a.scheduled_at < b.scheduled_at) return -1;
|
||||
if (a.scheduled_at > b.scheduled_at) return 1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// 3. Ordenação Externa: Ordenar os DIAS (as chaves do objeto)
|
||||
// Para garantir que as chaves fiquem na sequência cronológica correta.
|
||||
|
||||
// Pega as chaves (datas)
|
||||
const chavesOrdenadas = Object.keys(DictAgendamentosOrganizados).sort((a, b) => {
|
||||
// Compara as chaves de data (strings 'YYYY-MM-DD')
|
||||
if (a < b) return -1;
|
||||
if (a > b) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
// Cria um novo objeto no formato desejado, garantindo a ordem das chaves
|
||||
let DictAgendamentosFinal = {};
|
||||
for (const data of chavesOrdenadas) {
|
||||
DictAgendamentosFinal[data] = DictAgendamentosOrganizados[data];
|
||||
}
|
||||
setAgendamentosOrganizados(DictAgendamentosFinal); // Use o objeto final ordenado
|
||||
setfilaEsperaData(ListaFilaDeEspera);
|
||||
};
|
||||
|
||||
// Requisição inicial para mostrar os agendamentos do banco de dados
|
||||
useEffect(() => {
|
||||
var myHeaders = new Headers();
|
||||
@ -86,7 +138,6 @@ const Agendamento = () => {
|
||||
let lista = []
|
||||
const TodosOsMedicos = await GetAllDoctors(authHeader)
|
||||
|
||||
//console.log(TodosOsMedicos, "tentativa")
|
||||
for(let d = 0; TodosOsMedicos.length > d; d++){
|
||||
lista.push({nomeMedico: TodosOsMedicos[d].full_name, idMedico: TodosOsMedicos[d].id })}
|
||||
setListaDeMedicos(lista)
|
||||
@ -96,44 +147,42 @@ const Agendamento = () => {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
console.log("mudou FiltredTodosMedicos:", FiltredTodosMedicos);
|
||||
|
||||
if (FiltredTodosMedicos.length === 1) {
|
||||
|
||||
const unicoMedico = FiltredTodosMedicos[0];
|
||||
console.log(unicoMedico)
|
||||
|
||||
const idMedicoFiltrado = unicoMedico.idMedico;
|
||||
|
||||
console.log(`Médico único encontrado: ${unicoMedico.nomeMedico}. ID: ${idMedicoFiltrado}`);
|
||||
|
||||
|
||||
|
||||
const agendamentosDoMedico = filtrarAgendamentosPorMedico(
|
||||
DictAgendamentosOrganizados,
|
||||
idMedicoFiltrado
|
||||
);
|
||||
|
||||
// =========================================================================
|
||||
|
||||
console.log(`Total de agendamentos filtrados para este médico: ${agendamentosDoMedico.length}`);
|
||||
console.log("Lista completa de Agendamentos do Médico:", agendamentosDoMedico);
|
||||
FiltrarAgendamentos(agendamentosDoMedico)
|
||||
|
||||
|
||||
// AQUI VOCÊ PODE APLICAR SUA LÓGICA FINAL:
|
||||
// Ex: setar um novo estado com os agendamentos filtrados, se for necessário:
|
||||
// setAgendamentosFiltrados(agendamentosDoMedico);
|
||||
|
||||
|
||||
} else {
|
||||
// Opcional: Limpar a lista filtrada se a busca não for mais única
|
||||
// setAgendamentosFiltrados([]);
|
||||
}
|
||||
|
||||
}, [FiltredTodosMedicos]);
|
||||
|
||||
const deleteConsulta = (selectedPatientId) => {
|
||||
console.log("tentando apagar")
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append("Authorization", authHeader);
|
||||
myHeaders.append("apikey", API_KEY)
|
||||
|
||||
var requestOptions = {
|
||||
method: 'DELETE',
|
||||
redirect: 'follow',
|
||||
headers: myHeaders
|
||||
};
|
||||
|
||||
fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?id=eq.${selectedPatientId}`, requestOptions)
|
||||
.then(response => response.json())
|
||||
.then(result => console.log(result))
|
||||
.catch(error => console.log('error', error));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -160,27 +209,6 @@ const filtrarAgendamentosPorMedico = (dictAgendamentos, idMedicoFiltrado) => {
|
||||
|
||||
|
||||
|
||||
|
||||
// Dados da fila de espera (sem alteração)
|
||||
const filaEsperaData = [
|
||||
{ nome: 'Ricardo Pereira', email: 'ricardo.pereira@gmail.com', cpf: '444.777.666-55', telefone: '(79) 99123-4567', entrada: '25/09/2025 às 08:00' },
|
||||
{ nome: 'Ana Costa', email: 'ana.costa@gmail.com', cpf: '321.654.987-00', telefone: '(79) 97777-3333', entrada: '25/09/2025 às 08:30' },
|
||||
{ nome: 'Lucas Martins', email: 'lucas.martins@gmail.com', cpf: '777.666.555-33', telefone: '(79) 99654-3210', entrada: '25/09/2025 às 09:00' },
|
||||
{ nome: 'João Souza', email: 'joao.souza@gmail.com', cpf: '987.654.321-00', telefone: '(79) 98888-2222', entrada: '25/09/2025 às 14:00' },
|
||||
{ nome: 'Maria Silva', email: 'maria.silva@gmail.com', cpf: '123.456.789-00', telefone: '(79) 99999-1111', entrada: '25/09/2025 às 14:30' },
|
||||
{ nome: 'Fernanda Lima', email: 'fernanda.lima@gmail.com', cpf: '888.999.000-22', telefone: '(79) 98877-6655', entrada: '26/09/2025 às 09:30' },
|
||||
{ nome: 'Carlos Andrade', email: 'carlos.andrade@gmail.com', cpf: '222.555.888-11', telefone: '(79) 99876-5432', entrada: '26/09/2025 às 10:00' },
|
||||
{ nome: 'Juliana Oliveira', email: 'juliana.o@gmail.com', cpf: '111.222.333-44', telefone: '(79) 98765-1234', entrada: '26/09/2025 às 11:30' },
|
||||
];
|
||||
|
||||
// Filtro da fila de espera (sem alteração)
|
||||
const filteredFila = filaEsperaData.filter(item =>
|
||||
item.nome.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
||||
item.email.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
||||
item.cpf.includes(searchTerm) ||
|
||||
item.telefone.includes(searchTerm)
|
||||
);
|
||||
|
||||
// Lógica para filtrar os dados da AGENDA (AgendamentosMes)
|
||||
const filteredAgendamentos = useMemo(() => {
|
||||
if (!searchTerm.trim()) {
|
||||
@ -253,6 +281,10 @@ const handleSearchMedicos = (term) => {
|
||||
Mudar Disponibilidade
|
||||
</button>
|
||||
|
||||
<button onClick={() => setPageConsulta(true)}>
|
||||
Adcionar consulta
|
||||
</button>
|
||||
|
||||
{!PageNovaConsulta ? (
|
||||
<div className='atendimento-eprocura'>
|
||||
|
||||
@ -351,9 +383,9 @@ const handleSearchMedicos = (term) => {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{tabela === "diario" && <TabelaAgendamentoDia handleClickAgendamento={handleClickAgendamento} agendamentos={DictAgendamentosOrganizados} setShowDeleteModal={setShowDeleteModal} />}
|
||||
{tabela === 'semanal' && <TabelaAgendamentoSemana agendamentos={DictAgendamentosOrganizados} ListarDiasdoMes={ListarDiasdoMes}/>}
|
||||
{tabela === 'mensal' && <TabelaAgendamentoMes ListarDiasdoMes={ListarDiasdoMes} aplicarCores={true} agendamentos={DictAgendamentosOrganizados} />}
|
||||
{tabela === "diario" && <TabelaAgendamentoDia handleClickAgendamento={handleClickAgendamento} agendamentos={DictAgendamentosOrganizados} setShowDeleteModal={setShowDeleteModal} setSelectedId={setSelectedId} setDictInfo={setDictInfo} />}
|
||||
{tabela === 'semanal' && <TabelaAgendamentoSemana agendamentos={DictAgendamentosOrganizados} ListarDiasdoMes={ListarDiasdoMes} setShowDeleteModal={setShowDeleteModal} setSelectedId={setSelectedId} setDictInfo={setDictInfo}/>}
|
||||
{tabela === 'mensal' && <TabelaAgendamentoMes ListarDiasdoMes={ListarDiasdoMes} aplicarCores={true} agendamentos={DictAgendamentosOrganizados} setShowDeleteModal={setShowDeleteModal} setSelectedId={setSelectedId} setDictInfo={setDictInfo} />}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
@ -374,20 +406,43 @@ const handleSearchMedicos = (term) => {
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome</th>
|
||||
<th>Email</th>
|
||||
<th>CPF</th>
|
||||
<th>Telefone</th>
|
||||
|
||||
<th>Telefone</th>
|
||||
<th>Entrou na fila de espera</th>
|
||||
<th>Ações</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{filteredFila.map((item, index) => (
|
||||
{filaEsperaData.map((item, index) => (
|
||||
<tr key={index}>
|
||||
<td>{item.nome}</td>
|
||||
<td>{item.email}</td>
|
||||
<td>{item.cpf}</td>
|
||||
<td>{item.telefone}</td>
|
||||
<td>{item.entrada}</td>
|
||||
<td> <p>{item.Infos?.paciente_nome} </p> </td>
|
||||
<td><p>{} </p></td>
|
||||
<td>{}</td>
|
||||
<td>{}</td>
|
||||
<td> <div className="d-flex gap-2">
|
||||
|
||||
<button className="btn btn-sm btn-edit"
|
||||
onClick={() => {
|
||||
console.log(item, 'item')
|
||||
navigate(`${2}/edit`)
|
||||
setDictInfo(item)
|
||||
}}
|
||||
>
|
||||
<i className="bi bi-pencil me-1"></i> Editar
|
||||
</button>
|
||||
|
||||
|
||||
<button
|
||||
className="btn btn-sm btn-delete"
|
||||
onClick={() => {
|
||||
setSelectedId(item.agendamento.id)
|
||||
setShowDeleteModal(true);
|
||||
}}
|
||||
>
|
||||
<i className="bi bi-trash me-1"></i> Excluir
|
||||
</button>
|
||||
</div></td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@ -429,7 +484,7 @@ const handleSearchMedicos = (term) => {
|
||||
|
||||
<div className="modal-body">
|
||||
<p className="mb-0 fs-5">
|
||||
Tem certeza que deseja excluir este paciente?
|
||||
Tem certeza que deseja excluir este agendamento?
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@ -447,7 +502,8 @@ const handleSearchMedicos = (term) => {
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-danger"
|
||||
//onClick={() => deletePatient(selectedPatientId)}
|
||||
onClick={() => {deleteConsulta(selectedID);setShowDeleteModal(false)}}
|
||||
|
||||
>
|
||||
<i className="bi bi-trash me-1"></i> Excluir
|
||||
</button>
|
||||
|
||||
@ -2,17 +2,33 @@ import React from 'react'
|
||||
import FormNovaConsulta from '../components/AgendarConsulta/FormNovaConsulta'
|
||||
import API_KEY from '../components/utils/apiKeys'
|
||||
import { useAuth } from '../components/utils/AuthProvider'
|
||||
import { useState } from 'react'
|
||||
import { useEffect,useState } from 'react'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
import { UserInfos } from '../components/utils/Functions-Endpoints/General'
|
||||
const AgendamentoCadastroManager = () => {
|
||||
|
||||
const {getAuthorizationHeader} = useAuth()
|
||||
const [agendamento, setAgendamento] = useState({})
|
||||
|
||||
const [agendamento, setAgendamento] = useState({status:'confirmed'})
|
||||
const [idUsuario, setIDusuario] = useState('0')
|
||||
|
||||
let authHeader = getAuthorizationHeader()
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
const ColherInfoUsuario =async () => {
|
||||
const result = await UserInfos(authHeader)
|
||||
|
||||
setIDusuario(result?.profile?.id)
|
||||
|
||||
}
|
||||
ColherInfoUsuario()
|
||||
|
||||
|
||||
}, [])
|
||||
|
||||
|
||||
|
||||
const handleSave = (Dict) => {
|
||||
let DataAtual = dayjs()
|
||||
var myHeaders = new Headers();
|
||||
@ -23,13 +39,14 @@ const AgendamentoCadastroManager = () => {
|
||||
var raw = JSON.stringify({
|
||||
"patient_id": Dict.patient_id,
|
||||
"doctor_id": Dict.doctor_id,
|
||||
"scheduled_at": DataAtual,
|
||||
"scheduled_at": `${Dict.dataAtendimento}T${Dict.horarioInicio}:00.000Z`,
|
||||
"duration_minutes": 30,
|
||||
"appointment_type": "presencial",
|
||||
"chief_complaint": "Dor de cabeça há 3 ",
|
||||
"appointment_type": Dict.tipo_consulta,
|
||||
|
||||
"patient_notes": "Prefiro horário pela manhã",
|
||||
"insurance_provider": "Unimed",
|
||||
"created_by": "87f2662c-9da7-45c0-9e05-521d9d92d105"
|
||||
"insurance_provider": Dict.convenio,
|
||||
"status": Dict.status,
|
||||
"created_by": idUsuario
|
||||
});
|
||||
|
||||
var requestOptions = {
|
||||
|
||||
@ -1,22 +1,41 @@
|
||||
import React from 'react'
|
||||
import FormNovaConsulta from '../components/AgendarConsulta/FormNovaConsulta'
|
||||
import { useState } from 'react'
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import API_KEY from '../components/utils/apiKeys'
|
||||
import { useAuth } from '../components/utils/AuthProvider'
|
||||
import dayjs from 'dayjs'
|
||||
import { UserInfos } from '../components/utils/Functions-Endpoints/General'
|
||||
|
||||
const AgendamentoEditPage = ({setDictInfo, DictInfo}) => {
|
||||
|
||||
const AgendamentoEditPage = () => {
|
||||
|
||||
let DataAtual = dayjs()
|
||||
const [idUsuario, setIDusuario] = useState('0')
|
||||
//let DataAtual = dayjs()
|
||||
const {getAuthorizationHeader} = useAuth()
|
||||
const params = useParams()
|
||||
const [PatientToPatch, setPatientToPatch] = useState({})
|
||||
|
||||
let id = params.id
|
||||
|
||||
console.log(id)
|
||||
//console.log(DictInfo, 'aqui')
|
||||
|
||||
useEffect(() => {
|
||||
setDictInfo({...DictInfo?.Infos,...DictInfo?.agendamento})
|
||||
|
||||
|
||||
const ColherInfoUsuario =async () => {
|
||||
const result = await UserInfos(authHeader)
|
||||
|
||||
setIDusuario(result?.profile?.id)
|
||||
|
||||
}
|
||||
ColherInfoUsuario()
|
||||
|
||||
|
||||
|
||||
}, [])
|
||||
|
||||
|
||||
|
||||
let authHeader = getAuthorizationHeader()
|
||||
|
||||
@ -30,13 +49,21 @@ const AgendamentoEditPage = () => {
|
||||
|
||||
var raw = JSON.stringify({"patient_id": DictParaPatch.patient_id,
|
||||
"doctor_id": DictParaPatch.doctor_id,
|
||||
"scheduled_at": DataAtual,
|
||||
|
||||
"duration_minutes": 30,
|
||||
"appointment_type": "presencial",
|
||||
|
||||
"chief_complaint": "Dor de cabeça há 3 ",
|
||||
|
||||
"created_by": idUsuario,
|
||||
|
||||
"scheduled_at": `${DictParaPatch.dataAtendimento}T${DictParaPatch.horarioInicio}:00.000Z`,
|
||||
|
||||
"appointment_type": DictParaPatch.tipo_consulta,
|
||||
|
||||
"patient_notes": "Prefiro horário pela manhã",
|
||||
"insurance_provider": "Unimed",
|
||||
"created_by": "87f2662c-9da7-45c0-9e05-521d9d92d105"
|
||||
"insurance_provider": DictParaPatch.convenio,
|
||||
"status": DictParaPatch.status,
|
||||
"created_by": idUsuario
|
||||
|
||||
|
||||
});
|
||||
@ -51,7 +78,7 @@ const AgendamentoEditPage = () => {
|
||||
redirect: 'follow'
|
||||
};
|
||||
|
||||
fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/appointments?id=eq.${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));
|
||||
@ -60,7 +87,7 @@ const AgendamentoEditPage = () => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<FormNovaConsulta onSave={handleSave} agendamento={PatientToPatch} setAgendamento={setPatientToPatch}/>
|
||||
<FormNovaConsulta onSave={handleSave} agendamento={DictInfo} setAgendamento={setDictInfo}/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@ -104,7 +104,7 @@ function TableDoctor() {
|
||||
|
||||
fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/doctors", requestOptions)
|
||||
.then(response => response.json())
|
||||
.then(result => setMedicos(result))
|
||||
.then(result => {setMedicos(result); console.log(result)})
|
||||
.catch(error => console.log('error', error));
|
||||
}, [isAuthenticated, getAuthorizationHeader]);
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@
|
||||
background-color: #2c5e37;
|
||||
}
|
||||
|
||||
.legenda-item-confirmado{
|
||||
.legenda-item-confirmed{
|
||||
background-color: #1e90ff;
|
||||
}
|
||||
.legenda-item-cancelado{
|
||||
@ -102,7 +102,7 @@
|
||||
background-color: #f0ad4e;
|
||||
}
|
||||
|
||||
#status-card-consulta-realizado, .legenda-item-realizado {
|
||||
#status-card-consulta-completed, .legenda-item-realizado {
|
||||
background-color: #b7ffbd;
|
||||
border:3px solid #91d392;
|
||||
padding: 5px;
|
||||
@ -110,7 +110,7 @@
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#status-card-consulta-cancelado, .legenda-item-cancelado {
|
||||
#status-card-consulta-cancelled, .legenda-item-cancelado {
|
||||
background-color: #ffb7cc;
|
||||
border:3px solid #ff6c84;
|
||||
padding: 5px;
|
||||
@ -118,7 +118,7 @@
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#status-card-consulta-confirmado, .legenda-item-confirmed {
|
||||
#status-card-consulta-confirmed, .legenda-item-confirmed {
|
||||
background-color: #eef8fb;
|
||||
border:3px solid #d8dfe7;
|
||||
padding: 5px;
|
||||
@ -358,26 +358,18 @@ html[data-bs-theme="dark"] {
|
||||
#tabela-seletor-container i {
|
||||
pointer-events: none;
|
||||
}
|
||||
/* 1. Contêiner de Limitação de Largura e Posicionamento */
|
||||
/* Este é o elemento mais importante. Ele deve envolver o input e o dropdown. */
|
||||
|
||||
|
||||
.input-e-dropdown-wrapper {
|
||||
position: relative;
|
||||
|
||||
/* IMPORTANTE: Defina aqui a largura EXATA que você deseja para o input
|
||||
e para o dropdown. Na sua imagem, o input parece ter cerca de 300px ou mais.
|
||||
*/
|
||||
width: 350px; /* Ajuste este valor conforme a largura desejada do seu input */
|
||||
|
||||
/* Se o input original estava alinhado à direita (como na imagem),
|
||||
você pode precisar de um float ou margin para posicionar este wrapper.
|
||||
*/
|
||||
margin-left: auto; /* Exemplo para alinhar o wrapper à direita se for o caso */
|
||||
width: 350px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
/* 2. Estilização da Área de Busca (Input) */
|
||||
/* Garante que o input utilize toda a largura do wrapper */
|
||||
.busca-atendimento {
|
||||
/* ... seus estilos de layout (flex, margin, etc.) para o busca-atendimento, se houver ... */
|
||||
|
||||
}
|
||||
|
||||
.busca-atendimento > div {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
|
||||
import { Routes, Route } from "react-router-dom";
|
||||
|
||||
import { useState } from "react";
|
||||
import Sidebar from "../../components/Sidebar";
|
||||
import FinanceiroDashboard from "../../pages/FinanceiroDashboard";
|
||||
import SecretariaItems from "../../data/sidebar-items-secretaria.json";
|
||||
@ -19,6 +19,7 @@ import ExcecoesDisponibilidade from "../../pages/ExcecoesDisponibilidade";
|
||||
import AgendamentoEditPage from "../../pages/AgendamentoEditPage";
|
||||
|
||||
function PerfilSecretaria({ onLogout }) {
|
||||
const [DictInfo, setDictInfo] = useState({})
|
||||
return (
|
||||
// <Router>
|
||||
<div id="app" className="active">
|
||||
@ -34,8 +35,8 @@ function PerfilSecretaria({ onLogout }) {
|
||||
<Route path="pacientes/:id/edit" element={<EditPage />} />
|
||||
<Route path="medicos/:id" element={<DoctorDetails />} />
|
||||
<Route path="medicos/:id/edit" element={<DoctorEditPage />} />
|
||||
<Route path="agendamento" element={<Agendamento />} />
|
||||
<Route path="agendamento/:id/edit" element={<AgendamentoEditPage/>} />
|
||||
<Route path="agendamento" element={<Agendamento setDictInfo={setDictInfo}/>} />
|
||||
<Route path="agendamento/:id/edit" element={<AgendamentoEditPage setDictInfo={setDictInfo} DictInfo={DictInfo}/>} />
|
||||
<Route path="laudo" element={<LaudoManager />} />
|
||||
<Route path="*" element={<h2>Página não encontrada</h2>} />
|
||||
<Route path="excecoes-disponibilidade" element={<ExcecoesDisponibilidade />} />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user