@openpeepshq/rn-components 0.7.2 → 0.8.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 (73) hide show
  1. package/README.md +1 -1
  2. package/package.json +11 -6
  3. package/src/components/custom/modals/media/audio-picker-sheet.tsx +21 -25
  4. package/src/components/custom/modals/media/document-picker-sheet.tsx +22 -16
  5. package/src/components/custom/modals/media/video-picker-sheet.tsx +4 -2
  6. package/src/components/custom/navigation/side-menu.tsx +59 -11
  7. package/src/components/icons/iconWithClassName.tsx +21 -0
  8. package/src/components/jams/JamActionsFooter.tsx +8 -2
  9. package/src/components/jams/JamCapacityGate.tsx +1 -1
  10. package/src/components/jams/JamCard.tsx +8 -4
  11. package/src/components/jams/JamConference.tsx +6 -1
  12. package/src/components/jams/JamParticipantConference.tsx +2 -0
  13. package/src/components/jams/JamRoom.tsx +2 -3
  14. package/src/components/jams/LiveJamsSection.tsx +12 -1
  15. package/src/components/jams/LivekitUnavailableNotice.tsx +25 -0
  16. package/src/components/jams/index.ts +1 -0
  17. package/src/components/markdown/MarkdownOverlay.tsx +75 -0
  18. package/src/components/markdown/OpenpeepsMarkdown.tsx +3 -1
  19. package/src/components/markdown/extensions/link.tsx +34 -0
  20. package/src/components/markdown/index.ts +2 -0
  21. package/src/components/navigation/tab-navigator.tsx +39 -17
  22. package/src/components/notifications/NotificationItem.tsx +27 -2
  23. package/src/components/notifications/types/JamStarted.tsx +13 -3
  24. package/src/components/notifications/types/Reply.tsx +1 -5
  25. package/src/components/notifications/types/WaitlistOffer.tsx +61 -0
  26. package/src/components/notifications/types/index.ts +1 -0
  27. package/src/components/post/CompactReplyParent.tsx +16 -15
  28. package/src/components/post/TruncatedMarkdown.tsx +60 -0
  29. package/src/components/post/helpers.ts +2 -2
  30. package/src/components/post/index.ts +2 -0
  31. package/src/components/post/pieces/EventRsvpButton.tsx +99 -5
  32. package/src/components/post/pieces/EventRsvpList.tsx +46 -0
  33. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +30 -19
  34. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +62 -0
  35. package/src/components/post/pieces/PollContent.tsx +7 -7
  36. package/src/components/post/pieces/PostActions.tsx +89 -23
  37. package/src/components/post/pieces/ShareMenu.tsx +2 -2
  38. package/src/components/post/post-form/DescriptionEditModal.tsx +1 -0
  39. package/src/components/post/post-form/EventForm.tsx +50 -10
  40. package/src/components/post/post-form/ResourceForm.tsx +131 -8
  41. package/src/components/post/types/Article.tsx +6 -2
  42. package/src/components/post/types/Poll.tsx +4 -1
  43. package/src/components/post/types/event/CardEvent.tsx +101 -76
  44. package/src/components/post/types/event/FullEvent.tsx +60 -23
  45. package/src/components/post/types/event/ProfileEventRelationship.tsx +2 -0
  46. package/src/components/post/types/resource/FullResource.tsx +9 -1
  47. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  48. package/src/components/preview-link/helpers.ts +5 -1
  49. package/src/components/preview-link/index.ts +1 -0
  50. package/src/components/preview-link/local/WelcomePreview.tsx +59 -0
  51. package/src/components/profile/Avatar.tsx +0 -1
  52. package/src/components/profile/EditProfileForm.tsx +23 -2
  53. package/src/components/profile/ProfileSheet.tsx +1 -1
  54. package/src/components/resources/ResourceCard.tsx +62 -14
  55. package/src/components/resources/ResourceLibrary.tsx +2 -2
  56. package/src/components/ui/badge.tsx +2 -3
  57. package/src/components/ui/bottom-sheet.tsx +0 -6
  58. package/src/components/ui/popup-menu-button.tsx +2 -2
  59. package/src/components/ui/popup-menu-separator.tsx +1 -1
  60. package/src/components/ui/popup-menu.tsx +2 -2
  61. package/src/lib/utils.ts +10 -3
  62. package/src/pages/auth/Register.tsx +34 -4
  63. package/src/pages/conversations/Show.tsx +38 -7
  64. package/src/pages/feeds/Bookmarks.tsx +1 -1
  65. package/src/pages/jams/Index.tsx +6 -4
  66. package/src/pages/posts/New.tsx +1 -1
  67. package/src/pages/resources/Edit.tsx +2 -1
  68. package/src/pages/resources/New.tsx +6 -1
  69. package/src/pages/settings/Account.tsx +46 -2
  70. package/src/pages/settings/Index.tsx +3 -4
  71. package/src/pages/settings/NotificationPreferences.tsx +3 -3
  72. package/src/pages/settings/Theme.tsx +1 -1
  73. package/src/components/icons/iconWithClassName.ts +0 -12
