@openpeepshq/rn-components 0.7.2 → 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 (70) hide show
  1. package/README.md +1 -1
  2. package/package.json +12 -7
  3. package/src/components/custom/navigation/side-menu.tsx +59 -11
  4. package/src/components/icons/iconWithClassName.tsx +21 -0
  5. package/src/components/jams/JamActionsFooter.tsx +8 -2
  6. package/src/components/jams/JamCapacityGate.tsx +1 -1
  7. package/src/components/jams/JamCard.tsx +8 -4
  8. package/src/components/jams/JamConference.tsx +6 -1
  9. package/src/components/jams/JamParticipantConference.tsx +2 -0
  10. package/src/components/jams/JamRoom.tsx +2 -3
  11. package/src/components/jams/LiveJamsSection.tsx +12 -1
  12. package/src/components/jams/LivekitUnavailableNotice.tsx +25 -0
  13. package/src/components/jams/index.ts +1 -0
  14. package/src/components/markdown/MarkdownOverlay.tsx +75 -0
  15. package/src/components/markdown/OpenpeepsMarkdown.tsx +3 -1
  16. package/src/components/markdown/extensions/link.tsx +34 -0
  17. package/src/components/markdown/index.ts +2 -0
  18. package/src/components/navigation/tab-navigator.tsx +39 -17
  19. package/src/components/notifications/NotificationItem.tsx +27 -2
  20. package/src/components/notifications/types/JamStarted.tsx +13 -3
  21. package/src/components/notifications/types/Reply.tsx +1 -5
  22. package/src/components/notifications/types/WaitlistOffer.tsx +61 -0
  23. package/src/components/notifications/types/index.ts +1 -0
  24. package/src/components/post/CompactReplyParent.tsx +16 -15
  25. package/src/components/post/TruncatedMarkdown.tsx +60 -0
  26. package/src/components/post/helpers.ts +2 -2
  27. package/src/components/post/index.ts +2 -0
  28. package/src/components/post/pieces/EventRsvpButton.tsx +99 -5
  29. package/src/components/post/pieces/EventRsvpList.tsx +46 -0
  30. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +30 -19
  31. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +62 -0
  32. package/src/components/post/pieces/PollContent.tsx +7 -7
  33. package/src/components/post/pieces/PostActions.tsx +89 -23
  34. package/src/components/post/pieces/ShareMenu.tsx +2 -2
  35. package/src/components/post/post-form/DescriptionEditModal.tsx +1 -0
  36. package/src/components/post/post-form/EventForm.tsx +50 -10
  37. package/src/components/post/post-form/ResourceForm.tsx +115 -5
  38. package/src/components/post/types/Article.tsx +6 -2
  39. package/src/components/post/types/Poll.tsx +4 -1
  40. package/src/components/post/types/event/CardEvent.tsx +101 -76
  41. package/src/components/post/types/event/FullEvent.tsx +60 -23
  42. package/src/components/post/types/event/ProfileEventRelationship.tsx +2 -0
  43. package/src/components/post/types/resource/FullResource.tsx +9 -1
  44. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  45. package/src/components/preview-link/helpers.ts +5 -1
  46. package/src/components/preview-link/index.ts +1 -0
  47. package/src/components/preview-link/local/WelcomePreview.tsx +59 -0
  48. package/src/components/profile/Avatar.tsx +0 -1
  49. package/src/components/profile/EditProfileForm.tsx +23 -2
  50. package/src/components/profile/ProfileSheet.tsx +1 -1
  51. package/src/components/resources/ResourceCard.tsx +62 -14
  52. package/src/components/resources/ResourceLibrary.tsx +2 -2
  53. package/src/components/ui/badge.tsx +2 -3
  54. package/src/components/ui/bottom-sheet.tsx +0 -6
  55. package/src/components/ui/popup-menu-button.tsx +2 -2
  56. package/src/components/ui/popup-menu-separator.tsx +1 -1
  57. package/src/components/ui/popup-menu.tsx +2 -2
  58. package/src/lib/utils.ts +10 -3
  59. package/src/pages/auth/Register.tsx +34 -4
  60. package/src/pages/conversations/Show.tsx +38 -7
  61. package/src/pages/feeds/Bookmarks.tsx +1 -1
  62. package/src/pages/jams/Index.tsx +6 -4
  63. package/src/pages/posts/New.tsx +1 -1
  64. package/src/pages/resources/Edit.tsx +2 -1
  65. package/src/pages/resources/New.tsx +6 -1
  66. package/src/pages/settings/Account.tsx +46 -2
  67. package/src/pages/settings/Index.tsx +3 -4
  68. package/src/pages/settings/NotificationPreferences.tsx +3 -3
  69. package/src/pages/settings/Theme.tsx +1 -1
  70. package/src/components/icons/iconWithClassName.ts +0 -12
