import { userData } from "@/features/User/userDataTypes"; import { Box, Typography } from "@linagora/twake-mui"; import { Dispatch, SetStateAction } from "react"; import { useI18n } from "twake-i18n"; import { ContextualizedEvent } from "../EventsTypes"; import { RSVPButton } from "./RSVPButton"; interface AttendanceValidationProps { contextualizedEvent: ContextualizedEvent; user: userData | undefined; setAfterChoiceFunc: Dispatch>; setOpenEditModePopup: Dispatch>; } export function AttendanceValidation({ contextualizedEvent, user, setAfterChoiceFunc, setOpenEditModePopup, }: AttendanceValidationProps) { const { currentUserAttendee, isOwn } = contextualizedEvent; const { t } = useI18n(); // Check if we should show RSVP buttons const hasNoAttendeesOrOrganizer = !(contextualizedEvent.event?.attendee?.length > 0) && !contextualizedEvent.event?.organizer; if (!((currentUserAttendee || hasNoAttendeesOrOrganizer) && isOwn)) { return null; } const commonButtonProps = { contextualizedEvent, user, setAfterChoiceFunc, setOpenEditModePopup, }; return ( <> {t("eventPreview.attendingQuestion")} ); }