@openpeepshq/react 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/dist/components/configuration/ConfigurationCategory.js +3 -2
  2. package/dist/components/configuration/ConfigurationList.js +1 -1
  3. package/dist/components/form/LocationInput.js +1 -1
  4. package/dist/components/jams/JamCapacityGate.js +1 -1
  5. package/dist/components/jams/JamConference.js +2 -0
  6. package/dist/components/jams/JamParticipantConference.js +2 -0
  7. package/dist/components/jams/JamRoom.js +2 -3
  8. package/dist/components/jams/LiveJamsSection.js +8 -2
  9. package/dist/components/jams/LivekitUnavailableNotice.d.ts +9 -0
  10. package/dist/components/jams/LivekitUnavailableNotice.js +19 -0
  11. package/dist/components/jams/dropLateAudio.d.ts +22 -0
  12. package/dist/components/jams/dropLateAudio.js +115 -0
  13. package/dist/components/jams/index.d.ts +1 -0
  14. package/dist/components/jams/index.js +1 -0
  15. package/dist/components/markdown/compileMarkdown.js +1 -0
  16. package/dist/components/navigation/FooterMobile.js +4 -3
  17. package/dist/components/navigation/HeaderMobile.js +5 -2
  18. package/dist/components/navigation/MobileMenuItem.d.ts +3 -1
  19. package/dist/components/navigation/MobileMenuItem.js +7 -2
  20. package/dist/components/navigation/NavWithTooltip.d.ts +9 -0
  21. package/dist/components/navigation/NavWithTooltip.js +4 -0
  22. package/dist/components/navigation/index.d.ts +2 -0
  23. package/dist/components/navigation/index.js +1 -0
  24. package/dist/components/navigation/sideBarNavLinkClass.d.ts +6 -4
  25. package/dist/components/navigation/sideBarNavLinkClass.js +6 -2
  26. package/dist/components/notifications/TypedNotification.js +46 -4
  27. package/dist/components/post/CompactReplyParent.js +5 -6
  28. package/dist/components/post/Markdown.d.ts +2 -2
  29. package/dist/components/post/Markdown.js +1 -1
  30. package/dist/components/post/TruncatedMarkdown.d.ts +27 -0
  31. package/dist/components/post/TruncatedMarkdown.js +37 -0
  32. package/dist/components/post/attachmentPreview.js +1 -1
  33. package/dist/components/post/helpers.d.ts +2 -2
  34. package/dist/components/post/helpers.js +3 -16
  35. package/dist/components/post/index.d.ts +2 -0
  36. package/dist/components/post/index.js +1 -0
  37. package/dist/components/post/pieces/Attachments.js +23 -17
  38. package/dist/components/post/pieces/EventLocation.js +14 -0
  39. package/dist/components/post/pieces/EventRsvpButton.js +39 -7
  40. package/dist/components/post/pieces/EventRsvpList.js +23 -3
  41. package/dist/components/post/pieces/EventRsvpScopeDialog.d.ts +1 -1
  42. package/dist/components/post/pieces/EventRsvpScopeDialog.js +34 -22
  43. package/dist/components/post/pieces/EventWaitlistJoinDialog.d.ts +10 -0
  44. package/dist/components/post/pieces/EventWaitlistJoinDialog.js +26 -0
  45. package/dist/components/post/pieces/ParticipantsCard.d.ts +1 -1
  46. package/dist/components/post/pieces/ParticipantsCard.js +1 -1
  47. package/dist/components/post/pieces/PollContent.js +8 -2
  48. package/dist/components/post/pieces/PostActions.d.ts +1 -1
  49. package/dist/components/post/pieces/PostActions.js +20 -12
  50. package/dist/components/post/pieces/ShareMenu.d.ts +6 -1
  51. package/dist/components/post/pieces/ShareMenu.js +40 -7
  52. package/dist/components/post/post-form/ArticleForm.js +1 -1
  53. package/dist/components/post/post-form/EventForm.js +33 -5
  54. package/dist/components/post/post-form/ResourceForm.d.ts +3 -1
  55. package/dist/components/post/post-form/ResourceForm.js +48 -7
  56. package/dist/components/post/post-form/VisibilitySelector.js +9 -3
  57. package/dist/components/post/types/Article.js +2 -3
  58. package/dist/components/post/types/Event.js +10 -1
  59. package/dist/components/post/types/article/FullArticle.js +1 -1
  60. package/dist/components/post/types/event/CardEvent.js +2 -1
  61. package/dist/components/post/types/event/FullEvent.js +22 -13
  62. package/dist/components/post/types/event/ProfileEventRelationship.js +8 -0
  63. package/dist/components/post/types/resource/FullResource.js +3 -3
  64. package/dist/components/preview-link/LocalPreviewLink.js +4 -2
  65. package/dist/components/preview-link/PreviewLink.js +1 -1
  66. package/dist/components/preview-link/helpers.d.ts +5 -0
  67. package/dist/components/preview-link/helpers.js +27 -1
  68. package/dist/components/preview-link/local/WelcomePreview.d.ts +1 -0
  69. package/dist/components/preview-link/local/WelcomePreview.js +8 -0
  70. package/dist/components/profile/Avatar.js +2 -2
  71. package/dist/components/profile/ProfileFromId.js +1 -1
  72. package/dist/components/resources/ResourceCard.d.ts +5 -1
  73. package/dist/components/resources/ResourceCard.js +29 -5
  74. package/dist/components/resources/ResourceCard.test.d.ts +1 -0
  75. package/dist/components/resources/ResourceCard.test.js +75 -0
  76. package/dist/components/resources/ResourceLibrary.js +1 -1
  77. package/dist/components/server-data/context.d.ts +1 -0
  78. package/dist/contexts/openpeeps/hooks/accounts.d.ts +5 -5
  79. package/dist/contexts/openpeeps/hooks/accounts.js +1 -3
  80. package/dist/contexts/openpeeps/hooks/admin.d.ts +165 -66
  81. package/dist/contexts/openpeeps/hooks/admin.js +11 -3
  82. package/dist/contexts/openpeeps/hooks/auth.d.ts +2 -2
  83. package/dist/contexts/openpeeps/hooks/groups.d.ts +8 -8
  84. package/dist/contexts/openpeeps/hooks/jams.d.ts +73 -24
  85. package/dist/contexts/openpeeps/hooks/other.d.ts +7 -6
  86. package/dist/contexts/openpeeps/hooks/payments.d.ts +2 -2
  87. package/dist/contexts/openpeeps/hooks/posts.d.ts +368 -170
  88. package/dist/contexts/openpeeps/hooks/streaming.d.ts +1 -1
  89. package/dist/hooks/admin/useCanAccessAdminSection.d.ts +13 -0
  90. package/dist/hooks/admin/useCanAccessAdminSection.js +21 -0
  91. package/dist/hooks/events/useEventComposer.d.ts +94 -41
  92. package/dist/hooks/events/useEventForm.d.ts +1 -0
  93. package/dist/hooks/events/useEventRsvp.d.ts +12 -2
  94. package/dist/hooks/events/useEventRsvp.js +59 -10
  95. package/dist/hooks/events/useEventsCalendar.d.ts +174 -76
  96. package/dist/hooks/groups/useNewGroup.js +22 -2
  97. package/dist/hooks/index.d.ts +5 -1
  98. package/dist/hooks/index.js +4 -1
  99. package/dist/hooks/jams/useCanDiagnoseLivekit.d.ts +2 -0
  100. package/dist/hooks/jams/useCanDiagnoseLivekit.js +3 -0
  101. package/dist/hooks/jams/useCreateNewJamForm.d.ts +3 -1
  102. package/dist/hooks/jams/useJamDetails.d.ts +87 -38
  103. package/dist/hooks/jams/useJamLobby.d.ts +1 -0
  104. package/dist/hooks/jams/useJamRoom.d.ts +175 -76
  105. package/dist/hooks/posts/useArticleComposer.d.ts +93 -41
  106. package/dist/hooks/posts/useFeedPostPresentation.d.ts +174 -76
  107. package/dist/hooks/posts/usePostDetailTitle.d.ts +87 -38
  108. package/dist/hooks/posts/useResourceComposer.d.ts +95 -41
  109. package/dist/hooks/posts/useResourceComposer.js +135 -27
  110. package/dist/hooks/posts/useShareMenu.d.ts +2 -0
  111. package/dist/hooks/posts/useShareMenu.js +7 -0
  112. package/dist/hooks/resources/useResourceLibrary.d.ts +177 -79
  113. package/dist/hooks/resources/useResourceLibrary.js +6 -2
  114. package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
  115. package/dist/hooks/useWelcomePreview.d.ts +16 -0
  116. package/dist/hooks/useWelcomePreview.js +40 -0
  117. package/dist/lib/groupFormErrors.d.ts +1 -0
  118. package/dist/lib/groupFormErrors.js +5 -2
  119. package/dist/lib/threadHelpers.js +1 -5
  120. package/dist/navigation/menuItems.js +15 -0
  121. package/dist/navigation/targets.d.ts +2 -0
  122. package/dist/pages/admin/ConfigurationCommunity.js +1 -1
  123. package/dist/pages/admin/Diagnostics.js +1 -1
  124. package/dist/pages/admin/DiagnosticsLivekit.d.ts +1 -0
  125. package/dist/pages/admin/DiagnosticsLivekit.js +50 -0
  126. package/dist/pages/admin/Invites.js +5 -3
  127. package/dist/pages/admin/Media.d.ts +1 -0
  128. package/dist/pages/admin/Media.js +135 -0
  129. package/dist/pages/admin/community/CommunityForbiddenUsernames.d.ts +1 -0
  130. package/dist/pages/admin/community/CommunityForbiddenUsernames.js +106 -0
  131. package/dist/pages/admin/community/CommunityMarkdownPage.js +2 -1
  132. package/dist/pages/admin/community/CommunityRoles.js +1 -1
  133. package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
  134. package/dist/pages/admin/components/EditInviteLinkModal.d.ts +5 -0
  135. package/dist/pages/admin/components/EditInviteLinkModal.js +131 -0
  136. package/dist/pages/auth/Register.js +33 -9
  137. package/dist/pages/conversations/Show.js +11 -0
  138. package/dist/pages/index.d.ts +3 -0
  139. package/dist/pages/index.js +3 -0
  140. package/dist/pages/jams/Index.js +2 -4
  141. package/dist/pages/resources/Edit.js +3 -3
  142. package/dist/pages/resources/New.js +2 -2
  143. package/dist/pages/settings/Account.js +30 -2
  144. package/dist/pages/settings/PublicProfile.js +15 -3
  145. package/dist/pwa/sw.d.ts +0 -1
  146. package/dist/react-native.d.ts +1 -0
  147. package/dist/react-native.js +1 -0
  148. package/dist/stores/newPosts.d.ts +4 -2
  149. package/dist/stores/newPosts.js +6 -1
  150. package/package.json +12 -7
  151. package/src/components/configuration/ConfigurationCategory.tsx +23 -10
  152. package/src/components/configuration/ConfigurationList.tsx +6 -1
  153. package/src/components/form/LocationInput.tsx +7 -1
  154. package/src/components/jams/JamCapacityGate.tsx +1 -1
  155. package/src/components/jams/JamConference.tsx +2 -0
  156. package/src/components/jams/JamParticipantConference.tsx +2 -0
  157. package/src/components/jams/JamRoom.tsx +2 -6
  158. package/src/components/jams/LiveJamsSection.tsx +16 -2
  159. package/src/components/jams/LivekitUnavailableNotice.tsx +40 -0
  160. package/src/components/jams/dropLateAudio.ts +153 -0
  161. package/src/components/jams/index.ts +1 -0
  162. package/src/components/markdown/compileMarkdown.ts +1 -0
  163. package/src/components/navigation/FooterMobile.tsx +41 -33
  164. package/src/components/navigation/HeaderMobile.tsx +55 -41
  165. package/src/components/navigation/MobileMenuItem.tsx +15 -2
  166. package/src/components/navigation/NavWithTooltip.tsx +26 -0
  167. package/src/components/navigation/index.ts +2 -0
  168. package/src/components/navigation/sideBarNavLinkClass.ts +9 -6
  169. package/src/components/notifications/TypedNotification.tsx +81 -9
  170. package/src/components/post/CompactReplyParent.tsx +17 -10
  171. package/src/components/post/Markdown.tsx +8 -2
  172. package/src/components/post/TruncatedMarkdown.tsx +91 -0
  173. package/src/components/post/attachmentPreview.ts +1 -3
  174. package/src/components/post/helpers.ts +4 -18
  175. package/src/components/post/index.ts +2 -0
  176. package/src/components/post/pieces/Attachments.tsx +93 -78
  177. package/src/components/post/pieces/EventLocation.tsx +27 -0
  178. package/src/components/post/pieces/EventRsvpButton.tsx +110 -7
  179. package/src/components/post/pieces/EventRsvpList.tsx +64 -0
  180. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +39 -27
  181. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +77 -0
  182. package/src/components/post/pieces/ParticipantsCard.tsx +4 -1
  183. package/src/components/post/pieces/PollContent.tsx +8 -2
  184. package/src/components/post/pieces/PostActions.tsx +73 -42
  185. package/src/components/post/pieces/ShareMenu.tsx +67 -9
  186. package/src/components/post/post-form/ArticleForm.tsx +1 -1
  187. package/src/components/post/post-form/EventForm.tsx +69 -15
  188. package/src/components/post/post-form/ResourceForm.tsx +132 -4
  189. package/src/components/post/post-form/VisibilitySelector.tsx +12 -5
  190. package/src/components/post/types/Article.tsx +6 -6
  191. package/src/components/post/types/Event.tsx +68 -7
  192. package/src/components/post/types/article/FullArticle.tsx +2 -2
  193. package/src/components/post/types/event/CardEvent.tsx +26 -14
  194. package/src/components/post/types/event/FullEvent.tsx +48 -35
  195. package/src/components/post/types/event/ProfileEventRelationship.tsx +8 -0
  196. package/src/components/post/types/note/FullNote.tsx +1 -4
  197. package/src/components/post/types/poll/FullPoll.tsx +1 -4
  198. package/src/components/post/types/resource/FullResource.tsx +9 -1
  199. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  200. package/src/components/preview-link/PreviewLink.tsx +2 -7
  201. package/src/components/preview-link/helpers.ts +32 -1
  202. package/src/components/preview-link/local/GroupPreview.tsx +1 -1
  203. package/src/components/preview-link/local/JamPreview.tsx +1 -1
  204. package/src/components/preview-link/local/WelcomePreview.tsx +45 -0
  205. package/src/components/profile/Avatar.tsx +6 -2
  206. package/src/components/profile/ProfileFromId.tsx +1 -5
  207. package/src/components/resources/ResourceCard.tsx +68 -11
  208. package/src/components/resources/ResourceLibrary.tsx +2 -2
  209. package/src/contexts/openpeeps/hooks/accounts.ts +1 -3
  210. package/src/contexts/openpeeps/hooks/admin.ts +11 -3
  211. package/src/contexts/openpeeps/hooks/other.ts +9 -12
  212. package/src/contexts/openpeeps/hooks/streaming.ts +3 -3
  213. package/src/css.d.ts +4 -0
  214. package/src/hooks/admin/useCanAccessAdminSection.ts +27 -0
  215. package/src/hooks/events/useEventRsvp.ts +69 -13
  216. package/src/hooks/groups/useNewGroup.ts +28 -3
  217. package/src/hooks/index.ts +8 -1
  218. package/src/hooks/jams/useCanDiagnoseLivekit.ts +5 -0
  219. package/src/hooks/posts/useResourceComposer.ts +165 -39
  220. package/src/hooks/posts/useShareMenu.ts +9 -0
  221. package/src/hooks/resources/useResourceLibrary.ts +6 -2
  222. package/src/hooks/useWelcomePreview.ts +61 -0
  223. package/src/i18n/I18nProvider.tsx +1 -4
  224. package/src/lib/groupFormErrors.ts +9 -2
  225. package/src/lib/threadHelpers.ts +1 -5
  226. package/src/navigation/menuItems.ts +16 -0
  227. package/src/navigation/targets.ts +2 -0
  228. package/src/pages/admin/ConfigurationCommunity.tsx +5 -0
  229. package/src/pages/admin/Diagnostics.tsx +4 -0
  230. package/src/pages/admin/DiagnosticsLivekit.tsx +147 -0
  231. package/src/pages/admin/Invites.tsx +23 -1
  232. package/src/pages/admin/Media.tsx +290 -0
  233. package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +223 -0
  234. package/src/pages/admin/community/CommunityMarkdownPage.tsx +5 -1
  235. package/src/pages/admin/community/CommunityRoles.tsx +2 -2
  236. package/src/pages/admin/components/EditInviteLinkModal.tsx +263 -0
  237. package/src/pages/auth/Register.tsx +45 -4
  238. package/src/pages/conversations/Show.tsx +11 -0
  239. package/src/pages/index.ts +3 -0
  240. package/src/pages/jams/Index.tsx +2 -6
  241. package/src/pages/resources/Edit.tsx +3 -2
  242. package/src/pages/resources/New.tsx +6 -1
  243. package/src/pages/settings/Account.tsx +51 -1
  244. package/src/pages/settings/PublicProfile.tsx +20 -2
  245. package/src/pwa/sw.ts +6 -3
  246. package/src/pwa/useNotificationBadgeSync.ts +3 -1
  247. package/src/react-native.ts +1 -0
  248. package/src/stores/newPosts.ts +6 -1
  249. package/src/streaming.ts +3 -3
  250. package/dist/setupTests.d.ts +0 -1
  251. package/dist/setupTests.js +0 -5