@@ -1,6 +1,9 @@
1
- import { View } from 'react-native';
1
+ import { Pressable, View } from 'react-native';
2
2
  import React from 'react';
3
3
  import { PublicNotification } from '@openpeepshq/common';
4
+ import { useNavigation } from '@react-navigation/native';
5
+ import { NativeStackNavigationProp } from '@react-navigation/native-stack';
6
+ import type { MainStackParamList } from '../../components/navigation/types/index';
4
7
  import {
5
8
  Announcement,
6
9
  DirectMessage,
@@ -20,6 +23,7 @@ import {
20
23
  Reaction,
21
24
  Rsvp,
22
25
  RsvpCanceled,
26
+ WaitlistOffer,
23
27
  } from './types';
24
28
  import { ThemedText } from '../ui/themed-text';
25
29
  import { NewGroupPost } from './types/NewGroupPost';
@@ -52,11 +56,14 @@ const notificationComponentMap: Record<
52
56
  reaction: Reaction,
53
57
  rsvp: Rsvp,
54
58
  rsvpCanceled: RsvpCanceled,
59
+ waitlistOffer: WaitlistOffer,
55
60
  };
56
61
 
57
62
  export const NotificationItem: React.FC<NotificationComponentProps> = ({
58
63
  notification,
59
64
  }) => {
65
+ const navigation =
66
+ useNavigation<NativeStackNavigationProp<MainStackParamList>>();
60
67
  const NotificationToRender: React.ComponentType<{
61
68
  notification: PublicNotification;
62
69
  }> = notificationComponentMap[notification.type];
@@ -70,11 +77,29 @@ export const NotificationItem: React.FC<NotificationComponentProps> = ({
70
77
  </View>
71
78
  );
72
79
  }
73
- return (
80
+
81
+ const PostBody = (
74
82
  <NotificationErrorBoundary notificationId={notification.id}>
75
83
  <View className="flex w-full items-center justify-between border-b">
76
84
  <NotificationToRender notification={notification} />
77
85
  </View>
78
86
  </NotificationErrorBoundary>
79
87
  );
88
+
89
+ if (notification.post?.id) {
90
+ return (
91
+ <Pressable
92
+ onPress={() =>
93
+ navigation.navigate('Post', {
94
+ id: notification.post!.id,
95
+ occurrence: notification.post?.occurrenceRecurrenceId ?? undefined,
96
+ })
97
+ }
98
+ >
99
+ {PostBody}
100
+ </Pressable>
101
+ );
102
+ }
103
+
104
+ return PostBody;
80
105
  };
@@ -16,15 +16,25 @@ export const JamStarted: React.FC<NotificationTypeProps> = ({
16
16
  }) => {
17
17
  const profile = notification.senderProfile!;
18
18
  const { t } = useTranslation();
19
+ const eventName =
20
+ notification.post?.data?.type === 'event'
21
+ ? notification.post.data.name?.trim()
22
+ : undefined;
19
23
 
20
24
  return (
21
25
  <NotificationWrapper profile={profile} seen={notification.seen}>
22
26
  <View className="w-full">
23
27
  <View className="mb-2 min-w-0 flex-row flex-wrap items-center gap-2">
24
28
  <ThemedText className="shrink">
25
- {t('notification.jamStarted.text', {
26
- profileName: profileName(profile),
27
- })}
29
+ {t(
30
+ eventName
31
+ ? 'notification.jamStarted.text'
32
+ : 'notification.jamStarted.textNoEvent',
33
+ {
34
+ profileName: profileName(profile),
35
+ eventName,
36
+ }
37
+ )}
28
38
  </ThemedText>
29
39
  <UpdatingDate date={notification.createdAt} />
30
40
  </View>
@@ -22,11 +22,7 @@ export const Reply: React.FC<NotificationTypeProps> = ({ notification }) => {
22
22
  useNavigation<NativeStackNavigationProp<MainStackParamList>>();
23
23
 
24
24
  return (
25
- <NotificationWrapper
26
- profile={profile}
27
- seen={notification.seen}
28
- showProfile
29
- >
25
+ <NotificationWrapper profile={profile} seen={notification.seen} showProfile>
30
26
  <Pressable
31
27
  onPress={() => navigation.navigate('Post', { id: replyPost.id })}
32
28
  className="w-full flex"
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import { Pressable, View } from 'react-native';
3
+ import { ThemedText } from '../../ui/themed-text';
4
+ import { PublicNotification } from '@openpeepshq/common';
5
+ import { isWaitlistOfferNotice } from '@openpeepshq/common/lib';
6
+ import { NotificationWrapper } from '../NotificationWrapper';
7
+ import { useTranslation } from 'react-i18next';
8
+ import { MainStackParamList } from '../../navigation/types/index';
9
+ import { NativeStackNavigationProp } from '@react-navigation/native-stack';
10
+ import { useNavigation } from '@react-navigation/native';
11
+ import { FeedPost } from '../../post';
12
+
13
+ interface NotificationTypeProps {
14
+ notification: PublicNotification;
15
+ }
16
+
17
+ export const WaitlistOffer: React.FC<NotificationTypeProps> = ({
18
+ notification,
19
+ }) => {
20
+ const profile = notification.senderProfile ?? notification.post?.profile;
21
+ const { t } = useTranslation();
22
+ const navigation =
23
+ useNavigation<NativeStackNavigationProp<MainStackParamList>>();
24
+ const post = notification.post;
25
+ const eventName =
26
+ post?.data?.type === 'event' ? post.data.name?.trim() : undefined;
27
+ const notice = isWaitlistOfferNotice(notification.data)
28
+ ? notification.data
29
+ : undefined;
30
+ if (!profile || !post) return null;
31
+
32
+ return (
33
+ <NotificationWrapper
34
+ profile={profile}
35
+ seen={notification.seen}
36
+ showProfile={false}
37
+ >
38
+ <Pressable
39
+ onPress={() => navigation.navigate('Post', { id: post.id })}
40
+ className="w-full"
41
+ >
42
+ <View className="mb-2 flex flex-row flex-wrap items-center gap-2">
43
+ <ThemedText className="font-semibold">
44
+ {t('notification.waitlistOffer.text', {
45
+ eventName:
46
+ eventName || t('notification.waitlistOffer.eventFallback'),
47
+ })}
48
+ </ThemedText>
49
+ </View>
50
+ {notice?.offerExpiresAt ? (
51
+ <ThemedText className="text-muted-foreground mb-2 text-sm">
52
+ {t('notification.waitlistOffer.expires', {
53
+ until: new Date(notice.offerExpiresAt).toLocaleString(),
54
+ })}
55
+ </ThemedText>
56
+ ) : null}
57
+ <FeedPost post={post} />
58
+ </Pressable>
59
+ </NotificationWrapper>
60
+ );
61
+ };
@@ -17,3 +17,4 @@ export * from './Reply';
17
17
  export * from './Repost';
18
18
  export * from './Rsvp';
19
19
  export * from './RsvpCanceled';
20
+ export * from './WaitlistOffer';
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  formatEventWhen,
3
- markdownPlainText,
4
3
  type Article,
5
4
  type Event,
6
5
  type MediaAttachmentData,
@@ -19,6 +18,7 @@ import { MainStackParamList } from '../navigation/types/index';
19
18
  import { ThemedText } from '../ui/themed-text';
20
19
  import { ThemedView } from '../ui/themed-view';
21
20
  import { SvgImage } from '../ui/svg-image';
21
+ import { TruncatedMarkdown } from '../post/TruncatedMarkdown';
22
22
 
23
23
  type CompactPost = Pick<
24
24
  PublicReplyPost,
@@ -126,21 +126,21 @@ const CompactTypeBody = ({ post }: { post: CompactPost }) => {
126
126
  switch (post.type) {
127
127
  case 'note': {
128
128
  const attachments = attachmentsOf(post);
129
- const text = markdownPlainText(
130
- post.data?.type === 'note' ? post.data.content : ''
131
- );
132
129
  const hasVisual = !!visualAttachment(attachments);
133
130
  const docName =
134
131
  !hasVisual && attachments[0]
135
132
  ? attachments[0].filename || t('posts.compact.document')
136
133
  : undefined;
134
+ if (!post.data.content && !docName) return null;
137
135
  return (
138
136
  <>
139
- {text ? (
140
- <ThemedText className="text-sm" numberOfLines={2}>
141
- {text}
142
- </ThemedText>
143
- ) : null}
137
+ <TruncatedMarkdown
138
+ source={post.data.content ?? ''}
139
+ maxBlocks={1}
140
+ maxChars={80}
141
+ maxLines={1}
142
+ className="text-sm text-muted-foreground"
143
+ />
144
144
  {docName ? (
145
145
  <View className="flex-row items-center gap-1">
146
146
  <PaperclipIcon className="size-3.5 text-muted-foreground" />
@@ -157,15 +157,16 @@ const CompactTypeBody = ({ post }: { post: CompactPost }) => {
157
157
  }
158
158
  case 'question': {
159
159
  const data = post.data as Question;
160
- const text = markdownPlainText(data.content);
161
160
  const optionCount = data.options?.length ?? 0;
162
161
  return (
163
162
  <>
164
- {text ? (
165
- <ThemedText className="text-sm" numberOfLines={2}>
166
- {text}
167
- </ThemedText>
168
- ) : null}
163
+ <TruncatedMarkdown
164
+ source={data.content ?? ''}
165
+ maxBlocks={1}
166
+ maxChars={80}
167
+ maxLines={1}
168
+ className="text-sm text-muted-foreground"
169
+ />
169
170
  {optionCount > 0 ? (
170
171
  <ThemedText
171
172
  className="text-xs text-muted-foreground"
@@ -0,0 +1,60 @@
1
+ import { useMemo } from 'react';
2
+ import type { ReactNode } from 'react';
3
+ import { truncateMarkdown } from '@openpeepshq/common/lib';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { OpenpeepsMarkdown } from '../markdown';
6
+ import { MarkdownOverlay } from '../markdown/MarkdownOverlay';
7
+
8
+ export interface TruncatedMarkdownProps {
9
+ /** Full markdown; rendered in the overlay when `interactive`. */
10
+ source: string;
11
+ /** Pre-truncated excerpt (e.g. `firstNWords`). Computed otherwise. */
12
+ snippet?: string;
13
+ maxBlocks?: number;
14
+ maxChars?: number;
15
+ /** Lines the excerpt target (best-effort on RN; excerpt is word/char bounded). */
16
+ maxLines?: number;
17
+ /**
18
+ * When true, the excerpt lives in a long-press trigger that opens a
19
+ * `MarkdownOverlay` with the full markdown. When false, only the excerpt
20
+ * renders (callers own their own navigation).
21
+ */
22
+ interactive?: boolean;
23
+ // Accepted for web parity; RN styling is theme-driven via markdownTheme.
24
+ className?: string;
25
+ }
26
+
27
+ /**
28
+ * RN mirror of the web `TruncatedMarkdown`. Excerpt is word/char-bounded
29
+ * (RN cannot line-clamp rendered markdown nodes); the full markdown is revealed
30
+ * via the reusable `MarkdownOverlay` on long-press.
31
+ */
32
+ export const TruncatedMarkdown = ({
33
+ source,
34
+ snippet: snippetProp,
35
+ maxBlocks = 2,
36
+ maxChars = 240,
37
+ interactive = true,
38
+ }: TruncatedMarkdownProps): ReactNode => {
39
+ const { t } = useTranslation();
40
+ const excerpt = useMemo(
41
+ () => snippetProp ?? truncateMarkdown(source, maxBlocks, maxChars),
42
+ [snippetProp, source, maxBlocks, maxChars]
43
+ );
44
+ if (!excerpt) return null;
45
+
46
+ if (!interactive) {
47
+ return <OpenpeepsMarkdown source={excerpt} linkPreviewMode="none" />;
48
+ }
49
+
50
+ return (
51
+ <MarkdownOverlay
52
+ source={source}
53
+ label={t('posts.truncatedMarkdown.showHint', {
54
+ defaultValue: 'Show more',
55
+ })}
56
+ >
57
+ <OpenpeepsMarkdown source={excerpt} linkPreviewMode="none" />
58
+ </MarkdownOverlay>
59
+ );
60
+ };
@@ -3,8 +3,8 @@ import { FileIcon } from 'lucide-react-native';
3
3
  import { FileChartPieIcon, FileTextIcon } from '../icons/index';
4
4
 
5
5
  export const getFileType = (attachment: MediaAttachmentData) => {
6
- let name = attachment.description?.toLowerCase();
7
- let mime = attachment.meta?.mimetype?.toLowerCase();
6
+ const name = attachment.description?.toLowerCase();
7
+ const mime = attachment.meta?.mimetype?.toLowerCase();
8
8
 
9
9
  if (!name || !mime) {
10
10
  return 'unknown';
@@ -9,6 +9,8 @@ export * from './FeedPostContent';
9
9
  export * from './FullPostLayout';
10
10
  export * from './helpers';
11
11
  export * from './Markdown';
12
+ export { TruncatedMarkdown } from './TruncatedMarkdown';
13
+ export type { TruncatedMarkdownProps } from './TruncatedMarkdown';
12
14
  export * from './NewEventButton';
13
15
  export * from './NewResourceButton';
14
16
  export * from './NewNoteButton';
@@ -12,6 +12,7 @@ import {
12
12
  EventRsvpScopeDialog,
13
13
  type RsvpScopeChoice,
14
14
  } from './EventRsvpScopeDialog';
15
+ import { EventWaitlistJoinDialog } from './EventWaitlistJoinDialog';
15
16
 
16
17
  export interface EventRsvpButtonProps {
17
18
  post: PublicPost;
@@ -26,21 +27,30 @@ export const EventRsvpButton = ({
26
27
  }: EventRsvpButtonProps) => {
27
28
  const { t } = useTranslation();
28
29
  const scopeSheetRef = useRef<BottomSheetModal>(null);
30
+ const waitlistSheetRef = useRef<BottomSheetModal>(null);
29
31
  const {
30
32
  profile,
31
33
  myEvent,
32
34
  myRsvp,
33
35
  canRsvp,
34
36
  rsvpClosed,
37
+ hideRsvpButton,
35
38
  recurring,
36
39
  defaultId,
37
40
  occurrences,
38
41
  capacityEvent,
39
42
  full,
43
+ onWaitlist,
44
+ offerExpiresAt,
40
45
  error,
41
46
  pending,
47
+ confirmingWaitlist,
48
+ setConfirmingWaitlist,
42
49
  submitting,
43
50
  requestRespond,
51
+ requestJoinWaitlist,
52
+ confirmJoinWaitlist,
53
+ claimSpot,
44
54
  confirmScope,
45
55
  } = useEventRsvp({
46
56
  post,
@@ -55,6 +65,9 @@ export const EventRsvpButton = ({
55
65
  useEffect(() => {
56
66
  if (showScopeSheet) bottomSheetPresent(scopeSheetRef);
57
67
  }, [showScopeSheet]);
68
+ useEffect(() => {
69
+ if (confirmingWaitlist) bottomSheetPresent(waitlistSheetRef);
70
+ }, [confirmingWaitlist]);
58
71
 
59
72
  const onConfirmScope = async (scope: RsvpScopeChoice) => {
60
73
  const ok = await confirmScope(scope);
@@ -79,7 +92,9 @@ export const EventRsvpButton = ({
79
92
  <ThemedText className="text-center text-sm">
80
93
  {myRsvp.response === 'yes'
81
94
  ? t('posts.rsvp.attendingMessage')
82
- : t('posts.rsvp.maybeMessage')}
95
+ : myRsvp.response === 'waitlist'
96
+ ? t('events.rsvp.onWaitlist')
97
+ : t('posts.rsvp.maybeMessage')}
83
98
  </ThemedText>
84
99
  ) : null}
85
100
  <ThemedText className="mt-2 text-center text-sm text-muted-foreground">
@@ -89,6 +104,8 @@ export const EventRsvpButton = ({
89
104
  );
90
105
  }
91
106
 
107
+ if (hideRsvpButton) return null;
108
+
92
109
  const scopeDialog = (
93
110
  <EventRsvpScopeDialog
94
111
  ref={scopeSheetRef}
@@ -109,6 +126,77 @@ export const EventRsvpButton = ({
109
126
  </ThemedText>
110
127
  ) : null;
111
128
 
129
+ const waitlistDialog = (
130
+ <EventWaitlistJoinDialog
131
+ ref={waitlistSheetRef}
132
+ post={post}
133
+ error={error}
134
+ isLoading={submitting}
135
+ onClose={() => {
136
+ if (!submitting) setConfirmingWaitlist(false);
137
+ }}
138
+ onConfirm={async () => {
139
+ const ok = await confirmJoinWaitlist();
140
+ if (ok) waitlistSheetRef.current?.close();
141
+ }}
142
+ />
143
+ );
144
+
145
+ if (offerExpiresAt) {
146
+ return (
147
+ <View className="mt-4 w-full">
148
+ <ThemedText className="text-center text-sm">
149
+ {t('events.rsvp.offerOpen', {
150
+ until: new Date(offerExpiresAt).toLocaleString(),
151
+ })}
152
+ </ThemedText>
153
+ <Button
154
+ className="mt-2 w-full"
155
+ disabled={submitting}
156
+ onPress={claimSpot}
157
+ >
158
+ <ThemedText>{t('events.rsvp.claimSpot')}</ThemedText>
159
+ </Button>
160
+ <Button
161
+ variant="outline"
162
+ className="mt-2 w-full"
163
+ disabled={submitting}
164
+ onPress={() => requestRespond('no')}
165
+ >
166
+ <ThemedText className="text-destructive">
167
+ {t('events.rsvp.leaveWaitlist')}
168
+ </ThemedText>
169
+ </Button>
170
+ {errorText}
171
+ </View>
172
+ );
173
+ }
174
+
175
+ if (onWaitlist) {
176
+ return (
177
+ <View className="mt-4 w-full">
178
+ <ThemedText className="text-center text-sm">
179
+ {t('events.rsvp.onWaitlist')}
180
+ </ThemedText>
181
+ <ThemedText className="mt-1 text-center text-sm text-muted-foreground">
182
+ {t('events.rsvp.atCapacity')}
183
+ </ThemedText>
184
+ <Button
185
+ variant="outline"
186
+ className="mt-2 w-full"
187
+ disabled={submitting}
188
+ onPress={() => requestRespond('no')}
189
+ >
190
+ <ThemedText className="text-destructive">
191
+ {t('events.rsvp.leaveWaitlist')}
192
+ </ThemedText>
193
+ </Button>
194
+ {errorText}
195
+ {scopeDialog}
196
+ </View>
197
+ );
198
+ }
199
+
112
200
  if (myRsvp && myRsvp.response !== 'no') {
113
201
  return (
114
202
  <View className="w-full">
@@ -135,14 +223,19 @@ export const EventRsvpButton = ({
135
223
 
136
224
  return (
137
225
  <View className="mt-4 w-full">
226
+ {full ? (
227
+ <ThemedText className="mb-2 text-center text-sm text-muted-foreground">
228
+ {t('events.rsvp.atCapacity')}
229
+ </ThemedText>
230
+ ) : null}
138
231
  <View className="w-full flex-col gap-2">
139
232
  <Button
140
233
  className="w-full"
141
- disabled={full || submitting}
142
- onPress={() => requestRespond('yes')}
234
+ disabled={submitting}
235
+ onPress={() => (full ? requestJoinWaitlist() : requestRespond('yes'))}
143
236
  >
144
237
  <ThemedText numberOfLines={1}>
145
- {full ? t('events.rsvp.full') : t('posts.rsvp.register')}
238
+ {full ? t('events.rsvp.joinWaitlist') : t('posts.rsvp.register')}
146
239
  </ThemedText>
147
240
  </Button>
148
241
  <View className="w-full flex-row gap-x-2">
@@ -170,8 +263,9 @@ export const EventRsvpButton = ({
170
263
  </Button>
171
264
  </View>
172
265
  </View>
173
- {errorText}
266
+ {error && !pending && !confirmingWaitlist ? errorText : null}
174
267
  {scopeDialog}
268
+ {waitlistDialog}
175
269
  </View>
176
270
  );
177
271
  };
@@ -10,6 +10,8 @@ import {
10
10
  isRecurringEvent,
11
11
  listedRsvps,
12
12
  listRsvpCancellations,
13
+ offerStillOpen,
14
+ orderedWaitlist,
13
15
  profileName,
14
16
  rsvpCancelWhenLabels,
15
17
  sameRecurrenceId,
@@ -108,6 +110,9 @@ export const EventRsvpList: React.FC<EventRsvpListProps> = ({
108
110
  recurrenceId={occurrenceId}
109
111
  onManage={onManage}
110
112
  />
113
+ {canManageRsvps ? (
114
+ <WaitlistSection post={post} recurrenceId={occurrenceId} />
115
+ ) : null}
111
116
  {history}
112
117
  </View>
113
118
  );
@@ -144,6 +149,9 @@ export const EventRsvpList: React.FC<EventRsvpListProps> = ({
144
149
  recurrenceId={key}
145
150
  onManage={onManage}
146
151
  />
152
+ {canManageRsvps ? (
153
+ <WaitlistSection post={post} recurrenceId={key} />
154
+ ) : null}
147
155
  </RsvpPanel>
148
156
  );
149
157
  })}
@@ -152,6 +160,44 @@ export const EventRsvpList: React.FC<EventRsvpListProps> = ({
152
160
  );
153
161
  };
154
162
 
163
+ const WaitlistSection: React.FC<{
164
+ post: PublicPost;
165
+ recurrenceId?: string;
166
+ }> = ({ post, recurrenceId }) => {
167
+ const { t } = useTranslation();
168
+ const waiting = orderedWaitlist(post, recurrenceId);
169
+ if (!waiting.length) return null;
170
+ const profiles = new Map(
171
+ (post.rsvps ?? []).map((rsvp) => [rsvp.profile.id, rsvp.profile])
172
+ );
173
+ return (
174
+ <View className="mt-4 border-t border-border pt-3">
175
+ <ThemedText className="mb-2 text-sm font-semibold">
176
+ {t('events.rsvp.waitlistTitle')}
177
+ </ThemedText>
178
+ {waiting.map((member, index) => {
179
+ const profile = profiles.get(member.profileId);
180
+ if (!profile) return null;
181
+ const until = member.offerExpiresAt;
182
+ const offered = !!until && offerStillOpen({ offerExpiresAt: until });
183
+ return (
184
+ <ThemedText key={member.profileId} className="text-sm">
185
+ {index + 1}. {profileName(profile)}
186
+ {offered
187
+ ? ` — ${t('events.rsvp.waitlistOffered', {
188
+ until: new Date(until).toLocaleString(),
189
+ })}`
190
+ : ''}
191
+ {profile.type === 'federated'
192
+ ? ` — ${t('events.rsvp.waitlistRemote')}`
193
+ : ''}
194
+ </ThemedText>
195
+ );
196
+ })}
197
+ </View>
198
+ );
199
+ };
200
+
155
201
  const RsvpCancellationHistory: React.FC<{ post: PublicPost }> = ({ post }) => {
156
202
  const { t } = useTranslation();
157
203
  const cancellations = listRsvpCancellations(post);
@@ -5,10 +5,9 @@ import { useTranslation } from 'react-i18next';
5
5
  import type { PublicPost } from '@openpeepshq/common/types';
6
6
  import type { ExpandedOccurrence } from '@openpeepshq/common/lib';
7
7
  import {
8
- countYesRsvps,
9
- getEffectiveRsvp,
10
- isCapacityEvent,
11
- seriesYesBlockedByCapacity,
8
+ canClaimYesRsvp,
9
+ canJoinWaitlist,
10
+ seriesClaimBlocked,
12
11
  } from '@openpeepshq/common/lib';
13
12
  import { BaseSheet, SheetFooter } from '../../custom/modals/common';
14
13
  import { Checkbox } from '../../ui/checkbox';
@@ -26,7 +25,7 @@ type ScopeKind = 'this' | 'selected' | 'series';
26
25
 
27
26
  export interface EventRsvpScopeDialogProps {
28
27
  post: PublicPost;
29
- response: 'yes' | 'tentative' | 'no';
28
+ response: 'yes' | 'tentative' | 'no' | 'waitlist';
30
29
  defaultRecurrenceId?: string;
31
30
  occurrences: ExpandedOccurrence[];
32
31
  error?: string | null;
@@ -61,19 +60,19 @@ export const EventRsvpScopeDialog = forwardRef<
61
60
  ) => {
62
61
  const { t } = useTranslation();
63
62
  const { currentProfile } = useOpenpeeps();
64
- const event = post.data?.type === 'event' ? post.data : undefined;
65
- const capacityEvent = event ? isCapacityEvent(event) : false;
63
+ const joiningWaitlist = response === 'waitlist';
66
64
  const seriesFull =
67
65
  response === 'yes' &&
68
66
  !!currentProfile &&
69
- seriesYesBlockedByCapacity(post, currentProfile.id);
70
- const occurrenceIsFull = (recurrenceId: string) =>
71
- response === 'yes' &&
72
- capacityEvent &&
73
- event?.maxAttendees !== undefined &&
74
- getEffectiveRsvp(post, currentProfile?.id ?? '', recurrenceId)
75
- ?.response !== 'yes' &&
76
- countYesRsvps(post, recurrenceId) >= event.maxAttendees;
67
+ seriesClaimBlocked(post, currentProfile.id);
68
+ const occurrenceIsFull = (recurrenceId: string) => {
69
+ if (!currentProfile) return false;
70
+ if (joiningWaitlist) {
71
+ return !canJoinWaitlist(post, currentProfile.id, recurrenceId);
72
+ }
73
+ if (response !== 'yes') return false;
74
+ return !canClaimYesRsvp(post, currentProfile.id, recurrenceId);
75
+ };
77
76
  const currentFull =
78
77
  !!defaultRecurrenceId && occurrenceIsFull(defaultRecurrenceId);
79
78
  const initialScope: ScopeKind = currentFull
@@ -129,7 +128,9 @@ export const EventRsvpScopeDialog = forwardRef<
129
128
  <BaseSheet ref={ref} snapPoints={['80%']} scrollable>
130
129
  <View className="flex-1 p-4">
131
130
  <ThemedText className="text-center text-lg mb-4">
132
- {t('events.rsvp.scope.title')}
131
+ {joiningWaitlist
132
+ ? t('events.rsvp.scope.waitlistTitle')
133
+ : t('events.rsvp.scope.title')}
133
134
  </ThemedText>
134
135
  <RadioGroup
135
136
  value={scope}
@@ -157,7 +158,7 @@ export const EventRsvpScopeDialog = forwardRef<
157
158
  <ThemedText>{t('events.rsvp.scope.selectedDates')}</ThemedText>
158
159
  </Pressable>
159
160
  ) : null}
160
- {currentFull ? null : (
161
+ {currentFull || joiningWaitlist ? null : (
161
162
  <Pressable
162
163
  onPress={() => !seriesFull && setScope('series')}
163
164
  className="py-3 flex-row items-start gap-x-3"
@@ -204,7 +205,13 @@ export const EventRsvpScopeDialog = forwardRef<
204
205
  }`}
205
206
  >
206
207
  {formatOccurrenceStart(occurrence.start)}
207
- {full ? ` — ${t('events.rsvp.full')}` : ''}
208
+ {full
209
+ ? ` — ${
210
+ joiningWaitlist
211
+ ? t('events.rsvp.spotsOpen')
212
+ : t('events.rsvp.full')
213
+ }`
214
+ : ''}
208
215
  </ThemedText>
209
216
  </Pressable>
210
217
  );
@@ -224,7 +231,11 @@ export const EventRsvpScopeDialog = forwardRef<
224
231
  <SheetFooter
225
232
  onCancel={() => bottomSheetClose(ref)}
226
233
  onConfirm={confirm}
227
- confirmText={t('events.rsvp.scope.confirm')}
234
+ confirmText={
235
+ joiningWaitlist
236
+ ? t('events.rsvp.joinWaitlist')
237
+ : t('events.rsvp.scope.confirm')
238
+ }
228
239
  cancelText={t('events.rsvp.scope.cancel')}
229
240
  disabled={confirmDisabled}
230
241
  isLoading={isLoading}