All files / src/viewmodels/event useEventDetailViewModel.ts

87% Statements 241/277
66.48% Branches 123/185
94.28% Functions 33/35
91.53% Lines 227/248

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 6011x               1x                           1x 1x 1x                                                                                                                                 2x           2x 1x 1x 1x     1x       5x 5x 5x 5x 5x     5x       1x         75x   75x 75x           4x 4x     75x 75x 5x 5x 4x       75x     1x 183x 183x   183x 183x 183x 183x 183x 183x 183x 183x 183x 183x 183x 183x 183x 183x 183x 183x 183x 183x   183x   183x   183x 183x   183x 183x     183x     183x 111x 61x 52x 14x 9x 9x 9x 9x   8x     183x   111x           183x 60x 60x 60x 60x 60x 60x 60x     183x 13x 13x 13x 13x     183x 2x 2x 2x 2x       2x 2x 2x   2x       183x 2x 2x 2x 2x       2x 2x 2x   2x       183x 60x           60x 60x 60x   60x 60x 57x 57x 57x 57x 11x     2x   59x       183x 50x     183x 100x       183x 100x       183x 4x   4x 4x   4x 4x 2x 2x   2x 2x 2x             183x 4x   4x 4x   4x 4x 4x 2x 2x       2x   2x 2x 1x   1x         183x 4x   4x 4x   4x 4x         3x 3x                   3x 3x 3x 3x   1x 1x 1x             183x 3x   3x 3x 3x       3x 3x 3x     3x 3x 2x   1x     1x 1x 1x   1x       183x 2x   2x 2x   2x 2x 1x   1x 1x         2x       183x         2x   2x 2x   2x 2x           1x   1x 1x                     2x       183x   1x 1x 1x 1x                                 183x   1x 1x 1x 1x                               183x 2x 2x 2x 1x   1x 1x             183x 4x 4x     183x 2x 2x 2x     183x 1x     183x 183x   183x                   183x                   183x                                                                                              
import { useCallback, useEffect, useMemo, useState } from 'react';
import {
  EventDetail,
  EventDetailApprovedParticipant,
  EventDetailPendingJoinRequest,
  EventHostContextSummary,
  ParticipationStatus,
} from '@/models/event';
import {
  getEventDetail,
  getEventHostContextSummary,
  joinEvent,
  leaveEvent,
  requestJoinEvent,
  listEventApprovedParticipants,
  listEventPendingJoinRequests,
  approveJoinRequest,
  rejectJoinRequest,
  cancelEvent,
  upsertEventRating,
  upsertParticipantRating,
} from '@/services/eventService';
import { addFavorite, removeFavorite } from '@/services/favoriteService';
import { useAuth } from '@/contexts/AuthContext';
import { ApiError } from '@/services/api';
 
export type ActionState =
  | 'idle'
  | 'joining'
  | 'leaving'
  | 'requesting'
  | 'saving'
  | 'success_joined'
  | 'success_left'
  | 'success_requested'
  | 'success_saved';
 
export interface EventDetailViewModel {
  event: EventDetail | null;
  hostContextSummary: EventHostContextSummary | null;
  approvedParticipants: EventDetailApprovedParticipant[];
  pendingJoinRequests: EventDetailPendingJoinRequest[];
  approvedParticipantsLoading: boolean;
  pendingJoinRequestsLoading: boolean;
  approvedParticipantsHasNext: boolean;
  pendingJoinRequestsHasNext: boolean;
  isLoading: boolean;
  apiError: string | null;
  actionError: string | null;
  actionState: ActionState;
  isFavorited: boolean;
  participationStatus: ParticipationStatus | null;
  isQuotaFull: boolean;
  constraintViolation: string | null;
  viewerRatingLoading: boolean;
  viewerRatingError: string | null;
  participantRatingLoadingId: string | null;
  participantRatingError: { participantUserId: string; message: string } | null;
 
  showJoinRequestModal: boolean;
  joinRequestMessage: string;
 
  openJoinRequestModal: () => void;
  closeJoinRequestModal: () => void;
  setJoinRequestMessage: (message: string) => void;
 
  canLeave: boolean;
  handleJoin: () => Promise<void>;
  handleLeaveEvent: () => Promise<void>;
  handleRequestJoin: () => Promise<void>;
  handleToggleFavorite: () => Promise<void>;
  handleViewerRatingSubmit: (rating: number, message?: string) => Promise<void>;
  handleParticipantRatingSubmit: (participantUserId: string, rating: number, message?: string) => Promise<void>;
  dismissViewerRatingError: () => void;
  dismissParticipantRatingError: () => void;
  retry: () => void;
 
