@openpeepshq/react 0.7.1 → 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 (91) hide show
  1. package/dist/components/markdown/compileMarkdown.js +1 -0
  2. package/dist/components/navigation/FooterMobile.js +4 -3
  3. package/dist/components/navigation/HeaderMobile.js +5 -2
  4. package/dist/components/navigation/MobileMenuItem.d.ts +3 -1
  5. package/dist/components/navigation/MobileMenuItem.js +7 -2
  6. package/dist/components/navigation/NavWithTooltip.d.ts +9 -0
  7. package/dist/components/navigation/NavWithTooltip.js +4 -0
  8. package/dist/components/navigation/index.d.ts +2 -0
  9. package/dist/components/navigation/index.js +1 -0
  10. package/dist/components/navigation/sideBarNavLinkClass.d.ts +6 -4
  11. package/dist/components/navigation/sideBarNavLinkClass.js +6 -2
  12. package/dist/components/post/CompactReplyParent.js +5 -6
  13. package/dist/components/post/TruncatedMarkdown.d.ts +27 -0
  14. package/dist/components/post/TruncatedMarkdown.js +37 -0
  15. package/dist/components/post/helpers.d.ts +2 -2
  16. package/dist/components/post/helpers.js +3 -16
  17. package/dist/components/post/index.d.ts +2 -0
  18. package/dist/components/post/index.js +1 -0
  19. package/dist/components/post/pieces/EventLocation.js +14 -0
  20. package/dist/components/post/pieces/EventRsvpButton.js +3 -1
  21. package/dist/components/post/pieces/PollContent.js +8 -2
  22. package/dist/components/post/post-form/ArticleForm.js +1 -1
  23. package/dist/components/post/post-form/ComposeAttachments.d.ts +5 -1
  24. package/dist/components/post/post-form/ComposeAttachments.js +20 -6
  25. package/dist/components/post/post-form/ComposeAttachments.test.d.ts +1 -0
  26. package/dist/components/post/post-form/ComposeAttachments.test.js +131 -0
  27. package/dist/components/post/post-form/EventForm.js +23 -3
  28. package/dist/components/post/post-form/ResourceForm.d.ts +3 -1
  29. package/dist/components/post/post-form/ResourceForm.js +51 -7
  30. package/dist/components/post/post-form/VisibilitySelector.js +9 -3
  31. package/dist/components/post/types/Article.js +2 -3
  32. package/dist/components/post/types/Event.js +10 -1
  33. package/dist/components/post/types/resource/FullResource.js +3 -3
  34. package/dist/components/preview-link/local/WelcomePreview.js +4 -2
  35. package/dist/components/resources/ResourceCard.d.ts +5 -1
  36. package/dist/components/resources/ResourceCard.js +94 -37
  37. package/dist/components/resources/ResourceCard.test.d.ts +1 -0
  38. package/dist/components/resources/ResourceCard.test.js +75 -0
  39. package/dist/components/resources/ResourceLibrary.js +1 -1
  40. package/dist/hooks/events/useEventRsvp.d.ts +1 -0
  41. package/dist/hooks/events/useEventRsvp.js +15 -7
  42. package/dist/hooks/posts/useResourceComposer.d.ts +2 -0
  43. package/dist/hooks/posts/useResourceComposer.js +131 -25
  44. package/dist/hooks/resources/useResourceLibrary.d.ts +1 -1
  45. package/dist/hooks/resources/useResourceLibrary.js +6 -2
  46. package/dist/hooks/useWelcomePreview.d.ts +3 -0
  47. package/dist/hooks/useWelcomePreview.js +1 -0
  48. package/dist/navigation/menuItems.js +15 -0
  49. package/dist/navigation/targets.d.ts +2 -0
  50. package/dist/pages/admin/community/CommunityMarkdownPage.js +2 -1
  51. package/dist/pages/auth/Register.js +3 -1
  52. package/dist/pages/resources/Edit.js +3 -3
  53. package/dist/pages/resources/New.js +2 -2
  54. package/dist/pages/settings/Account.js +30 -2
  55. package/package.json +2 -2
  56. package/src/components/markdown/compileMarkdown.ts +1 -0
  57. package/src/components/navigation/FooterMobile.tsx +41 -33
  58. package/src/components/navigation/HeaderMobile.tsx +55 -41
  59. package/src/components/navigation/MobileMenuItem.tsx +15 -2
  60. package/src/components/navigation/NavWithTooltip.tsx +26 -0
  61. package/src/components/navigation/index.ts +2 -0
  62. package/src/components/navigation/sideBarNavLinkClass.ts +9 -6
  63. package/src/components/post/CompactReplyParent.tsx +17 -10
  64. package/src/components/post/TruncatedMarkdown.tsx +91 -0
  65. package/src/components/post/helpers.ts +4 -18
  66. package/src/components/post/index.ts +2 -0
  67. package/src/components/post/pieces/EventLocation.tsx +27 -0
  68. package/src/components/post/pieces/EventRsvpButton.tsx +3 -0
  69. package/src/components/post/pieces/PollContent.tsx +8 -2
  70. package/src/components/post/post-form/ArticleForm.tsx +1 -1
  71. package/src/components/post/post-form/ComposeAttachments.tsx +24 -3
  72. package/src/components/post/post-form/EventForm.tsx +43 -15
  73. package/src/components/post/post-form/ResourceForm.tsx +135 -4
  74. package/src/components/post/post-form/VisibilitySelector.tsx +11 -3
  75. package/src/components/post/types/Article.tsx +5 -5
  76. package/src/components/post/types/Event.tsx +68 -7
  77. package/src/components/post/types/resource/FullResource.tsx +9 -1
  78. package/src/components/preview-link/local/WelcomePreview.tsx +11 -2
  79. package/src/components/resources/ResourceCard.tsx +184 -62
  80. package/src/components/resources/ResourceLibrary.tsx +2 -2
  81. package/src/hooks/events/useEventRsvp.ts +19 -7
  82. package/src/hooks/posts/useResourceComposer.ts +157 -33
  83. package/src/hooks/resources/useResourceLibrary.ts +6 -2
  84. package/src/hooks/useWelcomePreview.ts +4 -0
  85. package/src/navigation/menuItems.ts +16 -0
  86. package/src/navigation/targets.ts +2 -0
  87. package/src/pages/admin/community/CommunityMarkdownPage.tsx +5 -1
  88. package/src/pages/auth/Register.tsx +12 -0
  89. package/src/pages/resources/Edit.tsx +3 -2
  90. package/src/pages/resources/New.tsx +6 -1
  91. package/src/pages/settings/Account.tsx +51 -1