@@ -20,13 +20,14 @@ import { mentionPlugin, mentionRenderer } from './extensions/mention';
20
20
  import { codeBlockRenderer, fenceRenderer } from './extensions/codeBlock';
21
21
  import { codeInlineRenderer } from './extensions/codeInline';
22
22
  import { htmlBlockRenderer, htmlInlineRenderer } from './extensions/html';
23
+ import { linkRenderer } from './extensions/link';
23
24
  import { markdownTheme } from './theme';
24
25
  import { extractLinks, isEmail, isInternalLink, toGotoUrl } from './utils';
25
26
  import { PreviewLink } from '../preview-link';
26
27
  import { useOpenPeepsTheme } from '../../theme/OpenPeepsThemeProvider';
27
28
  import { recordOutboundClick } from '@openpeepshq/react';
28
29
 
29
- export interface OpenpeepsMarkdownProps extends MarkdownRenderProps {}
30
+ export type OpenpeepsMarkdownProps = MarkdownRenderProps;
30
31
 
31
32
  export const OpenpeepsMarkdown = ({
32
33
  source,
@@ -113,6 +114,7 @@ export const OpenpeepsMarkdown = ({
113
114
  code_inline: codeInlineRenderer(colors),
114
115
  html_block: htmlBlockRenderer(handleIframePress),
115
116
  html_inline: htmlInlineRenderer(handleIframePress),
117
+ link: linkRenderer(handleLinkPress),
116
118
  }}
117
119
  >
118
120
  {ast as unknown as ReactNode[]}
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { type RenderFunction } from 'react-native-markdown-display';
3
+ import { isExternalLink } from '@openpeepshq/common/lib';
4
+ import { ThemedText } from '../../ui/themed-text';
5
+ import { BASE_URL } from '../../../lib/constants';
6
+
7
+ /**
8
+ * Custom link renderer that appends a Unicode external-link indicator
9
+ * (↗) after links pointing outside the instance.
10
+ */
11
+ export const linkRenderer =
12
+ (handleLinkPress: (url: string) => void): RenderFunction =>
13
+ (node, children, _parentNodes, styles) => {
14
+ const href = (node as { url?: string }).url || '';
15
+ const origin = BASE_URL as string;
16
+ const isExternal = isExternalLink(href, origin);
17
+
18
+ const rec =
19
+ styles && typeof styles === 'object'
20
+ ? (styles as Record<string, object>)
21
+ : {};
22
+ const linkStyle: object = 'link' in rec && rec.link ? rec.link : {};
23
+
24
+ return (
25
+ <ThemedText
26
+ key={node.key}
27
+ style={[linkStyle, styles?.text]}
28
+ onPress={() => handleLinkPress(href)}
29
+ >
30
+ {children}
31
+ {isExternal ? ' ↗' : null}
32
+ </ThemedText>
33
+ );
34
+ };
@@ -1,2 +1,4 @@
1
1
  export * from './OpenpeepsMarkdown';
2
+ export { MarkdownOverlay } from './MarkdownOverlay';
3
+ export type { MarkdownOverlayProps } from './MarkdownOverlay';
2
4
  export type { MarkdownRenderProps } from '@openpeepshq/common/lib';
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
+ import { PlatformPressable } from '@react-navigation/elements';
2
3
  import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
4
+ import { useTranslation } from 'react-i18next';
3
5
  import { TabStackParamList } from './types';
4
6
  import { TAB_ROUTES } from './types';
5
7
  import {
@@ -43,6 +45,16 @@ import { RootLayout } from '../layout';
43
45
 
44
46
  const Tab = createBottomTabNavigator<TabStackParamList>();
45
47
 
48
+ const tabTooltipKeys: Partial<Record<keyof TabStackParamList, string>> = {
49
+ [TAB_ROUTES.HOME]: 'community',
50
+ [TAB_ROUTES.FEED]: 'myFeed',
51
+ [TAB_ROUTES.NEW_POST]: 'newPost',
52
+ [TAB_ROUTES.GROUPS]: 'groups',
53
+ [TAB_ROUTES.NOTIFICATIONS]: 'notifications',
54
+ [TAB_ROUTES.ARTICLES]: 'articles',
55
+ [TAB_ROUTES.RESOURCES]: 'resources',
56
+ };
57
+
46
58
  const TabBarIcon = ({
47
59
  route,
48
60
  focused,
@@ -75,6 +87,7 @@ const TabBarIcon = ({
75
87
  };
76
88
 
77
89
  export const TabNavigator = () => {
90
+ const { t } = useTranslation();
78
91
  const { openpeepsApi } = useOpenpeeps();
79
92
  const {
80
93
  colors: { background },
@@ -97,23 +110,32 @@ export const TabNavigator = () => {
97
110
  return (
98
111
  <Tab.Navigator
99
112
  screenLayout={({ children }) => <RootLayout>{children}</RootLayout>}
100
- screenOptions={({ route }) => ({
101
- headerShown: false,
102
- tabBarShowLabel: false,
103
- tabBarIcon: ({ focused }) => TabBarIcon({ route, focused }),
104
- tabBarItemStyle: {
105
- display,
106
- },
107
- tabBarStyle: {
108
- backgroundColor: background,
109
- borderTopWidth: 0,
110
- height: 80,
111
- paddingBottom: 20,
112
- paddingTop: 10,
113
- elevation: 0,
114
- display,
115
- },
116
- })}
113
+ screenOptions={({ route }) => {
114
+ const tooltipKey = tabTooltipKeys[route.name];
115
+ const tabHint = tooltipKey
116
+ ? t(`navigation.tooltips.${tooltipKey}`)
117
+ : undefined;
118
+ return {
119
+ headerShown: false,
120
+ tabBarShowLabel: false,
121
+ tabBarIcon: ({ focused }) => TabBarIcon({ route, focused }),
122
+ tabBarButton: (props) => (
123
+ <PlatformPressable {...props} accessibilityHint={tabHint} />
124
+ ),
125
+ tabBarItemStyle: {
126
+ display,
127
+ },
128
+ tabBarStyle: {
129
+ backgroundColor: background,
130
+ borderTopWidth: 0,
131
+ height: 80,
132
+ paddingBottom: 20,
133
+ paddingTop: 10,
134
+ elevation: 0,
135
+ display,
136
+ },
137
+ };
138
+ }}
117
139
  initialRouteName={TAB_ROUTES.HOME}
118
140
  >
119
141
  <Tab.Screen name={TAB_ROUTES.HOME} component={FeedsLocal} />
@@ -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
  };