  showRequestsModal: boolean;
  setShowRequestsModal: (val: boolean) => void;
  showAttendeesModal: boolean;
  setShowAttendeesModal: (val: boolean) => void;
  loadMoreApprovedParticipants: () => Promise<void>;
  loadMorePendingJoinRequests: () => Promise<void>;
  handleApproveRequest: (joinRequestId: string) => Promise<void>;
  handleRejectRequest: (joinRequestId: string) => Promise<void>;
  handleCancelEvent: () => Promise<void>;
}
 
function mapRatingError(err: ApiError, fallback: string): string {
  const errorMap: Record<string, string> = {
    rating_not_allowed: 'You are not allowed to submit a rating for this event.',
    rating_window_closed: 'The 7-day rating window has already closed.',
    host_cannot_rate_self: 'Hosts cannot rate themselves.',
  };
 
  if (err.code === 'validation_error') {
    const ratingMessage = err.details?.rating;
    const feedbackMessage = err.details?.message;
    return feedbackMessage ?? ratingMessage ?? err.message;
  }
 
  return errorMap[err.code] ?? err.message ?? fallback;
}
 
function computeAgeFromBirthDate(birthDate: string): number {
  const birth = new Date(birthDate);
  const now = new Date();
  let age = now.getFullYear() - birth.getFullYear();
  const monthDiff = now.getMonth() - birth.getMonth();
  Iif (monthDiff < 0 || (monthDiff === 0 && now.getDate() < birth.getDate())) {
    age -= 1;
  }
  return age;
}
 
 
export function resolveConstraintViolation(
  event: EventDetail,
  userGender?: string | null,
  userBirthDate?: string | null,
): string | null {
  const violations: string[] = [];
 
  const genderTrim = userGender?.trim() ?? '';
  if (
    event.preferred_gender != null &&
    genderTrim !== '' &&
    genderTrim.toUpperCase() !== event.preferred_gender
  ) {
    const label =
      event.preferred_gender.charAt(0) + event.preferred_gender.slice(1).toLowerCase();
    violations.push(`This event is open to ${label} participants only`);
  }
 
  const birthTrim = userBirthDate?.trim() ?? '';
  if (event.minimum_age != null && birthTrim !== '') {
    const age = computeAgeFromBirthDate(birthTrim);
    if (age < event.minimum_age) {
      violations.push(`Participants must be ${event.minimum_age}+ years old`);
    }
  }
 
  return violations.length > 0 ? violations.join(' ยท ') : null;
}
 
