@openpeepshq/react 0.7.0 → 0.7.1

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 (188) 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/notifications/TypedNotification.js +46 -4
  16. package/dist/components/post/Markdown.d.ts +2 -2
  17. package/dist/components/post/Markdown.js +1 -1
  18. package/dist/components/post/attachmentPreview.js +1 -1
  19. package/dist/components/post/pieces/Attachments.js +23 -17
  20. package/dist/components/post/pieces/EventRsvpButton.js +37 -7
  21. package/dist/components/post/pieces/EventRsvpList.js +23 -3
  22. package/dist/components/post/pieces/EventRsvpScopeDialog.d.ts +1 -1
  23. package/dist/components/post/pieces/EventRsvpScopeDialog.js +34 -22
  24. package/dist/components/post/pieces/EventWaitlistJoinDialog.d.ts +10 -0
  25. package/dist/components/post/pieces/EventWaitlistJoinDialog.js +26 -0
  26. package/dist/components/post/pieces/ParticipantsCard.d.ts +1 -1
  27. package/dist/components/post/pieces/ParticipantsCard.js +1 -1
  28. package/dist/components/post/pieces/PostActions.d.ts +1 -1
  29. package/dist/components/post/pieces/PostActions.js +20 -12
  30. package/dist/components/post/pieces/ShareMenu.d.ts +6 -1
  31. package/dist/components/post/pieces/ShareMenu.js +40 -7
  32. package/dist/components/post/post-form/EventForm.js +10 -2
  33. package/dist/components/post/types/Article.js +1 -1
  34. package/dist/components/post/types/article/FullArticle.js +1 -1
  35. package/dist/components/post/types/event/CardEvent.js +2 -1
  36. package/dist/components/post/types/event/FullEvent.js +22 -13
  37. package/dist/components/post/types/event/ProfileEventRelationship.js +8 -0
  38. package/dist/components/preview-link/LocalPreviewLink.js +4 -2
  39. package/dist/components/preview-link/PreviewLink.js +1 -1
  40. package/dist/components/preview-link/helpers.d.ts +5 -0
  41. package/dist/components/preview-link/helpers.js +27 -1
  42. package/dist/components/preview-link/local/WelcomePreview.d.ts +1 -0
  43. package/dist/components/preview-link/local/WelcomePreview.js +6 -0
  44. package/dist/components/profile/Avatar.js +2 -2
  45. package/dist/components/profile/ProfileFromId.js +1 -1
  46. package/dist/components/server-data/context.d.ts +1 -0
  47. package/dist/contexts/openpeeps/hooks/accounts.d.ts +5 -5
  48. package/dist/contexts/openpeeps/hooks/accounts.js +1 -3
  49. package/dist/contexts/openpeeps/hooks/admin.d.ts +165 -66
  50. package/dist/contexts/openpeeps/hooks/admin.js +11 -3
  51. package/dist/contexts/openpeeps/hooks/auth.d.ts +2 -2
  52. package/dist/contexts/openpeeps/hooks/groups.d.ts +8 -8
  53. package/dist/contexts/openpeeps/hooks/jams.d.ts +73 -24
  54. package/dist/contexts/openpeeps/hooks/other.d.ts +7 -6
  55. package/dist/contexts/openpeeps/hooks/payments.d.ts +2 -2
  56. package/dist/contexts/openpeeps/hooks/posts.d.ts +368 -170
  57. package/dist/contexts/openpeeps/hooks/streaming.d.ts +1 -1
  58. package/dist/hooks/admin/useCanAccessAdminSection.d.ts +13 -0
  59. package/dist/hooks/admin/useCanAccessAdminSection.js +21 -0
  60. package/dist/hooks/events/useEventComposer.d.ts +94 -41
  61. package/dist/hooks/events/useEventForm.d.ts +1 -0
  62. package/dist/hooks/events/useEventRsvp.d.ts +11 -2
  63. package/dist/hooks/events/useEventRsvp.js +46 -5
  64. package/dist/hooks/events/useEventsCalendar.d.ts +174 -76
  65. package/dist/hooks/groups/useNewGroup.js +22 -2
  66. package/dist/hooks/index.d.ts +5 -1
  67. package/dist/hooks/index.js +4 -1
  68. package/dist/hooks/jams/useCanDiagnoseLivekit.d.ts +2 -0
  69. package/dist/hooks/jams/useCanDiagnoseLivekit.js +3 -0
  70. package/dist/hooks/jams/useCreateNewJamForm.d.ts +3 -1
  71. package/dist/hooks/jams/useJamDetails.d.ts +87 -38
  72. package/dist/hooks/jams/useJamLobby.d.ts +1 -0
  73. package/dist/hooks/jams/useJamRoom.d.ts +175 -76
  74. package/dist/hooks/posts/useArticleComposer.d.ts +93 -41
  75. package/dist/hooks/posts/useFeedPostPresentation.d.ts +174 -76
  76. package/dist/hooks/posts/usePostDetailTitle.d.ts +87 -38
  77. package/dist/hooks/posts/useResourceComposer.d.ts +93 -41
  78. package/dist/hooks/posts/useResourceComposer.js +4 -2
  79. package/dist/hooks/posts/useShareMenu.d.ts +2 -0
  80. package/dist/hooks/posts/useShareMenu.js +7 -0
  81. package/dist/hooks/resources/useResourceLibrary.d.ts +176 -78
  82. package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
  83. package/dist/hooks/useWelcomePreview.d.ts +13 -0
  84. package/dist/hooks/useWelcomePreview.js +39 -0
  85. package/dist/lib/groupFormErrors.d.ts +1 -0
  86. package/dist/lib/groupFormErrors.js +5 -2
  87. package/dist/lib/threadHelpers.js +1 -5
  88. package/dist/pages/admin/ConfigurationCommunity.js +1 -1
  89. package/dist/pages/admin/Diagnostics.js +1 -1
  90. package/dist/pages/admin/DiagnosticsLivekit.d.ts +1 -0
  91. package/dist/pages/admin/DiagnosticsLivekit.js +50 -0
  92. package/dist/pages/admin/Invites.js +5 -3
  93. package/dist/pages/admin/Media.d.ts +1 -0
  94. package/dist/pages/admin/Media.js +135 -0
  95. package/dist/pages/admin/community/CommunityForbiddenUsernames.d.ts +1 -0
  96. package/dist/pages/admin/community/CommunityForbiddenUsernames.js +106 -0
  97. package/dist/pages/admin/community/CommunityRoles.js +1 -1
  98. package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
  99. package/dist/pages/admin/components/EditInviteLinkModal.d.ts +5 -0
  100. package/dist/pages/admin/components/EditInviteLinkModal.js +131 -0
  101. package/dist/pages/auth/Register.js +30 -8
  102. package/dist/pages/conversations/Show.js +11 -0
  103. package/dist/pages/index.d.ts +3 -0
  104. package/dist/pages/index.js +3 -0
  105. package/dist/pages/jams/Index.js +2 -4
  106. package/dist/pages/settings/PublicProfile.js +15 -3
  107. package/dist/pwa/sw.d.ts +0 -1
  108. package/dist/react-native.d.ts +1 -0
  109. package/dist/react-native.js +1 -0
  110. package/dist/stores/newPosts.d.ts +4 -2
  111. package/dist/stores/newPosts.js +6 -1
  112. package/package.json +12 -7
  113. package/src/components/configuration/ConfigurationCategory.tsx +23 -10
  114. package/src/components/configuration/ConfigurationList.tsx +6 -1
  115. package/src/components/form/LocationInput.tsx +7 -1
  116. package/src/components/jams/JamCapacityGate.tsx +1 -1
  117. package/src/components/jams/JamConference.tsx +2 -0
  118. package/src/components/jams/JamParticipantConference.tsx +2 -0
  119. package/src/components/jams/JamRoom.tsx +2 -6
  120. package/src/components/jams/LiveJamsSection.tsx +16 -2
  121. package/src/components/jams/LivekitUnavailableNotice.tsx +40 -0
  122. package/src/components/jams/dropLateAudio.ts +153 -0
  123. package/src/components/jams/index.ts +1 -0
  124. package/src/components/notifications/TypedNotification.tsx +81 -9
  125. package/src/components/post/Markdown.tsx +8 -2
  126. package/src/components/post/attachmentPreview.ts +1 -3
  127. package/src/components/post/pieces/Attachments.tsx +93 -78
  128. package/src/components/post/pieces/EventRsvpButton.tsx +107 -7
  129. package/src/components/post/pieces/EventRsvpList.tsx +64 -0
  130. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +39 -27
  131. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +77 -0
  132. package/src/components/post/pieces/ParticipantsCard.tsx +4 -1
  133. package/src/components/post/pieces/PostActions.tsx +73 -42
  134. package/src/components/post/pieces/ShareMenu.tsx +67 -9
  135. package/src/components/post/post-form/EventForm.tsx +26 -0
  136. package/src/components/post/post-form/VisibilitySelector.tsx +1 -2
  137. package/src/components/post/types/Article.tsx +1 -1
  138. package/src/components/post/types/article/FullArticle.tsx +2 -2
  139. package/src/components/post/types/event/CardEvent.tsx +26 -14
  140. package/src/components/post/types/event/FullEvent.tsx +48 -35
  141. package/src/components/post/types/event/ProfileEventRelationship.tsx +8 -0
  142. package/src/components/post/types/note/FullNote.tsx +1 -4
  143. package/src/components/post/types/poll/FullPoll.tsx +1 -4
  144. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  145. package/src/components/preview-link/PreviewLink.tsx +2 -7
  146. package/src/components/preview-link/helpers.ts +32 -1
  147. package/src/components/preview-link/local/GroupPreview.tsx +1 -1
  148. package/src/components/preview-link/local/JamPreview.tsx +1 -1
  149. package/src/components/preview-link/local/WelcomePreview.tsx +36 -0
  150. package/src/components/profile/Avatar.tsx +6 -2
  151. package/src/components/profile/ProfileFromId.tsx +1 -5
  152. package/src/components/resources/ResourceCard.tsx +0 -1
  153. package/src/contexts/openpeeps/hooks/accounts.ts +1 -3
  154. package/src/contexts/openpeeps/hooks/admin.ts +11 -3
  155. package/src/contexts/openpeeps/hooks/other.ts +9 -12
  156. package/src/contexts/openpeeps/hooks/streaming.ts +3 -3
  157. package/src/css.d.ts +4 -0
  158. package/src/hooks/admin/useCanAccessAdminSection.ts +27 -0
  159. package/src/hooks/events/useEventRsvp.ts +51 -7
  160. package/src/hooks/groups/useNewGroup.ts +28 -3
  161. package/src/hooks/index.ts +8 -1
  162. package/src/hooks/jams/useCanDiagnoseLivekit.ts +5 -0
  163. package/src/hooks/posts/useResourceComposer.ts +8 -6
  164. package/src/hooks/posts/useShareMenu.ts +9 -0
  165. package/src/hooks/useWelcomePreview.ts +57 -0
  166. package/src/i18n/I18nProvider.tsx +1 -4
  167. package/src/lib/groupFormErrors.ts +9 -2
  168. package/src/lib/threadHelpers.ts +1 -5
  169. package/src/pages/admin/ConfigurationCommunity.tsx +5 -0
  170. package/src/pages/admin/Diagnostics.tsx +4 -0
  171. package/src/pages/admin/DiagnosticsLivekit.tsx +147 -0
  172. package/src/pages/admin/Invites.tsx +23 -1
  173. package/src/pages/admin/Media.tsx +290 -0
  174. package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +223 -0
  175. package/src/pages/admin/community/CommunityRoles.tsx +2 -2
  176. package/src/pages/admin/components/EditInviteLinkModal.tsx +263 -0
  177. package/src/pages/auth/Register.tsx +33 -4
  178. package/src/pages/conversations/Show.tsx +11 -0
  179. package/src/pages/index.ts +3 -0
  180. package/src/pages/jams/Index.tsx +2 -6
  181. package/src/pages/settings/PublicProfile.tsx +20 -2
  182. package/src/pwa/sw.ts +6 -3
  183. package/src/pwa/useNotificationBadgeSync.ts +3 -1
  184. package/src/react-native.ts +1 -0
  185. package/src/stores/newPosts.ts +6 -1
  186. package/src/streaming.ts +3 -3
  187. package/dist/setupTests.d.ts +0 -1
  188. package/dist/setupTests.js +0 -5
