"use client"; import AnimatedContainer from "@components/AnimatedConainer/AnimatedContainer"; import WhatsAppIcon from "@mui/icons-material/WhatsApp"; import LocationOnIcon from "@mui/icons-material/LocationOn"; import Button from "@core/app/components/Button/Button"; import LocationMap from "@core/app/components/LocationMap/LocationMap"; import EventIcon from "@mui/icons-material/Event"; import LocalOfferIcon from "@mui/icons-material/LocalOffer"; import PersonIcon from "@mui/icons-material/Person"; import AttachMoneyIcon from "@mui/icons-material/AttachMoney"; import { PublicOrganizationView } from "@core/Models/Company.model"; import OrganizationHeader from "@core/app/components/Home/OrganizationHeader/OrganizationHeader"; import { UserAppointmentView, UserAppointmentViewParams } from "@core/Models/Views.model"; import { useEffect, useState } from "react"; import { deleteAppointment, viewAppointment } from "../Appointments.Service"; import { useAlert } from "@core/Store/Alert.Store"; import { useParams } from "next/navigation"; import { EVENT_TYPES, useEventHandlerStore } from "@core/Store/EventHandler.Store"; import { useSessionStore } from "@core/Store/Sesion.Store"; import style from "./page.module.css"; import dayjs from "dayjs"; import "dayjs/locale/es"; import { formatPrice } from "@core/app/helpers/Numbers"; import { DeleteAppointmentParams } from "@core/Models/Appointments.model"; import { useConfirmStore } from "@core/Store/Confirm.Store"; import { useNavigation } from "@core/app/hooks/goto"; import { ScrollToTop } from "@core/app/components/ScrollTop"; dayjs.locale("es"); type UrlData = { aid: string; }; type PositionType = [number, number]; export default function OrganizationPublicProfile() { const data = useParams(); const aid = data.aid; const [appointmentInfo, setAppointmentInfo] = useState(null); const [orgData, setOrgData] = useState(null); const [position, setPosition] = useState([0, 0]); const alert = useAlert(); const confirm = useConfirmStore(); const eventHandler = useEventHandlerStore(); const SessionInfo = useSessionStore(); const { goTo } = useNavigation(); const loadAppointmentData = async () => { const data: UserAppointmentViewParams = { appointmentId: aid, sessionUser: SessionInfo.userId, }; eventHandler.setEventType(EVENT_TYPES.LOADING); viewAppointment(data) .then((response) => { setAppointmentInfo(response); setOrgData(response.organization); setPosition([response.organization.latitude, response.organization.longitude]); }) .catch((error) => { console.error(error); alert.showError(error.format()); }) .finally(() => { eventHandler.setEventType(EVENT_TYPES.SLEEP); }); }; const handleCancellAppointment = () => { confirm.show( "¿Está seguro que desea cancelar el turno?", () => { const data: DeleteAppointmentParams = { id: aid, validation: true, notification: true, sessionUser: SessionInfo.userId, }; eventHandler.setEventType(EVENT_TYPES.LOADING); deleteAppointment(data) .then(() => { alert.showSuccess("Turno cancelado correctamente."); setTimeout(() => { goTo("/landing/my-appointments"); }, 2000); }) .catch((error) => { alert.showError(error.format()); }) .finally(() => { eventHandler.setEventType(EVENT_TYPES.SLEEP); }); }, () => {} ); }; useEffect(() => { if (!SessionInfo.userId) { eventHandler.setEventType(EVENT_TYPES.SLEEP); return; } loadAppointmentData(); }, [SessionInfo.userId]); return ( <> {appointmentInfo && orgData && (

Detalles de tu Reserva

Bienvenido a los detalles de tu turno. Aquí encontrarás toda la información sobre tu reserva, así como opciones para cancelarla o ponerte en contacto directo con nosotros.

Fecha y Hora {dayjs(appointmentInfo.appointment.appointmentDate) .format("D [de] MMMM [de] YYYY - HH:mm [hs]")}
Servicio {appointmentInfo.appointment.serviceName} {appointmentInfo.appointment.serviceDescription}
Profesional {appointmentInfo.appointment.collaboratorName}
Precio {formatPrice(appointmentInfo.appointment.price)}

Información Útil

{orgData.address}
{orgData.phone}
)} {appointmentInfo === null &&

Cargando...

} ); }