tring to fix asignacion mesa
This commit is contained in:
@@ -9,12 +9,33 @@ type Props = {
|
||||
inscripcion: any[];
|
||||
};
|
||||
|
||||
export default function AsignacionMesas({ idCuenta }: Props) {
|
||||
export default function AsignacionMesas({
|
||||
idCuenta,
|
||||
inscripcion,
|
||||
}: Props) {
|
||||
const [puedeContinuar, setPuedeContinuar] = useState(false);
|
||||
const [mesas, setMesas] = useState<any[]>([]);
|
||||
const [loadingMesas, setLoadingMesas] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!idCuenta) return;
|
||||
if (!Array.isArray(inscripcion) || inscripcion.length === 0) return;
|
||||
|
||||
const todasAsistieron = inscripcion.every(
|
||||
(ins) => ins.platica?.data?.[0] === 1
|
||||
);
|
||||
|
||||
if (!todasAsistieron) {
|
||||
toast.error("El alumno no asistió a todas las pláticas");
|
||||
setPuedeContinuar(false);
|
||||
return;
|
||||
}
|
||||
|
||||
setPuedeContinuar(true);
|
||||
}, [inscripcion]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!puedeContinuar || !idCuenta) return;
|
||||
|
||||
const fetchMesas = async () => {
|
||||
try {
|
||||
@@ -39,11 +60,15 @@ export default function AsignacionMesas({ idCuenta }: Props) {
|
||||
};
|
||||
|
||||
fetchMesas();
|
||||
}, [idCuenta]);
|
||||
}, [puedeContinuar, idCuenta]);
|
||||
|
||||
if (!puedeContinuar) return null;
|
||||
|
||||
return (
|
||||
<div className="containerForm">
|
||||
<label style={{ marginTop: "1rem" }}>Seleccionar tiempo</label>
|
||||
<label style={{ marginTop: "1rem" }}>
|
||||
Seleccionar tiempo
|
||||
</label>
|
||||
|
||||
<select>
|
||||
<option>6 minutos</option>
|
||||
@@ -53,7 +78,9 @@ export default function AsignacionMesas({ idCuenta }: Props) {
|
||||
<option>60 minutos</option>
|
||||
</select>
|
||||
|
||||
<label style={{ marginTop: "1rem" }}>Seleccione una mesa</label>
|
||||
<label style={{ marginTop: "1rem" }}>
|
||||
Seleccione una mesa
|
||||
</label>
|
||||
|
||||
<div className="groupInput">
|
||||
<select disabled={loadingMesas || mesas.length === 0}>
|
||||
|
||||
Reference in New Issue
Block a user