@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
@@ -8,7 +8,12 @@ import type {
8
8
  ResourceKind,
9
9
  ResourcePost,
10
10
  } from '@openpeepshq/common';
11
- import { RESOURCE_KINDS, normalizeResourceTags } from '@openpeepshq/common/lib';
11
+ import {
12
+ RESOURCE_KINDS,
13
+ RESOURCE_TITLE_MAX_LENGTH,
14
+ normalizeResourceTags,
15
+ resourceFormIssues,
16
+ } from '@openpeepshq/common/lib';
12
17
  import { applyAudienceSetting, useCurrentProfile } from '@openpeepshq/react';
13
18
  import { BottomSheetModal } from '@gorhom/bottom-sheet';
14
19
  import {
@@ -28,12 +33,15 @@ export interface ResourceFormProps {
28
33
  postData: PostCreationData;
29
34
  onChange: (data: PostCreationData) => void;
30
35
  isEdit?: boolean;
36
+ /** Member can post this resource only to a group. */
37
+ groupOnly?: boolean;
31
38
  }
32
39
 
33
40
  export const ResourceForm = ({
34
41
  postData,
35
42
  onChange,
36
43
  isEdit = false,
44
+ groupOnly = false,
37
45
  }: ResourceFormProps) => {
38
46
  const { t } = useTranslation();
39
47
  const me = useCurrentProfile();
@@ -66,6 +74,26 @@ export const ResourceForm = ({
66
74
  setTagDraft('');
67
75
  };
68
76
 
77
+ const issues = resourceFormIssues({
78
+ title: resource.title,
79
+ resourceKind: resource.resourceKind,
80
+ url: resource.url,
81
+ attachments: resource.attachments,
82
+ visibility: postData.visibility,
83
+ audience: postData.audience,
84
+ groupId: postData.groupId,
85
+ });
86
+ const titleMissing = issues.includes('title');
87
+ const titleTooLong = issues.includes('titleLength');
88
+ const urlIssue = issues.includes('url');
89
+ const urlInvalid = urlIssue && Boolean(resource.url?.trim());
90
+ const mediaMissing = issues.includes('media');
91
+ const audienceMissing = issues.includes('audience');
92
+ const groupMissing = issues.includes('group');
93
+ const urlMessage = t('resources.validation.url', {
94
+ defaultValue: 'Enter a real link, like https://example.com',
95
+ });
96
+
69
97
  const openMedia = () => {
70
98
  if (resource.resourceKind === 'gallery') imageRef.current?.present();
71
99
  else if (resource.resourceKind === 'video') videoRef.current?.present();
@@ -77,14 +105,49 @@ export const ResourceForm = ({
77
105
  <View>
78
106
  <View className="mt-4 gap-y-4 px-3">
79
107
  <ThemedText className="text-sm font-medium">
80
- {t('resources.form.name', {
81
- defaultValue: 'Title',
108
+ {t('resources.form.nameRequired', {
109
+ defaultValue: 'Title (Required)',
82
110
  })}
83
111
  </ThemedText>
84
112
  <Input
85
113
  value={resource.title}
114
+ maxLength={RESOURCE_TITLE_MAX_LENGTH}
86
115
  onChangeText={(title) => patchResource({ title })}
116
+ accessibilityHint={
117
+ titleMissing
118
+ ? t('resources.validation.titleRequired', {
119
+ defaultValue: 'Title is required',
120
+ })
121
+ : titleTooLong
122
+ ? t('resources.validation.titleTooLong', {
123
+ defaultValue: 'Title must be 200 characters or fewer',
124
+ })
125
+ : undefined
126
+ }
87
127
  />
128
+ {titleMissing ? (
129
+ <ThemedText className="text-sm text-muted-foreground">
130
+ {t('resources.validation.titleRequired', {
131
+ defaultValue: 'Title is required',
132
+ })}
133
+ </ThemedText>
134
+ ) : null}
135
+ {titleTooLong ? (
136
+ <ThemedText className="text-sm text-destructive">
137
+ {t('resources.validation.titleTooLong', {
138
+ defaultValue: 'Title must be 200 characters or fewer',
139
+ })}
140
+ </ThemedText>
141
+ ) : null}
142
+ <ThemedText
143
+ className={
144
+ titleTooLong
145
+ ? 'px-2 text-right text-sm text-destructive'
146
+ : 'px-2 text-right text-sm'
147
+ }
148
+ >
149
+ {resource.title.length} / {RESOURCE_TITLE_MAX_LENGTH}
150
+ </ThemedText>
88
151
 
89
152
  <ThemedText className="text-sm font-medium">
90
153
  {t('resources.form.kind', {
@@ -118,15 +181,33 @@ export const ResourceForm = ({
118
181
  {resource.resourceKind === 'link' ? (
119
182
  <>
120
183
  <ThemedText className="text-sm font-medium">
121
- {t('resources.form.url', {
122
- defaultValue: 'URL',
184
+ {t('resources.form.urlRequired', {
185
+ defaultValue: 'URL (Required)',
123
186
  })}
124
187
  </ThemedText>
125
188
  <Input
126
189
  value={resource.url ?? ''}
127
190
  onChangeText={(url) => patchResource({ url })}
128
191
  autoCapitalize="none"
192
+ autoCorrect={false}
193
+ keyboardType="url"
194
+ placeholder={t('resources.form.urlPlaceholder', {
195
+ defaultValue: 'https://example.com',
196
+ })}
197
+ className={urlInvalid ? 'border-destructive' : undefined}
198
+ accessibilityHint={urlIssue ? urlMessage : undefined}
129
199
  />
200
+ {urlIssue ? (
201
+ <ThemedText
202
+ className={
203
+ urlInvalid
204
+ ? 'text-sm text-destructive'
205
+ : 'text-sm text-muted-foreground'
206
+ }
207
+ >
208
+ {urlMessage}
209
+ </ThemedText>
210
+ ) : null}
130
211
  </>
131
212
  ) : (
132
213
  <>
@@ -155,6 +236,13 @@ export const ResourceForm = ({
155
236
  })
156
237
  }
157
238
  />
239
+ {mediaMissing ? (
240
+ <ThemedText className="text-sm text-muted-foreground">
241
+ {t('resources.validation.mediaRequired', {
242
+ defaultValue: 'Add the media or link this resource needs',
243
+ })}
244
+ </ThemedText>
245
+ ) : null}
158
246
  </>
159
247
  )}
160
248
 
@@ -231,11 +319,46 @@ export const ResourceForm = ({
231
319
  disabled={isEdit}
232
320
  showDirect
233
321
  />
322
+ {!isEdit && groupOnly ? (
323
+ <ThemedText className="text-sm text-muted-foreground">
324
+ {t('resources.form.groupOnly', {
325
+ defaultValue: 'You can only share resources with a group.',
326
+ })}
327
+ </ThemedText>
328
+ ) : null}
329
+ {groupMissing ? (
330
+ <ThemedText className="text-sm text-muted-foreground">
331
+ {t('resources.validation.groupRequired', {
332
+ defaultValue: 'Choose a group before creating this resource.',
333
+ })}
334
+ </ThemedText>
335
+ ) : null}
336
+ {audienceMissing ? (
337
+ <ThemedText className="text-sm text-muted-foreground">
338
+ {t('resources.validation.directAudience', {
339
+ defaultValue:
340
+ 'Choose at least one recipient for a direct resource.',
341
+ })}
342
+ </ThemedText>
343
+ ) : null}
234
344
  </View>
235
345
  <ImagePickerSheet ref={imageRef} onSelect={addAttachments} />
236
- <VideoPickerSheet ref={videoRef} onSelect={addAttachments} />
237
- <AudioPickerSheet ref={audioRef} onSelect={addAttachments} />
238
- <DocumentPickerSheet ref={documentRef} onSelect={addAttachments} />
346
+ {/* Only galleries take more than one file; other kinds pick one. */}
347
+ <VideoPickerSheet
348
+ ref={videoRef}
349
+ multiple={false}
350
+ onSelect={addAttachments}
351
+ />
352
+ <AudioPickerSheet
353
+ ref={audioRef}
354
+ multiple={false}
355
+ onSelect={addAttachments}
356
+ />
357
+ <DocumentPickerSheet
358
+ ref={documentRef}
359
+ multiple={false}
360
+ onSelect={addAttachments}
361
+ />
239
362
  </View>
240
363
  );
241
364
  };
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import type { Article, PublicPost } from '@openpeepshq/common/types';
3
3
  import { View } from 'react-native';
4
4
  import { ThemedText } from '../../ui/themed-text';
5
- import { OpenpeepsMarkdown } from '../../markdown/index';
6
5
  import { useMemo } from 'react';
7
6
  import { firstNWords } from '@openpeepshq/common';
8
7
  import { Button } from '../../ui/button';
@@ -12,6 +11,7 @@ import { NativeStackNavigationProp } from '@react-navigation/native-stack';
12
11
  import { MainStackParamList } from '../../navigation/types/index';
13
12
  import { useTranslation } from 'react-i18next';
14
13
  import { CachedImage } from '../../custom/common/index';
14
+ import { TruncatedMarkdown } from '../TruncatedMarkdown';
15
15
 
16
16
  export interface FeedArticleProps {
17
17
  post: PublicPost;
@@ -40,7 +40,11 @@ export const FeedArticle = ({ post }: FeedArticleProps) => {
40
40
  <ThemedText className="text-xl font-bold text-foreground">
41
41
  {article.title}
42
42
  </ThemedText>
43
- <OpenpeepsMarkdown source={previewContent} linkPreviewMode="none" />
43
+ <TruncatedMarkdown
44
+ source={article.content ?? ''}
45
+ snippet={previewContent}
46
+ interactive={false}
47
+ />
44
48
  <View className="w-full flex flex-row justify-end">
45
49
  <Button
46
50
  onPress={() => navigation.navigate('Post', { id: post.id })}
@@ -14,7 +14,10 @@ export interface FeedPollProps {
14
14
  interactive?: boolean;
15
15
  }
16
16
 
17
- export const FeedPoll = ({ post, interactive = true }: FeedPollProps) =>
17
+ export const FeedPoll = ({
18
+ post,
19
+ interactive: _interactive = true,
20
+ }: FeedPollProps) =>
18
21
  post?.data?.type === 'question' ? (
19
22
  <View>
20
23
  <Attachments {...{ post }} />
@@ -1,4 +1,10 @@
1
- import { View, Image, TouchableOpacity, ActivityIndicator } from 'react-native';
1
+ import {
2
+ View,
3
+ Image,
4
+ Pressable,
5
+ TouchableOpacity,
6
+ ActivityIndicator,
7
+ } from 'react-native';
2
8
  import React from 'react';
3
9
  import { ThemedText } from '../../../ui/themed-text';
4
10
  import { Event, PublicPost } from '@openpeepshq/common';
@@ -15,6 +21,8 @@ import { MainStackParamList } from '../../../navigation/types/index';
15
21
  import { Button } from '../../../ui/button';
16
22
  import { Timespan } from '../../../custom/date/index';
17
23
  import { EventLocation } from '../../pieces/EventLocation';
24
+ import { ShareMenu } from '../../pieces/ShareMenu';
25
+ import { ShareIcon } from '../../../icons/index';
18
26
  import { ProfileEventRelationship } from './ProfileEventRelationship';
19
27
 
20
28
  import { useTranslation } from 'react-i18next';
@@ -43,67 +51,82 @@ export const CardEvent = ({ post, showEventDate = true }: CardEventProps) => {
43
51
  const attendeesLength = jamState?.participants.length ?? 0;
44
52
 
45
53
  return (
46
- <TouchableOpacity
47
- onPress={() => {
48
- navigation.navigate('Post', {
49
- id: post.id,
50
- occurrence: occurrenceId,
51
- });
52
- }}
53
- className="mb-6 w-full rounded-lg border border-border"
54
- >
55
- <View className="w-full aspect-video overflow-hidden rounded-t-md">
56
- <Image
57
- source={
58
- event.image
59
- ? { uri: event.image }
60
- : require('../../../../assets/images/event-placeholder.png')
61
- }
62
- className="w-full h-full"
63
- resizeMode="cover"
64
- />
65
- </View>
66
- <View className="grid gap-y-5 p-4">
67
- {showEventDate ? (
68
- <View className="flex-row items-center gap-x-1">
69
- <Timespan
70
- start={post.occurrenceStart ?? event.start}
71
- end={post.occurrenceEnd ?? event.end}
72
- timeZone={event.timeZone}
73
- />
74
- </View>
75
- ) : null}
76
- {event.recurrence ? (
77
- <ThemedText className="text-muted-foreground text-sm">
78
- {formatEventRecurrence(event.recurrence, t, event.start)}
79
- </ThemedText>
80
- ) : null}
81
- <ThemedText className="text-xl font-semibold">
82
- {truncateText(event?.name, 100) || '-'}
83
- </ThemedText>
84
- <View className="flex flex-row gap-x-2">
85
- <EventLocation post={post} truncate={true} />
86
- <ProfileEventRelationship post={post} />
54
+ <View className="mb-6 w-full rounded-lg border border-border">
55
+ <TouchableOpacity
56
+ onPress={() => {
57
+ navigation.navigate('Post', {
58
+ id: post.id,
59
+ occurrence: occurrenceId,
60
+ });
61
+ }}
62
+ >
63
+ <View className="w-full aspect-video overflow-hidden rounded-t-md">
64
+ <Image
65
+ source={
66
+ event.image
67
+ ? { uri: event.image }
68
+ : require('../../../../assets/images/event-placeholder.png')
69
+ }
70
+ className="w-full h-full"
71
+ resizeMode="cover"
72
+ />
87
73
  </View>
88
- {jam && me && livekitEnabled ? (
89
- isLoading ? (
90
- <ActivityIndicator size="small" />
91
- ) : jamState?.active ? (
92
- <View className="flex flex-row items-center gap-x-2 text-xs text-muted-foreground">
93
- <View className="w-12">
94
- <ParticipantsCard jamState={jamState} />
74
+ <View className="grid gap-y-5 p-4">
75
+ {showEventDate ? (
76
+ <View className="flex-row items-center gap-x-1">
77
+ <Timespan
78
+ start={post.occurrenceStart ?? event.start}
79
+ end={post.occurrenceEnd ?? event.end}
80
+ timeZone={event.timeZone}
81
+ />
82
+ </View>
83
+ ) : null}
84
+ {event.recurrence ? (
85
+ <ThemedText className="text-muted-foreground text-sm">
86
+ {formatEventRecurrence(event.recurrence, t, event.start)}
87
+ </ThemedText>
88
+ ) : null}
89
+ <ThemedText className="text-xl font-semibold">
90
+ {truncateText(event?.name, 100) || '-'}
91
+ </ThemedText>
92
+ <View className="flex flex-row gap-x-2">
93
+ <EventLocation post={post} truncate={true} />
94
+ <ProfileEventRelationship post={post} />
95
+ </View>
96
+ {jam && me && livekitEnabled ? (
97
+ isLoading ? (
98
+ <ActivityIndicator size="small" />
99
+ ) : jamState?.active ? (
100
+ <View className="flex flex-row items-center gap-x-2 text-xs text-muted-foreground">
101
+ <View className="w-12">
102
+ <ParticipantsCard jamState={jamState} />
103
+ </View>
104
+ <ThemedText>
105
+ {attendeesLength}{' '}
106
+ {attendeesLength === 1
107
+ ? t('events.jam.attendee', { defaultValue: 'attendee' })
108
+ : t('events.jam.attendees', {
109
+ defaultValue: 'attendees',
110
+ })}
111
+ </ThemedText>
112
+ <Button
113
+ variant="default"
114
+ size="sm"
115
+ onPress={() =>
116
+ navigation.navigate('JamSession', {
117
+ jamId: post.id,
118
+ occurrence: occurrenceId,
119
+ })
120
+ }
121
+ >
122
+ <ThemedText numberOfLines={1}>
123
+ {t('jam.join.submit', { defaultValue: 'Join Jam' })}
124
+ </ThemedText>
125
+ </Button>
95
126
  </View>
96
- <ThemedText>
97
- {attendeesLength}{' '}
98
- {attendeesLength === 1
99
- ? t('events.jam.attendee', { defaultValue: 'attendee' })
100
- : t('events.jam.attendees', {
101
- defaultValue: 'attendees',
102
- })}
103
- </ThemedText>
127
+ ) : canModerateJam(me, post) ? (
104
128
  <Button
105
- variant="default"
106
- size="sm"
129
+ className="mt-2 w-full"
107
130
  onPress={() =>
108
131
  navigation.navigate('JamSession', {
109
132
  jamId: post.id,
@@ -112,27 +135,29 @@ export const CardEvent = ({ post, showEventDate = true }: CardEventProps) => {
112
135
  }
113
136
  >
114
137
  <ThemedText numberOfLines={1}>
115
- {t('jam.join.submit', { defaultValue: 'Join Jam' })}
138
+ {t('jam.start.submit', { defaultValue: 'Start Jam' })}
116
139
  </ThemedText>
117
140
  </Button>
118
- </View>
119
- ) : canModerateJam(me, post) ? (
120
- <Button
121
- className="mt-2 w-full"
122
- onPress={() =>
123
- navigation.navigate('JamSession', {
124
- jamId: post.id,
125
- occurrence: occurrenceId,
126
- })
127
- }
141
+ ) : null
142
+ ) : null}
143
+ </View>
144
+ </TouchableOpacity>
145
+ <View className="flex-row justify-end px-2 pb-2">
146
+ <ShareMenu
147
+ post={post}
148
+ menuButton={
149
+ <Pressable
150
+ accessibilityLabel={t('posts.footer.share')}
151
+ className="flex-row items-center gap-1 px-2 py-1"
128
152
  >
129
- <ThemedText numberOfLines={1}>
130
- {t('jam.start.submit', { defaultValue: 'Start Jam' })}
153
+ <ShareIcon size={18} className="text-foreground" />
154
+ <ThemedText className="text-sm">
155
+ {t('posts.footer.share')}
131
156
  </ThemedText>
132
- </Button>
133
- ) : null
134
- ) : null}
157
+ </Pressable>
158
+ }
159
+ />
135
160
  </View>
136
- </TouchableOpacity>
161
+ </View>
137
162
  );
138
163
  };
@@ -21,8 +21,8 @@ import {
21
21
  DropdownMenuTrigger,
22
22
  } from '../../../ui/dropdown-menu';
23
23
  import { ThemedText } from '../../../ui/themed-text';
24
- import { Image, TouchableOpacity, View } from 'react-native';
25
-
24
+ import { Image, Pressable, Share, TouchableOpacity, View } from 'react-native';
25
+ import RNFS from 'react-native-fs';
26
26
  import {
27
27
  Event,
28
28
  PublicPost,
@@ -49,22 +49,20 @@ import Toast from 'react-native-toast-message';
49
49
  import { useNewConversationStore } from '../../../../stores/useNewConversationStore';
50
50
  import { BottomSheetModal } from '@gorhom/bottom-sheet';
51
51
  import { useTranslation } from 'react-i18next';
52
- import {
53
- canManageEventRsvps,
54
- countYesRsvps,
55
- isCapacityEvent,
56
- } from '../../../../lib/utils';
52
+ import { canManageEventRsvps } from '../../../../lib/utils';
57
53
  import { bottomSheetPresent } from '../../../../lib/bottom-sheet-ref';
58
54
  import {
55
+ availableSpots,
59
56
  canAccessJamRecordings,
60
57
  canModerateJam,
61
58
  canViewJamAttendees,
62
- defaultRsvpRecurrenceId,
63
59
  effectiveEventTimes,
64
60
  eventTimeZoneOptions,
65
61
  formatEventClockTime,
66
62
  formatEventRecurrence,
67
63
  listRsvpOccurrences,
64
+ parseOccurrenceQuery,
65
+ rsvpExportFilename,
68
66
  } from '@openpeepshq/common/lib';
69
67
  import { ThemedView } from '../../../ui/themed-view';
70
68
  import { EventOccurrenceList } from '../../pieces/EventOccurrenceList';
@@ -90,7 +88,7 @@ export interface FullEventProps {
90
88
 
91
89
  export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
92
90
  const { t } = useTranslation();
93
- const { currentProfile, openpeepsApi } = useOpenpeeps();
91
+ const { currentProfile, openpeepsApi, client } = useOpenpeeps();
94
92
  const navigation =
95
93
  useNavigation<NativeStackNavigationProp<MainStackParamList>>();
96
94
  const { openNewPost } = useNewPostModal();
@@ -103,18 +101,31 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
103
101
  const event = useMemo(() => post?.data as Event, [post]);
104
102
 
105
103
  const canManageRsvps = canManageEventRsvps(currentProfile, post);
106
- const slotsLeft =
107
- isCapacityEvent(event) &&
108
- event.maxAttendees !== undefined &&
109
- (!event.recurrence || occurrence)
110
- ? event.maxAttendees - countYesRsvps(post, occurrence)
111
- : null;
104
+ const slotsLeft = availableSpots(post, occurrence) ?? null;
112
105
  const rsvpManage = openpeepsApi.rsvpManageAction();
113
- const times = effectiveEventTimes(
114
- event,
115
- occurrence ??
116
- (event?.recurrence ? defaultRsvpRecurrenceId(event) : undefined)
117
- );
106
+ const exportRsvps = async () => {
107
+ try {
108
+ const csv = await client.posts.exportRsvps({
109
+ id: post.id,
110
+ occurrence: parseOccurrenceQuery(occurrence),
111
+ });
112
+ const filename = rsvpExportFilename(event?.name, new Date());
113
+ const path = `${RNFS.CachesDirectoryPath}/${filename}`;
114
+ await RNFS.writeFile(path, csv, 'utf8');
115
+ await Share.share({
116
+ url: `file://${path}`,
117
+ title: filename,
118
+ }).catch(() => undefined);
119
+ } catch {
120
+ Toast.show({
121
+ type: 'error',
122
+ text1: t('events.exportRsvpsError', {
123
+ defaultValue: 'Failed to export RSVPs',
124
+ }),
125
+ });
126
+ }
127
+ };
128
+ const times = effectiveEventTimes(event, occurrence);
118
129
  const tz = eventTimeZoneOptions(event?.timeZone);
119
130
  const recurrenceLabel = event?.recurrence
120
131
  ? formatEventRecurrence(event.recurrence, t, event.start)
@@ -152,9 +163,9 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
152
163
  const showJamAttendeesTab =
153
164
  !!event.jam && canExportAttendees && jamAttendeesQuery.isSuccess;
154
165
 
155
- let postContextQuery = openpeepsApi.usePostContext(post.id);
166
+ const postContextQuery = openpeepsApi.usePostContext(post.id);
156
167
 
157
- let descendentThreads = useMemo(
168
+ const descendentThreads = useMemo(
158
169
  () =>
159
170
  (postContextQuery.data &&
160
171
  buildThreads(postContextQuery.data.descendants)) ||
@@ -480,6 +491,19 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
480
491
  ))}
481
492
  </TabsContent>
482
493
  <TabsContent value="rsvps" className="px-0 py-4">
494
+ {canManageRsvps ? (
495
+ <Button
496
+ variant="outline"
497
+ className="mb-3 self-end"
498
+ onPress={() => {
499
+ void exportRsvps();
500
+ }}
501
+ >
502
+ <ThemedText>
503
+ {t('events.exportRsvps', { defaultValue: 'Export RSVPs' })}
504
+ </ThemedText>
505
+ </Button>
506
+ ) : null}
483
507
  <EventRsvpList
484
508
  post={post as PublicPost}
485
509
  occurrenceId={occurrence}
@@ -725,7 +749,20 @@ export const FullEventActions: React.FC<{
725
749
 
726
750
  return (
727
751
  <View className="flex-row items-center">
728
- <ShareMenu post={post} />
752
+ <ShareMenu
753
+ post={post}
754
+ menuButton={
755
+ <Pressable
756
+ accessibilityLabel={t('posts.footer.share')}
757
+ className="flex-row items-center gap-1 px-2"
758
+ >
759
+ <ShareIcon size={18} className="text-foreground" />
760
+ <ThemedText className="text-sm">
761
+ {t('posts.footer.share')}
762
+ </ThemedText>
763
+ </Pressable>
764
+ }
765
+ />
729
766
  {myEvent ? (
730
767
  <EventMenu post={post} occurrence={occurrence} />
731
768
  ) : (
@@ -38,6 +38,8 @@ export const ProfileEventRelationship: React.FC<
38
38
  return t('events.profileRelationship.attending');
39
39
  } else if (myRsvp?.response === 'tentative') {
40
40
  return t('events.profileRelationship.tentative');
41
+ } else if (myRsvp?.response === 'waitlist') {
42
+ return t('events.profileRelationship.waitlisted');
41
43
  }
42
44
  return null;
43
45
  })();
@@ -108,6 +108,8 @@ export const FullResource = ({ post }: FullResourceProps) => {
108
108
  return (
109
109
  <ResourceCard
110
110
  post={post}
111
+ showDescription={false}
112
+ inGroup={!!post.group}
111
113
  preview={<VideoPlayer attachment={videoAtt} />}
112
114
  />
113
115
  );
@@ -122,6 +124,8 @@ export const FullResource = ({ post }: FullResourceProps) => {
122
124
  return (
123
125
  <ResourceCard
124
126
  post={post}
127
+ showDescription={false}
128
+ inGroup={!!post.group}
125
129
  preview={
126
130
  <AudioAttachment
127
131
  src={audioAtt.url}
@@ -137,7 +141,11 @@ export const FullResource = ({ post }: FullResourceProps) => {
137
141
  // All kinds: ResourceCard with click overlay
138
142
  return (
139
143
  <View className="relative">
140
- <ResourceCard post={post} />
144
+ <ResourceCard
145
+ post={post}
146
+ showDescription={false}
147
+ inGroup={!!post.group}
148
+ />
141
149
  <View
142
150
  className="absolute top-0 left-0 right-0 h-48 items-center justify-center"
143
151
  pointerEvents="box-none"
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
2
  import { View, TouchableOpacity } from 'react-native';
3
- import { isJamPath, isPostPath, isGroupPath } from './helpers';
3
+ import { isJamPath, isPostPath, isGroupPath, isWelcomePath } from './helpers';
4
4
  import { PostPreview } from './local/PostPreview';
5
5
  import { JamPreview } from './local/JamPreview';
6
6
  import { GroupPreview } from './local/GroupPreview';
7
+ import { WelcomePreview } from './local/WelcomePreview';
7
8
  import { handleInternalURLNavigation } from '../../lib/utils';
8
9
  import { useNavigation } from '@react-navigation/native';
9
10
  import { NativeStackNavigationProp } from '@react-navigation/native-stack';
@@ -23,6 +24,7 @@ export const LocalPreviewLink = ({ url }: LocalPreviewLinkProps) => {
23
24
  const isPost = isPostPath(path);
24
25
  const isJam = isJamPath(path);
25
26
  const isGroup = isGroupPath(path);
27
+ const isWelcome = isWelcomePath(path);
26
28
 
27
29
  const handlePress = () => {
28
30
  handleInternalURLNavigation(url, goto);
@@ -34,6 +36,7 @@ export const LocalPreviewLink = ({ url }: LocalPreviewLinkProps) => {
34
36
  {isPost && <PostPreview path={path} />}
35
37
  {isGroup && <GroupPreview path={path} />}
36
38
  {isJam && <JamPreview path={path} />}
39
+ {isWelcome && <WelcomePreview />}
37
40
  </View>
38
41
  </TouchableOpacity>
39
42
  );