@@ -3,6 +3,7 @@ import { useT } from '../../../i18n';
3
3
  import { Button } from '@openpeepshq/react-ui';
4
4
  import { useEventRsvp } from '../../../hooks/events/useEventRsvp';
5
5
  import { EventRsvpScopeDialog } from './EventRsvpScopeDialog';
6
+ import { EventWaitlistJoinDialog } from './EventWaitlistJoinDialog';
6
7
 
7
8
  export interface EventRsvpButtonProps {
8
9
  post: PublicPost;
@@ -27,11 +28,18 @@ export const EventRsvpButton = ({
27
28
  occurrences,
28
29
  capacityEvent,
29
30
  full,
31
+ onWaitlist,
32
+ offerExpiresAt,
30
33
  error,
31
34
  pending,
32
35
  setPending,
36
+ confirmingWaitlist,
37
+ setConfirmingWaitlist,
33
38
  submitting,
34
39
  requestRespond,
40
+ requestJoinWaitlist,
41
+ confirmJoinWaitlist,
42
+ claimSpot,
35
43
  confirmScope,
36
44
  } = useEventRsvp({ post, recurrenceId, lockToOccurrence });
37
45
 
@@ -57,9 +65,13 @@ export const EventRsvpButton = ({
57
65
  ? t('posts.rsvp.attendingMessage', {
58
66
  defaultValue: 'You are attending.',
59
67
  })
60
- : t('posts.rsvp.maybeMessage', {
61
- defaultValue: 'You responded maybe.',
62
- })}
68
+ : myRsvp.response === 'waitlist'
69
+ ? t('events.rsvp.onWaitlist', {
70
+ defaultValue: 'You are on the waitlist.',
71
+ })
72
+ : t('posts.rsvp.maybeMessage', {
73
+ defaultValue: 'You responded maybe.',
74
+ })}
63
75
  </p>
64
76
  ) : null}