@@ -1,17 +1,26 @@
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
26
  const asResource = (data: PostDataUnion | undefined): ResourcePost | null =>
@@ -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);
@@ -137,12 +254,18 @@ export const useEditResource = (resourceId: string) => {
137
254
  }, [postQuery.data]);
138
255
 
139
256
  const resourceTitle = asResource(postQuery.data?.data)?.title;
257
+ const canSubmit = !!postData && issuesFor(postData).length === 0;
140
258
 
141
259
  const submit = useCallback(async () => {
142
260
  if (!postData) return;
143
261
  const resource = asResource(postData.data);
144
262
  if (!resource) return;
145
263
  setError(null);
264
+ const issue = issuesFor(postData)[0];
265
+ if (issue) {
266
+ setError(issueMessage(issue, t));
267
+ return;
268
+ }
146
269
  setSubmitting(true);
147
270
  try {
148
271
  await updatePost(preparedResource(resource));
@@ -152,13 +275,14 @@ export const useEditResource = (resourceId: string) => {
152
275
  } finally {
153
276
  setSubmitting(false);
154
277
  }
155
- }, [navigate, postData, resourceId, updatePost]);
278
+ }, [navigate, postData, resourceId, t, updatePost]);
156
279
 
157
280
  return {
158
281
  postQuery,
159
282
  postData,
160
283
  setPostData,
161
284
  resourceTitle,
285
+ canSubmit,
162
286
  submitting,
163
287
  error,
164
288
  clearError: () => setError(null),
@@ -8,12 +8,16 @@ import {
8
8
  import { useOpenpeeps } from '../../contexts/openpeeps';
9
9
  import { useFeedListParams } from '../useResolvedFeedFormat';
10
10
 
11
- export const useResourceLibrary = (groupId?: string) => {
11
+ export const useResourceLibrary = (groupId?: string, ungrouped?: boolean) => {
12
12
  const { openpeepsApi } = useOpenpeeps();
13
13
  const params = useFeedListParams({ format: 'linear' });
14
14
  const query = openpeepsApi.usePostsByType('resource', {
15
15
  ...params,
16
- ...(groupId ? { groupId } : { ungrouped: 'true' as const }),
16
+ ...(groupId
17
+ ? { groupId }
18
+ : ungrouped
19
+ ? { ungrouped: 'true' as const }
20
+ : {}),
17
21
  });
18
22
  const bookmarkedIds = openpeepsApi.useCurrentProfileBookmarkedIds();
19
23
 
@@ -11,7 +11,10 @@ export type WelcomePreviewContent = {
11
11
  /** Short label above the title. Omitted when it would repeat the title. */
12
12
  eyebrow?: string;
13
13
  title: string;
14
+ /** Plain-text excerpt (image-stripped) for non-markdown consumers / fallback. */
14
15
  description: string;
16
+ /** Raw welcome markdown (image-bearing) for markdown rendering + overlays. */
17
+ markdown: string;
15
18
  imageUrl?: string;
16
19
  imageFit: 'cover' | 'contain';
17
20
  };
@@ -51,6 +54,7 @@ export const useWelcomePreview = (
51
54
  : t('welcome.defaultIntro', {
52
55
  defaultValue: 'Welcome to this community, hosted on AllPeep.',
53
56
  }),
57
+ markdown: configured,
54
58
  imageUrl: markdownImage || logo || undefined,
55
59
  imageFit: markdownImage ? 'cover' : 'contain',
56
60
  };
@@ -5,6 +5,8 @@ export type MainMenuCapabilities = {
5
5
  showAdmin: boolean;
6
6
  };
7
7
 
8
+ const navTooltip = (id: string) => `navigation.tooltips.${id}` as const;
9
+
8
10
  /** Default main-menu targets for hosts to render with their own icons/labels. */
9
11
  export const buildMainNavItems = (caps: MainMenuCapabilities): NavItemDef[] => {
10
12
  const items: NavItemDef[] = [
@@ -12,24 +14,28 @@ export const buildMainNavItems = (caps: MainMenuCapabilities): NavItemDef[] => {
12
14
  id: 'community',
13
15
  target: { type: 'feed', feed: 'local' },
14
16
  labelKey: 'navigation.community',
17
+ tooltipKey: navTooltip('community'),
15
18
  icon: 'Home',
16
19
  },
17
20
  {
18
21
  id: 'welcome',
19
22
  target: { type: 'welcome' },
20
23
  labelKey: 'navigation.goToWelcomePage',
24
+ tooltipKey: navTooltip('welcome'),
21
25
  icon: 'BookCheck',
22
26
  },
23
27
  {
24
28
  id: 'explore',
25
29
  target: { type: 'explore' },
26
30
  labelKey: 'navigation.explore',
31
+ tooltipKey: navTooltip('explore'),
27
32
  icon: 'Search',
28
33
  },
29
34
  {
30
35
  id: 'myFeed',
31
36
  target: { type: 'feed', feed: 'my' },
32
37
  labelKey: 'navigation.myFeed',
38
+ tooltipKey: navTooltip('myFeed'),
33
39
  icon: 'Newspaper',
34
40
  },
35
41
  ];
@@ -38,6 +44,7 @@ export const buildMainNavItems = (caps: MainMenuCapabilities): NavItemDef[] => {
38
44
  id: 'jams',
39
45
  target: { type: 'jams' },
40
46
  labelKey: 'navigation.jams',
47
+ tooltipKey: navTooltip('jams'),
41
48
  icon: 'PhoneCall',
42
49
  });
43
50
  }
@@ -46,48 +53,56 @@ export const buildMainNavItems = (caps: MainMenuCapabilities): NavItemDef[] => {
46
53
  id: 'groups',
47
54
  target: { type: 'groups' },
48
55
  labelKey: 'navigation.groups',
56
+ tooltipKey: navTooltip('groups'),
49
57
  icon: 'Users',
50
58
  },
51
59
  {
52
60
  id: 'events',
53
61
  target: { type: 'events' },
54
62
  labelKey: 'navigation.events',
63
+ tooltipKey: navTooltip('events'),
55
64
  icon: 'CalendarDays',
56
65
  },
57
66
  {
58
67
  id: 'articles',
59
68
  target: { type: 'articles' },
60
69
  labelKey: 'navigation.articles',
70
+ tooltipKey: navTooltip('articles'),
61
71
  icon: 'ScrollText',
62
72
  },
63
73
  {
64
74
  id: 'resources',
65
75
  target: { type: 'resources' },
66
76
  labelKey: 'navigation.resources',
77
+ tooltipKey: navTooltip('resources'),
67
78
  icon: 'Library',
68
79
  },
69
80
  {
70
81
  id: 'messages',
71
82
  target: { type: 'conversation' },
72
83
  labelKey: 'navigation.messages',
84
+ tooltipKey: navTooltip('messages'),
73
85
  icon: 'MessageSquareText',
74
86
  },
75
87
  {
76
88
  id: 'members',
77
89
  target: { type: 'members' },
78
90
  labelKey: 'navigation.members',
91
+ tooltipKey: navTooltip('members'),
79
92
  icon: 'BookUser',
80
93
  },
81
94
  {
82
95
  id: 'bookmarks',
83
96
  target: { type: 'feed', feed: 'bookmarks' },
84
97
  labelKey: 'navigation.bookmarks',
98
+ tooltipKey: navTooltip('bookmarks'),
85
99
  icon: 'Bookmark',
86
100
  },
87
101
  {
88
102
  id: 'settings',
89
103
  target: { type: 'settings' },
90
104
  labelKey: 'navigation.settings',
105
+ tooltipKey: navTooltip('settings'),
91
106
  icon: 'Settings',
92
107
  },
93
108
  );
@@ -96,6 +111,7 @@ export const buildMainNavItems = (caps: MainMenuCapabilities): NavItemDef[] => {
96
111
  id: 'admin',
97
112
  target: { type: 'admin' },
98
113
  labelKey: 'navigation.administration',
114
+ tooltipKey: navTooltip('administration'),
99
115
  icon: 'Bolt',
100
116
  });
101
117
  }