export function useEventDetailViewModel(eventId: string): EventDetailViewModel {
  const hostCollectionPageSize = 25;
  const { token, user } = useAuth();
 
  const [event, setEvent] = useState<EventDetail | null>(null);
  const [hostContextSummary, setHostContextSummary] = useState<EventHostContextSummary | null>(null);
  const [approvedParticipants, setApprovedParticipants] = useState<EventDetailApprovedParticipant[]>([]);
  const [approvedParticipantsLoading, setApprovedParticipantsLoading] = useState(false);
  const [approvedParticipantsNextCursor, setApprovedParticipantsNextCursor] = useState<string | null>(null);
  const [approvedParticipantsHasNext, setApprovedParticipantsHasNext] = useState(false);
  const [pendingJoinRequests, setPendingJoinRequests] = useState<EventDetailPendingJoinRequest[]>([]);
  const [pendingJoinRequestsLoading, setPendingJoinRequestsLoading] = useState(false);
  const [pendingJoinRequestsNextCursor, setPendingJoinRequestsNextCursor] = useState<string | null>(null);
  const [pendingJoinRequestsHasNext, setPendingJoinRequestsHasNext] = useState(false);
  const [isLoading, setIsLoading] = useState(true);
  const [apiError, setApiError] = useState<string | null>(null);
  const [actionError, setActionError] = useState<string | null>(null);
  const [actionState, setActionState] = useState<ActionState>('idle');
  const [viewerRatingLoading, setViewerRatingLoading] = useState(false);
  const [viewerRatingError, setViewerRatingError] = useState<string | null>(null);
  const [participantRatingLoadingId, setParticipantRatingLoadingId] = useState<string | null>(null);
  const [participantRatingError, setParticipantRatingError] = useState<{ participantUserId: string; message: string } | null>(null);
 
  const [isFavorited, setIsFavorited] = useState(false);
  const [participationStatus, setParticipationStatus] =
    useState<ParticipationStatus | null>(null);
 
  const [showJoinRequestModal, setShowJoinRequestModal] = useState(false);
  const [joinRequestMessage, setJoinRequestMessage] = useState('');
 
  const [showRequestsModal, setShowRequestsModal] = useState(false);
  const [showAttendeesModal, setShowAttendeesModal] = useState(false);
 
  const isQuotaFull =
    event?.capacity != null &&
    event.approved_participant_count >= event.capacity;
 
  const canLeave = useMemo(() => {
    if (!event) return false;
    if (event.viewer_context.is_host) return false;
    if (participationStatus !== 'JOINED') return false;
    if (event.status === 'CANCELED' || event.status === 'COMPLETED') return false;
    Eif (event.end_time) {
      const now = new Date();
      const endTime = new Date(event.end_time);
      if (now >= endTime) return false;
    }
    return true;
  }, [event, participationStatus]);
 
  const constraintViolation = useMemo(
    () =>
      event != null
        ? resolveConstraintViolation(event, user?.gender, user?.birth_date)
        : null,
    [event, user?.gender, user?.birth_date],
  );
 
  const resetHostManagement = useCallback(() => {
    setHostContextSummary(null);
    setApprovedParticipants([]);
    setApprovedParticipantsNextCursor(null);
    setApprovedParticipantsHasNext(false);
    setPendingJoinRequests([]);
    setPendingJoinRequestsNextCursor(null);
    setPendingJoinRequestsHasNext(false);
  }, []);
 
  const refreshHostContextSummary = useCallback(async () => {
    Iif (!token) return null;
    const summary = await getEventHostContextSummary(eventId, token);
    setHostContextSummary(summary);
    return summary;
  }, [eventId, token]);
 
  const refreshApprovedParticipants = useCallback(async (cursor?: string | null, append = false) => {
    Iif (!token) return;
    setApprovedParticipantsLoading(true);
    try {
      const response = await listEventApprovedParticipants(eventId, token, {
        limit: hostCollectionPageSize,
        cursor,
      });
      setApprovedParticipants((prev) => append ? [...prev, ...response.items] : response.items);
      setApprovedParticipantsNextCursor(response.page_info.next_cursor ?? null);
      setApprovedParticipantsHasNext(response.page_info.has_next);
    } finally {
      setApprovedParticipantsLoading(false);
    }
  }, [eventId, token]);
 
  const refreshPendingJoinRequests = useCallback(async (cursor?: string | null, append = false) => {
    Iif (!token) return;
    setPendingJoinRequestsLoading(true);
    try {
      const response = await listEventPendingJoinRequests(eventId, token, {
        limit: hostCollectionPageSize,
        cursor,
      });
      setPendingJoinRequests((prev) => append ? [...prev, ...response.items] : response.items);
      setPendingJoinRequestsNextCursor(response.page_info.next_cursor ?? null);
      setPendingJoinRequestsHasNext(response.page_info.has_next);
    } finally {
      setPendingJoinRequestsLoading(false);
    }
  }, [eventId, token]);
 
  const fetchEvent = useCallback(async (silent = false) => {
    Iif (!token) {
      setApiError('You must be logged in to view this event.');
      if (!silent) setIsLoading(false);
      return;
    }
 
    if (!silent) setIsLoading(true);
    setApiError(null);
    resetHostManagement();
 
    try {
      const data = await getEventDetail(eventId, token);
      setEvent(data);
      setIsFavorited(data.viewer_context.is_favorited);
      setParticipationStatus(data.viewer_context.participation_status);
      if (data.viewer_context.is_host) {
        void refreshHostContextSummary();
      }
    } catch {
      Eif (!silent) setApiError('Failed to load event details. Please try again.');
    } finally {
      if (!silent) setIsLoading(false);
    }
  }, [eventId, token, resetHostManagement, refreshHostContextSummary]);
 
  useEffect(() => {
    void fetchEvent();
  }, [fetchEvent]);
 
  useEffect(() => {
    Eif (!showAttendeesModal || !event?.viewer_context.is_host || approvedParticipants.length > 0) return;
    void refreshApprovedParticipants();
  }, [approvedParticipants.length, event?.viewer_context.is_host, refreshApprovedParticipants, showAttendeesModal]);
 
  useEffect(() => {
    Eif (!showRequestsModal || !event?.viewer_context.is_host || pendingJoinRequests.length > 0) return;
    void refreshPendingJoinRequests();
  }, [event?.viewer_context.is_host, pendingJoinRequests.length, refreshPendingJoinRequests, showRequestsModal]);
 
  const handleJoin = useCallback(async () => {
    Iif (!token || !event) return;
 
    setActionError(null);
    setActionState('joining');
 
    try {
      await joinEvent(event.id, token);
      setActionState('success_joined');
      await fetchEvent(true);
    } catch (err: unknown) {
      setActionState('idle');
      if (err && typeof err === 'object' && 'message' in err) {
        setActionError((err as { message: string }).message);
      } else E{
        setActionError('Failed to join the event. Please try again.');
      }
    }
  }, [token, event, fetchEvent]);
 
  const handleLeaveEvent = useCallback(async () => {
    Iif (!token || !event) return;
 
    setActionError(null);
    setActionState('leaving');
 
    try {
      const leftBeforeStart = new Date() < new Date(event.start_time);
      await leaveEvent(event.id, token);
      setParticipationStatus('LEAVED');
      await fetchEvent(true);
      // Pre-start leave: backend resets participation, so go back to idle
      // to let the join/request button render based on refreshed status.
      // Post-start leave: show the "You left" chip.
      setActionState(leftBeforeStart ? 'idle' : 'success_left');
    } catch (err: unknown) {
      setActionState('idle');
      if (err && typeof err === 'object' && 'message' in err) {
        setActionError((err as { message: string }).message);
      } else {
        setActionError('Failed to leave the event. Please try again.');
      }
    }
  }, [token, event, fetchEvent]);
 
  const handleRequestJoin = useCallback(async () => {
    Iif (!token || !event) return;
 
    setActionError(null);
    setActionState('requesting');
 
    try {
      await requestJoinEvent(
        event.id,
        { message: joinRequestMessage.trim() || null },
        token,
      );
      setEvent((prev) =>
        prev
          ? {
              ...prev,
              viewer_context: {
                ...prev.viewer_context,
                participation_status: 'PENDING',
              },
            }
          : prev,
      );
      setParticipationStatus('PENDING');
      setActionState('success_requested');
      setShowJoinRequestModal(false);
      setJoinRequestMessage('');
    } catch (err: unknown) {
      setActionState('idle');
      if (err && typeof err === 'object' && 'message' in err) {
        setActionError((err as { message: string }).message);
      } else E{
        setActionError('Failed to send join request. Please try again.');
      }
    }
  }, [token, event, joinRequestMessage]);
 
  const handleToggleFavorite = useCallback(async () => {
    Iif (!token || !event) return;
 
    const wasFavorited = isFavorited;
    const previousCount = event.favorite_count;
    const nextCount = wasFavorited
      ? Math.max(0, previousCount - 1)
      : previousCount + 1;
 
    setIsFavorited(!wasFavorited);
    setEvent((prev) =>
      prev ? { ...prev, favorite_count: nextCount } : prev,
    );
 
    try {
      if (wasFavorited) {
        await removeFavorite(event.id, token);
      } else {
        await addFavorite(event.id, token);
      }
    } catch {
      setIsFavorited(wasFavorited);
      setEvent((prev) =>
        prev ? { ...prev, favorite_count: previousCount } : prev,
      );
      setActionError('Failed to update favorite. Please try again.');
    }
  }, [token, event, isFavorited]);
 
  const handleViewerRatingSubmit = useCallback(async (rating: number, message?: string) => {
    Iif (!token || !event) return;
 
    setViewerRatingLoading(true);
    setViewerRatingError(null);
 
    try {
      await upsertEventRating(event.id, { rating, message: message?.trim() || null }, token);
      await fetchEvent(true);
    } catch (err: unknown) {
      if (err instanceof ApiError) {
        setViewerRatingError(mapRatingError(err, 'Failed to save your rating. Please try again.'));
      } else E{
        setViewerRatingError('Failed to save your rating. Please try again.');
      }
    } finally {
      setViewerRatingLoading(false);
    }
  }, [token, event, fetchEvent]);
 
  const handleParticipantRatingSubmit = useCallback(async (
    participantUserId: string,
    rating: number,
    message?: string,
  ) => {
    Iif (!token || !event) return;
 
    setParticipantRatingLoadingId(participantUserId);
    setParticipantRatingError(null);
 
    try {
      await upsertParticipantRating(
        event.id,
        participantUserId,
        { rating, message: message?.trim() || null },
        token,
      );
      await Promise.all([fetchEvent(true), refreshApprovedParticipants(undefined, false)]);
    } catch (err: unknown) {
      if (err instanceof ApiError) {
        setParticipantRatingError({
          participantUserId,
          message: mapRatingError(err, 'Failed to save the participant rating. Please try again.'),
        });
      } else E{
        setParticipantRatingError({
          participantUserId,
          message: 'Failed to save the participant rating. Please try again.',
        });
      }
    } finally {
      setParticipantRatingLoadingId(null);
    }
  }, [token, event, fetchEvent, refreshApprovedParticipants]);
 
  const handleApproveRequest = useCallback(
    async (joinRequestId: string) => {
      Iif (!token || !event) return;
      try {
        await approveJoinRequest(event.id, joinRequestId, token);
        await Promise.all([
          fetchEvent(true),
          refreshHostContextSummary(),
          refreshApprovedParticipants(undefined, false),
          refreshPendingJoinRequests(undefined, false),
        ]);
      } catch (err: unknown) {
        if (err && typeof err === 'object' && 'message' in err) {
          setActionError((err as { message: string }).message);
        } else {
          setActionError('Failed to approve request.');
        }
      }
    },
    [token, event, fetchEvent, refreshApprovedParticipants, refreshHostContextSummary, refreshPendingJoinRequests],
  );
 
  const handleRejectRequest = useCallback(
    async (joinRequestId: string) => {
      Iif (!token || !event) return;
      try {
        await rejectJoinRequest(event.id, joinRequestId, token);
        await Promise.all([
          fetchEvent(true),
          refreshHostContextSummary(),
          refreshPendingJoinRequests(undefined, false),
        ]);
      } catch (err: unknown) {
        if (err && typeof err === 'object' && 'message' in err) {
          setActionError((err as { message: string }).message);
        } else {
          setActionError('Failed to reject request.');
        }
      }
    },
    [token, event, fetchEvent, refreshHostContextSummary, refreshPendingJoinRequests],
  );
 
  const handleCancelEvent = useCallback(async () => {
    Iif (!token || !event) return;
    try {
      await cancelEvent(event.id, token);
      await fetchEvent(true);
    } catch (err: unknown) {
      if (err && typeof err === 'object' && 'message' in err) {
        setActionError((err as { message: string }).message);
      } else E{
        setActionError('Failed to cancel event.');
      }
    }
  }, [token, event, fetchEvent]);
 
  const openJoinRequestModal = useCallback(() => {
    setActionError(null);
    setShowJoinRequestModal(true);
  }, []);
 
  const closeJoinRequestModal = useCallback(() => {
    setShowJoinRequestModal(false);
    setJoinRequestMessage('');
    setActionError(null);
  }, []);
 
  const retry = useCallback(() => {
    void fetchEvent();
  }, [fetchEvent]);
 
  const dismissViewerRatingError = useCallback(() => setViewerRatingError(null), []);
  const dismissParticipantRatingError = useCallback(() => setParticipantRatingError(null), []);
 
  const loadMoreApprovedParticipants = useCallback(async () => {
    if (!approvedParticipantsHasNext || !approvedParticipantsNextCursor || approvedParticipantsLoading) return;
    await refreshApprovedParticipants(approvedParticipantsNextCursor, true);
  }, [
    approvedParticipantsHasNext,
    approvedParticipantsLoading,
    approvedParticipantsNextCursor,
    refreshApprovedParticipants,
  ]);
 
  const loadMorePendingJoinRequests = useCallback(async () => {
    if (!pendingJoinRequestsHasNext || !pendingJoinRequestsNextCursor || pendingJoinRequestsLoading) return;
    await refreshPendingJoinRequests(pendingJoinRequestsNextCursor, true);
  }, [
    pendingJoinRequestsHasNext,
    pendingJoinRequestsLoading,
    pendingJoinRequestsNextCursor,
    refreshPendingJoinRequests,
  ]);
 
  return {
    event,
    hostContextSummary,
    approvedParticipants,
    pendingJoinRequests,
    approvedParticipantsLoading,
    pendingJoinRequestsLoading,
    approvedParticipantsHasNext,
    pendingJoinRequestsHasNext,
    isLoading,
    apiError,
    actionError,
    actionState,
    isFavorited,
    participationStatus,
    isQuotaFull,
    viewerRatingLoading,
    viewerRatingError,
    participantRatingLoadingId,
    participantRatingError,
    canLeave,
    constraintViolation,
    showJoinRequestModal,
    joinRequestMessage,
    openJoinRequestModal,
    closeJoinRequestModal,
    setJoinRequestMessage,
    handleJoin,
    handleLeaveEvent,
    handleRequestJoin,
    handleToggleFavorite,
    handleViewerRatingSubmit,
    handleParticipantRatingSubmit,
    dismissViewerRatingError,
    dismissParticipantRatingError,
    retry,
    showRequestsModal,
    setShowRequestsModal,
    showAttendeesModal,
    setShowAttendeesModal,
    loadMoreApprovedParticipants,
    loadMorePendingJoinRequests,
    handleApproveRequest,
    handleRejectRequest,
    handleCancelEvent,
  };
}