@openpeepshq/react 0.6.3 → 0.7.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.
@@ -3,6 +3,7 @@ import { groupName } from '@openpeepshq/common/lib';
3
3
  import { useT } from '../../i18n/index.js';
4
4
  import { useCurrentProfile } from '../layout/IdentityContext.js';
5
5
  import { JoinGroupButton } from './JoinGroupButton.js';
6
+ import { GroupNotificationButton } from './GroupNotificationSettingsModal.js';
6
7
  import { GroupOptionsMenu } from './GroupOptionsMenu.js';
7
8
  import { GroupShareMenu } from './GroupShareMenu.js';
8
9
  import { GroupAvatar } from './GroupAvatar.js';
@@ -10,5 +11,5 @@ export function GroupHeader({ group }) {
10
11
  const t = useT();
11
12
  const me = useCurrentProfile();
12
13
  const isMember = me?.memberships?.some((m) => m.group.id === group.id);
13
- return (_jsxs("div", { className: "relative", children: [_jsxs("div", { className: "relative aspect-[3/1] w-full", children: [_jsx("div", { className: "bg-surface-2 absolute inset-0 overflow-hidden", children: group.header && (_jsx("img", { src: group.header, alt: "banner", className: "h-full w-full object-cover" })) }), _jsx(GroupAvatar, { group: group, size: 6, borderless: true, containerClassName: "absolute -bottom-12 left-4" })] }), _jsx("div", { className: "flex justify-end space-x-2 p-2", children: !isMember ? (_jsx(JoinGroupButton, { group: group })) : (_jsxs(_Fragment, { children: [_jsx(GroupShareMenu, { group: group }), _jsx(GroupOptionsMenu, { group: group })] })) }), _jsxs("div", { className: "mb-8 p-2 pt-6", children: [_jsx("h1", { className: "text-xl font-semibold", "data-testid": "groups-header-title", children: groupName(group) }), _jsxs("p", { className: "text-muted-foreground text-sm", children: ["@", group.handle] }), _jsxs("a", { href: `/groups/@${group.handle}/members`, title: t('groups.viewMembers', { defaultValue: 'View members' }), className: "text-muted-foreground text-sm hover:underline", children: [group.membersCount, " member", group.membersCount === 1 ? '' : 's'] })] })] }));
14
+ return (_jsxs("div", { className: "relative", children: [_jsxs("div", { className: "relative aspect-[3/1] w-full", children: [_jsx("div", { className: "bg-surface-2 absolute inset-0 overflow-hidden", children: group.header && (_jsx("img", { src: group.header, alt: "banner", className: "h-full w-full object-cover" })) }), _jsx(GroupAvatar, { group: group, size: 6, borderless: true, containerClassName: "absolute -bottom-12 left-4" })] }), _jsx("div", { className: "flex justify-end space-x-2 p-2", children: !isMember ? (_jsx(JoinGroupButton, { group: group })) : (_jsxs(_Fragment, { children: [_jsx(GroupShareMenu, { group: group }), _jsx(GroupNotificationButton, { group: group }), _jsx(GroupOptionsMenu, { group: group })] })) }), _jsxs("div", { className: "mb-8 p-2 pt-6", children: [_jsx("h1", { className: "text-xl font-semibold", "data-testid": "groups-header-title", children: groupName(group) }), _jsxs("p", { className: "text-muted-foreground text-sm", children: ["@", group.handle] }), _jsxs("a", { href: `/groups/@${group.handle}/members`, title: t('groups.viewMembers', { defaultValue: 'View members' }), className: "text-muted-foreground text-sm hover:underline", children: [group.membersCount, " member", group.membersCount === 1 ? '' : 's'] })] })] }));
14
15
  }
@@ -0,0 +1,9 @@
1
+ import { type GroupWithMeta } from '@openpeepshq/common';
2
+ export interface GroupNotificationSettingsModalProps {
3
+ group: GroupWithMeta;
4
+ onClose: () => void;
5
+ }
6
+ export declare function GroupNotificationSettingsModal({ group, onClose, }: GroupNotificationSettingsModalProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function GroupNotificationButton({ group }: {
8
+ group: GroupWithMeta;
9
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { Bell } from 'lucide-react';
4
+ import { groupName, groupNotificationLevelOptions, } from '@openpeepshq/common';
5
+ import { Dialog, DialogActions, DialogContent, DialogHeader, DialogTitle, LoadingSpinner, RadioGroup, RadioGroupItem, } from '@openpeepshq/react-ui';
6
+ import { useT } from '../../i18n/index.js';
7
+ import { useGroupNotificationLevel } from '../../hooks/index.js';
8
+ import { useToast } from '../layout/ToastProvider.js';
9
+ const optionLabelKey = {
10
+ all: 'groups.modals.manageNotifications.options.all',
11
+ mostRelevant: 'groups.modals.manageNotifications.options.mostRelevant',
12
+ off: 'groups.modals.manageNotifications.options.off',
13
+ };
14
+ const optionDescriptionKey = {
15
+ all: 'groups.modals.manageNotifications.options.allDescription',
16
+ mostRelevant: 'groups.modals.manageNotifications.options.mostRelevantDescription',
17
+ off: 'groups.modals.manageNotifications.options.offDescription',
18
+ };
19
+ const optionDescriptionDefault = {
20
+ all: 'Every post and membership change, using your account notification settings.',
21
+ mostRelevant: 'Posts from people you follow.',
22
+ off: 'No posts or membership changes from this group.',
23
+ };
24
+ export function GroupNotificationSettingsModal({ group, onClose, }) {
25
+ const t = useT();
26
+ const { success } = useToast();
27
+ const { level, setLevel, save, saving, ready, loadFailed, error } = useGroupNotificationLevel(group.id);
28
+ const onSave = async () => {
29
+ const saved = await save();
30
+ if (!saved)
31
+ return;
32
+ success(t('groups.modals.manageNotifications.saved', {
33
+ defaultValue: 'Group notification settings updated.',
34
+ }));
35
+ onClose();
36
+ };
37
+ return (_jsx(Dialog, { open: true, onOpenChange: (open) => !open && onClose(), children: _jsxs(DialogContent, { className: "max-h-[85vh] max-w-md overflow-y-auto", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: t('groups.modals.manageNotifications.title', {
38
+ defaultValue: 'Manage notifications',
39
+ }) }) }), _jsx("p", { className: "text-muted-foreground px-1 text-sm", children: t('groups.modals.manageNotifications.description', {
40
+ defaultValue: 'Manage notifications about {{groupName}}.',
41
+ groupName: groupName(group),
42
+ }) }), ready ? (_jsx(RadioGroup, { value: level, onValueChange: (value) => setLevel(value), className: "gap-3 px-1", children: groupNotificationLevelOptions.map((option) => (_jsxs("label", { className: "flex items-start gap-2 text-sm", children: [_jsx(RadioGroupItem, { value: option, className: "mt-0.5" }), _jsxs("span", { children: [_jsx("span", { className: "font-medium", children: t(optionLabelKey[option], { defaultValue: option }) }), _jsx("span", { className: "text-muted-foreground mt-0.5 block", children: t(optionDescriptionKey[option], {
43
+ defaultValue: optionDescriptionDefault[option],
44
+ }) })] })] }, option))) })) : loadFailed ? (_jsx("p", { className: "text-error px-1 text-sm", children: t('groups.modals.manageNotifications.loadError', {
45
+ defaultValue: 'Could not load notification settings.',
46
+ }) })) : (_jsx("div", { className: "text-muted-foreground flex h-24 items-center justify-center", children: _jsx(LoadingSpinner, {}) })), error ? (_jsx("p", { className: "border-error/40 text-error rounded-md border p-2 text-sm", children: error })) : null, _jsx(DialogActions, { cancelLabel: t('common.cancel', { defaultValue: 'Cancel' }), onCancel: onClose, actionLabel: saving
47
+ ? t('common.saving', { defaultValue: 'Saving…' })
48
+ : t('common.save', { defaultValue: 'Save' }), onAction: onSave, disabled: saving || !ready })] }) }));
49
+ }
50
+ export function GroupNotificationButton({ group }) {
51
+ const t = useT();
52
+ const [open, setOpen] = useState(false);
53
+ const label = t('groups.modals.manageNotifications.title', {
54
+ defaultValue: 'Manage notifications',
55
+ });
56
+ return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", title: label, "aria-label": label, className: "rounded-button inline-flex items-center justify-center", onClick: () => setOpen(true), children: _jsx(Bell, { size: 16, "aria-hidden": "true" }) }), open ? (_jsx(GroupNotificationSettingsModal, { group: group, onClose: () => setOpen(false) })) : null] }));
57
+ }
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Link, Pencil, Share } from 'lucide-react';
3
+ import { groupSectionPath } from '@openpeepshq/common/lib';
3
4
  import { PopupMenu, PopupMenuButton, PopupSection, } from '@openpeepshq/react-ui';
