Pues no funciona asi xD y no se por que pero al ponerle lo anterior si funcionaba o sea al poner .form-error en el css
Quizas tenga algo que ver el critical.css?
/* critical.css */
,::before,*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 16px;
}
input:focus, textarea:focus, select:focus {
outline: none;
}
body{
background-color: #F5F5f5;
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
a {
text-decoration: none;
color: inherit;
}
ul, ol {
list-style: none;
padding: 0;
margin: 0;
}
li {
list-style-type: none;
}
h1, h2, h3, h4, h5, h6 {
margin: 0;
padding: 0;
}
/* -------------------- Fonts */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url('/fonts/Roboto-Regular.woff2') format('woff2');
}
@font-face {
font-family: 'Roboto Condensed';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url('/fonts/RobotoCondensed-Bold.woff2') format('woff2');
}
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url('/fonts/Poppins-Regular.woff2') format('woff2');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url('/fonts/Montserrat-Regular.woff2') format('woff2');
}
/* -------------------- Colors /
:root {
/ Background Colors /
--bg-dark: #0f2942; / Fondo para login /
--bg-footer: #164064; / Fondo para footer /
--bg-contact: #164064; / Fondo para iconos de contacto /
--bg-contact-hover: #176fb2; / Fondo para header */
--bg-header-mobile: #145990;
/* Button Colors */
--button-primary-bg: #199968; /* Fondo del botón "Entrar" y noticias */
--button-primary-hover: #137a53; /* Hover del botón "Entrar" */
--button-secondary-bg: #3498db; /* Fondo del botón "Sacar turno" */
--button-secondary-hover: #2980b9; /* Hover del botón "Sacar turno" */
/* Accent Colors */
--accent-hover: #176fb2; /* Hover de los iconos de contacto */
--accent-red: #cc2323;
--accent-red-hover: #971a1a;
/* Section Background */
--news-bg: #199968; /* Fondo de la sección de noticias */
/* New Color - White */
--white: #ffffff;
--white-light: #dddbdb;
--black: #000000;
--dark: #333333;
/*Sombras*/
--shadow-lg: rgba(0, 0, 0, 0.5);
}
/* Estilos criticos del---------------HEADER /
.nav {
background-color:var(--bg-footer) ;/ #3498db*/
width: 100%;
height: 8vh;
padding: 10px;
display: flex;
justify-content: space-between;
align-items: center;
font-family: 'Roboto', sans-serif;
font-weight: 700;
font-size: 16px;
}
/* Estilos criticos del---------------INDEX */
.index-container{
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.hero-h1{
font-size: 1.5rem;
font-family: 'Poppins', sans-serif;
font-size: 3rem;
color: var(--dark);
}
.hero-p{
font-size: 2rem;
color: var(--dark);
}
.hero-h1-container,.hero-p-container{
padding-bottom: 20px;
}
/* Estilos criticos del---------------FOOTER */
footer {
background-color: var(--bg-footer);
width: 100%;
height: 10vh;
color: var(--white);
padding: 10px;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
font-family: "Lato", sans-serif;
font-weight: 400;
font-style: normal;
font-size: 1rem;
clear: both;
user-select: none;
}
import React, { useState, Suspense, lazy } from 'react';
import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
import * as Yup from 'yup';
import { db } from '../../firebase';
import { collection, addDoc, query, where, getDocs } from 'firebase/firestore';
import Modal from '../../components/Modal/Modal';
import PersonalInfoForm from '../../components/Formulario/PersonalInfoForm';
import SpecialitySelector from '../../components/Formulario/SpecialitySelector';
import QuickLinks from '../../components/Quicklinks/QuickLinks';
import './book-appointment.css';
// Carga diferida del componente Calendar
const Calendar = lazy(() => import('../../components/Calendar/Calendar'));
// Carga diferida del componente HCaptchaComponent
const HCaptchaComponent = lazy(() => import('../../components/Hcaptcha/HCaptcha'));
const schema = Yup.object().shape({
name: Yup.string()
.matches(/^[a-zA-ZáéíóúÁÉÍÓÚñÑ\s]+/, "El DNI debe tener exactamente 8 dígitos numéricos")
.required("El DNI es obligatorio"),
speciality: Yup.string().required("La especialidad es obligatoria"),
});
const Bookappointment = () => {
const [error, setError] = useState('');
const [selectedDate, setSelectedDate] = useState(null);
const [selectedTime, setSelectedTime] = useState(null);
const [isSubmitting, setIsSubmitting] = useState(false);
const [showModal, setShowModal] = useState(false);
const [modalMessage, setModalMessage] = useState('');
const [captchaVerified, setCaptchaVerified] = useState(false); // Nuevo estado para hCaptcha
const { register, handleSubmit, formState: { errors }, reset } = useForm({
resolver: yupResolver(schema),
});
const onSubmit = async (data) => {
if (!captchaVerified) {
setError('Debe resolver el captcha para continuar.');
return;
}
setIsSubmitting(true);
data = {
...data,
date: selectedDate ? selectedDate.format('DD/MM/YY') : '',
time: selectedTime || ''
};
if (!data.date || !data.time) {
setError('Debe seleccionar una fecha y hora.');
setIsSubmitting(false);
return;
}
const appointmentsRef = collection(db, 'turnos');
const appointmentQuery = query(
appointmentsRef,
where('speciality', '==', data.speciality),
where('date', '==', data.date),
where('time', '==', data.time)
);
const dniQuery = query(
appointmentsRef,
where('dni', '==', data.dni),
where('speciality', '==', data.speciality),
where('date', '==', data.date)
);
const [querySnapshot, dniQuerySnapshot] = await Promise.all([
getDocs(appointmentQuery),
getDocs(dniQuery),
]);
if (!querySnapshot.empty) {
setError('El turno para esta especialidad, fecha y hora ya está reservado.');
setIsSubmitting(false);
return;
}
if (!dniQuerySnapshot.empty) {
setError('El DNI ya tiene un turno reservado con esta especialidad en esta fecha.');
setIsSubmitting(false);
return;
}
try {
await addDoc(appointmentsRef, data);
setModalMessage('Turno reservado exitosamente,\npreséntate a tiempo en el hospital.');
setShowModal(true);
reset();
setSelectedDate(null);
setSelectedTime(null);
setError('');
} catch (error) {
console.error("Error al reservar turno:", error);
setError('Error al reservar el turno');
}
setIsSubmitting(false);
};
const handleCaptchaVerify = (token) => {
if (token) {
setCaptchaVerified(true);
console.log('hCaptcha verificado, token:', token);
}
};
return (
Sacar turno
{/* Personal Information Form /}
{/ Speciality Selector /}
{/ Calendar Section */}
Seleccione fecha y hora:
<Suspense fallback={Cargando calendar...}>
{/* Global Error Message */}
{error && (
<p className="validation-error"> {/* Cambié de "form-error" a "validation-error" */}
{error}
</p>
)}
<div className="form-enviardatos">
<Suspense fallback={<div>Cargando captcha...</div>}>
<HCaptchaComponent onVerify={handleCaptchaVerify} />
</Suspense>
<button type="submit" className="submit-button" disabled={isSubmitting}>
{isSubmitting ? 'Reservando...' : 'Reservar turno'}
</button>
</div>
</form>
<Modal isVisible={showModal} onClose={() => setShowModal(false)} message={modalMessage} />
</main>
</div>
);
};
export default Bookappointment;
/* Mensaje de error /
.validation-error {
color: #ff4d4f; / Color rojo para advertencias /
background-color: #fff4f4; / Fondo suave rosado /
border: 1px solid #ff4d4f; / Frontera roja */
padding: 10px;
border-radius: 5px;
font-size: 14px;
font-weight: bold;
margin-top: 15px;
text-align: center;
}
.validation-error::before {
content: "⚠️ "; /* Icono de advertencia */
}
.container-grid{
background-color: #144C78;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2000 1500'%3E%3Cdefs%3E%3CradialGradient id='a' gradientUnits='objectBoundingBox'%3E%3Cstop offset='0' stop-color='%232385D2'/%3E%3Cstop offset='1' stop-color='%23144C78'/%3E%3C/radialGradient%3E%3ClinearGradient id='b' gradientUnits='userSpaceOnUse' x1='0' y1='750' x2='1550' y2='750'%3E%3Cstop offset='0' stop-color='%231c69a5'/%3E%3Cstop offset='1' stop-color='%23144C78'/%3E%3C/linearGradient%3E%3Cpath id='s' fill='url(%23b)' d='M1549.2 51.6c-5.4 99.1-20.2 197.6-44.2 293.6c-24.1 96-57.4 189.4-99.3 278.6c-41.9 89.2-92.4 174.1-150.3 253.3c-58 79.2-123.4 152.6-195.1 219c-71.7 66.4-149.6 125.8-232.2 177.2c-82.7 51.4-170.1 94.7-260.7 129.1c-90.6 34.4-184.4 60-279.5 76.3C192.6 1495 96.1 1502 0 1500c96.1-2.1 191.8-13.3 285.4-33.6c93.6-20.2 185-49.5 272.5-87.2c87.6-37.7 171.3-83.8 249.6-137.3c78.4-53.5 151.5-114.5 217.9-181.7c66.5-67.2 126.4-140.7 178.6-218.9c52.3-78.3 96.9-161.4 133-247.9c36.1-86.5 63.8-176.2 82.6-267.6c18.8-91.4 28.6-184.4 29.6-277.4c0.3-27.6 23.2-48.7 50.8-48.4s49.5 21.8 49.2 49.5c0 0.7 0 1.3-0.1 2L1549.2 51.6z'/%3E%3Cg id='g'%3E%3Cuse href='%23s' transform='scale(0.12) rotate(60)'/%3E%3Cuse href='%23s' transform='scale(0.2) rotate(10)'/%3E%3Cuse href='%23s' transform='scale(0.25) rotate(40)'/%3E%3Cuse href='%23s' transform='scale(0.3) rotate(-20)'/%3E%3Cuse href='%23s' transform='scale(0.4) rotate(-30)'/%3E%3Cuse href='%23s' transform='scale(0.5) rotate(20)'/%3E%3Cuse href='%23s' transform='scale(0.6) rotate(60)'/%3E%3Cuse href='%23s' transform='scale(0.7) rotate(10)'/%3E%3Cuse href='%23s' transform='scale(0.835) rotate(-40)'/%3E%3Cuse href='%23s' transform='scale(0.9) rotate(40)'/%3E%3Cuse href='%23s' transform='scale(1.05) rotate(25)'/%3E%3Cuse href='%23s' transform='scale(1.2) rotate(8)'/%3E%3Cuse href='%23s' transform='scale(1.333) rotate(-60)'/%3E%3Cuse href='%23s' transform='scale(1.45) rotate(-30)'/%3E%3Cuse href='%23s' transform='scale(1.6) rotate(10)'/%3E%3C/g%3E%3C/defs%3E%3Cg transform='rotate(0 0 0)'%3E%3Cg transform='rotate(0 0 0)'%3E%3Ccircle fill='url(%23a)' r='3000'/%3E%3Cg opacity='0.5'%3E%3Ccircle fill='url(%23a)' r='2000'/%3E%3Ccircle fill='url(%23a)' r='1800'/%3E%3Ccircle fill='url(%23a)' r='1700'/%3E%3Ccircle fill='url(%23a)' r='1651'/%3E%3Ccircle fill='url(%23a)' r='1450'/%3E%3Ccircle fill='url(%23a)' r='1250'/%3E%3Ccircle fill='url(%23a)' r='1175'/%3E%3Ccircle fill='url(%23a)' r='900'/%3E%3Ccircle fill='url(%23a)' r='750'/%3E%3Ccircle fill='url(%23a)' r='500'/%3E%3Ccircle fill='url(%23a)' r='380'/%3E%3Ccircle fill='url(%23a)' r='250'/%3E%3C/g%3E%3Cg transform='rotate(0 0 0)'%3E%3Cuse href='%23g' transform='rotate(10)'/%3E%3Cuse href='%23g' transform='rotate(120)'/%3E%3Cuse href='%23g' transform='rotate(240)'/%3E%3C/g%3E%3Ccircle fill-opacity='0.1' fill='url(%23a)' r='3000'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
background-attachment: fixed;
background-size: cover;
transition: background-image 0.5s ease-in-out;
min-height: 82vh;
width: 100%;
}
.main-content {
width: 100%;
height: 100%;
padding: 20px;
display: flex;
align-items: center;
flex-direction: column;
}
.main-form {
width: 100%;
height: 100%;
text-align: left;
}
.main-form-text {
color: #fff;
padding-bottom: 5px;
}
.main-form-datehorus{
color: #ffffff;
padding-bottom: 20px;
}
/* Header */
.main-header {
width: 100%;
height: auto;
display: flex;
justify-content: space-between;
align-items: center;
}
.main-title{
align-items: center;
justify-content: center;
}
.main-title h2{
color: #fff;
padding: 10px 20px;
font-family: 'Roboto', sans-serif;
}
.main-autenticator{
display: flex;
align-items: center;
padding: 0 20px;
}
/* ICON STYLE HELP */
.help-icon{
background-color:transparent;
margin-left: 10px;
display:inline-flex;
justify-content: center;
align-items: center;
width: 18px;
height: 18px;
border: 2px solid #fff;
color: #fff;
border-radius: 50%;
box-sizing: border-box;
}
.help-icon .fa-solid{
font-size: 0.9rem;
}
.help-icon:hover{
background-color: #042049;
color: #fff;
border: 2px solid #fff;
}
.tooltip {
position: absolute;
width: 150px;
top: 80px;
right: 100px;
background-color: #333;
color: #fff;
padding: 5px 10px;
border-radius: 4px;
font-size: 0.8rem;
z-index: 10;
}
.tooltip::after {
content: "";
position: absolute;
bottom: -5px;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #333 transparent transparent transparent;
}
.help-icon:hover .tooltip {
display: block;
}
.form-name,
.form-edad,
.form-dni,
.form-especialista{
padding: 5px 20px;
display: flex;
flex-direction: column;
justify-content: flex-start;
font-family: 'Roboto Condensed', sans-serif;
}
.form-name input,
.form-edad input,
.form-dni input,
.main-form-selection,
.form-calendar-section input {
padding: 10px;
width: 100%;
}
.form-calendar-section{
display: flex;
justify-content: center;
align-items: flex-start;
flex-direction: column;
font-family: 'Roboto Condensed', sans-serif;
padding: 5px 20px;
}
.form-enviardatos {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
padding: 0 20px;
}
.submit-button{
padding: 10px;
font-size: 1rem;
cursor: pointer;
background-color: #3498db;
color: #ffffff;
border: none;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
font-family: 'Roboto Condensed', sans-serif;
}
.submit-button:hover {
background-color: #2980b9;
}
.input-capitalizar{
text-transform: capitalize;
}
.form-hcaptcha{
padding: 10px 0;
}
/* Estilos para dispositivos grandes */
@media (min-width: 1024px) {
.container-grid {
display: grid;
grid-template-columns: 200px 1fr;
grid-template-areas:
"quicklinks main";
}
.quicklinks-contenido{
width: 100%;
height: 100%;
grid-area: quicklinks;
}
.main-content{
width: 100%;
height: 100%;
grid-area: main;
}
}