@openpeepshq/react 0.7.0 → 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 (251) hide show
  1. package/dist/components/configuration/ConfigurationCategory.js +3 -2
  2. package/dist/components/configuration/ConfigurationList.js +1 -1
  3. package/dist/components/form/LocationInput.js +1 -1
  4. package/dist/components/jams/JamCapacityGate.js +1 -1
  5. package/dist/components/jams/JamConference.js +2 -0
  6. package/dist/components/jams/JamParticipantConference.js +2 -0
  7. package/dist/components/jams/JamRoom.js +2 -3
  8. package/dist/components/jams/LiveJamsSection.js +8 -2
  9. package/dist/components/jams/LivekitUnavailableNotice.d.ts +9 -0
  10. package/dist/components/jams/LivekitUnavailableNotice.js +19 -0
  11. package/dist/components/jams/dropLateAudio.d.ts +22 -0
  12. package/dist/components/jams/dropLateAudio.js +115 -0
  13. package/dist/components/jams/index.d.ts +1 -0
  14. package/dist/components/jams/index.js +1 -0
  15. package/dist/components/markdown/compileMarkdown.js +1 -0
  16. package/dist/components/navigation/FooterMobile.js +4 -3
  17. package/dist/components/navigation/HeaderMobile.js +5 -2
  18. package/dist/components/navigation/MobileMenuItem.d.ts +3 -1
  19. package/dist/components/navigation/MobileMenuItem.js +7 -2
  20. package/dist/components/navigation/NavWithTooltip.d.ts +9 -0
  21. package/dist/components/navigation/NavWithTooltip.js +4 -0
  22. package/dist/components/navigation/index.d.ts +2 -0
  23. package/dist/components/navigation/index.js +1 -0
  24. package/dist/components/navigation/sideBarNavLinkClass.d.ts +6 -4
  25. package/dist/components/navigation/sideBarNavLinkClass.js +6 -2
  26. package/dist/components/notifications/TypedNotification.js +46 -4
  27. package/dist/components/post/CompactReplyParent.js +5 -6
  28. package/dist/components/post/Markdown.d.ts +2 -2
  29. package/dist/components/post/Markdown.js +1 -1
  30. package/dist/components/post/TruncatedMarkdown.d.ts +27 -0
  31. package/dist/components/post/TruncatedMarkdown.js +37 -0
  32. package/dist/components/post/attachmentPreview.js +1 -1
  33. package/dist/components/post/helpers.d.ts +2 -2
  34. package/dist/components/post/helpers.js +3 -16
  35. package/dist/components/post/index.d.ts +2 -0
  36. package/dist/components/post/index.js +1 -0
  37. package/dist/components/post/pieces/Attachments.js +23 -17
  38. package/dist/components/post/pieces/EventLocation.js +14 -0
  39. package/dist/components/post/pieces/EventRsvpButton.js +39 -7
  40. package/dist/components/post/pieces/EventRsvpList.js +23 -3
  41. package/dist/components/post/pieces/EventRsvpScopeDialog.d.ts +1 -1
  42. package/dist/components/post/pieces/EventRsvpScopeDialog.js +34 -22
  43. package/dist/components/post/pieces/EventWaitlistJoinDialog.d.ts +10 -0
  44. package/dist/components/post/pieces/EventWaitlistJoinDialog.js +26 -0
  45. package/dist/components/post/pieces/ParticipantsCard.d.ts +1 -1
  46. package/dist/components/post/pieces/ParticipantsCard.js +1 -1
  47. package/dist/components/post/pieces/PollContent.js +8 -2
  48. package/dist/components/post/pieces/PostActions.d.ts +1 -1
  49. package/dist/components/post/pieces/PostActions.js +20 -12
  50. package/dist/components/post/pieces/ShareMenu.d.ts +6 -1
  51. package/dist/components/post/pieces/ShareMenu.js +40 -7
  52. package/dist/components/post/post-form/ArticleForm.js +1 -1
  53. package/dist/components/post/post-form/EventForm.js +33 -5
  54. package/dist/components/post/post-form/ResourceForm.d.ts +3 -1
  55. package/dist/components/post/post-form/ResourceForm.js +48 -7
  56. package/dist/components/post/post-form/VisibilitySelector.js +9 -3
  57. package/dist/components/post/types/Article.js +2 -3
  58. package/dist/components/post/types/Event.js +10 -1
  59. package/dist/components/post/types/article/FullArticle.js +1 -1
  60. package/dist/components/post/types/event/CardEvent.js +2 -1
  61. package/dist/components/post/types/event/FullEvent.js +22 -13
  62. package/dist/components/post/types/event/ProfileEventRelationship.js +8 -0
  63. package/dist/components/post/types/resource/FullResource.js +3 -3
  64. package/dist/components/preview-link/LocalPreviewLink.js +4 -2
  65. package/dist/components/preview-link/PreviewLink.js +1 -1
  66. package/dist/components/preview-link/helpers.d.ts +5 -0
  67. package/dist/components/preview-link/helpers.js +27 -1
  68. package/dist/components/preview-link/local/WelcomePreview.d.ts +1 -0
  69. package/dist/components/preview-link/local/WelcomePreview.js +8 -0
  70. package/dist/components/profile/Avatar.js +2 -2
  71. package/dist/components/profile/ProfileFromId.js +1 -1
  72. package/dist/components/resources/ResourceCard.d.ts +5 -1
  73. package/dist/components/resources/ResourceCard.js +29 -5
  74. package/dist/components/resources/ResourceCard.test.d.ts +1 -0
  75. package/dist/components/resources/ResourceCard.test.js +75 -0
  76. package/dist/components/resources/ResourceLibrary.js +1 -1
  77. package/dist/components/server-data/context.d.ts +1 -0
  78. package/dist/contexts/openpeeps/hooks/accounts.d.ts +5 -5
  79. package/dist/contexts/openpeeps/hooks/accounts.js +1 -3
  80. package/dist/contexts/openpeeps/hooks/admin.d.ts +165 -66
  81. package/dist/contexts/openpeeps/hooks/admin.js +11 -3
  82. package/dist/contexts/openpeeps/hooks/auth.d.ts +2 -2
  83. package/dist/contexts/openpeeps/hooks/groups.d.ts +8 -8
  84. package/dist/contexts/openpeeps/hooks/jams.d.ts +73 -24
  85. package/dist/contexts/openpeeps/hooks/other.d.ts +7 -6
  86. package/dist/contexts/openpeeps/hooks/payments.d.ts +2 -2
  87. package/dist/contexts/openpeeps/hooks/posts.d.ts +368 -170
  88. package/dist/contexts/openpeeps/hooks/streaming.d.ts +1 -1
  89. package/dist/hooks/admin/useCanAccessAdminSection.d.ts +13 -0
  90. package/dist/hooks/admin/useCanAccessAdminSection.js +21 -0
  91. package/dist/hooks/events/useEventComposer.d.ts +94 -41
  92. package/dist/hooks/events/useEventForm.d.ts +1 -0
  93. package/dist/hooks/events/useEventRsvp.d.ts +12 -2
  94. package/dist/hooks/events/useEventRsvp.js +59 -10
  95. package/dist/hooks/events/useEventsCalendar.d.ts +174 -76
  96. package/dist/hooks/groups/useNewGroup.js +22 -2
  97. package/dist/hooks/index.d.ts +5 -1
  98. package/dist/hooks/index.js +4 -1
  99. package/dist/hooks/jams/useCanDiagnoseLivekit.d.ts +2 -0
  100. package/dist/hooks/jams/useCanDiagnoseLivekit.js +3 -0
  101. package/dist/hooks/jams/useCreateNewJamForm.d.ts +3 -1
  102. package/dist/hooks/jams/useJamDetails.d.ts +87 -38
  103. package/dist/hooks/jams/useJamLobby.d.ts +1 -0
  104. package/dist/hooks/jams/useJamRoom.d.ts +175 -76
  105. package/dist/hooks/posts/useArticleComposer.d.ts +93 -41
  106. package/dist/hooks/posts/useFeedPostPresentation.d.ts +174 -76
  107. package/dist/hooks/posts/usePostDetailTitle.d.ts +87 -38
  108. package/dist/hooks/posts/useResourceComposer.d.ts +95 -41
  109. package/dist/hooks/posts/useResourceComposer.js +135 -27
  110. package/dist/hooks/posts/useShareMenu.d.ts +2 -0
  111. package/dist/hooks/posts/useShareMenu.js +7 -0
  112. package/dist/hooks/resources/useResourceLibrary.d.ts +177 -79
  113. package/dist/hooks/resources/useResourceLibrary.js +6 -2
  114. package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
  115. package/dist/hooks/useWelcomePreview.d.ts +16 -0
  116. package/dist/hooks/useWelcomePreview.js +40 -0
  117. package/dist/lib/groupFormErrors.d.ts +1 -0
  118. package/dist/lib/groupFormErrors.js +5 -2
  119. package/dist/lib/threadHelpers.js +1 -5
  120. package/dist/navigation/menuItems.js +15 -0
  121. package/dist/navigation/targets.d.ts +2 -0
  122. package/dist/pages/admin/ConfigurationCommunity.js +1 -1
  123. package/dist/pages/admin/Diagnostics.js +1 -1
  124. package/dist/pages/admin/DiagnosticsLivekit.d.ts +1 -0
  125. package/dist/pages/admin/DiagnosticsLivekit.js +50 -0
  126. package/dist/pages/admin/Invites.js +5 -3
  127. package/dist/pages/admin/Media.d.ts +1 -0
  128. package/dist/pages/admin/Media.js +135 -0
  129. package/dist/pages/admin/community/CommunityForbiddenUsernames.d.ts +1 -0
  130. package/dist/pages/admin/community/CommunityForbiddenUsernames.js +106 -0
  131. package/dist/pages/admin/community/CommunityMarkdownPage.js +2 -1
  132. package/dist/pages/admin/community/CommunityRoles.js +1 -1
  133. package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
  134. package/dist/pages/admin/components/EditInviteLinkModal.d.ts +5 -0
  135. package/dist/pages/admin/components/EditInviteLinkModal.js +131 -0
  136. package/dist/pages/auth/Register.js +33 -9
  137. package/dist/pages/conversations/Show.js +11 -0
  138. package/dist/pages/index.d.ts +3 -0
  139. package/dist/pages/index.js +3 -0
  140. package/dist/pages/jams/Index.js +2 -4
  141. package/dist/pages/resources/Edit.js +3 -3
  142. package/dist/pages/resources/New.js +2 -2
  143. package/dist/pages/settings/Account.js +30 -2
  144. package/dist/pages/settings/PublicProfile.js +15 -3
  145. package/dist/pwa/sw.d.ts +0 -1
  146. package/dist/react-native.d.ts +1 -0
  147. package/dist/react-native.js +1 -0
  148. package/dist/stores/newPosts.d.ts +4 -2
  149. package/dist/stores/newPosts.js +6 -1
  150. package/package.json +12 -7
  151. package/src/components/configuration/ConfigurationCategory.tsx +23 -10
  152. package/src/components/configuration/ConfigurationList.tsx +6 -1
  153. package/src/components/form/LocationInput.tsx +7 -1
  154. package/src/components/jams/JamCapacityGate.tsx +1 -1
  155. package/src/components/jams/JamConference.tsx +2 -0
  156. package/src/components/jams/JamParticipantConference.tsx +2 -0
  157. package/src/components/jams/JamRoom.tsx +2 -6
  158. package/src/components/jams/LiveJamsSection.tsx +16 -2
  159. package/src/components/jams/LivekitUnavailableNotice.tsx +40 -0
  160. package/src/components/jams/dropLateAudio.ts +153 -0
  161. package/src/components/jams/index.ts +1 -0
  162. package/src/components/markdown/compileMarkdown.ts +1 -0
  163. package/src/components/navigation/FooterMobile.tsx +41 -33
  164. package/src/components/navigation/HeaderMobile.tsx +55 -41
  165. package/src/components/navigation/MobileMenuItem.tsx +15 -2
  166. package/src/components/navigation/NavWithTooltip.tsx +26 -0
  167. package/src/components/navigation/index.ts +2 -0
  168. package/src/components/navigation/sideBarNavLinkClass.ts +9 -6
  169. package/src/components/notifications/TypedNotification.tsx +81 -9
  170. package/src/components/post/CompactReplyParent.tsx +17 -10
  171. package/src/components/post/Markdown.tsx +8 -2
  172. package/src/components/post/TruncatedMarkdown.tsx +91 -0
  173. package/src/components/post/attachmentPreview.ts +1 -3
  174. package/src/components/post/helpers.ts +4 -18
  175. package/src/components/post/index.ts +2 -0
  176. package/src/components/post/pieces/Attachments.tsx +93 -78
  177. package/src/components/post/pieces/EventLocation.tsx +27 -0
  178. package/src/components/post/pieces/EventRsvpButton.tsx +110 -7
  179. package/src/components/post/pieces/EventRsvpList.tsx +64 -0
  180. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +39 -27
  181. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +77 -0
  182. package/src/components/post/pieces/ParticipantsCard.tsx +4 -1
  183. package/src/components/post/pieces/PollContent.tsx +8 -2
  184. package/src/components/post/pieces/PostActions.tsx +73 -42
  185. package/src/components/post/pieces/ShareMenu.tsx +67 -9
  186. package/src/components/post/post-form/ArticleForm.tsx +1 -1
  187. package/src/components/post/post-form/EventForm.tsx +69 -15
  188. package/src/components/post/post-form/ResourceForm.tsx +132 -4
  189. package/src/components/post/post-form/VisibilitySelector.tsx +12 -5
  190. package/src/components/post/types/Article.tsx +6 -6
  191. package/src/components/post/types/Event.tsx +68 -7
  192. package/src/components/post/types/article/FullArticle.tsx +2 -2
  193. package/src/components/post/types/event/CardEvent.tsx +26 -14
  194. package/src/components/post/types/event/FullEvent.tsx +48 -35
  195. package/src/components/post/types/event/ProfileEventRelationship.tsx +8 -0
  196. package/src/components/post/types/note/FullNote.tsx +1 -4
  197. package/src/components/post/types/poll/FullPoll.tsx +1 -4
  198. package/src/components/post/types/resource/FullResource.tsx +9 -1
  199. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  200. package/src/components/preview-link/PreviewLink.tsx +2 -7
  201. package/src/components/preview-link/helpers.ts +32 -1
  202. package/src/components/preview-link/local/GroupPreview.tsx +1 -1
  203. package/src/components/preview-link/local/JamPreview.tsx +1 -1
  204. package/src/components/preview-link/local/WelcomePreview.tsx +45 -0
  205. package/src/components/profile/Avatar.tsx +6 -2
  206. package/src/components/profile/ProfileFromId.tsx +1 -5
  207. package/src/components/resources/ResourceCard.tsx +68 -11
  208. package/src/components/resources/ResourceLibrary.tsx +2 -2
  209. package/src/contexts/openpeeps/hooks/accounts.ts +1 -3
  210. package/src/contexts/openpeeps/hooks/admin.ts +11 -3
  211. package/src/contexts/openpeeps/hooks/other.ts +9 -12
  212. package/src/contexts/openpeeps/hooks/streaming.ts +3 -3
  213. package/src/css.d.ts +4 -0
  214. package/src/hooks/admin/useCanAccessAdminSection.ts +27 -0
  215. package/src/hooks/events/useEventRsvp.ts +69 -13
  216. package/src/hooks/groups/useNewGroup.ts +28 -3
  217. package/src/hooks/index.ts +8 -1
  218. package/src/hooks/jams/useCanDiagnoseLivekit.ts +5 -0
  219. package/src/hooks/posts/useResourceComposer.ts +165 -39
  220. package/src/hooks/posts/useShareMenu.ts +9 -0
  221. package/src/hooks/resources/useResourceLibrary.ts +6 -2
  222. package/src/hooks/useWelcomePreview.ts +61 -0
  223. package/src/i18n/I18nProvider.tsx +1 -4
  224. package/src/lib/groupFormErrors.ts +9 -2
  225. package/src/lib/threadHelpers.ts +1 -5
  226. package/src/navigation/menuItems.ts +16 -0
  227. package/src/navigation/targets.ts +2 -0
  228. package/src/pages/admin/ConfigurationCommunity.tsx +5 -0
  229. package/src/pages/admin/Diagnostics.tsx +4 -0
  230. package/src/pages/admin/DiagnosticsLivekit.tsx +147 -0
  231. package/src/pages/admin/Invites.tsx +23 -1
  232. package/src/pages/admin/Media.tsx +290 -0
  233. package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +223 -0
  234. package/src/pages/admin/community/CommunityMarkdownPage.tsx +5 -1
  235. package/src/pages/admin/community/CommunityRoles.tsx +2 -2
  236. package/src/pages/admin/components/EditInviteLinkModal.tsx +263 -0
  237. package/src/pages/auth/Register.tsx +45 -4
  238. package/src/pages/conversations/Show.tsx +11 -0
  239. package/src/pages/index.ts +3 -0
  240. package/src/pages/jams/Index.tsx +2 -6
  241. package/src/pages/resources/Edit.tsx +3 -2
  242. package/src/pages/resources/New.tsx +6 -1
  243. package/src/pages/settings/Account.tsx +51 -1
  244. package/src/pages/settings/PublicProfile.tsx +20 -2
  245. package/src/pwa/sw.ts +6 -3
  246. package/src/pwa/useNotificationBadgeSync.ts +3 -1
  247. package/src/react-native.ts +1 -0
  248. package/src/stores/newPosts.ts +6 -1
  249. package/src/streaming.ts +3 -3
  250. package/dist/setupTests.d.ts +0 -1
  251. package/dist/setupTests.js +0 -5