4
5
  import { useT } from '../../i18n/index.js';
5
6
  import { useToast } from '../layout/ToastProvider.js';
@@ -10,20 +11,41 @@ export function GroupShareMenu({ group }) {
10
11
  const { success } = useToast();
11
12
  const { openNewPost } = useNewPostModal();
12
13
  const { openCreateConversation } = useCreateNewConversation();
13
- const groupUrl = typeof window !== 'undefined'
14
- ? `${window.location.origin}/groups/@${group.handle}`
15
- : `/groups/@${group.handle}`;
14
+ const sectionUrl = (section = 'posts') => {
15
+ const path = groupSectionPath(group.handle, section);
16
+ return typeof window !== 'undefined'
17
+ ? `${window.location.origin}${path}`
18
+ : path;
19
+ };
20
+ const groupUrl = sectionUrl();
16
21
  const inviteBlurb = t('groups.share.inviteBlurb', { url: groupUrl });
22
+ const copySectionLink = (section, copiedKey, copiedDefault) => {
23
+ void navigator.clipboard.writeText(sectionUrl(section));
24
+ success(t(copiedKey, { defaultValue: copiedDefault }));
25
+ };
17
26
  return (_jsxs(PopupMenu, { icon: Share, title: t('groups.actions.shareOnCommunity', {
18
27
  defaultValue: 'Share on community',
19
28
  }), children: [_jsx(PopupSection, { title: t('groups.actions.shareOnCommunity', {
20
29
  defaultValue: 'Share on community',
21
- }) }), _jsx(PopupMenuButton, { title: t('groups.actions.shareToFeed', { defaultValue: 'Share to feed' }), text: t('groups.share.postToFeed', { defaultValue: 'Post to feed' }), icon: Pencil, action: () => openNewPost({ visibility: 'public', initialContent: inviteBlurb }) }), _jsx(PopupMenuButton, { title: t('groups.actions.shareInMessage', {
30
+ }) }), _jsx(PopupMenuButton, { title: t('groups.actions.shareToFeed', {
31
+ defaultValue: 'Share to feed',
32
+ }), text: t('groups.share.postToFeed', { defaultValue: 'Post to feed' }), icon: Pencil, action: () => openNewPost({ visibility: 'public', initialContent: inviteBlurb }) }), _jsx(PopupMenuButton, { title: t('groups.actions.shareInMessage', {
22
33
  defaultValue: 'Share in a message',
23
34
  }), text: t('groups.share.sendInMessage', {
24
35
  defaultValue: 'Send in a message',
25
- }), icon: Pencil, action: () => openCreateConversation({ message: inviteBlurb }) }), _jsx(PopupSection, { title: t('groups.actions.otherOptions', { defaultValue: 'Other options' }) }), _jsx(PopupMenuButton, { title: t('groups.share.copyLink', { defaultValue: 'Copy link' }), text: t('groups.share.copyLink', { defaultValue: 'Copy link' }), icon: Link, action: () => {
26
- void navigator.clipboard.writeText(groupUrl);
27
- success(t('groups.share.linkCopied', { defaultValue: 'Group link copied' }));
28
- } })] }));
36
+ }), icon: Pencil, action: () => openCreateConversation({ message: inviteBlurb }) }), _jsx(PopupSection, { title: t('groups.actions.otherOptions', {
37
+ defaultValue: 'Other options',
38
+ }) }), _jsx(PopupMenuButton, { title: t('groups.share.copyLink', { defaultValue: 'Copy link' }), text: t('groups.share.copyLink', { defaultValue: 'Copy link' }), icon: Link, action: () => copySectionLink('posts', 'groups.share.linkCopied', 'Group link copied') }), _jsx(PopupMenuButton, { title: t('groups.share.copyEventsLink', {
39
+ defaultValue: 'Copy events link',
40
+ }), text: t('groups.share.copyEventsLink', {
41
+ defaultValue: 'Copy events link',
42
+ }), icon: Link, action: () => copySectionLink('events', 'groups.share.eventsLinkCopied', 'Events link copied') }), _jsx(PopupMenuButton, { title: t('groups.share.copyResourcesLink', {
43
+ defaultValue: 'Copy resources link',
44
+ }), text: t('groups.share.copyResourcesLink', {
45
+ defaultValue: 'Copy resources link',
46
+ }), icon: Link, action: () => copySectionLink('resources', 'groups.share.resourcesLinkCopied', 'Resources link copied') }), _jsx(PopupMenuButton, { title: t('groups.share.copyDescriptionLink', {
47
+ defaultValue: 'Copy description link',
48
+ }), text: t('groups.share.copyDescriptionLink', {
49
+ defaultValue: 'Copy description link',
50
+ }), icon: Link, action: () => copySectionLink('description', 'groups.share.descriptionLinkCopied', 'Description link copied') })] }));
29
51
  }
