ajustes barra de busca
This commit is contained in:
parent
f793e29272
commit
d76264f36e
@ -1,11 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
// ✏️ REMOVIDO: A importação do mock não é mais necessária aqui.
|
|
||||||
// import AgendamentosMes from './DadosConsultasMock';
|
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import CardConsulta from './CardConsulta';
|
import CardConsulta from './CardConsulta';
|
||||||
import "./style/styleTabelas/tabelames.css";
|
import "./style/styleTabelas/tabelames.css";
|
||||||
|
|
||||||
// ✨ MODIFICADO: Recebe 'agendamentos' como prop, além de 'ListarDiasdoMes'
|
|
||||||
const TabelaAgendamentoMes = ({ ListarDiasdoMes, agendamentos }) => {
|
const TabelaAgendamentoMes = ({ ListarDiasdoMes, agendamentos }) => {
|
||||||
|
|
||||||
const dataHoje = dayjs();
|
const dataHoje = dayjs();
|
||||||
@ -33,8 +32,6 @@ const TabelaAgendamentoMes = ({ ListarDiasdoMes, agendamentos }) => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{/* ✨ MODIFICADO: Itera sobre a prop 'agendamentos' em vez do mock importado.
|
|
||||||
O 'agendamentos &&' garante que o código não quebre se a prop ainda não chegou. */}
|
|
||||||
{agendamentos && Object.entries(agendamentos).map(([semana, dias], index) => (
|
{agendamentos && Object.entries(agendamentos).map(([semana, dias], index) => (
|
||||||
<tr key={index}>
|
<tr key={index}>
|
||||||
{/* Coluna de Segunda-feira */}
|
{/* Coluna de Segunda-feira */}
|
||||||
|
|||||||
@ -1,25 +1,21 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
// ✏️ REMOVIDO: A importação do mock foi removida.
|
|
||||||
// import AgendamentosMes from './DadosConsultasMock';
|
|
||||||
import CardConsulta from './CardConsulta';
|
import CardConsulta from './CardConsulta';
|
||||||
import "./style/styleTabelas/tabelasemana.css";
|
import "./style/styleTabelas/tabelasemana.css";
|
||||||
|
|
||||||
// ✨ MODIFICADO: Recebe 'agendamentos' como prop
|
|
||||||
const TabelaAgendamentoSemana = ({ agendamentos }) => {
|
const TabelaAgendamentoSemana = ({ agendamentos }) => {
|
||||||
|
|
||||||
// ✨ MODIFICADO: Usa os dados da prop, com fallback para um objeto vazio para evitar erros.
|
|
||||||
// Continua usando a 'semana1' como no seu código original.
|
|
||||||
const agendamentoSemana = agendamentos?.semana1 || {};
|
const agendamentoSemana = agendamentos?.semana1 || {};
|
||||||
|
|
||||||
// Pega os agendamentos de cada dia, com fallback para um array vazio.
|
|
||||||
const agendamentosDeSegunda = agendamentoSemana.segunda || [];
|
const agendamentosDeSegunda = agendamentoSemana.segunda || [];
|
||||||
const agendamentosDeTerca = agendamentoSemana.terca || [];
|
const agendamentosDeTerca = agendamentoSemana.terca || [];
|
||||||
const agendamentosDeQuarta = agendamentoSemana.quarta || [];
|
const agendamentosDeQuarta = agendamentoSemana.quarta || [];
|
||||||
const agendamentosDeQuinta = agendamentoSemana.quinta || [];
|
const agendamentosDeQuinta = agendamentoSemana.quinta || [];
|
||||||
const agendamentosDeSexta = agendamentoSemana.sexta || [];
|
const agendamentosDeSexta = agendamentoSemana.sexta || [];
|
||||||
|
|
||||||
// ✨ LÓGICA MELHORADA: Calcula o número de linhas com base no dia com mais horários.
|
|
||||||
// Isso evita que a tabela quebre se um dia tiver mais horários que outro após a busca.
|
|
||||||
const numLinhas = Math.max(
|
const numLinhas = Math.max(
|
||||||
agendamentosDeSegunda.length,
|
agendamentosDeSegunda.length,
|
||||||
agendamentosDeTerca.length,
|
agendamentosDeTerca.length,
|
||||||
@ -42,22 +38,20 @@ const TabelaAgendamentoSemana = ({ agendamentos }) => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{/* ✨ MODIFICADO: Itera com base no número de linhas calculado. */}
|
|
||||||
{Array.from({ length: numLinhas }).map((_, index) => {
|
{Array.from({ length: numLinhas }).map((_, index) => {
|
||||||
// Pega a consulta de cada dia para a linha atual (índice)
|
|
||||||
const consultaSeg = agendamentosDeSegunda[index];
|
const consultaSeg = agendamentosDeSegunda[index];
|
||||||
const consultaTer = agendamentosDeTerca[index];
|
const consultaTer = agendamentosDeTerca[index];
|
||||||
const consultaQua = agendamentosDeQuarta[index];
|
const consultaQua = agendamentosDeQuarta[index];
|
||||||
const consultaQui = agendamentosDeQuinta[index];
|
const consultaQui = agendamentosDeQuinta[index];
|
||||||
const consultaSex = agendamentosDeSexta[index];
|
const consultaSex = agendamentosDeSexta[index];
|
||||||
|
|
||||||
// Pega o horário da primeira consulta que existir na linha
|
|
||||||
const horarioDaLinha = consultaSeg?.horario || consultaTer?.horario || consultaQua?.horario || consultaQui?.horario || consultaSex?.horario;
|
const horarioDaLinha = consultaSeg?.horario || consultaTer?.horario || consultaQua?.horario || consultaQui?.horario || consultaSex?.horario;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr key={index}>
|
<tr key={index}>
|
||||||
<td>{horarioDaLinha}</td>
|
<td>{horarioDaLinha}</td>
|
||||||
{/* Renderiza o Card apenas se a consulta existir para aquele dia/horário */}
|
|
||||||
<td>{consultaSeg && <CardConsulta DadosConsulta={consultaSeg} />}</td>
|
<td>{consultaSeg && <CardConsulta DadosConsulta={consultaSeg} />}</td>
|
||||||
<td>{consultaTer && <CardConsulta DadosConsulta={consultaTer} />}</td>
|
<td>{consultaTer && <CardConsulta DadosConsulta={consultaTer} />}</td>
|
||||||
<td>{consultaQua && <CardConsulta DadosConsulta={consultaQua} />}</td>
|
<td>{consultaQua && <CardConsulta DadosConsulta={consultaQua} />}</td>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user