@@ -49,6 +49,8 @@ export type NavItemDef = {
49
49
  id: string;
50
50
  target: NavTarget;
51
51
  labelKey: string;
52
+ /** i18n key describing what happens when the item is activated. */
53
+ tooltipKey?: string;
52
54
  /** Lucide (or similar) icon component name — host maps to actual icon. */
53
55
  icon?: string;
54
56
  end?: boolean;
@@ -1,6 +1,7 @@
1
1
  import { useState } from 'react';
2
2
  import type { CommunityConfig } from '@openpeepshq/common/types';
3
3
  import { useT, useSetPageHeader } from '../../../index';
4
+ import { Markdown } from '../../../lib/Markdown';
4
5
  import { OpenpeepsMarkdownInput } from '../../../components';
5
6
  import { Button, Toast, deepGet, deepSet } from '@openpeepshq/react-ui';
6
7
  import { useCommunityConfig } from './useCommunityConfig';
@@ -55,7 +56,10 @@ export function CommunityMarkdownPage({
55
56
 
56
57
  return (
57
58
  <div className="flex flex-col gap-4 p-4">
58
- <p className="pb-2 pt-4">{t(descriptionKey)}</p>
59
+ <Markdown
60
+ source={t(descriptionKey)}
61
+ className="pb-2 pt-4 text-sm text-muted-foreground"
62
+ />
59
63
  <OpenpeepsMarkdownInput
60
64
  value={value}
61
65
  maxLength={10000}
@@ -340,6 +340,18 @@ export function Register({ invite = false }: RegisterProps) {
340
340
  )}
341
341
  />
342
342
 
343
+ {password && password.length > 0 && (
344
+ <p
345
+ data-testid="auth-register-password-rules"
346
+ className="text-xs text-muted-foreground"
347
+ >
348
+ {t('auth.register.passwordRules', {
349
+ defaultValue:
350
+ '8+ characters, with an uppercase letter, lowercase letter, number, and symbol',
351
+ })}
352
+ </p>
353
+ )}
354
+
343
355
  {(password ?? '').length > 0 &&
344
356
  (confirmPassword ?? '').length === 0 && (
345
357
  <div className="bg-surface border-border flex w-full justify-center rounded py-2">
@@ -14,6 +14,7 @@ export const EditResource = () => {
14
14
  postData,
15
15
  setPostData,
16
16
  resourceTitle,
17
+ canSubmit,
17
18
  submitting,
18
19
  error,
19
20
  clearError,
@@ -26,14 +27,14 @@ export const EditResource = () => {
26
27
  title={t('resources.update.title', { defaultValue: 'Update resource' })}
27
28
  variant="default"
28
29
  action={submit}
29
- disabled={submitting}
30
+ disabled={submitting || !canSubmit}
30
31
  >
31
32
  {submitting
32
33
  ? t('common.saving', { defaultValue: 'Saving…' })
33
34
  : t('resources.update.title', { defaultValue: 'Update resource' })}
34
35
  </Button>
35
36
  ),
36
- [submit, submitting, t],
37
+ [canSubmit, submit, submitting, t],
37
38
  );
38
39
 
39
40
  useSetPageHeader(
@@ -10,6 +10,7 @@ export const NewResource = () => {
10
10
  postData,
11
11
  setPostData,
12
12
  canSubmit,
13
+ groupOnly,
13
14
  submitting,
14
15
  error,
15
16
  clearError,
@@ -40,7 +41,11 @@ export const NewResource = () => {
40
41
 
41
42
  return (
42
43
  <div className="pb-12">
43
- <ResourceForm postData={postData} onChange={setPostData} />
44
+ <ResourceForm
45
+ postData={postData}
46
+ onChange={setPostData}
47
+ groupOnly={groupOnly}
48
+ />
44
49
  {error ? (
45
50
  <div className="px-3">
46
51
  <Toast variant="error" onDismiss={clearError}>
@@ -1,11 +1,12 @@
1
1
  import { useState } from 'react';
2
2
  import { useT, useOpenpeeps, useSetPageHeader } from '../../index';
3
- import { useCurrentAccount } from '../../components';
3
+ import { useCurrentAccount, useToast } from '../../components';
4
4
  import { Button, Input, Label, Toast } from '@openpeepshq/react-ui';
5
5
 
6
6
  export function AccountSettings() {
7
7
  const t = useT();
8
8
  const { openpeepsApi, client } = useOpenpeeps();
9
+ const { success, error: toastError } = useToast();
9
10
  const account = useCurrentAccount();
10
11
  const updateAccount = openpeepsApi.updateCurrentAccountAction();
11
12
 
@@ -65,6 +66,29 @@ export function AccountSettings() {
65
66
  }
66
67
  };
67
68
 
69
+ const validateEmail = openpeepsApi.validationEmailAction();
70
+ const [verifying, setVerifying] = useState(false);
71
+
72
+ const handleVerifyEmail = async () => {
73
+ setVerifying(true);
74
+ try {
75
+ await validateEmail();
76
+ success(
77
+ t('settings.account.verifyEmailSent', {
78
+ defaultValue: 'Verification email sent',
79
+ }),
80
+ );
81
+ } catch {
82
+ toastError(
83
+ t('settings.account.verifyEmailError', {
84
+ defaultValue: 'Failed to send verification email',
85
+ }),
86
+ );
87
+ } finally {
88
+ setVerifying(false);
89
+ }
90
+ };
91
+
68
92
  const exportAccount = async () => {
69
93
  setExporting(true);
70
94
  try {
@@ -136,6 +160,32 @@ export function AccountSettings() {
136
160
  />
137
161
  </div>
138
162
 
163
+ {!account?.emailValidated ? (
164
+ <div className="space-y-2">
165
+ <p className="text-muted-foreground text-sm">
166
+ {t('settings.account.verifyEmailDescription', {
167
+ defaultValue:
168
+ 'Your email is not verified. Resend a verification email.',
169
+ })}
170
+ </p>
171
+ <Button
172
+ title={t('settings.account.verifyEmailButton', {
173
+ defaultValue: 'Verify email',
174
+ })}
175
+ variant="outline"
176
+ action={handleVerifyEmail}
177
+ loading={verifying}
178
+ data-testid="settings-verify-email-button"
179
+ >
180
+ {verifying
181
+ ? t('common.submitting', { defaultValue: 'Sending...' })
182
+ : t('settings.account.verifyEmailButton', {
183
+ defaultValue: 'Verify email',
184
+ })}
185
+ </Button>
186
+ </div>
187
+ ) : null}
188
+
139
189
  <div className="space-y-2">
140
190
  <Label htmlFor="newPassword">
141
191
  {t('settings.account.newPassword', {