@@ -14,6 +14,8 @@ export { GroupCapabilityMatrix } from './GroupCapabilityMatrix';
14
14
  export type { GroupCapabilityMatrixProps } from './GroupCapabilityMatrix';
15
15
  export { GroupOptionsMenu } from './GroupOptionsMenu';
16
16
  export type { GroupOptionsMenuProps } from './GroupOptionsMenu';
17
+ export { GroupNotificationButton, GroupNotificationSettingsModal, } from './GroupNotificationSettingsModal';
18
+ export type { GroupNotificationSettingsModalProps } from './GroupNotificationSettingsModal';
17
19
  export { GroupShareMenu } from './GroupShareMenu';
18
20
  export type { GroupShareMenuProps } from './GroupShareMenu';
19
21
  export { AddGroupMemberModal } from './AddGroupMemberModal';
@@ -6,6 +6,7 @@ export { GroupFeed } from './GroupFeed.js';
6
6
  export { GroupForm } from './GroupForm.js';
7
7
  export { GroupCapabilityMatrix } from './GroupCapabilityMatrix.js';
8
8
  export { GroupOptionsMenu } from './GroupOptionsMenu.js';
9
+ export { GroupNotificationButton, GroupNotificationSettingsModal, } from './GroupNotificationSettingsModal.js';
9
10
  export { GroupShareMenu } from './GroupShareMenu.js';
10
11
  export { AddGroupMemberModal } from './AddGroupMemberModal.js';
11
12
  export { AddGroupMembersButton } from './AddGroupMembersButton.js';
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Download, EyeOff, MoreHorizontal, Share, Trash2 } from 'lucide-react';
3
3
  import { useCallback, useMemo, useState } from 'react';
4
- import { buildThreads, canAccessJamRecordings, canManageEventRsvps, canModerateJam, canViewJamAttendees, countYesRsvps, effectiveEventTimes, eventTimeZoneOptions, formatEventClockTime, formatEventRecurrence, getJamUrl, groupName, isCapacityEvent, parseOccurrenceQuery, listRsvpOccurrences, profileName, } from '@openpeepshq/common/lib';
4
+ import { buildThreads, canAccessJamRecordings, canManageEventRsvps, canModerateJam, canViewJamAttendees, countYesRsvps, defaultRsvpRecurrenceId, effectiveEventTimes, eventTimeZoneOptions, formatEventClockTime, formatEventRecurrence, getJamUrl, groupName, isCapacityEvent, parseOccurrenceQuery, listRsvpOccurrences, profileName, } from '@openpeepshq/common/lib';
5
5
  import { Button, Dialog, DialogActions, DialogContent, DialogHeader, DialogTitle, LoadingSpinner, UpdatingDate, } from '@openpeepshq/react-ui';
6
6
  import { useOpenpeeps } from '../../../../contexts/openpeeps/index.js';
7
7
  import { useT } from '../../../../i18n/index.js';
