@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
@@ -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}
@@ -0,0 +1,62 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { View } from 'react-native';
3
+ import { BottomSheetModal } from '@gorhom/bottom-sheet';
4
+ import { useTranslation } from 'react-i18next';
5
+ import type { PublicPost } from '@openpeepshq/common/types';
6
+ import { waitlistOfferWindowMs } from '@openpeepshq/common/lib';
7
+ import { BaseSheet, SheetFooter } from '../../custom/modals/common';
8
+ import { ThemedText } from '../../ui/themed-text';
9
+ import { bottomSheetClose } from '../../../lib/bottom-sheet-ref';
10
+
11
+ export interface EventWaitlistJoinDialogProps {
12
+ post: PublicPost;
13
+ error?: string | null;
14
+ isLoading?: boolean;
15
+ onClose: () => void;
16
+ onConfirm: () => void | Promise<void>;
17
+ }
18
+
19
+ export const EventWaitlistJoinDialog = forwardRef<
20
+ BottomSheetModal,
21
+ EventWaitlistJoinDialogProps
22
+ >(({ post, error, isLoading, onClose, onConfirm }, ref) => {
23
+ const { t } = useTranslation();
24
+ const event = post.data?.type === 'event' ? post.data : undefined;
25
+ const minutes = event
26
+ ? Math.round(waitlistOfferWindowMs(event) / 60_000)
27
+ : 60;
28
+
29
+ return (
30
+ <BaseSheet ref={ref} snapPoints={['40%']} onDismiss={onClose}>
31
+ <View className="flex-1 gap-y-3 p-4">
32
+ <ThemedText className="text-center text-lg">
33
+ {t('events.rsvp.waitlistConfirmTitle')}
34
+ </ThemedText>
35
+ <ThemedText className="text-center text-sm">
36
+ {t('events.rsvp.atCapacity')}
37
+ </ThemedText>
38
+ <ThemedText className="text-center text-sm text-muted-foreground">
39
+ {t('events.rsvp.waitlistConfirmBody', { minutes })}
40
+ </ThemedText>
41
+ {error ? (
42
+ <ThemedText className="text-center text-sm text-destructive">
43
+ {error}
44
+ </ThemedText>
45
+ ) : null}
46
+ <SheetFooter
47
+ onCancel={() => {
48
+ bottomSheetClose(ref);
49
+ onClose();
50
+ }}
51
+ onConfirm={onConfirm}
52
+ confirmText={t('events.rsvp.joinWaitlist')}
53
+ cancelText={t('events.rsvp.scope.cancel')}
54
+ disabled={isLoading}
55
+ isLoading={isLoading}
56
+ />
57
+ </View>
58
+ </BaseSheet>
59
+ );
60
+ });
61
+
62
+ EventWaitlistJoinDialog.displayName = 'EventWaitlistJoinDialog';
@@ -26,19 +26,19 @@ export const PollContent = ({ post }: Props) => {
26
26
 
27
27
  const votePoll = openpeepsApi.voteOnPostAction({ id: post!.id });
28
28
 
29
- let hasPollEnded: boolean = !!(
29
+ const hasPollEnded: boolean = !!(
30
30
  post?.data?.type === 'question' &&
31
31
  post.data.expiresAt &&
32
32
  isPast(post.data.expiresAt)
33
33
  );
34
34
 
35
- let hasVoted: boolean = !!(
35
+ const hasVoted: boolean = !!(
36
36
  currentProfile &&
37
37
  (votes.find((v) => v?.profile?.id === currentProfile.id)?.selection
38
38
  ?.length ?? 0) > 0
39
39
  );
40
40
 
41
- let canVote: boolean = !!(currentProfile && !hasPollEnded && !hasVoted);
41
+ const canVote: boolean = !!(currentProfile && !hasPollEnded && !hasVoted);
42
42
 
43
43
  const handleVote = async () => {
44
44
  if (post?.data?.type !== 'question') {
@@ -191,15 +191,15 @@ export const PollContent = ({ post }: Props) => {
191
191
 
192
192
  <View className="mt-4 flex-row items-center gap-3">
193
193
  <Text className="text-sm text-muted-foreground">
194
- {`${votes.length || 0} ${t('posts.vote.count')}`}
194
+ {t('posts.vote.count', { count: votes.length || 0 })}
195
195
  </Text>
196
196
  {post?.data?.type === 'question' && post.data.expiresAt && (
197
197
  <Text className="text-sm text-muted-foreground">
198
198
  {hasPollEnded
199
199
  ? t('posts.poll.ended')
200
- : `${formatDistanceToNow(post.data.expiresAt)} ${t(
201
- 'posts.poll.timeLeft'
202
- )}`}
200
+ : t('posts.poll.timeLeft', {
201
+ time: formatDistanceToNow(post.data.expiresAt),
202
+ })}
203
203
  </Text>
204
204
  )}
205
205
  {hasVoted && !hasPollEnded && (
@@ -1,11 +1,18 @@
1
1
  import React from 'react';
2
- import { View } from 'react-native';
2
+ import { Pressable, View } from 'react-native';
3
+ import { cn } from '../../../lib/utils';
3
4
  import { Button } from '../../ui/button';
4
5
  import { ThemedText } from '../../ui/themed-text';
5
- import { Repeat2Icon, ReplyIcon, ThumbsUpIcon } from '../../icons/index';
6
+ import {
7
+ Repeat2Icon,
8
+ ReplyIcon,
9
+ ShareIcon,
10
+ ThumbsUpIcon,
11
+ } from '../../icons/index';
6
12
  import { type PublicPost } from '@openpeepshq/common';
7
13
  import { useTranslation } from 'react-i18next';
8
14
  import { useFeedPostActions } from '@openpeepshq/react';
15
+ import { ShareMenu } from './ShareMenu';
9
16
 
10
17
  interface PostActionsProps {
11
18
  post: PublicPost;
@@ -16,7 +23,7 @@ interface PostActionsProps {
16
23
  export const PostActions = ({
17
24
  post,
18
25
  previewMode = false,
19
- compact = false,
26
+ compact: _compact = false,
20
27
  }: PostActionsProps) => {
21
28
  const { t } = useTranslation();
22
29
  const {
@@ -31,51 +38,110 @@ export const PostActions = ({
31
38
  toggleReaction,
32
39
  } = useFeedPostActions(post);
33
40
 
34
- if (!me) {
35
- return null;
36
- }
41
+ const replyActive = !previewMode && canReply;
42
+ const repostActive = !previewMode && canRepost;
43
+ const reactActive = !previewMode && canReact;
44
+ const shareActive = !previewMode;
37
45
 
38
46
  const actionClass = 'flex-1 flex-row items-center gap-2 native:p-2';
47
+ const shareClass = 'flex-row items-center gap-2 native:p-2';
48
+ const shareLabel = t('posts.footer.share');
49
+
50
+ // Button fades every disabled control. These should read as plain text.
51
+ const idleClass =
52
+ 'opacity-100 web:hover:bg-transparent active:bg-transparent';
53
+
54
+ const iconClass = (active: boolean, highlighted: boolean) =>
55
+ !active
56
+ ? 'text-muted-foreground'
57
+ : highlighted
58
+ ? 'text-primary'
59
+ : 'text-foreground';
60
+
61
+ const labelClass = (active: boolean, highlighted: boolean) =>
62
+ cn(
63
+ 'text-sm',
64
+ !active && 'text-muted-foreground',
65
+ active && highlighted && 'text-primary'
66
+ );
67
+
68
+ const shareIconClass = iconClass(shareActive, false);
69
+ const shareTextClass = labelClass(shareActive, false);
70
+
71
+ const shareButton = shareActive ? (
72
+ <ShareMenu
73
+ post={post}
74
+ menuButton={
75
+ <Button variant="ghost" className={shareClass}>
76
+ <ShareIcon size={16} className={shareIconClass} />
77
+ <ThemedText className={shareTextClass}>{shareLabel}</ThemedText>
78
+ </Button>
79
+ }
80
+ />
81
+ ) : (
82
+ <Button variant="ghost" disabled className={cn(shareClass, idleClass)}>
83
+ <ShareIcon size={16} className={shareIconClass} />
84
+ <ThemedText className={shareTextClass}>{shareLabel}</ThemedText>
85
+ </Button>
86
+ );
87
+
88
+ if (!me) {
89
+ return (
90
+ <View className="w-full flex-row items-center justify-end py-2">
91
+ {shareButton}
92
+ </View>
93
+ );
94
+ }
39
95
 
40
96
  return (
41
- <View className="w-full flex-row items-center py-2">
97
+ // A disabled control does not take the touch, so the feed card would open
98
+ // the post. This row absorbs that tap and still yields to scrolling.
99
+ <Pressable
100
+ accessible={false}
101
+ onPress={() => {}}
102
+ className="w-full flex-row items-center py-2"
103
+ >
42
104
  <Button
43
105
  variant="ghost"
44
- disabled={previewMode || !canReply}
106
+ disabled={!replyActive}
45
107
  onPress={() => reply()}
46
- className={`${actionClass} justify-start`}
108
+ className={cn(actionClass, 'justify-start', !replyActive && idleClass)}
47
109
  >
48
- <ReplyIcon size={16} className="text-foreground" />
49
- <ThemedText className="text-sm">{t('posts.footer.reply')}</ThemedText>
110
+ <ReplyIcon size={16} className={iconClass(replyActive, false)} />
111
+ <ThemedText className={labelClass(replyActive, false)}>
112
+ {t('posts.footer.reply')}
113
+ </ThemedText>
50
114
  </Button>
51
115
  <Button
52
116
  variant="ghost"
53
- disabled={previewMode || !canRepost}
117
+ disabled={!repostActive}
54
118
  onPress={() => void toggleRepost()}
55
- className={`${actionClass} justify-center`}
119
+ className={cn(
120
+ actionClass,
121
+ 'justify-center',
122
+ !repostActive && idleClass
123
+ )}
56
124
  >
57
125
  <Repeat2Icon
58
126
  size={16}
59
- className={myRepost ? 'text-primary' : 'text-foreground'}
127
+ className={iconClass(repostActive, !!myRepost)}
60
128
  />
61
- <ThemedText className={`text-sm ${myRepost ? 'text-primary' : ''}`}>
129
+ <ThemedText className={labelClass(repostActive, !!myRepost)}>
62
130
  {t('posts.footer.repost')}
63
131
  </ThemedText>
64
132
  </Button>
65
133
  <Button
66
134
  variant="ghost"
67
- disabled={previewMode || !canReact}
135
+ disabled={!reactActive}
68
136
  onPress={() => void toggleReaction()}
69
- className={`${actionClass} justify-end`}
137
+ className={cn(actionClass, 'justify-end', !reactActive && idleClass)}
70
138
  >
71
- <ThumbsUpIcon
72
- size={16}
73
- className={iReacted ? 'text-primary' : 'text-foreground'}
74
- />
75
- <ThemedText className={`text-sm ${iReacted ? 'text-primary' : ''}`}>
139
+ <ThumbsUpIcon size={16} className={iconClass(reactActive, iReacted)} />
140
+ <ThemedText className={labelClass(reactActive, iReacted)}>
76
141
  {t('posts.footer.like')}
77
142
  </ThemedText>
78
143
  </Button>
79
- </View>
144
+ <View className="flex-1 items-end">{shareButton}</View>
145
+ </Pressable>
80
146
  );
81
147
  };
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
7
7
  import { useNavigation } from '@react-navigation/native';
8
8
  import { NativeStackNavigationProp } from '@react-navigation/native-stack';
9
9
  import type { PublicPost } from '@openpeepshq/common';
10
- import { useShareMenu } from '@openpeepshq/react';
10
+ import { postPublicPath, useShareMenu } from '@openpeepshq/react';
11
11
  import {
12
12
  CalendarIcon,
13
13
  CopyIcon,
@@ -35,7 +35,7 @@ export const ShareMenu = ({ post, menuButton }: ShareMenuProps) => {
35
35
  const navigation =
36
36
  useNavigation<NativeStackNavigationProp<MainStackParamList>>();
37
37
  const setDraftMessage = useNewConversationStore((s) => s.setContt);
38
- const postUrl = `${BASE_URL}/posts/${post.id}`;
38
+ const postUrl = `${BASE_URL}${postPublicPath(post)}`;
39
39
  const { signedIn, isEvent, repost, eventIcsFile } = useShareMenu(
40
40
  post,
41
41
  postUrl
@@ -27,6 +27,7 @@ export const DescriptionEditModal = forwardRef<
27
27
  } catch (error) {
28
28
  console.error('Failed to Save', error);
29
29
  } finally {
30
+ // swallowed
30
31
  }
31
32
  };
32
33
 
@@ -1,10 +1,13 @@
1
- import React, { useRef } from 'react';
1
+ import React, { useRef, useState } from 'react';
2
2
  import { Pressable, View } from 'react-native';
3
3
  import { BottomSheetModal } from '@gorhom/bottom-sheet';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import timezones from 'timezones-list';
6
6
  import type { PostCreationData } from '@openpeepshq/common';
7
- import { parseEventMaxAttendeesInput } from '@openpeepshq/common/lib';
7
+ import {
8
+ parseEventMaxAttendeesInput,
9
+ parseEventWaitlistOfferMinutesInput,
10
+ } from '@openpeepshq/common/lib';
8
11
  import {
9
12
  EVENT_WEEKDAYS,
10
13
  useEventForm,
@@ -86,6 +89,7 @@ export const EventForm = ({
86
89
  occurrenceEdit = false,
87
90
  }: EventFormProps) => {
88
91
  const { t } = useTranslation();
92
+ const [endBeforeStart, setEndBeforeStart] = useState(false);
89
93
  const startSheetRef = useRef<BottomSheetModal>(null);
90
94
  const endSheetRef = useRef<BottomSheetModal>(null);
91
95
  const untilSheetRef = useRef<BottomSheetModal>(null);
@@ -173,13 +177,22 @@ export const EventForm = ({
173
177
  </Pressable>
174
178
 
175
179
  {showEndDate ? (
176
- <PickerField
177
- label={t('events.form.endDate')}
178
- value={formatDate(event.end, eventTimeZone)}
179
- placeholder={t('events.form.endDate')}
180
- icon={<CalendarIcon className="text-muted-foreground" size={18} />}
181
- onPress={() => bottomSheetPresent(endSheetRef)}
182
- />
180
+ <>
181
+ <PickerField
182
+ label={t('events.form.endDate')}
183
+ value={formatDate(event.end, eventTimeZone)}
184
+ placeholder={t('events.form.endDate')}
185
+ icon={
186
+ <CalendarIcon className="text-muted-foreground" size={18} />
187
+ }
188
+ onPress={() => bottomSheetPresent(endSheetRef)}
189
+ />
190
+ {endBeforeStart ? (
191
+ <ThemedText className="text-sm text-destructive">
192
+ {t('events.form.endBeforeStart')}
193
+ </ThemedText>
194
+ ) : null}
195
+ </>
183
196
  ) : null}
184
197
 
185
198
  <PickerField
@@ -381,6 +394,26 @@ export const EventForm = ({
381
394
  ) : null}
382
395
  </View>
383
396
  </View>
397
+ {event.maxAttendees != null ? (
398
+ <View className="gap-y-1">
399
+ <Label nativeID="event-waitlist-minutes">
400
+ {t('events.form.waitlistOfferMinutes')}
401
+ </Label>
402
+ <ThemedText className="text-sm text-muted-foreground">
403
+ {t('events.form.waitlistOfferMinutesDescription')}
404
+ </ThemedText>
405
+ <Input
406
+ keyboardType="numeric"
407
+ value={event.waitlistOfferMinutes?.toString() ?? ''}
408
+ onChangeText={(value) =>
409
+ patchEvent({
410
+ waitlistOfferMinutes:
411
+ parseEventWaitlistOfferMinutesInput(value),
412
+ })
413
+ }
414
+ />
415
+ </View>
416
+ ) : null}
384
417
  </View>
385
418
 
386
419
  <DateSheet
@@ -394,7 +427,14 @@ export const EventForm = ({
394
427
  ref={endSheetRef}
395
428
  value={event.end}
396
429
  timeZone={eventTimeZone}
397
- onChange={(end) => patchEvent({ end })}
430
+ onChange={(end) => {
431
+ if (end && event.start && new Date(end) <= new Date(event.start)) {
432
+ setEndBeforeStart(true);
433
+ return;
434
+ }
435
+ setEndBeforeStart(false);
436
+ patchEvent({ end });
437
+ }}
398
438
  onClose={() => bottomSheetClose(endSheetRef)}
399
439
  />
400
440
  <DateSheet