Resolucao de conflitos
This commit is contained in:
parent
6312a72895
commit
ef7ef93887
6250
package-lock.json
generated
6250
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -135,200 +135,19 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
setAppointmentToCancel(null);
|
setAppointmentToCancel(null);
|
||||||
setCancellationReason('');
|
setCancellationReason('');
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if (success) {
|
if (success) {
|
||||||
alert("Solicitação cancelada com sucesso!");
|
alert("Solicitação cancelada com sucesso!");
|
||||||
=======
|
|
||||||
const [searchConsultas, setSearchConsultas] = useState('');
|
|
||||||
const [searchFilaEspera, setSearchFilaEspera] = useState('');
|
|
||||||
|
|
||||||
|
|
||||||
const [waitPage, setWaitPage] = useState(1);
|
|
||||||
const [waitPerPage, setWaitPerPage] = useState(10);
|
|
||||||
const [waitSortKey, setWaitSortKey] = useState(null);
|
|
||||||
const [waitSortDir, setWaitSortDir] = useState('asc');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const [isCancelModalOpen, setIsCancelModalOpen] = useState(false);
|
|
||||||
const [appointmentToCancel, setAppointmentToCancel] = useState(null);
|
|
||||||
const [cancellationReason, setCancellationReason] = useState('');
|
|
||||||
|
|
||||||
const authHeader = useMemo(() => getAuthorizationHeader(), [getAuthorizationHeader]);
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
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.");
|
||||||
=======
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const handleCancelClick = (appointmentId) => {
|
|
||||||
setAppointmentToCancel(appointmentId);
|
|
||||||
setCancellationReason('');
|
|
||||||
setIsCancelModalOpen(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const executeCancellation = async () => {
|
|
||||||
if (!appointmentToCancel) return;
|
|
||||||
|
|
||||||
setIsLoading(true);
|
|
||||||
|
|
||||||
|
|
||||||
const motivo = cancellationReason.trim() || "Cancelado pelo paciente (motivo não especificado)";
|
|
||||||
|
|
||||||
const success = await updateAppointmentStatus(appointmentToCancel, {
|
|
||||||
status: "cancelled",
|
|
||||||
cancellation_reason: motivo,
|
|
||||||
updated_at: new Date().toISOString()
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
setIsCancelModalOpen(false);
|
|
||||||
setAppointmentToCancel(null);
|
|
||||||
setCancellationReason('');
|
|
||||||
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
alert("Solicitação cancelada com sucesso!");
|
|
||||||
|
|
||||||
setDictAgendamentosOrganizados(prev => {
|
|
||||||
const newDict = { ...prev };
|
|
||||||
for (const date in newDict) {
|
|
||||||
newDict[date] = newDict[date].filter(app => app.id !== appointmentToCancel);
|
|
||||||
}
|
|
||||||
return newDict;
|
|
||||||
});
|
|
||||||
setFilaDeEsperaData(prev => prev.filter(item => item.agendamento.id !== appointmentToCancel));
|
|
||||||
} else {
|
|
||||||
alert("Falha ao cancelar a solicitação.");
|
|
||||||
}
|
|
||||||
setIsLoading(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const handleQuickJumpChange = (type, value) => setQuickJump(prev => ({ ...prev, [type]: Number(value) }));
|
|
||||||
const applyQuickJump = () => {
|
|
||||||
const newDate = dayjs().year(quickJump.year).month(quickJump.month).date(1);
|
|
||||||
setCurrentDate(newDate);
|
|
||||||
setSelectedDay(newDate);
|
|
||||||
};
|
|
||||||
const dateGrid = useMemo(() => {
|
|
||||||
const grid = [];
|
|
||||||
const startOfMonth = currentDate.startOf('month');
|
|
||||||
let currentDay = startOfMonth.subtract(startOfMonth.day(), 'day');
|
|
||||||
for (let i = 0; i < 42; i++) {
|
|
||||||
grid.push(currentDay);
|
|
||||||
currentDay = currentDay.add(1, 'day');
|
|
||||||
}
|
|
||||||
return grid;
|
|
||||||
}, [currentDate]);
|
|
||||||
const weekDays = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'];
|
|
||||||
const handleDateClick = (day) => setSelectedDay(day);
|
|
||||||
|
|
||||||
|
|
||||||
const consultasDoDiaFiltradas = useMemo(() => {
|
|
||||||
const consultas = DictAgendamentosOrganizados[selectedDay.format('YYYY-MM-DD')] || [];
|
|
||||||
if (!searchConsultas.trim()) return consultas;
|
|
||||||
const term = searchConsultas.toLowerCase();
|
|
||||||
return consultas.filter(app =>
|
|
||||||
app.medico_nome?.toLowerCase().includes(term) ||
|
|
||||||
app.status?.toLowerCase().includes(term)
|
|
||||||
);
|
|
||||||
}, [DictAgendamentosOrganizados, selectedDay, searchConsultas]);
|
|
||||||
|
|
||||||
|
|
||||||
const filaEsperaFiltrada = useMemo(() => {
|
|
||||||
if (!searchFilaEspera.trim()) return filaEsperaData;
|
|
||||||
const term = searchFilaEspera.toLowerCase();
|
|
||||||
return filaEsperaData.filter(item =>
|
|
||||||
item.Infos?.medico_nome?.toLowerCase().includes(term)
|
|
||||||
);
|
|
||||||
}, [filaEsperaData, searchFilaEspera]);
|
|
||||||
|
|
||||||
const applySortingWaitlist = (arr) => {
|
|
||||||
if (!Array.isArray(arr) || !waitSortKey) return arr;
|
|
||||||
const copy = [...arr];
|
|
||||||
if (waitSortKey === 'medico') {
|
|
||||||
copy.sort((a, b) => (a?.Infos?.medico_nome || '').localeCompare(b?.Infos?.medico_nome || ''));
|
|
||||||
} else if (waitSortKey === 'data') {
|
|
||||||
copy.sort((a, b) => new Date(a?.agendamento?.created_at || 0) - new Date(b?.agendamento?.created_at || 0));
|
|
||||||
}
|
|
||||||
if (waitSortDir === 'desc') copy.reverse();
|
|
||||||
return copy;
|
|
||||||
};
|
|
||||||
|
|
||||||
const filaEsperaOrdenada = applySortingWaitlist(filaEsperaFiltrada);
|
|
||||||
|
|
||||||
// Paginação
|
|
||||||
const waitTotalPages = Math.ceil(filaEsperaOrdenada.length / waitPerPage) || 1;
|
|
||||||
const waitIndiceInicial = (waitPage - 1) * waitPerPage;
|
|
||||||
const waitIndiceFinal = waitIndiceInicial + waitPerPage;
|
|
||||||
const filaEsperaPaginada = filaEsperaOrdenada.slice(waitIndiceInicial, waitIndiceFinal);
|
|
||||||
|
|
||||||
const gerarNumerosWaitPages = () => {
|
|
||||||
const paginas = [];
|
|
||||||
const paginasParaMostrar = 5;
|
|
||||||
let inicio = Math.max(1, waitPage - Math.floor(paginasParaMostrar / 2));
|
|
||||||
let fim = Math.min(waitTotalPages, inicio + paginasParaMostrar - 1);
|
|
||||||
inicio = Math.max(1, fim - paginasParaMostrar + 1);
|
|
||||||
for (let i = inicio; i <= fim; i++) {
|
|
||||||
paginas.push(i);
|
|
||||||
}
|
|
||||||
return paginas;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setWaitPage(1);
|
|
||||||
}, [searchFilaEspera, waitSortKey, waitSortDir]);
|
|
||||||
|
|
||||||
const activeButtonStyle = {
|
|
||||||
backgroundColor: '#1B2A41',
|
|
||||||
color: 'white',
|
|
||||||
padding: '6px 12px',
|
|
||||||
fontSize: '0.875rem',
|
|
||||||
borderRadius: '8px',
|
|
||||||
border: '1px solid white',
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
gap: '8px',
|
|
||||||
cursor: 'pointer'
|
|
||||||
};
|
|
||||||
|
|
||||||
const inactiveButtonStyle = {
|
|
||||||
backgroundColor: '#1B2A41',
|
|
||||||
color: 'white',
|
|
||||||
padding: '6px 12px',
|
|
||||||
fontSize: '0.875rem',
|
|
||||||
borderRadius: '8px',
|
|
||||||
border: '1px solid #1B2A41',
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
gap: '8px',
|
|
||||||
cursor: 'pointer'
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return (
|
|
||||||
<div className="form-container" style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '50vh' }}>
|
|
||||||
<Spinner />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
}
|
}
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
};
|
};
|
||||||
@ -354,7 +173,6 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<<<<<<< HEAD
|
|
||||||
<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>
|
||||||
@ -439,310 +257,6 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
</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>
|
|
||||||
<h1>Minhas consultas</h1>
|
|
||||||
<div className="btns-gerenciamento-e-consulta" style={{ display: 'flex', gap: '10px', marginBottom: '20px' }}>
|
|
||||||
|
|
||||||
<button
|
|
||||||
style={PageNovaConsulta ? activeButtonStyle : inactiveButtonStyle}
|
|
||||||
onClick={() => {
|
|
||||||
setPageConsulta(true);
|
|
||||||
setFiladeEspera(false);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<i className="bi bi-plus-circle"></i> Solicitar Agendamento
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
style={FiladeEspera && !PageNovaConsulta ? activeButtonStyle : inactiveButtonStyle}
|
|
||||||
onClick={() => {
|
|
||||||
setFiladeEspera(!FiladeEspera);
|
|
||||||
setPageConsulta(false);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<i className="bi bi-list-task me-1"></i> Fila de Espera ({filaEsperaData.length})
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{!PageNovaConsulta ? (
|
|
||||||
<div className='atendimento-eprocura'>
|
|
||||||
<section className='calendario-ou-filaespera'>
|
|
||||||
{!FiladeEspera ? (
|
|
||||||
|
|
||||||
<div className="calendar-wrapper">
|
|
||||||
<div className="calendar-info-panel">
|
|
||||||
<div className="info-date-display"><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="mb-3">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control form-control-sm"
|
|
||||||
placeholder="Buscar por médico ou status..."
|
|
||||||
value={searchConsultas}
|
|
||||||
onChange={(e) => setSearchConsultas(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="appointments-list">
|
|
||||||
<h4>Consultas para {selectedDay.format('DD/MM')}</h4>
|
|
||||||
{(consultasDoDiaFiltradas.length > 0) ? (
|
|
||||||
consultasDoDiaFiltradas.map(app => (
|
|
||||||
<div key={app.id} className="appointment-item" data-status={app.status}>
|
|
||||||
<div className="item-time">{dayjs(app.scheduled_at).format('HH:mm')}</div>
|
|
||||||
<div className="item-details">
|
|
||||||
<span>Consulta com Dr(a). {app.medico_nome}</span>
|
|
||||||
</div>
|
|
||||||
<div className='item-actions'>
|
|
||||||
{app.status !== 'cancelled' && dayjs(app.scheduled_at).isAfter(dayjs()) && (
|
|
||||||
<button className="btn btn-sm btn-outline-danger" onClick={() => handleCancelClick(app.id)} title="Cancelar Consulta">
|
|
||||||
<Trash2 size={16} />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))
|
|
||||||
) : (<div className="no-appointments-info"><p>Nenhuma consulta agendada para esta data.</p></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="date-indicator">
|
|
||||||
<h2>{currentDate.format('MMMM [de] YYYY')}</h2>
|
|
||||||
<div className="quick-jump-controls" 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 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>
|
|
||||||
<button className="btn btn-sm btn-outline-primary" onClick={applyQuickJump} disabled={quickJump.month === currentDate.month() && quickJump.year === currentDate.year()}>Ir</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="nav-buttons">
|
|
||||||
<button onClick={() => setCurrentDate(c => c.subtract(1, 'month'))}><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 className="calendar-grid">
|
|
||||||
{weekDays.map(day => <div key={day} className="day-header">{day}</div>)}
|
|
||||||
{dateGrid.map((day, index) => {
|
|
||||||
const appointmentsOnDay = 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 (
|
|
||||||
<div key={index} className={cellClasses} onClick={() => handleDateClick(day)}>
|
|
||||||
<span>{day.format('D')}</span>
|
|
||||||
{appointmentsOnDay.length > 0 && <div className="appointments-indicator">{appointmentsOnDay.length}</div>}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="page-content table-paciente-container">
|
|
||||||
<section className="row">
|
|
||||||
<div className="col-12">
|
|
||||||
<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-body">
|
|
||||||
|
|
||||||
<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>
|
|
||||||
<div className="mb-3">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control"
|
|
||||||
placeholder="Buscar por médico..."
|
|
||||||
value={searchFilaEspera}
|
|
||||||
onChange={(e) => setSearchFilaEspera(e.target.value)}
|
|
||||||
/>
|
|
||||||
<small className="text-muted">Digite o nome do médico</small>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="d-flex align-items-center gap-2 mb-3">
|
|
||||||
<span className="text-muted small">Ordenar por:</span>
|
|
||||||
{(() => {
|
|
||||||
const sortValue = waitSortKey ? `${waitSortKey}-${waitSortDir}` : '';
|
|
||||||
return (
|
|
||||||
<select
|
|
||||||
className="form-select compact-select sort-select w-auto"
|
|
||||||
value={sortValue}
|
|
||||||
onChange={(e) => {
|
|
||||||
const v = e.target.value;
|
|
||||||
if (!v) { setWaitSortKey(null); setWaitSortDir('asc'); return; }
|
|
||||||
const [k, d] = v.split('-');
|
|
||||||
setWaitSortKey(k);
|
|
||||||
setWaitSortDir(d);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<option value="">Sem ordenação</option>
|
|
||||||
<option value="medico-asc">Médico (A-Z)</option>
|
|
||||||
<option value="medico-desc">Médico (Z-A)</option>
|
|
||||||
<option value="data-asc">Data (mais antiga)</option>
|
|
||||||
<option value="data-desc">Data (mais recente)</option>
|
|
||||||
</select>
|
|
||||||
);
|
|
||||||
})()}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-3">
|
|
||||||
<div className="contador-pacientes">
|
|
||||||
{filaEsperaFiltrada.length} DE {filaEsperaData.length} SOLICITAÇÕES ENCONTRADAS
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="table-responsive">
|
|
||||||
<table className="table table-striped table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Médico Solicitado</th>
|
|
||||||
<th>Data da Solicitação</th>
|
|
||||||
<th>Ações</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{filaEsperaPaginada.length > 0 ? (filaEsperaPaginada.map((item) => (
|
|
||||||
<tr key={item.agendamento.id}>
|
|
||||||
<td>Dr(a). {item.Infos?.medico_nome}</td>
|
|
||||||
<td>{dayjs(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>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))) : (
|
|
||||||
<tr>
|
|
||||||
<td colSpan="3" className="text-center py-4">
|
|
||||||
<div className="text-muted">Nenhuma solicitação na fila de espera.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
{filaEsperaFiltrada.length > 0 && (
|
|
||||||
<div className="d-flex justify-content-between align-items-center mt-3">
|
|
||||||
<div className="d-flex align-items-center">
|
|
||||||
<span className="me-2 text-muted">Itens por página:</span>
|
|
||||||
<select
|
|
||||||
className="form-select form-select-sm w-auto"
|
|
||||||
value={waitPerPage}
|
|
||||||
onChange={(e) => {
|
|
||||||
setWaitPerPage(Number(e.target.value));
|
|
||||||
setWaitPage(1);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<option value={5}>5</option>
|
|
||||||
<option value={10}>10</option>
|
|
||||||
<option value={25}>25</option>
|
|
||||||
<option value={50}>50</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<nav>
|
|
||||||
<ul className="pagination pagination-sm mb-0">
|
|
||||||
<li 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>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{gerarNumerosWaitPages().map(pagina => (
|
|
||||||
<li key={pagina} className={`page-item ${pagina === waitPage ? 'active' : ''}`}>
|
|
||||||
<button className="page-link" onClick={() => setWaitPage(pagina)}>
|
|
||||||
{pagina}
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
|
|
||||||
<li 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>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<AgendamentoCadastroManager setPageConsulta={setPageConsulta} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
|
|
||||||
{isCancelModalOpen && (
|
|
||||||
<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-content">
|
|
||||||
<div className="modal-header" style={{ backgroundColor: '#dc3545', color: 'white' }}>
|
|
||||||
<h5 className="modal-title">
|
|
||||||
Confirmação de Cancelamento
|
|
||||||
</h5>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="modal-body">
|
|
||||||
<p>Qual o motivo do cancelamento?</p>
|
|
||||||
<textarea
|
|
||||||
className="form-control"
|
|
||||||
rows="3"
|
|
||||||
value={cancellationReason}
|
|
||||||
onChange={(e) => setCancellationReason(e.target.value)}
|
|
||||||
placeholder="Ex: Precisei viajar, motivo pessoal, etc."
|
|
||||||
></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="modal-footer">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-primary"
|
|
||||||
onClick={() => setIsCancelModalOpen(false)}
|
|
||||||
>
|
|
||||||
Cancelar
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-danger"
|
|
||||||
onClick={executeCancellation}
|
|
||||||
>
|
|
||||||
Excluir
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
</div>
|
</div>
|
||||||
<div className="nav-buttons">
|
<div className="nav-buttons">
|
||||||
<button onClick={() => setCurrentDate(c => c.subtract(1, 'month'))}><ChevronLeft size={20} /></button>
|
<button onClick={() => setCurrentDate(c => c.subtract(1, 'month'))}><ChevronLeft size={20} /></button>
|
||||||
@ -808,10 +322,7 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<<<<<<< HEAD
|
|
||||||
</section>
|
</section>
|
||||||
=======
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<AgendamentoCadastroManager setPageConsulta={setPageConsulta} />
|
<AgendamentoCadastroManager setPageConsulta={setPageConsulta} />
|
||||||
|
|||||||
@ -489,28 +489,27 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* permite que cliques "passem" através do header (exceto para os elementos interativos) */
|
|
||||||
.header-container {
|
.header-container {
|
||||||
pointer-events: none; /* header não captura cliques */
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mas permite que os controles no canto (telefone e profile) continuem clicáveis */
|
|
||||||
.phone-icon-container,
|
.phone-icon-container,
|
||||||
.profile-section {
|
.profile-section {
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Garantir pointer-events nos elementos do header e overlays criados por portal */
|
|
||||||
.header-container { pointer-events: auto; }
|
.header-container { pointer-events: auto; }
|
||||||
.phone-icon-container, .profile-section { pointer-events: auto; }
|
.phone-icon-container, .profile-section { pointer-events: auto; }
|
||||||
|
|
||||||
/* Força que os overlays criados por portal fiquem por cima */
|
|
||||||
.logout-modal-overlay, .suporte-card-overlay, .chat-overlay {
|
.logout-modal-overlay, .suporte-card-overlay, .chat-overlay {
|
||||||
z-index: 110000 !important;
|
z-index: 110000 !important;
|
||||||
pointer-events: auto !important;
|
pointer-events: auto !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pequeno ajuste visual dos botões do modal (pode se misturar com seu CSS atual) */
|
|
||||||
.logout-cancel-button {
|
.logout-cancel-button {
|
||||||
padding: 10px 18px;
|
padding: 10px 18px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
@ -526,7 +525,3 @@
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
|
|||||||
@ -413,9 +413,3 @@ const Header = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default Header;
|
export default Header;
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
|
|||||||
@ -172,7 +172,6 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
paciente_cpf: paciente?.cpf
|
paciente_cpf: paciente?.cpf
|
||||||
};
|
};
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if (agendamento.status === "requested") {
|
if (agendamento.status === "requested") {
|
||||||
newFila.push({ agendamento: agendamentoMelhorado, Infos: agendamentoMelhorado });
|
newFila.push({ agendamento: agendamentoMelhorado, Infos: agendamentoMelhorado });
|
||||||
} else {
|
} else {
|
||||||
@ -190,84 +189,14 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
setAgendamentosOrganizados(newDict);
|
setAgendamentosOrganizados(newDict);
|
||||||
setFilaEsperaData(newFila);
|
setFilaEsperaData(newFila);
|
||||||
setShowSpinner(false);
|
setShowSpinner(false);
|
||||||
=======
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
fetchAppointments();
|
|
||||||
GetAllDoctors(authHeader).then(docs => setListaDeMedicos(docs.map(d => ({ nomeMedico: d.full_name, idMedico: d.id }))));
|
|
||||||
}, [authHeader]);
|
|
||||||
|
|
||||||
|
|
||||||
const handleSearchMedicos = (term) => {
|
|
||||||
setSearchTermDoctor(term);
|
|
||||||
if (term.trim() === '') {
|
|
||||||
setFiltredTodosMedicos([]);
|
|
||||||
setMedicoFiltrado({ id: "vazio" });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const filtered = ListaDeMedicos.filter(medico =>
|
|
||||||
medico.nomeMedico.toLowerCase().includes(term.toLowerCase())
|
|
||||||
);
|
|
||||||
setFiltredTodosMedicos(filtered);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const filaEsperaFiltrada = useMemo(() => {
|
|
||||||
if (!waitlistSearch.trim()) return filaEsperaData;
|
|
||||||
const term = waitlistSearch.toLowerCase();
|
|
||||||
return filaEsperaData.filter(item => (item?.Infos?.paciente_nome?.toLowerCase() || '').includes(term) || (item?.Infos?.paciente_cpf?.toLowerCase() || '').includes(term) || (item?.Infos?.nome_medico?.toLowerCase() || '').includes(term));
|
|
||||||
}, [waitlistSearch, filaEsperaData]);
|
|
||||||
|
|
||||||
const applySortingWaitlist = (arr) => {
|
|
||||||
if (!Array.isArray(arr) || !waitSortKey) return arr;
|
|
||||||
const copy = [...arr];
|
|
||||||
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) => new Date(a?.agendamento?.scheduled_at || 0) - new Date(b?.agendamento?.scheduled_at || 0)); }
|
|
||||||
if (waitSortDir === 'desc') copy.reverse();
|
|
||||||
return copy;
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
};
|
};
|
||||||
fetchDados();
|
fetchDados();
|
||||||
}, [listaTodosAgendamentos, authHeader, cacheMedicos, cachePacientes]);
|
}, [listaTodosAgendamentos, authHeader, cacheMedicos, cachePacientes]);
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
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 })))
|
||||||
=======
|
|
||||||
|
|
||||||
const generateDateGrid = () => {
|
|
||||||
const grid = []; const startOfMonth = currentDate.startOf('month');
|
|
||||||
let currentDay = startOfMonth.subtract(startOfMonth.day(), 'day');
|
|
||||||
for (let i = 0; i < 42; i++) { grid.push(currentDay); currentDay = currentDay.add(1, 'day'); }
|
|
||||||
return grid;
|
|
||||||
};
|
|
||||||
const dateGrid = useMemo(() => generateDateGrid(), [currentDate]);
|
|
||||||
const weekDays = ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'];
|
|
||||||
const handleDateClick = (day) => setSelectedDay(day);
|
|
||||||
|
|
||||||
|
|
||||||
const DeleteModal = () => (
|
|
||||||
<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-content">
|
|
||||||
<div className="modal-header" style={{ backgroundColor: '#dc3545', color: 'white' }}>
|
|
||||||
<h5 className="modal-title">Confirmação de Cancelamento</h5>
|
|
||||||
</div>
|
|
||||||
<div className="modal-body">
|
|
||||||
<p>Qual o motivo do cancelamento?</p>
|
|
||||||
<textarea className="form-control" rows="3" value={motivoCancelamento} onChange={(e) => setMotivoCancelamento(e.target.value)}></textarea>
|
|
||||||
</div>
|
|
||||||
<div className="modal-footer justify-content-center">
|
|
||||||
<button type="button" className="btn btn-secondary" onClick={() => { setShowDeleteModal(false); setMotivoCancelamento(""); }}>Cancelar</button>
|
|
||||||
<button type="button" className="btn btn-danger" onClick={() => deleteConsulta(selectedID)}>Excluir</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
);
|
);
|
||||||
}, [authHeader]);
|
}, [authHeader]);
|
||||||
|
|
||||||
@ -305,7 +234,6 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
const waitIndiceFinal = waitIndiceInicial + waitPerPage;
|
const waitIndiceFinal = waitIndiceInicial + waitPerPage;
|
||||||
const filaEsperaPaginada = filaEsperaOrdenada.slice(waitIndiceInicial, waitIndiceFinal);
|
const filaEsperaPaginada = filaEsperaOrdenada.slice(waitIndiceInicial, waitIndiceFinal);
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
const gerarNumerosWaitPages = () => {
|
const gerarNumerosWaitPages = () => {
|
||||||
const paginas = [];
|
const paginas = [];
|
||||||
const paginasParaMostrar = 5;
|
const paginasParaMostrar = 5;
|
||||||
@ -550,230 +478,6 @@ const Agendamento = ({ setDictInfo }) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
=======
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<h1>Agendar nova consulta</h1>
|
|
||||||
<div className="btns-gerenciamento-e-consulta" style={{ display: 'flex', gap: '10px', marginBottom: '20px' }}>
|
|
||||||
|
|
||||||
<button className="btn btn-primary" onClick={() => {
|
|
||||||
setPageConsulta(true);
|
|
||||||
setEditingAppointmentId(null);
|
|
||||||
setAppointmentToEdit(null);
|
|
||||||
}}><i className="bi bi-plus-circle"></i> Adicionar Consulta</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'>
|
|
||||||
<div className='container-btns-agenda-fila_esepera'>
|
|
||||||
<button className={`btn-agenda ${!FiladeEspera ? "opc-agenda-ativo" : ""}`} onClick={() => { setFiladeEspera(false); setSearchTerm(''); }}>Agenda</button>
|
|
||||||
<button className={`btn-fila-espera ${FiladeEspera ? "opc-filaespera-ativo" : ""}`} onClick={() => { setFiladeEspera(true); setSearchTerm(''); }}>Fila de espera</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{!FiladeEspera && (
|
|
||||||
<div className="card p-3 mb-3" style={{ marginTop: '20px' }}>
|
|
||||||
<h5 className="mb-3">
|
|
||||||
<i className="bi bi-funnel-fill me-2 text-primary"></i>
|
|
||||||
Filtrar por Médico
|
|
||||||
</h5>
|
|
||||||
<div className="mb-3">
|
|
||||||
<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">
|
|
||||||
Filtre os agendamentos por médico
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
{searchTermDoctor && FiltredTodosMedicos.length > 0 && (
|
|
||||||
<div className="list-group">
|
|
||||||
{FiltredTodosMedicos.map((medico) => (
|
|
||||||
<button
|
|
||||||
key={medico.idMedico}
|
|
||||||
className="list-group-item list-group-item-action"
|
|
||||||
onClick={() => {
|
|
||||||
setSearchTermDoctor(medico.nomeMedico);
|
|
||||||
setFiltredTodosMedicos([]);
|
|
||||||
setMedicoFiltrado(medico);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{medico.nomeMedico}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{MedicoFiltrado.id !== "vazio" && (
|
|
||||||
<div className="alert alert-info mt-2" style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
|
||||||
<span>
|
|
||||||
<i className="bi bi-info-circle me-2"></i>
|
|
||||||
Filtrando por: <strong>{searchTermDoctor}</strong>
|
|
||||||
</span>
|
|
||||||
<button
|
|
||||||
className="btn btn-sm btn-outline-secondary"
|
|
||||||
onClick={() => {
|
|
||||||
setSearchTermDoctor('');
|
|
||||||
setMedicoFiltrado({ id: "vazio" });
|
|
||||||
setFiltredTodosMedicos([]);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<i className="bi bi-x-circle me-1"></i>
|
|
||||||
Limpar filtro
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<section className='calendario-ou-filaespera'>
|
|
||||||
{FiladeEspera === false ? (
|
|
||||||
<div className="calendar-wrapper">
|
|
||||||
<div className="calendar-info-panel">
|
|
||||||
<div className="info-date-display"><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">
|
|
||||||
<h4>Consultas para {selectedDay.format('DD/MM')}</h4>
|
|
||||||
{showSpinner ? <Spinner/> : (DictAgendamentosOrganizados[selectedDay.format('YYYY-MM-DD')]?.length > 0) ? (
|
|
||||||
DictAgendamentosOrganizados[selectedDay.format('YYYY-MM-DD')]
|
|
||||||
.filter(app => {
|
|
||||||
if (MedicoFiltrado.id === "vazio") return true;
|
|
||||||
return app.doctor_id === MedicoFiltrado.idMedico;
|
|
||||||
})
|
|
||||||
.map(app => (
|
|
||||||
<div key={app.id} className="appointment-item" data-status={app.status}>
|
|
||||||
<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>
|
|
||||||
<div className="appointment-actions">
|
|
||||||
{app.status === 'cancelled' ? (
|
|
||||||
<button className="btn-action btn-edit" onClick={() => { setSelectedId(app.id); setShowConfirmModal(true); }}>
|
|
||||||
<Edit size={16} />
|
|
||||||
</button>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
|
|
||||||
<button
|
|
||||||
className="btn-action btn-edit"
|
|
||||||
onClick={() => {
|
|
||||||
setAppointmentToEdit(app);
|
|
||||||
setEditingAppointmentId(app.id);
|
|
||||||
setPageConsulta(true);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Edit size={16} />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button className="btn-action btn-delete" onClick={() => { setSelectedId(app.id); setShowDeleteModal(true); }}>
|
|
||||||
<Trash2 size={16} />
|
|
||||||
</button>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))) : (<div className="no-appointments-info"><p>Nenhuma consulta agendada.</p></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="date-indicator">
|
|
||||||
<h2>{currentDate.format('MMMM [de] YYYY')}</h2>
|
|
||||||
<div className="quick-jump-controls" 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
|
|
||||||
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>
|
|
||||||
<button
|
|
||||||
className="btn btn-sm btn-outline-primary"
|
|
||||||
onClick={applyQuickJump}
|
|
||||||
disabled={quickJump.month === currentDate.month() && quickJump.year === currentDate.year()}
|
|
||||||
>
|
|
||||||
Ir
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="nav-buttons">
|
|
||||||
<button onClick={() => { 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 className="calendar-grid">
|
|
||||||
{weekDays.map(day => <div key={day} className="day-header">{day}</div>)}
|
|
||||||
{dateGrid.map((day, index) => {
|
|
||||||
const appointmentsOnDay = 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 (<div key={index} className={cellClasses} onClick={() => handleDateClick(day)}><span>{day.format('D')}</span>{appointmentsOnDay.length > 0 && <div className="appointments-indicator">{appointmentsOnDay.length}</div>}</div>);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="page-content table-paciente-container">
|
|
||||||
<section className="row">
|
|
||||||
<div className="col-12">
|
|
||||||
<div className="card table-paciente-card">
|
|
||||||
<div className="card-header"><h4 className="card-title mb-0">Fila de Espera</h4></div>
|
|
||||||
<div className="card-body">
|
|
||||||
<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>
|
|
||||||
<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 align-items-center gap-2">
|
|
||||||
<span className="me-2 text-muted small">Ordenar por:</span>
|
|
||||||
{(() => { const sortValue = waitSortKey ? `${waitSortKey}-${waitSortDir}` : ''; return (<select className="form-select compact-select sort-select w-auto" value={sortValue} onChange={(e) => { const v = e.target.value; if (!v) { setWaitSortKey(null); setWaitSortDir('asc'); return; } const [k, d] = v.split('-'); setWaitSortKey(k); setWaitSortDir(d); }}>
|
|
||||||
<option value="">Sem ordenação</option><option value="paciente-asc">Paciente (A-Z)</option><option value="paciente-desc">Paciente (Z-A)</option><option value="medico-asc">Médico (A-Z)</option><option value="medico-desc">Médico (Z-A)</option><option value="data-asc">Data (mais antiga)</option><option value="data-desc">Data (mais recente)</option>
|
|
||||||
</select>);})()}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="mt-3"><div className="contador-pacientes">{filaEsperaFiltrada.length} DE {filaEsperaData.length} SOLICITAÇÕES ENCONTRADAS</div></div>
|
|
||||||
</div>
|
|
||||||
<div className="table-responsive">
|
|
||||||
<table className="table table-striped table-hover table-paciente-table">
|
|
||||||
<thead><tr><th>Nome do Paciente</th><th>CPF</th><th>Médico Solicitado</th><th>Data da Solicitação</th><th>Ações</th></tr></thead>
|
|
||||||
<tbody>
|
|
||||||
{filaEsperaPaginada.length > 0 ? (filaEsperaPaginada.map((item, index) => (
|
|
||||||
<tr key={index}><td>{item?.Infos?.paciente_nome}</td><td>{item?.Infos?.paciente_cpf}</td><td>{item?.Infos?.nome_medico}</td><td>{dayjs(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></td></tr>
|
|
||||||
))) : (<tr><td colSpan="5" className="text-center py-4"><div className="text-muted">{showSpinner ? <Spinner /> : (<><i className="bi bi-inbox display-4"></i><p className="mt-2">Nenhuma solicitação encontrada.</p></>)}</div></td></tr>)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{filaEsperaFiltrada.length > 0 && (<div className="d-flex justify-content-between align-items-center mt-3">
|
|
||||||
<div className="d-flex align-items-center"><span className="me-2 text-muted">Itens por página:</span><select className="form-select form-select-sm w-auto" value={waitPerPage} onChange={(e) => { setWaitPerPage(Number(e.target.value)); setWaitPage(1); }}><option value={5}>5</option><option value={10}>10</option><option value={25}>25</option><option value={50}>50</option></select></div>
|
|
||||||
<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><nav><ul className="pagination pagination-sm mb-0">
|
|
||||||
<li 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></button></li>
|
|
||||||
{gerarNumerosWaitPages().map(pagina => (<li key={pagina} className={`page-item ${pagina === waitPage ? 'active' : ''}`}><button className="page-link" onClick={() => setWaitPage(pagina)}>{pagina}</button></li>))}
|
|
||||||
<li 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></button></li>
|
|
||||||
</ul></nav></div>
|
|
||||||
</div>)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</section>
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="calendar-main">
|
<div className="calendar-main">
|
||||||
|
|||||||
@ -35,10 +35,12 @@ const DisponibilidadesDoctorPage = () => {
|
|||||||
const [doctors, setDoctors] = useState([]);
|
const [doctors, setDoctors] = useState([]);
|
||||||
const [searchTerm, setSearchTerm] = useState("");
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
const [editando, setEditando] = useState(null);
|
const [editando, setEditando] = useState(null);
|
||||||
<<<<<<< HEAD
|
|
||||||
const [expandedDoctors, setExpandedDoctors] = useState({});
|
const [expandedDoctors, setExpandedDoctors] = useState({});
|
||||||
const [showSuggestions, setShowSuggestions] = useState(false);
|
const [showSuggestions, setShowSuggestions] = useState(false);
|
||||||
const [availabilityEdit, setAvailabilityEdit] = useState([]);
|
const [availabilityEdit, setAvailabilityEdit] = useState([]);
|
||||||
|
// Add the missing state variables
|
||||||
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||||
|
const [selectedDisponibilidadeId, setSelectedDisponibilidadeId] = useState(null);
|
||||||
|
|
||||||
const getHeaders = () => {
|
const getHeaders = () => {
|
||||||
const myHeaders = new Headers();
|
const myHeaders = new Headers();
|
||||||
@ -49,11 +51,6 @@ const DisponibilidadesDoctorPage = () => {
|
|||||||
myHeaders.append("Prefer", "return=representation");
|
myHeaders.append("Prefer", "return=representation");
|
||||||
return myHeaders;
|
return myHeaders;
|
||||||
};
|
};
|
||||||
=======
|
|
||||||
const [doctorsLoading, setDoctorsLoading] = useState(true);
|
|
||||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
|
||||||
const [selectedDisponibilidadeId, setSelectedDisponibilidadeId] = useState(null);
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchDoctors = async () => {
|
const fetchDoctors = async () => {
|
||||||
@ -173,33 +170,27 @@ const DisponibilidadesDoctorPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const deletarDisponibilidade = async (id) => {
|
const deletarDisponibilidade = async (id) => {
|
||||||
<<<<<<< HEAD
|
|
||||||
if (!window.confirm("Deseja realmente excluir esta disponibilidade?")) return;
|
if (!window.confirm("Deseja realmente excluir esta disponibilidade?")) return;
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${ENDPOINT}?id=eq.${id}`, { method: "DELETE", headers: getHeaders() });
|
const res = await fetch(`${ENDPOINT}?id=eq.${id}`, { method: "DELETE", headers: getHeaders() });
|
||||||
if (res.ok) setDisponibilidades((prev) => prev.filter((d) => d.id !== id));
|
|
||||||
} catch (error) {}
|
|
||||||
=======
|
|
||||||
try {
|
|
||||||
const res = await fetch(`${ENDPOINT}?id=eq.${id}`, {
|
|
||||||
method: "DELETE",
|
|
||||||
headers: getHeaders(),
|
|
||||||
});
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
alert("Disponibilidade excluída com sucesso!");
|
|
||||||
setDisponibilidades((prev) => prev.filter((d) => d.id !== id));
|
setDisponibilidades((prev) => prev.filter((d) => d.id !== id));
|
||||||
setShowDeleteModal(false);
|
setShowDeleteModal(false);
|
||||||
setSelectedDisponibilidadeId(null);
|
setSelectedDisponibilidadeId(null);
|
||||||
} else {
|
|
||||||
const errorData = await res.json();
|
|
||||||
console.error("Erro na resposta:", errorData);
|
|
||||||
alert("Erro ao excluir disponibilidade");
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Erro:", error);
|
console.error("Erro ao excluir disponibilidade:", error);
|
||||||
alert("Erro ao conectar com o servidor");
|
|
||||||
}
|
}
|
||||||
>>>>>>> alteracoes-modais-tabela
|
};
|
||||||
|
|
||||||
|
const handleOpenDeleteModal = (id) => {
|
||||||
|
setSelectedDisponibilidadeId(id);
|
||||||
|
setShowDeleteModal(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCloseDeleteModal = () => {
|
||||||
|
setShowDeleteModal(false);
|
||||||
|
setSelectedDisponibilidadeId(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
const disponibilidadesAgrupadas = useMemo(() => {
|
const disponibilidadesAgrupadas = useMemo(() => {
|
||||||
@ -313,7 +304,6 @@ const DisponibilidadesDoctorPage = () => {
|
|||||||
setAvailabilityEdit([]);
|
setAvailabilityEdit([]);
|
||||||
};
|
};
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
const handleDoctorSelect = (doctor) => {
|
const handleDoctorSelect = (doctor) => {
|
||||||
setSearchTerm(doctor.full_name || doctor.name);
|
setSearchTerm(doctor.full_name || doctor.name);
|
||||||
setShowSuggestions(false);
|
setShowSuggestions(false);
|
||||||
@ -369,70 +359,6 @@ const DisponibilidadesDoctorPage = () => {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
=======
|
|
||||||
<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={searchTerm}
|
|
||||||
onChange={(e) => {
|
|
||||||
setSearchTerm(e.target.value);
|
|
||||||
if (!e.target.value) setSelectedDoctor(null);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<small className="text-muted">Buscar médico para filtrar disponibilidades</small>
|
|
||||||
|
|
||||||
{searchTerm && !selectedDoctor && filteredDoctors.length > 0 && (
|
|
||||||
<div className="list-group position-absolute w-100" style={{ zIndex: 1000, maxHeight: '200px', overflowY: 'auto' }}>
|
|
||||||
{filteredDoctors.map((doc) => (
|
|
||||||
<button
|
|
||||||
key={doc.id}
|
|
||||||
type="button"
|
|
||||||
className="list-group-item list-group-item-action"
|
|
||||||
onClick={() => {
|
|
||||||
setSelectedDoctor(doc);
|
|
||||||
setSearchTerm(doc.name);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{doc.name}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-3 d-flex justify-content-between align-items-center">
|
|
||||||
<div>
|
|
||||||
{selectedDoctor && (
|
|
||||||
<span className="badge bg-primary me-2">
|
|
||||||
<i className="bi bi-person-check me-1"></i>
|
|
||||||
{selectedDoctor.name}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
<div className="contador-pacientes" style={{ display: 'inline-block' }}>
|
|
||||||
{disponibilidades.length} DISPONIBILIDADES ENCONTRADAS
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{selectedDoctor && (
|
|
||||||
<button
|
|
||||||
className="btn btn-outline-secondary btn-sm"
|
|
||||||
onClick={() => {
|
|
||||||
setSelectedDoctor(null);
|
|
||||||
setSearchTerm('');
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<i className="bi bi-arrow-clockwise me-1"></i> Limpar Filtro
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section className="calendario-ou-filaespera">
|
<section className="calendario-ou-filaespera">
|
||||||
@ -467,7 +393,6 @@ const DisponibilidadesDoctorPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<<<<<<< HEAD
|
|
||||||
<div className="doctor-group-container">
|
<div className="doctor-group-container">
|
||||||
{disponibilidadesAgrupadas.length === 0 ? (
|
{disponibilidadesAgrupadas.length === 0 ? (
|
||||||
<p className="no-results">Nenhum médico encontrado</p>
|
<p className="no-results">Nenhum médico encontrado</p>
|
||||||
@ -514,7 +439,16 @@ const DisponibilidadesDoctorPage = () => {
|
|||||||
<td>
|
<td>
|
||||||
<span className={getStatusBadgeClass(disp)}>{getStatusText(disp)}</span>
|
<span className={getStatusBadgeClass(disp)}>{getStatusText(disp)}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{!disp.is_empty && <button onClick={() => deletarDisponibilidade(disp.id)} className="disp-btn-delete">Excluir</button>}</td>
|
<td>
|
||||||
|
{!disp.is_empty && (
|
||||||
|
<button
|
||||||
|
onClick={() => handleOpenDeleteModal(disp.id)}
|
||||||
|
className="disp-btn-delete"
|
||||||
|
>
|
||||||
|
Excluir
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -526,68 +460,6 @@ const DisponibilidadesDoctorPage = () => {
|
|||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
=======
|
|
||||||
<table className="fila-tabela">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Médico</th>
|
|
||||||
<th>Dia da Semana</th>
|
|
||||||
<th>Início</th>
|
|
||||||
<th>Término</th>
|
|
||||||
<th>Intervalo (min)</th>
|
|
||||||
<th>Tipo</th>
|
|
||||||
<th>Status</th>
|
|
||||||
<th>Ações</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{disponibilidades.map((disp) => {
|
|
||||||
const medico = doctors.find((d) => d.id === disp.doctor_id);
|
|
||||||
return (
|
|
||||||
<tr key={disp.id}>
|
|
||||||
<td>{medico ? medico.name : disp.doctor_id}</td>
|
|
||||||
<td>{diasDaSemana[disp.weekday]}</td>
|
|
||||||
<td>{disp.start_time}</td>
|
|
||||||
<td>{disp.end_time}</td>
|
|
||||||
<td>{disp.slot_minutes || 30}</td>
|
|
||||||
<td>{disp.appointment_type || "presencial"}</td>
|
|
||||||
<td>
|
|
||||||
<span
|
|
||||||
className={`badge ${
|
|
||||||
disp.active === false
|
|
||||||
? "badge-inactive"
|
|
||||||
: "badge-active"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{disp.active === false ? "Inativa" : "Ativa"}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div className="d-flex gap-2">
|
|
||||||
<button
|
|
||||||
className="btn btn-sm btn-edit"
|
|
||||||
onClick={() => setEditando(disp.id)}
|
|
||||||
>
|
|
||||||
<i className="bi bi-pencil me-1"></i> Editar
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
className="btn btn-sm btn-delete"
|
|
||||||
onClick={() => {
|
|
||||||
setSelectedDisponibilidadeId(disp.id);
|
|
||||||
setShowDeleteModal(true);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<i className="bi bi-trash me-1"></i> Excluir
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@ -619,10 +491,7 @@ const DisponibilidadesDoctorPage = () => {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-primary"
|
className="btn btn-primary"
|
||||||
onClick={() => {
|
onClick={handleCloseDeleteModal}
|
||||||
setShowDeleteModal(false);
|
|
||||||
setSelectedDisponibilidadeId(null);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Cancelar
|
Cancelar
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@ -1,11 +1,5 @@
|
|||||||
<<<<<<< HEAD
|
|
||||||
import React, { useState, useEffect, useMemo } from "react";
|
import React, { useState, useEffect, useMemo } from "react";
|
||||||
import { useParams, useNavigate, useLocation } from "react-router-dom";
|
import { useParams, useNavigate, useLocation } from "react-router-dom";
|
||||||
=======
|
|
||||||
import React, { useEffect, useState, useCallback } from "react";
|
|
||||||
import { useParams, useSearchParams, useNavigate } from "react-router-dom";
|
|
||||||
import { GetDoctorByID } from "../components/utils/Functions-Endpoints/Doctor";
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
import DoctorForm from "../components/doctors/DoctorForm";
|
import DoctorForm from "../components/doctors/DoctorForm";
|
||||||
import { useAuth } from "../components/utils/AuthProvider";
|
import { useAuth } from "../components/utils/AuthProvider";
|
||||||
import API_KEY from "../components/utils/apiKeys";
|
import API_KEY from "../components/utils/apiKeys";
|
||||||
@ -32,17 +26,11 @@ const EditDoctorPage = () => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { getAuthorizationHeader } = useAuth();
|
const { getAuthorizationHeader } = useAuth();
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
const [doctor, setDoctor] = useState(null);
|
const [doctor, setDoctor] = useState(null);
|
||||||
const [availability, setAvailability] = useState([]);
|
const [availability, setAvailability] = useState([]);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
=======
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const [DoctorToPUT, setDoctorPUT] = useState({});
|
|
||||||
const [showSuccessModal, setShowSuccessModal] = useState(false);
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
|
|
||||||
const effectiveId = id;
|
const effectiveId = id;
|
||||||
|
|
||||||
@ -51,58 +39,12 @@ const EditDoctorPage = () => {
|
|||||||
const authHeader = getAuthorizationHeader();
|
const authHeader = getAuthorizationHeader();
|
||||||
if (authHeader) myHeaders.append("Authorization", authHeader);
|
if (authHeader) myHeaders.append("Authorization", authHeader);
|
||||||
myHeaders.append("Content-Type", "application/json");
|
myHeaders.append("Content-Type", "application/json");
|
||||||
<<<<<<< HEAD
|
|
||||||
if (API_KEY) myHeaders.append("apikey", API_KEY);
|
if (API_KEY) myHeaders.append("apikey", API_KEY);
|
||||||
myHeaders.append("Prefer", "return=representation");
|
myHeaders.append("Prefer", "return=representation");
|
||||||
return myHeaders;
|
return myHeaders;
|
||||||
};
|
};
|
||||||
|
|
||||||
const salvarDisponibilidades = async (doctorId, horariosAtualizados) => {
|
const salvarDisponibilidades = async (doctorId, horariosAtualizados) => {
|
||||||
=======
|
|
||||||
|
|
||||||
var raw = JSON.stringify(DoctorToPUT);
|
|
||||||
|
|
||||||
console.log("Enviando médico para atualização (PUT):", DoctorToPUT);
|
|
||||||
|
|
||||||
var requestOptions = {
|
|
||||||
method: "PUT",
|
|
||||||
headers: myHeaders,
|
|
||||||
body: raw,
|
|
||||||
redirect: "follow",
|
|
||||||
};
|
|
||||||
|
|
||||||
fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/doctors?id=eq.${DictInfo.id}`,requestOptions)
|
|
||||||
.then(response => {
|
|
||||||
console.log(response)
|
|
||||||
if (response.ok) {
|
|
||||||
setShowSuccessModal(true)
|
|
||||||
}
|
|
||||||
return response
|
|
||||||
})
|
|
||||||
.catch(error => console.log("erro", error))
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const HandlePatchAvailability = async (data) => {
|
|
||||||
const authHeader = getAuthorizationHeader();
|
|
||||||
|
|
||||||
var myHeaders = new Headers();
|
|
||||||
myHeaders.append("apikey", API_KEY);
|
|
||||||
myHeaders.append("Authorization", authHeader);
|
|
||||||
myHeaders.append("Content-Type", "application/json");
|
|
||||||
|
|
||||||
var raw = JSON.stringify(data);
|
|
||||||
|
|
||||||
console.log("Enviando disponibilidade para atualização (PATCH):", data);
|
|
||||||
|
|
||||||
var requestOptions = {
|
|
||||||
method: "PATCH",
|
|
||||||
headers: myHeaders,
|
|
||||||
body: raw,
|
|
||||||
redirect: "follow",
|
|
||||||
};
|
|
||||||
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
try {
|
try {
|
||||||
const headers = getHeaders();
|
const headers = getHeaders();
|
||||||
const promises = [];
|
const promises = [];
|
||||||
@ -167,7 +109,6 @@ const EditDoctorPage = () => {
|
|||||||
`${ENDPOINT_AVAILABILITY}?doctor_id=eq.${String(doctorId)}`,
|
`${ENDPOINT_AVAILABILITY}?doctor_id=eq.${String(doctorId)}`,
|
||||||
{ method: "GET", headers }
|
{ method: "GET", headers }
|
||||||
);
|
);
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
if (existingDisponibilidadesRes.ok) {
|
if (existingDisponibilidadesRes.ok) {
|
||||||
const existingDisponibilidades = await existingDisponibilidadesRes.json();
|
const existingDisponibilidades = await existingDisponibilidadesRes.json();
|
||||||
@ -193,10 +134,6 @@ const EditDoctorPage = () => {
|
|||||||
const updatedData = await updatedResponse.json();
|
const updatedData = await updatedResponse.json();
|
||||||
setAvailability(updatedData);
|
setAvailability(updatedData);
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
console.log("Resposta PATCH Disponibilidade:", response);
|
|
||||||
alert("Disponibilidade atualizada com sucesso!");
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@ -375,7 +312,6 @@ const EditDoctorPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<<<<<<< HEAD
|
|
||||||
<div className="container mt-4">
|
<div className="container mt-4">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
@ -390,59 +326,6 @@ const EditDoctorPage = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
=======
|
|
||||||
<div>
|
|
||||||
<DoctorForm
|
|
||||||
onSave={
|
|
||||||
mode === "availability" ? HandlePatchAvailability : HandlePutDoctor
|
|
||||||
}
|
|
||||||
formData={mode === "availability" ? availabilityToPATCH : DoctorToPUT}
|
|
||||||
setFormData={
|
|
||||||
mode === "availability" ? setAvailabilityToPATCH : setDoctorPUT
|
|
||||||
}
|
|
||||||
isEditingAvailability={mode === "availability"}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{showSuccessModal && (
|
|
||||||
<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-content">
|
|
||||||
<div className="modal-header" style={{ backgroundColor: '#1e3a8a', color: 'white' }}>
|
|
||||||
<h5 className="modal-title">
|
|
||||||
Médico Editado
|
|
||||||
</h5>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="modal-body">
|
|
||||||
<p className="mb-0 fs-5">
|
|
||||||
Médico editado com sucesso!
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="modal-footer">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-primary"
|
|
||||||
onClick={() => {
|
|
||||||
setShowSuccessModal(false)
|
|
||||||
navigate(-1)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
OK
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -146,10 +146,6 @@ function TableDoctor({setDictInfo}) {
|
|||||||
return resultado;
|
return resultado;
|
||||||
}) : [];
|
}) : [];
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> alteracoes-modais-tabela
|
|
||||||
const applySorting = (arr) => {
|
const applySorting = (arr) => {
|
||||||
if (!Array.isArray(arr) || !sortKey) return arr;
|
if (!Array.isArray(arr) || !sortKey) return arr;
|
||||||
const copy = [...arr];
|
const copy = [...arr];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user