@@ -52,7 +52,8 @@ export function FullEvent({ post, occurrence }) {
52
52
  (!event.recurrence || occurrenceId)
53
53
  ? event.maxAttendees - countYesRsvps(post, occurrenceId)
54
54
  : null;
55
- const times = effectiveEventTimes(event, occurrenceId);
55
+ const times = effectiveEventTimes(event, occurrenceId ??
56
+ (event.recurrence ? defaultRsvpRecurrenceId(event) : undefined));
56
57
  const recurrenceLabel = event.recurrence
57
58
  ? formatEventRecurrence(event.recurrence, t, event.start)
58
59
  : '';
@@ -0,0 +1,9 @@
1
+ export declare const useGroupNotificationLevel: (groupId: string) => {
2
+ level: "all" | "mostRelevant" | "off";
3
+ setLevel: import("react").Dispatch<import("react").SetStateAction<"all" | "mostRelevant" | "off">>;
4
+ save: () => Promise<boolean>;
5
+ saving: boolean;
6
+ ready: boolean;
7
+ loadFailed: boolean;
8
+ error: string | null;
9
+ };
@@ -0,0 +1,57 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { useOpenpeeps } from '../../contexts/openpeeps/index.js';
3
+ export const useGroupNotificationLevel = (groupId) => {
4
+ const { openpeepsApi } = useOpenpeeps();
5
+ const settingsQuery = openpeepsApi.useCurrentProfileSettings();
6
+ const updateSettings = openpeepsApi.updateCurrentProfileSettingsAction();
7
+ const [level, setLevel] = useState('all');
8
+ const [ready, setReady] = useState(false);
9
+ const [saving, setSaving] = useState(false);
10
+ const [error, setError] = useState(null);
11
+ useEffect(() => {
12
+ const settings = settingsQuery.data;
13
+ if (!settings || ready)
14
+ return;
15
+ setLevel(settings.groupNotificationLevels?.[groupId] ?? 'all');
16
+ setReady(true);
17
+ }, [settingsQuery.data, groupId, ready]);
18
+ const save = async () => {
19
+ const current = settingsQuery.data;
20
+ if (!current)
21
+ return false;
22
+ setError(null);
23
+ setSaving(true);
24
+ try {
25
+ const groupNotificationLevels = {
26
+ ...(current.groupNotificationLevels ?? {}),
27
+ };
28
+ if (level === 'all') {
29
+ delete groupNotificationLevels[groupId];
30
+ }
31
+ else {
32
+ groupNotificationLevels[groupId] = level;
33
+ }
34
+ await updateSettings({
35
+ ...current,
36
+ groupNotificationLevels,
37
+ });
38
+ return true;
39
+ }
40
+ catch (err) {
41
+ setError(err.message);
42
+ return false;
43
+ }
44
+ finally {
45
+ setSaving(false);
46
+ }
47
+ };
48
+ return {
49
+ level,
50
+ setLevel,
51
+ save,
52
+ saving,
53
+ ready: ready && !settingsQuery.isLoading,
54
+ loadFailed: settingsQuery.isError,
55
+ error,
56
+ };
57
+ };
@@ -1,4 +1,5 @@
1
1
  export { useJoinGroup } from './groups/useJoinGroup';
2
+ export { useGroupNotificationLevel } from './groups/useGroupNotificationLevel';
2
3
  export { useCreateConversation } from './conversations/useCreateConversation';
3
4
  export type { UseCreateConversationArgs } from './conversations/useCreateConversation';
4
5
  export { useLeaveCloseJam } from './jams/useLeaveCloseJam';
@@ -1,4 +1,5 @@
1
1
  export { useJoinGroup } from './groups/useJoinGroup.js';
2
+ export { useGroupNotificationLevel } from './groups/useGroupNotificationLevel.js';
2
3
  export { useCreateConversation } from './conversations/useCreateConversation.js';
3
4
  export { useLeaveCloseJam } from './jams/useLeaveCloseJam.js';
4
5
  export { useCreateNewJamForm } from './jams/useCreateNewJamForm.js';
@@ -115,6 +115,10 @@ export declare const useSsoConfig: () => {
115
115
  local: {
116
116
  path: string;
117
117
  };
118
+ retention: {
119
+ zipAfterDays: number;
120
+ deleteAfterDays: number;
121
+ };
118
122
  };
119
123
  media: {
120
124
  maxUploadMb: number;
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
3
- import { useNavigate, useParams } from 'react-router-dom';
2
+ import { useEffect, useState } from 'react';
3
+ import { Link, useLocation, useNavigate, useParams } from 'react-router-dom';
4
+ import { groupSectionFromHash } from '@openpeepshq/common/lib';
4
5
  import { useT, useOpenpeeps } from '../../index.js';
5
6
  import { EventsView, Feed, GroupFeed, GroupHeader, NewEventButton, NewResourceButton, PostMarkdown, useCurrentProfile, } from '../../components/index.js';
6
7
  import { routeHandleParam } from '../../lib/routeHandles.js';
@@ -9,13 +10,25 @@ import { ResourceLibrary } from '../../components/resources/ResourceLibrary.js';
9
10
  export function GroupShow() {
10
11
  const t = useT();
11
12
  const navigate = useNavigate();
13
+ const location = useLocation();
12
14
  const { handle: handleParam = '' } = useParams();
13
15
  const handle = routeHandleParam(handleParam);
14
16
  const { openpeepsApi } = useOpenpeeps();
15
17
  const groupQuery = openpeepsApi.useGroupByHandle(handle);
16
18
  const group = groupQuery.data;
17
19
  const currentProfile = useCurrentProfile();
18
- const [tab, setTab] = useState('posts');
20
+ const tab = groupSectionFromHash(location.hash);
21
+ // Raw anchors (shared links, markdown) change the hash without going
22
+ // through the router. Mirror that into the location so the tab follows.
23
+ useEffect(() => {
24
+ const syncHash = () => {
25
+ if (window.location.hash === location.hash)
26
+ return;
27
+ navigate({ pathname: location.pathname, hash: window.location.hash }, { replace: true });
28
+ };
29
+ window.addEventListener('hashchange', syncHash);
30
+ return () => window.removeEventListener('hashchange', syncHash);
31
+ }, [location.hash, location.pathname, navigate]);
19
32
  const upcomingEvents = openpeepsApi.useGroupUpcomingEventsFeed(group?.id ?? '');
20
33
  const pastEvents = openpeepsApi.useGroupPastEventsFeed(group?.id ?? '');
21
34
  const [eventsTab, setEventsTab] = useState('upcoming');
@@ -47,22 +60,12 @@ export function GroupShow() {
47
60
  }
48
61
  return (_jsxs("div", { children: [_jsx(GroupHeader, { group: group }), _jsxs("nav", { "aria-label": t('groups.sections.label', {
49
62
  defaultValue: 'Group sections',
50
- }), className: "border-border flex border-b", "data-testid": "tab-group", children: [_jsx(TabButton, { active: tab === 'posts', onClick: () => {
51
- setTab('posts');
52
- window.history.replaceState(null, '', window.location.pathname);
53
- }, children: t('groups.sections.posts', { defaultValue: 'Posts' }) }), _jsx(TabButton, { active: tab === 'events', onClick: () => {
54
- setTab('events');
55
- window.history.replaceState(null, '', `${window.location.pathname}#events`);
56
- }, testId: "groups-tab-events", children: t('groups.sections.events', { defaultValue: 'Events' }) }), _jsx(TabButton, { active: tab === 'resources', onClick: () => {
57
- setTab('resources');
58
- window.history.replaceState(null, '', `${window.location.pathname}#resources`);
59
- }, testId: "groups-tab-resources", children: t('groups.sections.resources', { defaultValue: 'Resources' }) }), _jsx(TabButton, { active: tab === 'description', onClick: () => {
60
- setTab('description');
61
- window.history.replaceState(null, '', `${window.location.pathname}#description`);
62
- }, testId: "groups-tab-description", children: t('groups.sections.description', { defaultValue: 'Description' }) })] }), tab === 'posts' && _jsx(GroupFeed, { group: group }), tab === 'events' && (_jsxs("div", { children: [_jsx(NewEventButton, { visibility: "group", currentProfile: currentProfile, group: group, onNavigate: () => navigate('/events/new') }), _jsxs("nav", { "aria-label": t('groups.eventsTabs.label', {
63
+ }), className: "border-border flex border-b", "data-testid": "tab-group", children: [_jsx(TabLink, { active: tab === 'posts', hash: "", children: t('groups.sections.posts', { defaultValue: 'Posts' }) }), _jsx(TabLink, { active: tab === 'events', hash: "#events", testId: "groups-tab-events", children: t('groups.sections.events', { defaultValue: 'Events' }) }), _jsx(TabLink, { active: tab === 'resources', hash: "#resources", testId: "groups-tab-resources", children: t('groups.sections.resources', { defaultValue: 'Resources' }) }), _jsx(TabLink, { active: tab === 'description', hash: "#description", testId: "groups-tab-description", children: t('groups.sections.description', { defaultValue: 'Description' }) })] }), tab === 'posts' && _jsx(GroupFeed, { group: group }), tab === 'events' && (_jsxs("div", { children: [_jsx(NewEventButton, { visibility: "group", currentProfile: currentProfile, group: group, onNavigate: () => navigate('/events/new') }), _jsxs("nav", { "aria-label": t('groups.eventsTabs.label', {
63
64
  defaultValue: 'Event timeframe',
64
65
  }), className: "border-border flex border-b", children: [_jsx(TabButton, { active: eventsTab === 'upcoming', onClick: () => setEventsTab('upcoming'), children: t('events.feed.upcoming', { defaultValue: 'Upcoming' }) }), _jsx(TabButton, { active: eventsTab === 'past', onClick: () => setEventsTab('past'), children: t('events.feed.past', { defaultValue: 'Past' }) })] }), _jsx(EventsView, { query: eventsTab === 'upcoming' ? upcomingEvents : pastEvents, agenda: eventsTab, list: _jsx(Feed, { query: eventsTab === 'upcoming' ? upcomingEvents : pastEvents, formatSwitch: false }) })] })), tab === 'resources' && (_jsxs("div", { children: [_jsx(NewResourceButton, { visibility: "group", currentProfile: currentProfile, group: group }), _jsx(ResourceLibrary, { groupId: group.id })] })), tab === 'description' && (_jsxs("div", { className: "space-y-2 p-4", children: [_jsxs("section", { className: "border-b py-2", children: [_jsx("h3", { className: "text-lg font-semibold", children: "Description" }), _jsx(PostMarkdown, { source: group.description || 'No description yet' })] }), _jsxs("section", { className: "space-y-2 border-b py-2", children: [_jsx("h3", { className: "text-lg font-semibold", children: "Details" }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: "Created" }), _jsx("p", { children: new Date(group.createdAt).toLocaleDateString() })] }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: t('groups.visibility.title') }), _jsx("p", { children: t(`groups.visibility.${visibilityValue}.description`) })] }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: t('groups.whoCanJoin.title') }), _jsx("p", { children: t(`groups.whoCanJoin.${whoCanJoinValue}.description`) })] }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: t('groups.whoCanPost.title') }), _jsxs("p", { children: [t(`groups.whoCanPost.${whoCanPostValue}.description`), ".", ' ', t(`groups.whoCanPostEvents.${whoCanPostEventsValue}.description`)] })] }), _jsxs("div", { children: [_jsx("h4", { className: "font-semibold", children: t('groups.postsVisibility.title') }), _jsx("p", { children: t(`groups.postsVisibility.${postsVisibilityValue}.description`) })] })] }), _jsxs("section", { className: "border-b py-2", children: [_jsx("h3", { className: "text-lg font-semibold", children: "Rules" }), _jsx(PostMarkdown, { source: group.rules || 'No rules yet' })] })] }))] }));