@@ -1,6 +1,6 @@
1
1
  import type { PublicPost } from '@openpeepshq/common/types';
2
2
  import type { ExpandedOccurrence } from '@openpeepshq/common/lib';
3
- export type RsvpChoice = 'yes' | 'tentative' | 'no';
3
+ export type RsvpChoice = 'yes' | 'tentative' | 'no' | 'waitlist';
4
4
  export type RsvpScopeChoice = {
5
5
  kind: 'this';
6
6
  recurrenceId: string;
@@ -22,7 +22,7 @@ export declare const useEventRsvp: ({ post, recurrenceId, lockToOccurrence, onSu
22
22
  profile: import("@openpeepshq/common").ProfileWithMeta | undefined;
23
23
  myEvent: boolean;
24
24
  myRsvp: {
25
- response: "no" | "yes" | "tentative" | "removed";
25
+ response: "no" | "yes" | "tentative" | "removed" | "waitlist";
26
26
  profile: {
27
27
  id: string;
28
28
  type: "local" | "guest" | "federated";
@@ -83,18 +83,28 @@ export declare const useEventRsvp: ({ post, recurrenceId, lockToOccurrence, onSu
83
83
  };
84
84
  createdAt: string;
85
85
  recurrenceId?: string | undefined;
86
+ waitlistJoinedAt?: string | undefined;
87
+ offerExpiresAt?: string | undefined;
86
88
  } | undefined;
87
89
  canRsvp: boolean;
88
90
  rsvpClosed: boolean;
91
+ hideRsvpButton: boolean;
89
92
  recurring: boolean;
90
93
  defaultId: string | undefined;
91
94
  occurrences: ExpandedOccurrence[];
92
95
  capacityEvent: boolean;
93
96
  full: boolean;
97
+ onWaitlist: boolean;
98
+ offerExpiresAt: string | undefined;
94
99
  error: string | null;
95
100
  pending: RsvpChoice | null;
96
101
  setPending: import("react").Dispatch<import("react").SetStateAction<RsvpChoice | null>>;
102
+ confirmingWaitlist: boolean;
103
+ setConfirmingWaitlist: import("react").Dispatch<import("react").SetStateAction<boolean>>;
97
104
  submitting: boolean;
98
105
  requestRespond: (response: RsvpChoice) => void;
106
+ requestJoinWaitlist: () => void;
107
+ confirmJoinWaitlist: () => Promise<boolean>;
108
+ claimSpot: () => void;
99
109
  confirmScope: (scope: RsvpScopeChoice) => Promise<boolean>;
100
110
  };
@@ -1,5 +1,5 @@
1
1
  import { useMemo, useState } from 'react';
2
- import { checkPostCapabilities, countYesRsvps, defaultRsvpRecurrenceId, displayRsvpForProfile, eventRsvpOpen, isCapacityEvent, isRecurringEvent, listRsvpOccurrences, recurringEventHasOpenOccurrence, } from '@openpeepshq/common/lib';
2
+ import { canClaimYesRsvp, checkPostCapabilities, defaultRsvpRecurrenceId, displayRsvpForProfile, effectiveEventTimes, eventRsvpOpen, isCapacityEvent, isRecurringEvent, listRsvpOccurrences, occurrenceHasEnded, offerStillOpen, seriesHasClaimableOccurrence, } from '@openpeepshq/common/lib';
3
3
  import { useOpenpeeps } from '../../contexts/openpeeps/index.js';
4
4
  import { useT } from '../../i18n/context.js';
5
5
  import { apiErrorMessage } from '../../lib/apiErrorMessage.js';
@@ -14,26 +14,36 @@ export const useEventRsvp = ({ post, recurrenceId, lockToOccurrence = false, onS
14
14
  const rsvpToEvent = openpeepsApi.rsvpToEventAction({ id: post.id });
15
15
  const [error, setError] = useState(null);
16
16
  const [pending, setPending] = useState(null);
17
+ const [confirmingWaitlist, setConfirmingWaitlist] = useState(false);
17
18
  const [submitting, setSubmitting] = useState(false);
18
19
  const eventData = post.data?.type === 'event' ? post.data : undefined;
19
20
  const recurring = eventData ? isRecurringEvent(eventData) : false;
21
+ const viewedTimes = eventData
22
+ ? effectiveEventTimes(eventData, recurrenceId)
23
+ : undefined;
24
+ // Series home shows its first start. Once that time has passed, RSVP stays
25
+ // off that page; upcoming dates are opened from their own links.
26
+ const viewedEnded = !!viewedTimes && occurrenceHasEnded(viewedTimes.start, viewedTimes.end);
27
+ // A selected date, or a one-off, is closed on its own end time.
20
28
  const rsvpClosed = eventData
21
- ? !eventRsvpOpen(eventData, { recurrenceId, lockToOccurrence })
29
+ ? !eventRsvpOpen(eventData, recurrenceId ? { recurrenceId, lockToOccurrence: true } : undefined)
22
30
  : false;
23
- const queriedOccurrenceClosed = !!eventData &&
24
- !!recurrenceId &&
25
- !eventRsvpOpen(eventData, { recurrenceId, lockToOccurrence: true });
31
+ const queriedOccurrenceClosed = !!recurrenceId && rsvpClosed;
26
32
  const defaultId = eventData
27
33
  ? defaultRsvpRecurrenceId(eventData, queriedOccurrenceClosed ? undefined : recurrenceId)
28
34
  : undefined;
29
35
  const occurrences = eventData && recurring ? listRsvpOccurrences(eventData) : [];
30
- const capacityRecurrenceId = lockToOccurrence ? recurrenceId : defaultId;
36
+ const capacityRecurrenceId = recurring
37
+ ? lockToOccurrence
38
+ ? recurrenceId
39
+ : defaultId
40
+ : undefined;
31
41
  const capacityEvent = eventData ? isCapacityEvent(eventData) : false;
32
42
  const atCapacity = capacityEvent &&
33
- eventData?.maxAttendees !== undefined &&
43
+ !!profile &&
34
44
  (recurring && !lockToOccurrence
35
- ? !recurringEventHasOpenOccurrence(post, profile?.id)
36
- : countYesRsvps(post, capacityRecurrenceId) >= eventData.maxAttendees);
45
+ ? !seriesHasClaimableOccurrence(post, profile.id)
46
+ : !canClaimYesRsvp(post, profile.id, capacityRecurrenceId));
37
47
  const myEvent = post.profile?.id === profile?.id;
38
48
  const myRsvp = useMemo(() => profile
39
49
  ? displayRsvpForProfile(post, profile.id, {
@@ -44,6 +54,8 @@ export const useEventRsvp = ({ post, recurrenceId, lockToOccurrence = false, onS
44
54
  const canRsvp = useMemo(() => checkPostCapabilities(authData, ['core-posts-rsvp'], post, capabilities)
45
55
  .success, [authData, post, capabilities]);
46
56
  const full = atCapacity && myRsvp?.response !== 'yes';
57
+ const onWaitlist = myRsvp?.response === 'waitlist';
58
+ const offerExpiresAt = onWaitlist && offerStillOpen(myRsvp) ? myRsvp.offerExpiresAt : undefined;
47
59
  const writeRsvp = async (response, recurrenceIds) => {
48
60
  setError(null);
49
61
  setSubmitting(true);
@@ -69,8 +81,37 @@ export const useEventRsvp = ({ post, recurrenceId, lockToOccurrence = false, onS
69
81
  setSubmitting(false);
70
82
  }
71
83
  };
84
+ const requestJoinWaitlist = () => {
85
+ if (rsvpClosed || viewedEnded)
86
+ return;
87
+ if (!recurring || lockToOccurrence) {
88
+ setError(null);
89
+ setConfirmingWaitlist(true);
90
+ return;
91
+ }
92
+ setError(null);
93
+ setPending('waitlist');
94
+ };
95
+ const confirmJoinWaitlist = async () => {
96
+ try {
97
+ await writeRsvp('waitlist', recurrenceId ? [recurrenceId] : undefined);
98
+ setConfirmingWaitlist(false);
99
+ return true;
100
+ }
101
+ catch {
102
+ return false;
103
+ }
104
+ };
105
+ const claimSpot = () => {
106
+ if (rsvpClosed || viewedEnded)
107
+ return;
108
+ const id = recurring
109
+ ? (myRsvp?.recurrenceId ?? (lockToOccurrence ? recurrenceId : defaultId))
110
+ : undefined;
111
+ writeRsvp('yes', id ? [id] : undefined).catch(() => undefined);
112
+ };
72
113
  const requestRespond = (response) => {
73
- if (rsvpClosed)
114
+ if (rsvpClosed || viewedEnded)
74
115
  return;
75
116
  if (!recurring || lockToOccurrence) {
76
117
  writeRsvp(response, recurrenceId ? [recurrenceId] : undefined).catch(() => undefined);
@@ -105,16 +146,24 @@ export const useEventRsvp = ({ post, recurrenceId, lockToOccurrence = false, onS
105
146
  myRsvp,
106
147
  canRsvp,
107
148
  rsvpClosed,
149
+ hideRsvpButton: rsvpClosed || viewedEnded,
108
150
  recurring,
109
151
  defaultId,
110
152
  occurrences,
111
153
  capacityEvent,
112
154
  full,
155
+ onWaitlist,
156
+ offerExpiresAt,
113
157
  error,
114
158
  pending,
115
159
  setPending,
160
+ confirmingWaitlist,
161
+ setConfirmingWaitlist,
116
162
  submitting,
117
163
  requestRespond,
164
+ requestJoinWaitlist,
165
+ confirmJoinWaitlist,
166
+ claimSpot,
118
167
  confirmScope,
119
168
  };
120
169
  };