65
77
  <p className="text-muted-foreground mt-2 text-center text-sm">
@@ -90,6 +102,86 @@ export const EventRsvpButton = ({
90
102
  />
91
103
  ) : null;
92
104
 
105
+ const waitlistDialog = (
106
+ <EventWaitlistJoinDialog
107
+ open={confirmingWaitlist}
108
+ post={post}
109
+ error={error}
110
+ submitting={submitting}
111
+ onClose={() => {
112
+ if (!submitting) setConfirmingWaitlist(false);
113
+ }}
114
+ onConfirm={async () => {
115
+ await confirmJoinWaitlist();
116
+ }}
117
+ />
118
+ );
119
+
120
+ if (offerExpiresAt) {
121
+ return (
122
+ <div className="mt-4 w-full">
123
+ <p className="text-center text-sm">
124
+ {t('events.rsvp.offerOpen', {
125
+ defaultValue: 'A spot is open for you until {{until}}.',
126
+ until: new Date(offerExpiresAt).toLocaleString(),
127
+ })}
128
+ </p>
129
+ <Button
130
+ variant="default"
131
+ className="mt-2 w-full"
132
+ disabled={submitting}
133
+ action={claimSpot}
134
+ >
135
+ {t('events.rsvp.claimSpot', { defaultValue: 'Claim spot' })}
136
+ </Button>
137
+ <Button
138
+ variant="outline"
139
+ className="text-error mt-2 w-full"
140
+ disabled={submitting}
141
+ action={() => requestRespond('no')}
142
+ >
143
+ {t('events.rsvp.leaveWaitlist', {
144
+ defaultValue: 'Leave waitlist',
145
+ })}
146
+ </Button>
147
+ {error ? (
148
+ <p className="text-error mt-2 text-center text-sm">{error}</p>
149
+ ) : null}
150
+ </div>
151
+ );
152
+ }
153
+
154
+ if (onWaitlist) {
155
+ return (
156
+ <div className="mt-4 w-full">
157
+ <p className="text-center text-sm">
158
+ {t('events.rsvp.onWaitlist', {
159
+ defaultValue: 'You are on the waitlist.',
160
+ })}
161
+ </p>
162
+ <p className="text-muted-foreground mt-1 text-center text-sm">
163
+ {t('events.rsvp.atCapacity', {
164
+ defaultValue: 'This event is at capacity.',
165
+ })}
166
+ </p>
167
+ <Button
168
+ variant="outline"
169
+ className="text-error mt-2 w-full"
170
+ disabled={submitting}
171
+ action={() => requestRespond('no')}
172
+ >
173
+ {t('events.rsvp.leaveWaitlist', {
174
+ defaultValue: 'Leave waitlist',
175
+ })}
176
+ </Button>
177
+ {error && !pending ? (
178
+ <p className="text-error mt-2 text-center text-sm">{error}</p>
179
+ ) : null}
180
+ {scopeDialog}
181
+ </div>
182
+ );
183
+ }
184
+
93
185
  if (myRsvp && myRsvp.response !== 'no') {
94
186
  return (
95
187
  <div className="w-full">
@@ -122,15 +214,22 @@ export const EventRsvpButton = ({
122
214
 
123
215
  return (
124
216
  <div className="mt-4 w-full">
217
+ {full ? (
218
+ <p className="text-muted-foreground mb-2 text-center text-sm">
219
+ {t('events.rsvp.atCapacity', {
220
+ defaultValue: 'This event is at capacity.',
221
+ })}
222
+ </p>
223
+ ) : null}
125
224
  <div className="flex w-full gap-x-2">
126
225
  <Button
127
226
  variant="default"
128
227
  className="w-[70%]"
129
- disabled={full || submitting}
130
- action={() => requestRespond('yes')}
228
+ disabled={submitting}
229
+ action={() => (full ? requestJoinWaitlist() : requestRespond('yes'))}
131
230
  >
132
231
  {full
133
- ? t('events.rsvp.full', { defaultValue: 'Event is full' })
232
+ ? t('events.rsvp.joinWaitlist', { defaultValue: 'Join waitlist' })
134
233
  : t('posts.rsvp.register', { defaultValue: 'Register' })}
135
234
  </Button>
136
235
  {!capacityEvent ? (
@@ -150,10 +249,11 @@ export const EventRsvpButton = ({
150
249
  {t('posts.rsvp.no', { defaultValue: 'No' })}
151
250
  </Button>
152
251
  </div>
153
- {error && !pending ? (
252
+ {error && !pending && !confirmingWaitlist ? (
154
253
  <p className="text-error mt-2 text-center text-sm">{error}</p>
155
254
  ) : null}
156
255
  {scopeDialog}
256
+ {waitlistDialog}
157
257
  </div>
158
258
  );
159
259
  };
@@ -14,6 +14,8 @@ import {
14
14
  isRecurringEvent,
15
15
  listedRsvps,
16
16
  listRsvpCancellations,
17
+ offerStillOpen,
18
+ orderedWaitlist,
17
19
  profileName,
18
20
  rsvpCancelWhenLabels,
19
21
  sameRecurrenceId,
@@ -126,6 +128,9 @@ export const EventRsvpList = ({
126
128
  onMessage={onMessage}
127
129
  onManage={onManage}
128
130
  />
131
+ {canManageRsvps ? (
132
+ <WaitlistSection post={post} recurrenceId={occurrenceId} />
133
+ ) : null}
129
134
  {history}
130
135
  </>
131
136
  );
@@ -168,6 +173,9 @@ export const EventRsvpList = ({
168
173
  onMessage={onMessage}
169
174
  onManage={onManage}
170
175
  />
176
+ {canManageRsvps ? (
177
+ <WaitlistSection post={post} recurrenceId={key} />
178
+ ) : null}
171
179
  </RsvpPanel>
172
180
  );
173
181
  })}
@@ -176,6 +184,62 @@ export const EventRsvpList = ({
176
184
  );
177
185
  };
178
186
 
187
+ const WaitlistSection = ({
188
+ post,
189
+ recurrenceId,
190
+ }: {
191
+ post: PublicPost;
192
+ recurrenceId?: string;
193
+ }) => {
194
+ const t = useT();
195
+ const waiting = orderedWaitlist(post, recurrenceId);
196
+ if (!waiting.length) return null;
197
+ const profiles = new Map(
198
+ (post.rsvps ?? []).map((rsvp) => [rsvp.profile.id, rsvp.profile]),
199
+ );
200
+ return (
201
+ <div className="mt-4 border-t pt-3">
202
+ <h3 className="mb-2 text-sm font-semibold">
203
+ {t('events.rsvp.waitlistTitle', { defaultValue: 'Waitlist' })}
204
+ </h3>
205
+ <ol className="flex flex-col gap-2">
206
+ {waiting.map((member, index) => {
207
+ const profile = profiles.get(member.profileId);
208
+ if (!profile) return null;
209
+ const until = member.offerExpiresAt;
210
+ const offered = !!until && offerStillOpen({ offerExpiresAt: until });
211
+ return (
212
+ <li key={member.profileId} className="text-sm">
213
+ <span className="text-muted-foreground">{index + 1}. </span>
214
+ <span className="font-medium">{profileName(profile)}</span>
215
+ {offered ? (
216
+ <span className="text-muted-foreground">
217
+ {' '}
218
+ —{' '}
219
+ {t('events.rsvp.waitlistOffered', {
220
+ defaultValue: 'offered until {{until}}',
221
+ until: new Date(until ?? '').toLocaleString(),
222
+ })}
223
+ </span>
224
+ ) : null}
225
+ {profile.type === 'federated' ? (
226
+ <span className="text-muted-foreground">
227
+ {' '}
228
+ —{' '}
229
+ {t('events.rsvp.waitlistRemote', {
230
+ defaultValue:
231
+ 'Remote member, not offered a spot automatically',
232
+ })}
233
+ </span>
234
+ ) : null}
235
+ </li>
236
+ );
237
+ })}
238
+ </ol>
239
+ </div>
240
+ );
241
+ };
242
+
179
243
  const RsvpCancellationHistory = ({ post }: { post: PublicPost }) => {
180
244
  const t = useT();
181
245
  const cancellations = listRsvpCancellations(post);
@@ -2,10 +2,9 @@ import { useEffect, useState } from 'react';
2
2
  import type { PublicPost } from '@openpeepshq/common/types';
3
3
  import type { ExpandedOccurrence } from '@openpeepshq/common/lib';
4
4
  import {
5
- countYesRsvps,
6
- getEffectiveRsvp,
7
- isCapacityEvent,
8
- seriesYesBlockedByCapacity,
5
+ canClaimYesRsvp,
6
+ canJoinWaitlist,
7
+ seriesClaimBlocked,
9
8
  } from '@openpeepshq/common/lib';
10
9
  import type { RsvpScopeChoice } from '../../../hooks/events/useEventRsvp';
11
10
  import {
@@ -27,7 +26,7 @@ export type { RsvpScopeChoice };
27
26
  export type EventRsvpScopeDialogProps = {
28
27
  open: boolean;
29
28
  post: PublicPost;
30
- response: 'yes' | 'tentative' | 'no';
29
+ response: 'yes' | 'tentative' | 'no' | 'waitlist';
31
30
  defaultRecurrenceId?: string;
32
31
  occurrences: ExpandedOccurrence[];
33
32
  error?: string | null;
@@ -60,19 +59,16 @@ export const EventRsvpScopeDialog = ({
60
59
  }: EventRsvpScopeDialogProps) => {
61
60
  const t = useT();
62
61
  const profile = useCurrentProfile();
63
- const event = post.data?.type === 'event' ? post.data : undefined;
64
- const capacityEvent = event ? isCapacityEvent(event) : false;
62
+ const joiningWaitlist = response === 'waitlist';
65
63
  const seriesFull =
66
- response === 'yes' &&
67
- !!profile &&
68
- seriesYesBlockedByCapacity(post, profile.id);
69
- const occurrenceIsFull = (recurrenceId: string) =>
70
- response === 'yes' &&
71
- capacityEvent &&
72
- event?.maxAttendees !== undefined &&
73
- getEffectiveRsvp(post, profile?.id ?? '', recurrenceId)?.response !==
74
- 'yes' &&
75
- countYesRsvps(post, recurrenceId) >= event.maxAttendees;
64
+ response === 'yes' && !!profile && seriesClaimBlocked(post, profile.id);
65
+ const occurrenceIsFull = (recurrenceId: string) => {
66
+ if (!profile) return false;
67
+ if (joiningWaitlist)
68
+ return !canJoinWaitlist(post, profile.id, recurrenceId);
69
+ if (response !== 'yes') return false;
70
+ return !canClaimYesRsvp(post, profile.id, recurrenceId);
71
+ };
76
72
  const currentFull =
77
73
  !!defaultRecurrenceId && occurrenceIsFull(defaultRecurrenceId);
78
74
  const initialScope: ScopeKind = currentFull
@@ -130,9 +126,13 @@ export const EventRsvpScopeDialog = ({
130
126
  <DialogContent className="max-h-[85vh] max-w-md overflow-y-auto">
131
127
  <DialogHeader>
132
128
  <DialogTitle>
133
- {t('events.rsvp.scope.title', {
134
- defaultValue: 'Which dates?',
135
- })}
129
+ {joiningWaitlist
130
+ ? t('events.rsvp.scope.waitlistTitle', {
131
+ defaultValue: 'Join the waitlist for which dates?',
132
+ })
133
+ : t('events.rsvp.scope.title', {
134
+ defaultValue: 'Which dates?',
135
+ })}
136
136
  </DialogTitle>
137
137
  </DialogHeader>
138
138
  <RadioGroup
@@ -157,7 +157,7 @@ export const EventRsvpScopeDialog = ({
157
157
  })}
158
158
  </label>
159
159
  ) : null}
160
- {currentFull ? null : (
160
+ {currentFull || joiningWaitlist ? null : (
161
161
  <label className="flex items-start gap-2 text-sm">
162
162
  <RadioGroupItem value="series" disabled={seriesFull} />
163
163
  <span>
@@ -200,9 +200,15 @@ export const EventRsvpScopeDialog = ({
200
200
  <span className={full ? 'text-muted-foreground' : ''}>
201
201
  {formatOccurrenceStart(occurrence.start)}
202
202
  {full
203
- ? ` — ${t('events.rsvp.full', {
204
- defaultValue: 'Event is full',
205
- })}`
203
+ ? ` — ${
204
+ joiningWaitlist
205
+ ? t('events.rsvp.spotsOpen', {
206
+ defaultValue: 'Spots still open',
207
+ })
208
+ : t('events.rsvp.full', {
209
+ defaultValue: 'Event is full',
210
+ })
211
+ }`
206
212
  : ''}
207
213
  </span>
208
214
  </label>
@@ -225,9 +231,15 @@ export const EventRsvpScopeDialog = ({
225
231
  defaultValue: 'Cancel',
226
232
  })}
227
233
  onCancel={onClose}
228
- actionLabel={t('events.rsvp.scope.confirm', {
229
- defaultValue: 'Confirm',
230
- })}
234
+ actionLabel={
235
+ joiningWaitlist
236
+ ? t('events.rsvp.joinWaitlist', {
237
+ defaultValue: 'Join waitlist',
238
+ })
239
+ : t('events.rsvp.scope.confirm', {
240
+ defaultValue: 'Confirm',
241
+ })
242
+ }
231
243
  onAction={confirm}
232
244
  disabled={confirmDisabled}
233
245
  />
@@ -0,0 +1,77 @@
1
+ import type { PublicPost } from '@openpeepshq/common/types';
2
+ import { waitlistOfferWindowMs } from '@openpeepshq/common/lib';
3
+ import {
4
+ Dialog,
5
+ DialogActions,
6
+ DialogContent,
7
+ DialogHeader,
8
+ DialogTitle,
9
+ } from '@openpeepshq/react-ui';
10
+ import { useT } from '../../../i18n';
11
+
12
+ export type EventWaitlistJoinDialogProps = {
13
+ open: boolean;
14
+ post: PublicPost;
15
+ error?: string | null;
16
+ submitting?: boolean;
17
+ onClose: () => void;
18
+ onConfirm: () => void | Promise<void>;
19
+ };
20
+
21
+ export const EventWaitlistJoinDialog = ({
22
+ open,
23
+ post,
24
+ error,
25
+ submitting,
26
+ onClose,
27
+ onConfirm,
28
+ }: EventWaitlistJoinDialogProps) => {
29
+ const t = useT();
30
+ const event = post.data?.type === 'event' ? post.data : undefined;
31
+ const minutes = event
32
+ ? Math.round(waitlistOfferWindowMs(event) / 60_000)
33
+ : 60;
34
+
35
+ return (
36
+ <Dialog
37
+ open={open}
38
+ onOpenChange={(next) => {
39
+ if (!next && !submitting) onClose();
40
+ }}
41
+ >
42
+ <DialogContent className="max-w-md">
43
+ <DialogHeader>
44
+ <DialogTitle>
45
+ {t('events.rsvp.waitlistConfirmTitle', {
46
+ defaultValue: 'Join the waitlist?',
47
+ })}
48
+ </DialogTitle>
49
+ </DialogHeader>
50
+ <p className="text-sm">
51
+ {t('events.rsvp.atCapacity', {
52
+ defaultValue: 'This event is at capacity.',
53
+ })}
54
+ </p>
55
+ <p className="text-muted-foreground text-sm">
56
+ {t('events.rsvp.waitlistConfirmBody', {
57
+ defaultValue:
58
+ 'If a spot opens, you will have {{minutes}} minutes to claim it.',
59
+ minutes,
60
+ })}
61
+ </p>
62
+ {error ? <p className="text-error text-sm">{error}</p> : null}
63
+ <DialogActions
64
+ cancelLabel={t('events.rsvp.scope.cancel', {
65
+ defaultValue: 'Cancel',
66
+ })}
67
+ onCancel={onClose}
68
+ actionLabel={t('events.rsvp.joinWaitlist', {
69
+ defaultValue: 'Join waitlist',
70
+ })}
71
+ onAction={onConfirm}
72
+ disabled={submitting}
73
+ />
74
+ </DialogContent>
75
+ </Dialog>
76
+ );
77
+ };
@@ -22,7 +22,10 @@ function ParticipantAvatar({ id, size }: { id: string; size: number }) {
22
22
 
23
23
  /** Overlapping avatar stack of the first jam participants. Mirrors the Svelte
24
24
  * `ParticipantsCard`. */
25
- export function ParticipantsCard({ jamState, size = 1.5 }: ParticipantsCardProps) {
25
+ export function ParticipantsCard({
26
+ jamState,
27
+ size = 1.5,
28
+ }: ParticipantsCardProps) {
26
29
  return (
27
30
  <div className="flex w-full items-center justify-between gap-4">
28
31
  <div className="flex items-center">
@@ -1,9 +1,10 @@
1
- import { Reply, Repeat2, ThumbsUp } from 'lucide-react';
1
+ import { Reply, Repeat2, Share, ThumbsUp } from 'lucide-react';
2
2
  import type { PublicPost } from '@openpeepshq/common/types';
3
- import { Button } from '@openpeepshq/react-ui';
3
+ import { Button, cn } from '@openpeepshq/react-ui';
4
4
  import { useT } from '../../../i18n';
5
5
  import { useFeedPostActions } from '../../../hooks/posts/useFeedPostActions';
6
6
  import { postReactionStats } from '../helpers';
7
+ import { ShareMenu } from './ShareMenu';
7
8
 
8
9
  export interface PostActionsProps {
9
10
  post: PublicPost;
@@ -30,18 +31,31 @@ export function PostActions({
30
31
  toggleReaction,
31
32
  } = useFeedPostActions(post);
32
33
 
33
- if (!me) return null;
34
+ const replyActive = !previewMode && canReply;
35
+ const repostActive = !previewMode && canRepost;
36
+ const reactActive = !previewMode && canReact;
37
+ const shareActive = !previewMode;
34
38
 
35
- const actionClass =
36
- 'hover:bg-surface rounded-button flex gap-2 p-2 text-sm disabled:opacity-60';
39
+ // Unstyled buttons skip the shared disabled treatment. Mute them, and let
40
+ // presses fall through to this row so a feed link does not open the post.
41
+ const actionClass = (active: boolean) =>
42
+ cn(
43
+ 'rounded-button flex gap-2 p-2 text-sm',
44
+ active
45
+ ? 'cursor-pointer hover:bg-surface'
46
+ : 'pointer-events-none cursor-default text-muted-foreground disabled:text-muted-foreground',
47
+ );
37
48
 
38
49
  const replyLabel = t('posts.footer.reply', { defaultValue: 'Reply' });
39
50
  const repostLabel = t('posts.footer.repost', { defaultValue: 'Repost' });
40
51
  const likeLabel = t('posts.footer.like', { defaultValue: 'Like' });
52
+ const shareLabel = t('posts.footer.share', { defaultValue: 'Share' });
41
53
 
42
54
  return (
43
55
  <div
44
- className="mx-auto grid w-full grid-cols-3 items-center p-2"
56
+ className={`mx-auto flex w-full cursor-default items-center p-2 ${
57
+ me ? 'justify-between' : 'justify-end'
58
+ }`}
45
59
  onClick={(e) => {
46
60
  e.preventDefault();
47
61
  e.stopPropagation();
@@ -49,43 +63,60 @@ export function PostActions({
49
63
  onKeyDown={(e) => e.stopPropagation()}
50
64
  role="presentation"
51
65
  >
52
- <Button
66
+ {me ? (
67
+ <>
68
+ <Button
69
+ variant="unstyled"
70
+ className={actionClass(replyActive)}
71
+ title={t('posts.actions.reply', { defaultValue: 'Reply' })}
72
+ action={reply}
73
+ disabled={!replyActive}
74
+ >
75
+ <Reply className="h-4 w-4" />
76
+ {compact ? post.replyCount || null : replyLabel}
77
+ </Button>
78
+ <Button
79
+ variant="unstyled"
80
+ className={cn(
81
+ actionClass(repostActive),
82
+ myRepost && repostActive && 'text-primary',
83
+ )}
84
+ title={t('posts.actions.repost', { defaultValue: 'Repost' })}
85
+ action={toggleRepost}
86
+ disabled={!repostActive}
87
+ spinnerOnlyOnLoading
88
+ data-testid="posts-repost-button"
89
+ >
90
+ <Repeat2 className="h-4 w-4" />
91
+ {compact ? post.repostCount || null : repostLabel}
92
+ </Button>
93
+ <Button
94
+ variant="unstyled"
95
+ className={cn(
96
+ actionClass(reactActive),
97
+ iReacted && reactActive && 'text-primary',
98
+ )}
99
+ title={t('posts.actions.react', { defaultValue: 'React' })}
100
+ action={toggleReaction}
101
+ disabled={!reactActive}
102
+ spinnerOnlyOnLoading
103
+ >
104
+ <ThumbsUp className="h-4 w-4" />
105
+ {compact
106
+ ? post.reactions?.length
107
+ ? ` · ${postReactionStats(post)}`
108
+ : null
109
+ : likeLabel}
110
+ </Button>
111
+ </>
112
+ ) : null}
113
+ <ShareMenu
114
+ post={post}
53
115
  variant="unstyled"
54
- className={`${actionClass} justify-self-start`}
55
- title={t('posts.actions.reply', { defaultValue: 'Reply' })}
56
- action={reply}
57
- disabled={previewMode || !canReply}
58
- >
59
- <Reply className="h-4 w-4" />
60
- {compact ? post.replyCount || null : replyLabel}
61
- </Button>
62
- <Button
63
- variant="unstyled"
64
- className={`${actionClass} justify-self-center ${myRepost ? 'text-primary' : ''}`}
65
- title={t('posts.actions.repost', { defaultValue: 'Repost' })}
66
- action={toggleRepost}
67
- disabled={previewMode || !canRepost}
68
- spinnerOnlyOnLoading
69
- data-testid="posts-repost-button"
70
- >
71
- <Repeat2 className="h-4 w-4" />
72
- {compact ? post.repostCount || null : repostLabel}
73
- </Button>
74
- <Button
75
- variant="unstyled"
76
- className={`${actionClass} justify-self-end ${iReacted ? 'text-primary' : ''}`}
77
- title={t('posts.actions.react', { defaultValue: 'React' })}
78
- action={toggleReaction}
79
- disabled={previewMode || !canReact}
80
- spinnerOnlyOnLoading
81
- >
82
- <ThumbsUp className="h-4 w-4" />
83
- {compact
84
- ? post.reactions?.length
85
- ? ` · ${postReactionStats(post)}`
86
- : null
87
- : likeLabel}
88
- </Button>
116
+ className={actionClass(shareActive)}
117
+ text={compact ? undefined : shareLabel}
118
+ menuButton={<Share className="h-4 w-4" />}
119
+ />
89
120
  </div>
90
121
  );
91
122
  }