65
66
  }
66
- function TabButton({ active, onClick, children, testId, }) {
67
- return (_jsx("button", { type: "button", onClick: onClick, "data-testid": testId, className: `px-4 py-2 text-sm ${active ? 'border-primary border-b-2 font-semibold' : 'text-muted-foreground hover:text-foreground'}`, children: children }));
68
- }
67
+ const TabLink = ({ active, hash, children, testId, }) => {
68
+ const location = useLocation();
69
+ return (_jsx(Link, { replace: true, to: { pathname: location.pathname, hash }, "data-testid": testId, "aria-current": active ? 'page' : undefined, className: `px-4 py-2 text-sm no-underline ${active ? 'border-primary border-b-2 font-semibold' : 'text-muted-foreground hover:text-foreground'}`, children: children }));
70
+ };
71
+ const TabButton = ({ active, onClick, children, }) => (_jsx("button", { type: "button", onClick: onClick, className: `px-4 py-2 text-sm ${active ? 'border-primary border-b-2 font-semibold' : 'text-muted-foreground hover:text-foreground'}`, children: children }));
@@ -11,7 +11,7 @@ export * from './lib/unseenCountsOptimistic';
11
11
  export * from './lib/postUnread';
12
12
  export * from './lib/notificationBadge';
13
13
  export { getInitials, hueFromHandle, initialsBackground, } from './lib/initialsAvatar';
14
- export { svgCoverSrc } from './lib/svgCover';
14
+ export { isSvgUrl, svgCoverSrc } from './lib/svgCover';
15
15
  export * from './lib/capabilityMatrix';
16
16
  export * from './lib/groupFormErrors';
17
17
  export * from './lib/passwordStrength';
@@ -11,7 +11,7 @@ export * from './lib/unseenCountsOptimistic.js';
11
11
  export * from './lib/postUnread.js';
12
12
  export * from './lib/notificationBadge.js';
13
13
  export { getInitials, hueFromHandle, initialsBackground, } from './lib/initialsAvatar.js';
14
- export { svgCoverSrc } from './lib/svgCover.js';
14
+ export { isSvgUrl, svgCoverSrc } from './lib/svgCover.js';
15
15
  export * from './lib/capabilityMatrix.js';
16
16
  export * from './lib/groupFormErrors.js';
17
17
  export * from './lib/passwordStrength.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/react",
3
- "version": "0.6.3",
3
+ "version": "0.7.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -52,9 +52,9 @@
52
52
  "simple-icons": "^16.31.0",
53
53
  "uuidv7": "^1.0.2",
54
54
  "@openpeepshq/client": "^0.2.1",
55
- "@openpeepshq/greenscreen": "^0.2.1",
56
- "@openpeepshq/common": "^0.3.2",
57
- "@openpeepshq/react-ui": "^0.4.1"
55
+ "@openpeepshq/react-ui": "^0.4.1",
56
+ "@openpeepshq/common": "^0.4.0",
57
+ "@openpeepshq/greenscreen": "^0.2.1"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "react": "^18.3.0 || ^19.0.0",
@@ -4,6 +4,7 @@ import { groupName } from '@openpeepshq/common/lib';
4
4
  import { useT } from '../../i18n';
5
5
  import { useCurrentProfile } from '../layout/IdentityContext';
6
6
  import { JoinGroupButton } from './JoinGroupButton';
7
+ import { GroupNotificationButton } from './GroupNotificationSettingsModal';
7
8
  import { GroupOptionsMenu } from './GroupOptionsMenu';
8
9
  import { GroupShareMenu } from './GroupShareMenu';
9
10
  import { GroupAvatar } from './GroupAvatar';
@@ -42,6 +43,7 @@ export function GroupHeader({ group }: GroupHeaderProps) {
42
43
  ) : (
43
44
  <>
44
45
  <GroupShareMenu group={group} />
46
+ <GroupNotificationButton group={group} />
45
47
  <GroupOptionsMenu group={group} />
46
48
  </>
47
49
  )}