@@ -39,6 +39,10 @@ const adminBackupsConfig = (client: OpenpeepsClientInstance) => ({
39
39
  restoreBackupAction: payloadMutation(client.admin.backups.restore, [
40
40
  ['admin', 'backups'],
41
41
  ]),
42
+ useMediaList: () => apiHook(client.admin.media.list),
43
+ deleteMediaAction: noPayloadMutation(client.admin.media.delete, [
44
+ ['admin', 'media'],
45
+ ]),
42
46
  useConfigRead: (namespace: string, name: string) =>
43
47
  apiHook(client.admin.config.read, { pathParams: { namespace, name } }),
44
48
  updateConfigAction: payloadMutation(client.admin.config.update, [
@@ -68,14 +72,17 @@ const adminDbInvites = (client: OpenpeepsClientInstance) => ({
68
72
  ['admin', 'db', 'sql'],
69
73
  ]),
70
74
  createInviteAction: payloadMutation(client.admin.invites.create, [
71
- ['admin', 'invites'],
75
+ ['invite-links'],
72
76
  ]),
73
77
  useInvitesList: () => apiHook(client.admin.invites.list),
78
+ updateInviteAction: payloadMutation(client.admin.invites.update, [
79
+ ['invite-links'],
80
+ ]),
74
81
  activateInviteAction: noPayloadMutation(client.admin.invites.activate, [
75
- ['admin', 'invites'],
82
+ ['invite-links'],
76
83
  ]),
77
84
  deactivateInviteAction: noPayloadMutation(client.admin.invites.deactivate, [
78
- ['admin', 'invites'],
85
+ ['invite-links'],
79
86
  ]),
80
87
  useLogsList: (date?: string, refetchInterval?: number) =>
81
88
  apiHook(client.admin.logs.list, {
@@ -189,6 +196,7 @@ const adminDiagnostics = (client: OpenpeepsClientInstance) => ({
189
196
  apiHook(client.admin.diagnostics.performance, {
190
197
  refetchInterval: 15_000,
191
198
  }),
199
+ useLivekitDiagnosis: () => apiHook(client.admin.diagnostics.livekit),
192
200
  useJobDetail: (queue: string, jobId: string) =>
193
201
  apiHook(client.admin.diagnostics.jobs.jobDetail, {
194
202
  pathParams: { queue, jobId },
@@ -54,18 +54,15 @@ export const otherHooks = (client: OpenpeepsClient) => ({
54
54
  const ctrl = new AbortController();
55
55
  setController(ctrl);
56
56
  setState({ uploading: true, uploadPercent: 0 });
57
- const result = await client.mediaAttachment.createWithProgress(
58
- input,
59
- {
60
- signal: ctrl.signal,
61
- onUploadProgress: ({ percent, estimatedRemainingMs }) =>
62
- setState((s) => ({
63
- ...s,
64
- uploadPercent: percent,
65
- uploadEstimatedRemainingMs: estimatedRemainingMs,
66
- })),
67
- },
68
- );
57
+ const result = await client.mediaAttachment.createWithProgress(input, {
58
+ signal: ctrl.signal,
59
+ onUploadProgress: ({ percent, estimatedRemainingMs }) =>
60
+ setState((s) => ({
61
+ ...s,
62
+ uploadPercent: percent,
63
+ uploadEstimatedRemainingMs: estimatedRemainingMs,
64
+ })),
65
+ });
69
66
  if ('data' in result) {
70
67
  setState({
71
68
  uploading: false,
@@ -20,6 +20,6 @@ export type VodStreamStatusHook = ReturnType<
20
20
  StreamingHooks['useVodStreamStatus']
21
21
  >;
22
22
 
23
- export type CreateVodStreamAction = (
24
- input: { url: string },
25
- ) => Promise<MediaStream>;
23
+ export type CreateVodStreamAction = (input: {
24
+ url: string;
25
+ }) => Promise<MediaStream>;
package/src/css.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ declare module '*.css' {
2
+ const classes: Record<string, string>;
3
+ export default classes;
4
+ }
@@ -0,0 +1,27 @@
1
+ import {
2
+ adminSections,
3
+ canAccessAdminSection,
4
+ type AdminSectionKey,
5
+ } from '@openpeepshq/common/lib';
6
+ import { useCurrentProfile } from '../../components/layout/IdentityContext';
7
+
8
+ /**
9
+ * Local profile roles. Non-local profiles (e.g. remote or SAML) expose no role
10
+ * set, so every admin-section capability check resolves to false for them,
11
+ * mirroring the backend `ensureRoleCapabilities` gating.
12
+ */
13
+ export const useAdminRoles = () => {
14
+ const profile = useCurrentProfile();
15
+ return profile?.type === 'local' ? profile.roles : undefined;
16
+ };
17
+
18
+ /**
19
+ * Whether the current profile may access a given admin section. Reuses the
20
+ * shared `adminSections` definitions so Web, native, and route guards agree
21
+ * with the backend's capability checks.
22
+ */
23
+ export const useCanAccessAdminSection = (section: AdminSectionKey) => {
24
+ const roles = useAdminRoles();
25
+ const sectionDef = adminSections.find((s) => s.key === section);
26
+ return sectionDef ? canAccessAdminSection(roles, sectionDef) : false;
27
+ };
@@ -2,15 +2,18 @@ import { useMemo, useState } from 'react';
2
2
  import type { PublicPost } from '@openpeepshq/common/types';
3
3
  import type { ExpandedOccurrence } from '@openpeepshq/common/lib';
4
4
  import {
5
+ canClaimYesRsvp,
5
6
  checkPostCapabilities,
6
- countYesRsvps,
7
7
  defaultRsvpRecurrenceId,
8
8
  displayRsvpForProfile,
9
+ effectiveEventTimes,
9
10
  eventRsvpOpen,
10
11
  isCapacityEvent,
11
12
  isRecurringEvent,
12
13
  listRsvpOccurrences,
13
- recurringEventHasOpenOccurrence,
14
+ occurrenceHasEnded,
15
+ offerStillOpen,
16
+ seriesHasClaimableOccurrence,
14
17
  } from '@openpeepshq/common/lib';
15
18
  import { useOpenpeeps } from '../../contexts/openpeeps';
16
19
  import { useT } from '../../i18n/context';
@@ -21,7 +24,7 @@ import {
21
24
  } from '../../components/layout/IdentityContext';
22
25
  import { useCapabilities } from '../../components/server-data';
23
26
 
24
- export type RsvpChoice = 'yes' | 'tentative' | 'no';
27
+ export type RsvpChoice = 'yes' | 'tentative' | 'no' | 'waitlist';
25
28
 
26
29
  export type RsvpScopeChoice =
27
30
  | { kind: 'this'; recurrenceId: string }
@@ -52,17 +55,26 @@ export const useEventRsvp = ({
52
55
  const rsvpToEvent = openpeepsApi.rsvpToEventAction({ id: post.id });
53
56
  const [error, setError] = useState<string | null>(null);
54
57
  const [pending, setPending] = useState<RsvpChoice | null>(null);
58
+ const [confirmingWaitlist, setConfirmingWaitlist] = useState(false);
55
59
  const [submitting, setSubmitting] = useState(false);
56
60
 
57
61
  const eventData = post.data?.type === 'event' ? post.data : undefined;
58
62
  const recurring = eventData ? isRecurringEvent(eventData) : false;
63
+ const viewedTimes = eventData
64
+ ? effectiveEventTimes(eventData, recurrenceId)
65
+ : undefined;
66
+ // Series home shows its first start. Once that time has passed, RSVP stays
67
+ // off that page; upcoming dates are opened from their own links.
68
+ const viewedEnded =
69
+ !!viewedTimes && occurrenceHasEnded(viewedTimes.start, viewedTimes.end);
70
+ // A selected date, or a one-off, is closed on its own end time.
59
71
  const rsvpClosed = eventData
60
- ? !eventRsvpOpen(eventData, { recurrenceId, lockToOccurrence })
72
+ ? !eventRsvpOpen(
73
+ eventData,
74
+ recurrenceId ? { recurrenceId, lockToOccurrence: true } : undefined,
75
+ )
61
76
  : false;
62
- const queriedOccurrenceClosed =
63
- !!eventData &&
64
- !!recurrenceId &&
65
- !eventRsvpOpen(eventData, { recurrenceId, lockToOccurrence: true });
77
+ const queriedOccurrenceClosed = !!recurrenceId && rsvpClosed;
66
78
  const defaultId = eventData
67
79
  ? defaultRsvpRecurrenceId(
68
80
  eventData,
@@ -71,14 +83,18 @@ export const useEventRsvp = ({
71
83
  : undefined;
72
84
  const occurrences: ExpandedOccurrence[] =
73
85
  eventData && recurring ? listRsvpOccurrences(eventData) : [];
74
- const capacityRecurrenceId = lockToOccurrence ? recurrenceId : defaultId;
86
+ const capacityRecurrenceId = recurring
87
+ ? lockToOccurrence
88
+ ? recurrenceId
89
+ : defaultId
90
+ : undefined;
75
91
  const capacityEvent = eventData ? isCapacityEvent(eventData) : false;
76
92
  const atCapacity =
77
93
  capacityEvent &&
78
- eventData?.maxAttendees !== undefined &&
94
+ !!profile &&
79
95
  (recurring && !lockToOccurrence
80
- ? !recurringEventHasOpenOccurrence(post, profile?.id)
81
- : countYesRsvps(post, capacityRecurrenceId) >= eventData.maxAttendees);
96
+ ? !seriesHasClaimableOccurrence(post, profile.id)
97
+ : !canClaimYesRsvp(post, profile.id, capacityRecurrenceId));
82
98
 
83
99
  const myEvent = post.profile?.id === profile?.id;
84
100
  const myRsvp = useMemo(
@@ -98,6 +114,9 @@ export const useEventRsvp = ({
98
114
  [authData, post, capabilities],
99
115
  );
100
116
  const full = atCapacity && myRsvp?.response !== 'yes';
117
+ const onWaitlist = myRsvp?.response === 'waitlist';
118
+ const offerExpiresAt =
119
+ onWaitlist && offerStillOpen(myRsvp) ? myRsvp.offerExpiresAt : undefined;
101
120
 
102
121
  const writeRsvp = async (response: RsvpChoice, recurrenceIds?: string[]) => {
103
122
  setError(null);
@@ -121,8 +140,37 @@ export const useEventRsvp = ({
121
140
  }
122
141
  };
123
142
 
143
+ const requestJoinWaitlist = () => {
144
+ if (rsvpClosed || viewedEnded) return;
145
+ if (!recurring || lockToOccurrence) {
146
+ setError(null);
147
+ setConfirmingWaitlist(true);
148
+ return;
149
+ }
150
+ setError(null);
151
+ setPending('waitlist');
152
+ };
153
+
154
+ const confirmJoinWaitlist = async () => {
155
+ try {
156
+ await writeRsvp('waitlist', recurrenceId ? [recurrenceId] : undefined);
157
+ setConfirmingWaitlist(false);
158
+ return true;
159
+ } catch {
160
+ return false;
161
+ }
162
+ };
163
+
164
+ const claimSpot = () => {
165
+ if (rsvpClosed || viewedEnded) return;
166
+ const id = recurring
167
+ ? (myRsvp?.recurrenceId ?? (lockToOccurrence ? recurrenceId : defaultId))
168
+ : undefined;
169
+ writeRsvp('yes', id ? [id] : undefined).catch(() => undefined);
170
+ };
171
+
124
172
  const requestRespond = (response: RsvpChoice) => {
125
- if (rsvpClosed) return;
173
+ if (rsvpClosed || viewedEnded) return;
126
174
  if (!recurring || lockToOccurrence) {
127
175
  writeRsvp(response, recurrenceId ? [recurrenceId] : undefined).catch(
128
176
  () => undefined,
@@ -156,16 +204,24 @@ export const useEventRsvp = ({
156
204
  myRsvp,
157
205
  canRsvp,
158
206
  rsvpClosed,
207
+ hideRsvpButton: rsvpClosed || viewedEnded,
159
208
  recurring,
160
209
  defaultId,
161
210
  occurrences,
162
211
  capacityEvent,
163
212
  full,
213
+ onWaitlist,
214
+ offerExpiresAt,
164
215
  error,
165
216
  pending,
166
217
  setPending,
218
+ confirmingWaitlist,
219
+ setConfirmingWaitlist,
167
220
  submitting,
168
221
  requestRespond,
222
+ requestJoinWaitlist,
223
+ confirmJoinWaitlist,
224
+ claimSpot,
169
225
  confirmScope,
170
226
  };
171
227
  };
@@ -1,5 +1,10 @@
1
1
  import { useState } from 'react';
2
- import type { GroupData, PublicProfile } from '@openpeepshq/common/types';
2
+ import {
3
+ HANDLE_RESERVED_MESSAGE,
4
+ isForbiddenHandle,
5
+ type GroupData,
6
+ type PublicProfile,
7
+ } from '@openpeepshq/common/types';
3
8
  import {
4
9
  applySimpleGroupTemplate,
5
10
  defaultSimpleGroupTemplate,
@@ -30,7 +35,10 @@ export const useNewGroup = () => {
30
35
  const navigate = useNavigate();
31
36
  const { openpeepsApi } = useOpenpeeps();
32
37
  const createGroup = openpeepsApi.createGroupAction();
33
- const { publicContent } = useServerInfo();
38
+ const serverInfo = useServerInfo();
39
+ const { publicContent } = serverInfo;
40
+ const additionalForbiddenHandles =
41
+ serverInfo.communityConfig?.settings?.additionalForbiddenHandles;
34
42
  const [members, setMembers] = useState<PublicProfile[]>([]);
35
43
  const [groupData, setGroupData] = useState<GroupData>(() => ({
36
44
  displayName: '',
@@ -47,7 +55,9 @@ export const useNewGroup = () => {
47
55
 
48
56
  const submit = async () => {
49
57
  setError(null);
50
- const nextFieldErrors = groupFormFieldErrors(groupData, t);
58
+ const nextFieldErrors = groupFormFieldErrors(groupData, t, {
59
+ additionalForbiddenHandles,
60
+ });
51
61
  if (hasGroupFormFieldErrors(nextFieldErrors)) {
52
62
  setFieldErrors(nextFieldErrors);
53
63
  return;
@@ -60,6 +70,13 @@ export const useNewGroup = () => {
60
70
  handle: handleFromDisplayName(groupData.displayName!),
61
71
  }
62
72
  : groupData;
73
+ if (isForbiddenHandle(data.handle, additionalForbiddenHandles)) {
74
+ const msg = t('profile.form.handleReserved', {
75
+ defaultValue: 'That handle is reserved. Please choose another.',
76
+ });
77
+ setFieldErrors({ handle: msg });
78
+ return;
79
+ }
63
80
  setSubmitting(true);
64
81
  try {
65
82
  const group = (await createGroup({ ...data, members })) as {
@@ -67,6 +84,14 @@ export const useNewGroup = () => {
67
84
  };
68
85
  navigate({ type: 'group', handle: group.handle });
69
86
  } catch (err) {
87
+ if ((err as Error).message === HANDLE_RESERVED_MESSAGE) {
88
+ const msg = t('profile.form.handleReserved', {
89
+ defaultValue: 'That handle is reserved. Please choose another.',
90
+ });
91
+ setFieldErrors({ handle: msg });
92
+ setError(msg);
93
+ return;
94
+ }
70
95
  if (isDuplicateHandleError(err)) {
71
96
  const msg = duplicateHandleMessage(t);
72
97
  setFieldErrors({ handle: msg });
@@ -2,6 +2,7 @@ export { useJoinGroup } from './groups/useJoinGroup';
2
2
  export { useGroupNotificationLevel } from './groups/useGroupNotificationLevel';
3
3
  export { useCreateConversation } from './conversations/useCreateConversation';
4
4
  export type { UseCreateConversationArgs } from './conversations/useCreateConversation';
5
+ export { useCanDiagnoseLivekit } from './jams/useCanDiagnoseLivekit';
5
6
  export { useLeaveCloseJam } from './jams/useLeaveCloseJam';
6
7
  export type { UseLeaveCloseJamArgs } from './jams/useLeaveCloseJam';
7
8
  export { useCreateNewJamForm } from './jams/useCreateNewJamForm';
@@ -94,7 +95,7 @@ export { useCommunityInfoPages } from './community/useCommunityInfoPages';
94
95
  export { usePostThreads } from './posts/usePostThreads';
95
96
  export { usePostDetailTitle } from './posts/usePostDetailTitle';
96
97
  export { useEventMenu } from './events/useEventMenu';
97
- export { useShareMenu } from './posts/useShareMenu';
98
+ export { postPublicPath, useShareMenu } from './posts/useShareMenu';
98
99
  export type { EventIcsFile } from './posts/useShareMenu';
99
100
  export { useNewEvent, useEditEvent } from './events/useEventComposer';
100
101
  export { EVENT_WEEKDAYS, useEventForm } from './events/useEventForm';
@@ -107,3 +108,9 @@ export type {
107
108
  EventFormat,
108
109
  UseEventTypeSwitcherArgs,
109
110
  } from './events/useEventTypeSwitcher';
111
+ export {
112
+ useAdminRoles,
113
+ useCanAccessAdminSection,
114
+ } from './admin/useCanAccessAdminSection';
115
+ export { useWelcomePreview } from './useWelcomePreview';
116
+ export type { WelcomePreviewContent } from './useWelcomePreview';
@@ -0,0 +1,5 @@
1
+ import { useCanAccessAdminSection } from '../admin/useCanAccessAdminSection';
2
+
3
+ /** Admins who can open Diagnostics can see why LiveKit failed. */
4
+ export const useCanDiagnoseLivekit = () =>
5
+ useCanAccessAdminSection('diagnostics');
@@ -1,21 +1,30 @@
1
- import { useCallback, useEffect, useState } from 'react';
1
+ import { useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import type {
3
+ GroupWithMeta,
3
4
  PostCreationData,
4
5
  PostDataUnion,
5
6
  ResourcePost,
6
7
  } from '@openpeepshq/common/types';
7
8
  import {
9
+ checkGroupCapabilities,
8
10
  normalizeResourceTags,
9
- resourceHasRequiredMedia,
11
+ resourceFormIssues,
12
+ resourceVisibilityForCapabilities,
13
+ type ResourceFormIssue,
10
14
  } from '@openpeepshq/common/lib';
11
15
  import { useOpenpeeps } from '../../contexts/openpeeps';
12
16
  import { useNavigate } from '../../contexts/router';
13
17
  import { useT } from '../../i18n/context';
18
+ import {
19
+ useAuthData,
20
+ useCurrentProfile,
21
+ } from '../../components/layout/IdentityContext';
14
22
  import { useServerInfo } from '../../components/server-data';
23
+ import { buildAudienceChoiceValues } from '../../lib/audienceChoices';
15
24
  import { defaultNewResource, getNewPostStores } from '../../stores';
16
25
 
17
- const asResource = (data: PostDataUnion): ResourcePost | null =>
18
- data.type === 'resource' ? data : null;
26
+ const asResource = (data: PostDataUnion | undefined): ResourcePost | null =>
27
+ data?.type === 'resource' ? data : null;
19
28
 
20
29
  const preparedResource = (resource: ResourcePost): ResourcePost => ({
21
30
  ...resource,
@@ -24,13 +33,79 @@ const preparedResource = (resource: ResourcePost): ResourcePost => ({
24
33
  categoryPath: (resource.categoryPath ?? [])
25
34
  .map((segment) => segment.trim())
26
35
  .filter(Boolean),
27
- url: resource.url?.trim() || undefined,
36
+ url:
37
+ resource.resourceKind === 'link'
38
+ ? resource.url?.trim() || undefined
39
+ : undefined,
28
40
  });
29
41
 
42
+ const issuesFor = (postData: PostCreationData): ResourceFormIssue[] => {
43
+ const resource = asResource(postData.data);
44
+ if (!resource) return ['title'];
45
+ return resourceFormIssues({
46
+ title: resource.title,
47
+ resourceKind: resource.resourceKind,
48
+ url: resource.url,
49
+ attachments: resource.attachments,
50
+ visibility: postData.visibility,
51
+ audience: postData.audience,
52
+ groupId: postData.groupId,
53
+ });
54
+ };
55
+
56
+ const issueMessage = (
57
+ issue: ResourceFormIssue,
58
+ t: (key: string, options: { defaultValue: string }) => string,
59
+ ): string => {
60
+ if (issue === 'title') {
61
+ return t('resources.validation.titleRequired', {
62
+ defaultValue: 'Title is required',
63
+ });
64
+ }
65
+ if (issue === 'titleLength') {
66
+ return t('resources.validation.titleTooLong', {
67
+ defaultValue: 'Title must be 200 characters or fewer',
68
+ });
69
+ }
70
+ if (issue === 'url') {
71
+ return t('resources.validation.url', {
72
+ defaultValue: 'Enter a real link, like https://example.com',
73
+ });
74
+ }
75
+ if (issue === 'media') {
76
+ return t('resources.validation.mediaRequired', {
77
+ defaultValue: 'Add the media or link this resource needs',
78
+ });
79
+ }
80
+ if (issue === 'group') {
81
+ return t('resources.validation.groupRequired', {
82
+ defaultValue: 'Choose a group before creating this resource.',
83
+ });
84
+ }
85
+ return t('resources.validation.directAudience', {
86
+ defaultValue: 'Choose at least one recipient for a direct resource.',
87
+ });
88
+ };
89
+
90
+ const submitErrorMessage = (
91
+ err: unknown,
92
+ t: (key: string, options: { defaultValue: string }) => string,
93
+ ) => {
94
+ const message = err instanceof Error ? err.message : '';
95
+ if (message === 'Forbidden') {
96
+ return t('resources.validation.audienceForbidden', {
97
+ defaultValue: 'Choose a group you can post this resource in.',
98
+ });
99
+ }
100
+ return message;
101
+ };
102
+
30
103
  export const useNewResource = () => {
31
104
  const t = useT();
32
105
  const navigate = useNavigate();
33
106
  const serverInfo = useServerInfo();
107
+ const authData = useAuthData();
108
+ const me = useCurrentProfile();
34
109
  const { openpeepsApi } = useOpenpeeps();
35
110
  const createPost = openpeepsApi.createPostAction();
36
111
  const stores = getNewPostStores();
@@ -45,12 +120,70 @@ export const useNewResource = () => {
45
120
  const [submitting, setSubmitting] = useState(false);
46
121
  const [error, setError] = useState<string | null>(null);
47
122
 
123
+ const audience = useMemo(() => {
124
+ if (!authData.profile || authData.scopes.length === 0) return null;
125
+ const choices = buildAudienceChoiceValues('resource', authData, t, {
126
+ publicContent: serverInfo.publicContent,
127
+ showDirect: true,
128
+ });
129
+ const memberships = me?.memberships;
130
+ const postableGroupIds =
131
+ memberships == null
132
+ ? null
133
+ : memberships
134
+ .map((membership) => membership.group as GroupWithMeta)
135
+ .filter(
136
+ (group) =>
137
+ checkGroupCapabilities(
138
+ authData,
139
+ ['core-posts-create-resource'],
140
+ group,
141
+ ).success,
142
+ )
143
+ .map((group) => group.id);
144
+ const next = resourceVisibilityForCapabilities({
145
+ visibility: postData.visibility,
146
+ groupId: postData.groupId,
147
+ allowed: choices.map((choice) => choice.value),
148
+ postableGroupIds,
149
+ });
150
+ return {
151
+ ...next,
152
+ groupOnly: choices.length === 1 && choices[0]?.value === 'group',
153
+ hasChoice: choices.length > 0,
154
+ };
155
+ }, [
156
+ authData,
157
+ me?.memberships,
158
+ postData.groupId,
159
+ postData.visibility,
160
+ serverInfo.publicContent,
161
+ t,
162
+ ]);
163
+
164
+ useEffect(() => {
165
+ if (!audience?.hasChoice) return;
166
+ if (
167
+ audience.visibility === postData.visibility &&
168
+ (audience.groupId ?? undefined) === (postData.groupId ?? undefined)
169
+ ) {
170
+ return;
171
+ }
172
+ const next = {
173
+ ...postData,
174
+ visibility: audience.visibility,
175
+ groupId: audience.groupId,
176
+ };
177
+ setPostDataState(next);
178
+ stores.resource = next;
179
+ }, [audience, postData, stores]);
180
+
48
181
  const resource = asResource(postData.data);
49
- const canSubmit =
50
- !!resource?.title.trim() &&
51
- !!resource &&
52
- resourceHasRequiredMedia(resource) &&
53
- !(postData.visibility === 'direct' && !postData.audience?.length);
182
+ const audienceReady =
183
+ !!audience?.hasChoice &&
184
+ audience.visibility === postData.visibility &&
185
+ (audience.groupId ?? undefined) === (postData.groupId ?? undefined);
186
+ const canSubmit = audienceReady && issuesFor(postData).length === 0;
54
187
 
55
188
  const setPostData = (data: PostCreationData) => {
56
189
  setPostDataState(data);
@@ -59,28 +192,10 @@ export const useNewResource = () => {
59
192
 
60
193
  const submit = useCallback(async () => {
61
194
  setError(null);
62
- if (!resource?.title.trim()) {
63
- setError(
64
- t('resources.validation.titleRequired', {
65
- defaultValue: 'Title is required',
66
- }),
67
- );
68
- return;
69
- }
70
- if (!resourceHasRequiredMedia(resource)) {
71
- setError(
72
- t('resources.validation.mediaRequired', {
73
- defaultValue: 'Add the media or link this resource needs',
74
- }),
75
- );
76
- return;
77
- }
78
- if (postData.visibility === 'direct' && !postData.audience?.length) {
79
- setError(
80
- t('resources.validation.directAudience', {
81
- defaultValue: 'Choose at least one recipient for a direct resource.',
82
- }),
83
- );
195
+ if (!audienceReady) return;
196
+ const issue = issuesFor(postData)[0];
197
+ if (!resource || issue) {
198
+ if (issue) setError(issueMessage(issue, t));
84
199
  return;
85
200
  }
86
201
  setSubmitting(true);
@@ -93,15 +208,16 @@ export const useNewResource = () => {
93
208
  stores.resetNewResourceState();
94
209
  navigate({ type: 'post', id: created.id });
95
210
  } catch (err) {
96
- setError((err as Error).message);
211
+ setError(submitErrorMessage(err, t));
97
212
  } finally {
98
213
  setSubmitting(false);
99
214
  }
100
- }, [createPost, navigate, postData, resource, stores, t]);
215
+ }, [audienceReady, createPost, navigate, postData, resource, stores, t]);
101
216
 
102
217
  return {
103
218
  postData,
104
219
  setPostData,
220
+ groupOnly: audience?.groupOnly ?? false,
105
221
  canSubmit,
106
222
  submitting,
107
223
  error,
@@ -111,6 +227,7 @@ export const useNewResource = () => {
111
227
  };
112
228
 
113
229
  export const useEditResource = (resourceId: string) => {
230
+ const t = useT();
114
231
  const navigate = useNavigate();
115
232
  const { openpeepsApi } = useOpenpeeps();
116
233
  const postQuery = openpeepsApi.usePost(resourceId);
@@ -121,7 +238,11 @@ export const useEditResource = (resourceId: string) => {
121
238
  const [error, setError] = useState<string | null>(null);
122
239
 
123
240
  useEffect(() => {
124
- if (postQuery.data && postQuery.data.type === 'resource') {
241
+ if (
242
+ postQuery.data &&
243
+ postQuery.data.type === 'resource' &&
244
+ postQuery.data.data
245
+ ) {
125
246
  setPostData({
126
247
  visibility: postQuery.data.visibility,
127
248
  type: 'resource',
@@ -132,15 +253,19 @@ export const useEditResource = (resourceId: string) => {
132
253
  }
133
254
  }, [postQuery.data]);
134
255
 
135
- const resourceTitle = asResource(
136
- postQuery.data?.data as PostDataUnion,
137
- )?.title;
256
+ const resourceTitle = asResource(postQuery.data?.data)?.title;
257
+ const canSubmit = !!postData && issuesFor(postData).length === 0;
138
258
 
139
259
  const submit = useCallback(async () => {
140
260
  if (!postData) return;
141
261
  const resource = asResource(postData.data);
142
262
  if (!resource) return;
143
263
  setError(null);
264
+ const issue = issuesFor(postData)[0];
265
+ if (issue) {
266
+ setError(issueMessage(issue, t));
267
+ return;
268
+ }
144
269
  setSubmitting(true);
145
270
  try {
146
271
  await updatePost(preparedResource(resource));
@@ -150,13 +275,14 @@ export const useEditResource = (resourceId: string) => {
150
275
  } finally {
151
276
  setSubmitting(false);
152
277
  }
153
- }, [navigate, postData, resourceId, updatePost]);
278
+ }, [navigate, postData, resourceId, t, updatePost]);
154
279
 
155
280
  return {
156
281
  postQuery,
157
282
  postData,
158
283
  setPostData,
159
284
  resourceTitle,
285
+ canSubmit,
160
286
  submitting,
161
287
  error,
162
288
  clearError: () => setError(null),
@@ -5,6 +5,15 @@ import { useCurrentProfile } from '../../components/layout/IdentityContext';
5
5
 
6
6
  export type EventIcsFile = { filename: string; content: string };
7
7
 
8
+ /** Canonical public path for a post, including a recurring event occurrence. */
9
+ export const postPublicPath = (
10
+ post: Pick<PublicPost, 'id' | 'occurrenceRecurrenceId'>,
11
+ ) => {
12
+ const occurrence = post.occurrenceRecurrenceId;
13
+ if (!occurrence) return `/posts/${post.id}`;
14
+ return `/posts/${post.id}?occurrence=${encodeURIComponent(occurrence)}`;
15
+ };
16
+
8
17
  /** Share actions for a post; `postUrl` is the platform's canonical public link. */
9
18
  export const useShareMenu = (post: PublicPost, postUrl: string) => {
10
19
  const me = useCurrentProfile();