@@ -0,0 +1,163 @@
1
+ import { useState } from 'react';
2
+ import { Bell } from 'lucide-react';
3
+ import {
4
+ groupName,
5
+ groupNotificationLevelOptions,
6
+ type GroupNotificationLevel,
7
+ type GroupWithMeta,
8
+ } from '@openpeepshq/common';
9
+ import {
10
+ Dialog,
11
+ DialogActions,
12
+ DialogContent,
13
+ DialogHeader,
14
+ DialogTitle,
15
+ LoadingSpinner,
16
+ RadioGroup,
17
+ RadioGroupItem,
18
+ } from '@openpeepshq/react-ui';
19
+ import { useT } from '../../i18n';
20
+ import { useGroupNotificationLevel } from '../../hooks';
21
+ import { useToast } from '../layout/ToastProvider';
22
+
23
+ export interface GroupNotificationSettingsModalProps {
24
+ group: GroupWithMeta;
25
+ onClose: () => void;
26
+ }
27
+
28
+ const optionLabelKey: Record<GroupNotificationLevel, string> = {
29
+ all: 'groups.modals.manageNotifications.options.all',
30
+ mostRelevant: 'groups.modals.manageNotifications.options.mostRelevant',
31
+ off: 'groups.modals.manageNotifications.options.off',
32
+ };
33
+
34
+ const optionDescriptionKey: Record<GroupNotificationLevel, string> = {
35
+ all: 'groups.modals.manageNotifications.options.allDescription',
36
+ mostRelevant:
37
+ 'groups.modals.manageNotifications.options.mostRelevantDescription',
38
+ off: 'groups.modals.manageNotifications.options.offDescription',
39
+ };
40
+
41
+ const optionDescriptionDefault: Record<GroupNotificationLevel, string> = {
42
+ all: 'Every post and membership change, using your account notification settings.',
43
+ mostRelevant: 'Posts from people you follow.',
44
+ off: 'No posts or membership changes from this group.',
45
+ };
46
+
47
+ export function GroupNotificationSettingsModal({
48
+ group,
49
+ onClose,
50
+ }: GroupNotificationSettingsModalProps) {
51
+ const t = useT();
52
+ const { success } = useToast();
53
+ const { level, setLevel, save, saving, ready, loadFailed, error } =
54
+ useGroupNotificationLevel(group.id);
55
+
56
+ const onSave = async () => {
57
+ const saved = await save();
58
+ if (!saved) return;
59
+ success(
60
+ t('groups.modals.manageNotifications.saved', {
61
+ defaultValue: 'Group notification settings updated.',
62
+ }),
63
+ );
64
+ onClose();
65
+ };
66
+
67
+ return (
68
+ <Dialog open onOpenChange={(open) => !open && onClose()}>
69
+ <DialogContent className="max-h-[85vh] max-w-md overflow-y-auto">
70
+ <DialogHeader>
71
+ <DialogTitle>
72
+ {t('groups.modals.manageNotifications.title', {
73
+ defaultValue: 'Manage notifications',
74
+ })}
75
+ </DialogTitle>
76
+ </DialogHeader>
77
+ <p className="text-muted-foreground px-1 text-sm">
78
+ {t('groups.modals.manageNotifications.description', {
79
+ defaultValue: 'Manage notifications about {{groupName}}.',
80
+ groupName: groupName(group),
81
+ })}
82
+ </p>
83
+ {ready ? (
84
+ <RadioGroup
85
+ value={level}
86
+ onValueChange={(value) => setLevel(value as GroupNotificationLevel)}
87
+ className="gap-3 px-1"
88
+ >
89
+ {groupNotificationLevelOptions.map((option) => (
90
+ <label key={option} className="flex items-start gap-2 text-sm">
91
+ <RadioGroupItem value={option} className="mt-0.5" />
92
+ <span>
93
+ <span className="font-medium">
94
+ {t(optionLabelKey[option], { defaultValue: option })}
95
+ </span>
96
+ <span className="text-muted-foreground mt-0.5 block">
97
+ {t(optionDescriptionKey[option], {
98
+ defaultValue: optionDescriptionDefault[option],
99
+ })}
100
+ </span>
101
+ </span>
102
+ </label>
103
+ ))}
104
+ </RadioGroup>
105
+ ) : loadFailed ? (
106
+ <p className="text-error px-1 text-sm">
107
+ {t('groups.modals.manageNotifications.loadError', {
108
+ defaultValue: 'Could not load notification settings.',
109
+ })}
110
+ </p>
111
+ ) : (
112
+ <div className="text-muted-foreground flex h-24 items-center justify-center">
113
+ <LoadingSpinner />
114
+ </div>
115
+ )}
116
+ {error ? (
117
+ <p className="border-error/40 text-error rounded-md border p-2 text-sm">
118
+ {error}
119
+ </p>
120
+ ) : null}
121
+ <DialogActions
122
+ cancelLabel={t('common.cancel', { defaultValue: 'Cancel' })}
123
+ onCancel={onClose}
124
+ actionLabel={
125
+ saving
126
+ ? t('common.saving', { defaultValue: 'Saving…' })
127
+ : t('common.save', { defaultValue: 'Save' })
128
+ }
129
+ onAction={onSave}
130
+ disabled={saving || !ready}
131
+ />
132
+ </DialogContent>
133
+ </Dialog>
134
+ );
135
+ }
136
+
137
+ export function GroupNotificationButton({ group }: { group: GroupWithMeta }) {
138
+ const t = useT();
139
+ const [open, setOpen] = useState(false);
140
+ const label = t('groups.modals.manageNotifications.title', {
141
+ defaultValue: 'Manage notifications',
142
+ });
143
+
144
+ return (
145
+ <>
146
+ <button
147
+ type="button"
148
+ title={label}
149
+ aria-label={label}
150
+ className="rounded-button inline-flex items-center justify-center"
151
+ onClick={() => setOpen(true)}
152
+ >
153
+ <Bell size={16} aria-hidden="true" />
154
+ </button>
155
+ {open ? (
156
+ <GroupNotificationSettingsModal
157
+ group={group}
158
+ onClose={() => setOpen(false)}
159
+ />
160
+ ) : null}
161
+ </>
162
+ );
163
+ }
@@ -1,4 +1,5 @@
1
1
  import { Link, Pencil, Share } from 'lucide-react';
2
+ import { groupSectionPath, type GroupSection } from '@openpeepshq/common/lib';
2
3
  import type { GroupWithMeta } from '@openpeepshq/common/types';
3
4
  import {
4
5
  PopupMenu,
@@ -20,11 +21,22 @@ export function GroupShareMenu({ group }: GroupShareMenuProps) {
20
21
  const { openNewPost } = useNewPostModal();
21
22
  const { openCreateConversation } = useCreateNewConversation();
22
23
 
23
- const groupUrl =
24
- typeof window !== 'undefined'
25
- ? `${window.location.origin}/groups/@${group.handle}`
26
- : `/groups/@${group.handle}`;
24
+ const sectionUrl = (section: GroupSection = 'posts') => {
25
+ const path = groupSectionPath(group.handle, section);
26
+ return typeof window !== 'undefined'
27
+ ? `${window.location.origin}${path}`
28
+ : path;
29
+ };
30
+ const groupUrl = sectionUrl();
27
31
  const inviteBlurb = t('groups.share.inviteBlurb', { url: groupUrl });
32
+ const copySectionLink = (
33
+ section: GroupSection,
34
+ copiedKey: string,
35
+ copiedDefault: string,
36
+ ) => {
37
+ void navigator.clipboard.writeText(sectionUrl(section));
38
+ success(t(copiedKey, { defaultValue: copiedDefault }));
39
+ };
28
40
 
29
41
  return (
30
42
  <PopupMenu
@@ -39,7 +51,9 @@ export function GroupShareMenu({ group }: GroupShareMenuProps) {
39
51
  })}
40
52
  />
41
53
  <PopupMenuButton
42
- title={t('groups.actions.shareToFeed', { defaultValue: 'Share to feed' })}
54
+ title={t('groups.actions.shareToFeed', {
55
+ defaultValue: 'Share to feed',
56
+ })}
43
57
  text={t('groups.share.postToFeed', { defaultValue: 'Post to feed' })}
44
58
  icon={Pencil}
45
59
  action={() =>
@@ -57,18 +71,69 @@ export function GroupShareMenu({ group }: GroupShareMenuProps) {
57
71
  action={() => openCreateConversation({ message: inviteBlurb })}
58
72
  />
59
73
  <PopupSection
60
- title={t('groups.actions.otherOptions', { defaultValue: 'Other options' })}
74
+ title={t('groups.actions.otherOptions', {
75
+ defaultValue: 'Other options',
76
+ })}
61
77
  />
62
78
  <PopupMenuButton
63
79
  title={t('groups.share.copyLink', { defaultValue: 'Copy link' })}
64
80
  text={t('groups.share.copyLink', { defaultValue: 'Copy link' })}
65
81
  icon={Link}
66
- action={() => {
67
- void navigator.clipboard.writeText(groupUrl);
68
- success(
69
- t('groups.share.linkCopied', { defaultValue: 'Group link copied' }),
70
- );
71
- }}
82
+ action={() =>
83
+ copySectionLink(
84
+ 'posts',
85
+ 'groups.share.linkCopied',
86
+ 'Group link copied',
87
+ )
88
+ }
89
+ />
90
+ <PopupMenuButton
91
+ title={t('groups.share.copyEventsLink', {
92
+ defaultValue: 'Copy events link',
93
+ })}
94
+ text={t('groups.share.copyEventsLink', {
95
+ defaultValue: 'Copy events link',
96
+ })}
97
+ icon={Link}
98
+ action={() =>
99
+ copySectionLink(
100
+ 'events',
101
+ 'groups.share.eventsLinkCopied',
102
+ 'Events link copied',
103
+ )
104
+ }
105
+ />
106
+ <PopupMenuButton
107
+ title={t('groups.share.copyResourcesLink', {
108
+ defaultValue: 'Copy resources link',
109
+ })}
110
+ text={t('groups.share.copyResourcesLink', {
111
+ defaultValue: 'Copy resources link',
112
+ })}
113
+ icon={Link}
114
+ action={() =>
115
+ copySectionLink(
116
+ 'resources',
117
+ 'groups.share.resourcesLinkCopied',
118
+ 'Resources link copied',
119
+ )
120
+ }
121
+ />
122
+ <PopupMenuButton
123
+ title={t('groups.share.copyDescriptionLink', {
124
+ defaultValue: 'Copy description link',
125
+ })}
126
+ text={t('groups.share.copyDescriptionLink', {
127
+ defaultValue: 'Copy description link',
128
+ })}
129
+ icon={Link}
130
+ action={() =>
131
+ copySectionLink(
132
+ 'description',
133
+ 'groups.share.descriptionLinkCopied',
134
+ 'Description link copied',
135
+ )
136
+ }
72
137
  />
73
138
  </PopupMenu>
74
139
  );
@@ -18,6 +18,11 @@ export { GroupCapabilityMatrix } from './GroupCapabilityMatrix';
18
18
  export type { GroupCapabilityMatrixProps } from './GroupCapabilityMatrix';
19
19
  export { GroupOptionsMenu } from './GroupOptionsMenu';
20
20
  export type { GroupOptionsMenuProps } from './GroupOptionsMenu';
21
+ export {
22
+ GroupNotificationButton,
23
+ GroupNotificationSettingsModal,
24
+ } from './GroupNotificationSettingsModal';
25
+ export type { GroupNotificationSettingsModalProps } from './GroupNotificationSettingsModal';
21
26
  export { GroupShareMenu } from './GroupShareMenu';
22
27
  export type { GroupShareMenuProps } from './GroupShareMenu';
23
28
  export { AddGroupMemberModal } from './AddGroupMemberModal';
@@ -13,6 +13,7 @@ import {
13
13
  canModerateJam,
14
14
  canViewJamAttendees,
15
15
  countYesRsvps,
16
+ defaultRsvpRecurrenceId,
16
17
  effectiveEventTimes,
17
18
  eventTimeZoneOptions,
18
19
  formatEventClockTime,
@@ -104,7 +105,11 @@ export function FullEvent({ post, occurrence }: FullEventProps) {
104
105
  (!event.recurrence || occurrenceId)
105
106
  ? event.maxAttendees - countYesRsvps(post, occurrenceId)
106
107
  : null;
107
- const times = effectiveEventTimes(event, occurrenceId);
108
+ const times = effectiveEventTimes(
109
+ event,
110
+ occurrenceId ??
111
+ (event.recurrence ? defaultRsvpRecurrenceId(event) : undefined),
112
+ );
108
113
  const recurrenceLabel = event.recurrence
109
114
  ? formatEventRecurrence(event.recurrence, t, event.start)
110
115
  : '';
@@ -0,0 +1,57 @@
1
+ import { useEffect, useState } from 'react';
2
+ import type { GroupNotificationLevel } from '@openpeepshq/common';
3
+ import { useOpenpeeps } from '../../contexts/openpeeps';
4
+
5
+ export const useGroupNotificationLevel = (groupId: string) => {
6
+ const { openpeepsApi } = useOpenpeeps();
7
+ const settingsQuery = openpeepsApi.useCurrentProfileSettings();
8
+ const updateSettings = openpeepsApi.updateCurrentProfileSettingsAction();
9
+ const [level, setLevel] = useState<GroupNotificationLevel>('all');
10
+ const [ready, setReady] = useState(false);
11
+ const [saving, setSaving] = useState(false);
12
+ const [error, setError] = useState<string | null>(null);
13
+
14
+ useEffect(() => {
15
+ const settings = settingsQuery.data;
16
+ if (!settings || ready) return;
17
+ setLevel(settings.groupNotificationLevels?.[groupId] ?? 'all');
18
+ setReady(true);
19
+ }, [settingsQuery.data, groupId, ready]);
20
+
21
+ const save = async () => {
22
+ const current = settingsQuery.data;
23
+ if (!current) return false;
24
+ setError(null);
25
+ setSaving(true);
26
+ try {
27
+ const groupNotificationLevels = {
28
+ ...(current.groupNotificationLevels ?? {}),
29
+ };
30
+ if (level === 'all') {
31
+ delete groupNotificationLevels[groupId];
32
+ } else {
33
+ groupNotificationLevels[groupId] = level;
34
+ }
35
+ await updateSettings({
36
+ ...current,
37
+ groupNotificationLevels,
38
+ });
39
+ return true;
40
+ } catch (err) {
41
+ setError((err as Error).message);
42
+ return false;
43
+ } finally {
44
+ setSaving(false);
45
+ }
46
+ };
47
+
48
+ return {
49
+ level,
50
+ setLevel,
51
+ save,
52
+ saving,
53
+ ready: ready && !settingsQuery.isLoading,
54
+ loadFailed: settingsQuery.isError,
55
+ error,
56
+ };
57
+ };
@@ -1,4 +1,5 @@
1
1
  export { useJoinGroup } from './groups/useJoinGroup';
2
+ export { useGroupNotificationLevel } from './groups/useGroupNotificationLevel';
2
3
  export { useCreateConversation } from './conversations/useCreateConversation';
3
4
  export type { UseCreateConversationArgs } from './conversations/useCreateConversation';
4
5
  export { useLeaveCloseJam } from './jams/useLeaveCloseJam';
@@ -1,5 +1,6 @@
1
- import { useState } from 'react';
2
- import { useNavigate, useParams } from 'react-router-dom';
1
+ import { useEffect, useState } from 'react';
2
+ import { Link, useLocation, useNavigate, useParams } from 'react-router-dom';
3
+ import { groupSectionFromHash } from '@openpeepshq/common/lib';
3
4
  import { useT, useOpenpeeps } from '../../index';
4
5
  import {
5
6
  EventsView,
@@ -18,6 +19,7 @@ import { ResourceLibrary } from '../../components/resources/ResourceLibrary';
18
19
  export function GroupShow() {
19
20
  const t = useT();
20
21
  const navigate = useNavigate();
22
+ const location = useLocation();
21
23
  const { handle: handleParam = '' } = useParams<{ handle: string }>();
22
24
  const handle = routeHandleParam(handleParam);
23
25
  const { openpeepsApi } = useOpenpeeps();
@@ -25,9 +27,21 @@ export function GroupShow() {
25
27
  const groupQuery = openpeepsApi.useGroupByHandle(handle);
26
28
  const group = groupQuery.data;
27
29
  const currentProfile = useCurrentProfile();
28
- const [tab, setTab] = useState<
29
- 'posts' | 'events' | 'resources' | 'description'
30
- >('posts');
30
+ const tab = groupSectionFromHash(location.hash);
31
+
32
+ // Raw anchors (shared links, markdown) change the hash without going
33
+ // through the router. Mirror that into the location so the tab follows.
34
+ useEffect(() => {
35
+ const syncHash = () => {
36
+ if (window.location.hash === location.hash) return;
37
+ navigate(
38
+ { pathname: location.pathname, hash: window.location.hash },
39
+ { replace: true },
40
+ );
41
+ };
42
+ window.addEventListener('hashchange', syncHash);
43
+ return () => window.removeEventListener('hashchange', syncHash);
44
+ }, [location.hash, location.pathname, navigate]);
31
45
 
32
46
  const upcomingEvents = openpeepsApi.useGroupUpcomingEventsFeed(
33
47
  group?.id ?? '',
@@ -91,57 +105,30 @@ export function GroupShow() {
91
105
  className="border-border flex border-b"
92
106
  data-testid="tab-group"
93
107
  >
94
- <TabButton
95
- active={tab === 'posts'}
96
- onClick={() => {
97
- setTab('posts');
98
- window.history.replaceState(null, '', window.location.pathname);
99
- }}
100
- >
108
+ <TabLink active={tab === 'posts'} hash="">
101
109
  {t('groups.sections.posts', { defaultValue: 'Posts' })}
102
- </TabButton>
103
- <TabButton
110
+ </TabLink>
111
+ <TabLink
104
112
  active={tab === 'events'}
105
- onClick={() => {
106
- setTab('events');
107
- window.history.replaceState(
108
- null,
109
- '',
110
- `${window.location.pathname}#events`,
111
- );
112
- }}
113
+ hash="#events"
113
114
  testId="groups-tab-events"
114
115
  >
115
116
  {t('groups.sections.events', { defaultValue: 'Events' })}
116
- </TabButton>
117
- <TabButton
117
+ </TabLink>
118
+ <TabLink
118
119
  active={tab === 'resources'}
119
- onClick={() => {
120
- setTab('resources');
121
- window.history.replaceState(
122
- null,
123
- '',
124
- `${window.location.pathname}#resources`,
125
- );
126
- }}
120
+ hash="#resources"
127
121
  testId="groups-tab-resources"
128
122
  >
129
123
  {t('groups.sections.resources', { defaultValue: 'Resources' })}
130
- </TabButton>
131
- <TabButton
124
+ </TabLink>
125
+ <TabLink
132
126
  active={tab === 'description'}
133
- onClick={() => {
134
- setTab('description');
135
- window.history.replaceState(
136
- null,
137
- '',
138
- `${window.location.pathname}#description`,
139
- );
140
- }}
127
+ hash="#description"
141
128
  testId="groups-tab-description"
142
129
  >
143
130
  {t('groups.sections.description', { defaultValue: 'Description' })}
144
- </TabButton>
131
+ </TabLink>
145
132
  </nav>
146
133
 
147
134
  {tab === 'posts' && <GroupFeed group={group} />}
@@ -247,25 +234,45 @@ export function GroupShow() {
247
234
  );
248
235
  }
249
236
 
250
- function TabButton({
237
+ const TabLink = ({
251
238
  active,
252
- onClick,
239
+ hash,
253
240
  children,
254
241
  testId,
255
242
  }: {
256
243
  active: boolean;
257
- onClick: () => void;
244
+ hash: string;
258
245
  children: React.ReactNode;
259
246
  testId?: string;
260
- }) {
247
+ }) => {
248
+ const location = useLocation();
261
249
  return (
262
- <button
263
- type="button"
264
- onClick={onClick}
250
+ <Link
251
+ replace
252
+ to={{ pathname: location.pathname, hash }}
265
253
  data-testid={testId}
266
- className={`px-4 py-2 text-sm ${active ? 'border-primary border-b-2 font-semibold' : 'text-muted-foreground hover:text-foreground'}`}
254
+ aria-current={active ? 'page' : undefined}
255
+ className={`px-4 py-2 text-sm no-underline ${active ? 'border-primary border-b-2 font-semibold' : 'text-muted-foreground hover:text-foreground'}`}
267
256
  >
268
257
  {children}
269
- </button>
258
+ </Link>
270
259
  );
271
- }
260
+ };
261
+
262
+ const TabButton = ({
263
+ active,
264
+ onClick,
265
+ children,
266
+ }: {
267
+ active: boolean;
268
+ onClick: () => void;
269
+ children: React.ReactNode;
270
+ }) => (
271
+ <button
272
+ type="button"
273
+ onClick={onClick}
274
+ className={`px-4 py-2 text-sm ${active ? 'border-primary border-b-2 font-semibold' : 'text-muted-foreground hover:text-foreground'}`}
275
+ >
276
+ {children}
277
+ </button>
278
+ );
@@ -15,7 +15,7 @@ export {
15
15
  hueFromHandle,
16
16
  initialsBackground,
17
17
  } from './lib/initialsAvatar';
18
- export { svgCoverSrc } from './lib/svgCover';
18
+ export { isSvgUrl, svgCoverSrc } from './lib/svgCover';
19
19
  export * from './lib/capabilityMatrix';
20
20
  export * from './lib/groupFormErrors';
21
21
  export * from './lib/passwordStrength';