@micha.bigler/ui-core-micha 4.19.0 → 4.21.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.
- package/CHANGELOG.md +16 -0
- package/README.md +33 -2
- package/dist/components/SignUpContent.js +11 -3
- package/dist/i18n/authTranslations.js +6 -0
- package/dist/pages/AccountPage.js +73 -6
- package/dist/pages/SignUpPage.js +5 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.21.0 - UCM-SHELL-9
|
|
4
|
+
|
|
5
|
+
`AccountPage` accepts an optional `groups` declaration (`[{ key, label, order?, tabs?, visible? }]`) that replaces the
|
|
6
|
+
kit's My account / Management / Help groups: app labels, order, built-in tabs placed in any declared group (their own
|
|
7
|
+
permission checks unchanged), `extraTabs[].group` naming any declared key, and a `visible(context)` rule that hides a
|
|
8
|
+
group together with its tabs (also for `?tab=`). Empty groups stay hidden; unplaced tabs land in "More". Without
|
|
9
|
+
`groups` nothing changes.
|
|
10
|
+
|
|
11
|
+
## 4.20.0 - UCM-AUTH-15
|
|
12
|
+
|
|
13
|
+
`SignUpContent` and `SignUpPage` accept an optional `preferredSignupMode`: when the server offers that mode it is shown
|
|
14
|
+
first and preselected, otherwise it is ignored and the server order applies (a QR link still selects the QR mode).
|
|
15
|
+
Visible change in every app: the submit button of open self-signup (`self_signup_open`) now reads "Konto anlegen" /
|
|
16
|
+
"Create account" (new key `Auth.SIGNUP_SUBMIT_OPEN`); access-code, e-mail-domain and QR signup keep "Einladung
|
|
17
|
+
anfordern" / "Request invitation".
|
|
18
|
+
|
|
3
19
|
## 4.19.0 - UCM-CHAT-8
|
|
4
20
|
|
|
5
21
|
`ChatWorkspace` starts the status, catalogue and both chat-list requests together on mount and on every scope change,
|
package/README.md
CHANGED
|
@@ -18,11 +18,39 @@ The privacy and cookie consent controls and their submitted values remain availa
|
|
|
18
18
|
|
|
19
19
|
## Account page: extra tabs in a navigation group
|
|
20
20
|
|
|
21
|
-
An entry of `AccountPage`'s `extraTabs` (`{ value, label,
|
|
21
|
+
An entry of `AccountPage`'s `extraTabs` (`{ value, label, render, visible? }`) may carry an optional `group` naming one of
|
|
22
22
|
the kit's navigation groups: `my-account` (Profile, Security), `management` (Users, Invite) or `help` (Support). The tab
|
|
23
23
|
then appears in that group after the kit's own tabs, in the order of `extraTabs`, in the desktop sidebar and in the
|
|
24
24
|
phone navigation. Without `group`, or with `more` or an unknown value, it stays in "More" as before.
|
|
25
25
|
|
|
26
|
+
## Account page: app-defined groups
|
|
27
|
+
|
|
28
|
+
Since 4.21.0 `AccountPage` takes an optional `groups` declaration that replaces the kit's three groups:
|
|
29
|
+
`[{ key, label, order?, tabs?, visible? }]`. `label` is the app's text (or `(context) => string`); groups render by
|
|
30
|
+
`order` (array order when absent); `tabs` places the built-in tabs (`profile`, `security`, `users`, `invite`,
|
|
31
|
+
`support`), each still shown only when its own permission check passes; `extraTabs[].group` may name any declared key.
|
|
32
|
+
`visible(context)` (`context` = `{ user, perms, isSuperUser, t }`, as for `extraTabs`) hides a group and makes its tabs
|
|
33
|
+
unreachable, `?tab=` included. Empty groups are hidden; a tab placed in no declared group lands in "More". Without
|
|
34
|
+
`groups` the hub is unchanged.
|
|
35
|
+
|
|
36
|
+
```jsx
|
|
37
|
+
<AccountPage
|
|
38
|
+
groups={[
|
|
39
|
+
{ key: 'personal', label: 'Persönlich', tabs: ['profile', 'security'] },
|
|
40
|
+
{ key: 'collaboration', label: 'Zusammenarbeit', tabs: ['invite'] },
|
|
41
|
+
{ key: 'help', label: 'Hilfe', tabs: ['support'] },
|
|
42
|
+
{ key: 'operations', label: 'Betrieb', tabs: ['users'], visible: ({ user }) => isOperator(user) },
|
|
43
|
+
]}
|
|
44
|
+
extraTabs={[
|
|
45
|
+
{ value: 'subscription', label: 'Abo und Token', group: 'personal', render: () => <Subscription /> },
|
|
46
|
+
{ value: 'teams', label: 'Teams', group: 'collaboration', render: () => <Teams /> },
|
|
47
|
+
{ value: 'all-projects', label: 'Alle Projekte', group: 'operations', render: () => <AllProjects /> },
|
|
48
|
+
]}
|
|
49
|
+
/>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Labels are passed already translated (for example `t('Maana.GROUP_PERSONAL')`), so an app's own DE and EN texts apply.
|
|
53
|
+
|
|
26
54
|
## Users tab: access column and delete
|
|
27
55
|
|
|
28
56
|
With billing in the account page, the user list shows two columns: "Zugang", a short coloured status ("Freigeschaltet",
|
|
@@ -54,7 +82,10 @@ project, import or payment work. Existing pages and the dialog `OnboardingProvid
|
|
|
54
82
|
ignored until it settles. `primaryForm` names a form in the content that the primary button submits natively.
|
|
55
83
|
- `SignUpContent` — the sign-up form of `SignUpPage` (all modes, Turnstile, QR token via `registrationContextToken`).
|
|
56
84
|
`onSubmitted(email)` switches it to the confirmation instruction; remount it (new `key`) to let the person change the
|
|
57
|
-
email. `showProviders` adds Google/Microsoft above the form.
|
|
85
|
+
email. `showProviders` adds Google/Microsoft above the form. `preferredSignupMode` (also on `SignUpPage`, e.g.
|
|
86
|
+
`'self_signup_open'`) shows that mode first and selected when the server offers it; otherwise it is ignored and the
|
|
87
|
+
server order applies. Open self-signup submits with "Konto anlegen" (`Auth.SIGNUP_SUBMIT_OPEN`); the other modes
|
|
88
|
+
keep "Einladung anfordern".
|
|
58
89
|
- `SignupConfirmContent` — the password form of `SignupConfirmPage`. Pass `token` (from the emailed
|
|
59
90
|
`/signup/confirm/?token=…` link, which your app routes) and `onSuccess()`; there is no automatic sign-in, show
|
|
60
91
|
`LoginContent` next.
|
|
@@ -32,6 +32,12 @@ export function resolveSignupModes(authMethods) {
|
|
|
32
32
|
}
|
|
33
33
|
return (authMethods === null || authMethods === void 0 ? void 0 : authMethods.signup) ? ['self_signup_access_code'] : [];
|
|
34
34
|
}
|
|
35
|
+
// An app's preferred mode moves to the front only when the server offers it; the server decides which modes exist.
|
|
36
|
+
export function orderSignupModes(modes, preferredMode) {
|
|
37
|
+
return preferredMode && modes.includes(preferredMode)
|
|
38
|
+
? [preferredMode, ...modes.filter((entry) => entry !== preferredMode)]
|
|
39
|
+
: modes;
|
|
40
|
+
}
|
|
35
41
|
/**
|
|
36
42
|
* The sign-up form shared by SignUpPage and embedded flows: every configured
|
|
37
43
|
* sign-up mode, Turnstile, the QR registration context and the existing
|
|
@@ -39,6 +45,7 @@ export function resolveSignupModes(authMethods) {
|
|
|
39
45
|
*
|
|
40
46
|
* Props:
|
|
41
47
|
* - `registrationContextToken`: the QR token (SignUpPage passes `?rt`).
|
|
48
|
+
* - `preferredSignupMode`: optional available mode to show and select first.
|
|
42
49
|
* - `onModeChange(mode)`: reports the selected sign-up mode.
|
|
43
50
|
* - `onSubmitted(email)`: embedded use. Called after the request succeeded with
|
|
44
51
|
* the email only; the component then shows the confirmation instruction instead
|
|
@@ -49,10 +56,11 @@ export function resolveSignupModes(authMethods) {
|
|
|
49
56
|
* the provider callback URL.
|
|
50
57
|
* The access code, QR token and Turnstile token never leave this component.
|
|
51
58
|
*/
|
|
52
|
-
export function SignUpContent({ registrationContextToken = '', onModeChange, onSubmitted, showProviders = false, continuation, }) {
|
|
59
|
+
export function SignUpContent({ registrationContextToken = '', preferredSignupMode, onModeChange, onSubmitted, showProviders = false, continuation, }) {
|
|
53
60
|
const { t, i18n } = useTranslation();
|
|
54
61
|
const { authMethods } = useContext(AuthContext) || {};
|
|
55
|
-
const
|
|
62
|
+
const serverSignupModes = useMemo(() => resolveSignupModes(authMethods), [authMethods]);
|
|
63
|
+
const signupModes = useMemo(() => orderSignupModes(serverSignupModes, preferredSignupMode), [preferredSignupMode, serverSignupModes]);
|
|
56
64
|
const initialMode = useMemo(() => {
|
|
57
65
|
if (registrationContextToken && signupModes.includes('self_signup_qr')) {
|
|
58
66
|
return 'self_signup_qr';
|
|
@@ -151,5 +159,5 @@ export function SignUpContent({ registrationContextToken = '', onModeChange, onS
|
|
|
151
159
|
}
|
|
152
160
|
return (_jsxs(_Fragment, { children: [successKey && (_jsx(Alert, { severity: "success", sx: SIGN_UP_PAGE_ALERT_SX, children: t(successKey, { email }) })), errorKey && (_jsx(Alert, { severity: "error", sx: SIGN_UP_PAGE_ALERT_SX, children: errorKey })), providersVisible && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsx(SocialLoginButtons, { onProviderClick: handleProviderLogin, providers: socialProviders }), providerTransition && (_jsx(Alert, { severity: "info", sx: SIGN_UP_PROVIDER_ALERT_SX, children: t('Auth.PROVIDER_TRANSITION', { provider: PROVIDER_NAMES[providerTransition] || providerTransition }) })), _jsx(Divider, { sx: SIGN_UP_PROVIDER_DIVIDER_SX, children: t('Auth.LOGIN_OR') })] })), signupModes.length > 1 && (_jsx(Stack, { spacing: 1, sx: { mb: 2 }, children: signupModes.map((entry) => (_jsx(Button, { variant: mode === entry ? 'contained' : 'outlined', onClick: () => setMode(entry), disabled: submitting, fullWidth: true, children: t(MODE_LABELS[entry] || entry, entry) }, entry))) })), _jsxs(Box, { component: "form", onSubmit: handleSubmit, sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsx(TextField, { label: t('Auth.EMAIL_LABEL'), type: "email", required: true, fullWidth: true, value: email, onChange: (e) => setEmail(e.target.value), disabled: submitting }), mode === 'self_signup_access_code' && (_jsx(TextField, { label: t('Auth.ACCESS_CODE_LABEL'), type: "text", required: true, fullWidth: true, value: accessCode, onChange: (e) => setAccessCode(e.target.value), disabled: submitting })), turnstileRequired && (_jsx(TurnstileWidget, { ref: turnstileWidgetRef, siteKey: authMethods.turnstile_site_key, onToken: setTurnstileToken })), _jsx(Button, { type: "submit", variant: "contained", disabled: submitting || Boolean(providerTransition) || (turnstileRequired && !turnstileToken), children: submitting
|
|
153
161
|
? t('Auth.SIGNUP_SUBMITTING')
|
|
154
|
-
: t('Auth.SIGNUP_SUBMIT') })] })] }));
|
|
162
|
+
: t(mode === 'self_signup_open' ? 'Auth.SIGNUP_SUBMIT_OPEN' : 'Auth.SIGNUP_SUBMIT') })] })] }));
|
|
155
163
|
}
|
|
@@ -444,6 +444,12 @@ export const authTranslations = {
|
|
|
444
444
|
"en": "Request invitation",
|
|
445
445
|
"sw": "Omba mwaliko"
|
|
446
446
|
},
|
|
447
|
+
"Auth.SIGNUP_SUBMIT_OPEN": {
|
|
448
|
+
"de": "Konto anlegen",
|
|
449
|
+
"fr": "Créer un compte",
|
|
450
|
+
"en": "Create account",
|
|
451
|
+
"sw": "Fungua akaunti"
|
|
452
|
+
},
|
|
447
453
|
"Auth.SIGNUP_SUBMITTING": {
|
|
448
454
|
"de": "Sende…",
|
|
449
455
|
"fr": "Envoi…",
|
|
@@ -31,8 +31,11 @@ import { useBillingUsersColumn } from '../billing/useBillingUsersColumn';
|
|
|
31
31
|
* `billingOperator({ user, account }) => boolean` (optional, UCM-BILL-10): the app's operator rule for the billing
|
|
32
32
|
* users columns built when `billingUsers` is set (status, badge and the "Ohne Abo" switch). Without it superusers are
|
|
33
33
|
* the operators. A new function on each render only recomputes the columns; it does not refetch the accounts.
|
|
34
|
+
* `groups` (optional): app-defined account navigation groups with `{ key, label, order?, tabs?, visible? }`. Labels
|
|
35
|
+
* may be strings or `(context) => string`; `tabs` assigns built-in tab values, and `visible(context)` can hide a group
|
|
36
|
+
* and its tabs. Without this prop, the default groups and placement are unchanged.
|
|
34
37
|
*/
|
|
35
|
-
export function AccountPage({ userListExtraColumns = [], userListExtraRowActions = [], userListExtraContext = null, userListRefreshTrigger = 0, userListCanEditUser = null, userListShowNewColumn = true, userListShowSuccessfulLoginColumn = true, userListShowRoleColumn = true, userListOnChangeRole = null, userListShowDeleteAction = true, userListCanDeleteUser = null, userListOnDeleteUser = null, showBulkInviteCsvTab = false, bulkInviteCsvProps = {}, extraTabs = [], showProfileStatements = true, billingUsers = false, billingOperator, }) {
|
|
38
|
+
export function AccountPage({ userListExtraColumns = [], userListExtraRowActions = [], userListExtraContext = null, userListRefreshTrigger = 0, userListCanEditUser = null, userListShowNewColumn = true, userListShowSuccessfulLoginColumn = true, userListShowRoleColumn = true, userListOnChangeRole = null, userListShowDeleteAction = true, userListCanDeleteUser = null, userListOnDeleteUser = null, showBulkInviteCsvTab = false, bulkInviteCsvProps = {}, extraTabs = [], showProfileStatements = true, billingUsers = false, billingOperator, groups: groupsProp, }) {
|
|
36
39
|
var _a;
|
|
37
40
|
const { t, i18n } = useTranslation();
|
|
38
41
|
const { user, login, loading } = useContext(AuthContext);
|
|
@@ -62,6 +65,25 @@ export function AccountPage({ userListExtraColumns = [], userListExtraRowActions
|
|
|
62
65
|
const canSendInvites = Boolean(isSuperUser || perms.can_send_invites);
|
|
63
66
|
const canManageAccessCodes = Boolean(isSuperUser || perms.can_manage_access_codes);
|
|
64
67
|
const canManageSignupQr = Boolean(isSuperUser || perms.can_manage_signup_qr);
|
|
68
|
+
const extensionContext = { user, perms, isSuperUser, t };
|
|
69
|
+
const declaredGroups = useMemo(() => {
|
|
70
|
+
if (!Array.isArray(groupsProp))
|
|
71
|
+
return null;
|
|
72
|
+
const definitions = groupsProp
|
|
73
|
+
.filter((group) => group && typeof group.key === 'string' && group.key.length > 0)
|
|
74
|
+
.map((group, index) => (Object.assign(Object.assign({}, group), { index, sortOrder: Number.isFinite(group.order) ? group.order : index, isVisible: typeof group.visible === 'function' ? Boolean(group.visible(extensionContext)) : true })))
|
|
75
|
+
.sort((left, right) => left.sortOrder - right.sortOrder || left.index - right.index);
|
|
76
|
+
const builtInAssignments = new Map();
|
|
77
|
+
definitions.forEach((group) => {
|
|
78
|
+
(Array.isArray(group.tabs) ? group.tabs : []).forEach((value) => {
|
|
79
|
+
if (['profile', 'security', 'users', 'invite', 'support'].includes(value)
|
|
80
|
+
&& !builtInAssignments.has(value)) {
|
|
81
|
+
builtInAssignments.set(value, group.key);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
return { definitions, builtInAssignments };
|
|
86
|
+
}, [groupsProp, user, perms, isSuperUser, t]);
|
|
65
87
|
const handleTabChange = (_event, newValue) => {
|
|
66
88
|
setSearchParams({ tab: newValue });
|
|
67
89
|
};
|
|
@@ -101,7 +123,6 @@ export function AccountPage({ userListExtraColumns = [], userListExtraRowActions
|
|
|
101
123
|
const tabs = useMemo(() => {
|
|
102
124
|
if (!user)
|
|
103
125
|
return [];
|
|
104
|
-
const extensionContext = { user, perms, isSuperUser, t };
|
|
105
126
|
const list = [
|
|
106
127
|
{ value: 'profile', label: t('Account.TAB_PROFILE', 'Profile') },
|
|
107
128
|
{ value: 'security', label: t('Account.TAB_SECURITY', 'Security') },
|
|
@@ -116,19 +137,65 @@ export function AccountPage({ userListExtraColumns = [], userListExtraRowActions
|
|
|
116
137
|
if (isSuperUser || perms.can_view_support) {
|
|
117
138
|
list.push({ value: 'support', label: t('Account.TAB_SUPPORT', 'Support') });
|
|
118
139
|
}
|
|
140
|
+
if (declaredGroups) {
|
|
141
|
+
for (let index = list.length - 1; index >= 0; index -= 1) {
|
|
142
|
+
const assignedGroupKey = declaredGroups.builtInAssignments.get(list[index].value);
|
|
143
|
+
const assignedGroup = declaredGroups.definitions.find((group) => group.key === assignedGroupKey);
|
|
144
|
+
if (assignedGroup && !assignedGroup.isVisible)
|
|
145
|
+
list.splice(index, 1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
119
148
|
extraTabs.forEach((tab) => {
|
|
120
149
|
if (!(tab === null || tab === void 0 ? void 0 : tab.value) || !(tab === null || tab === void 0 ? void 0 : tab.label))
|
|
121
150
|
return;
|
|
122
151
|
const isVisible = typeof tab.visible === 'function' ? tab.visible(extensionContext) : true;
|
|
152
|
+
const declaredGroup = declaredGroups === null || declaredGroups === void 0 ? void 0 : declaredGroups.definitions.find((group) => group.key === tab.group);
|
|
153
|
+
const collidesWithBuiltIn = declaredGroups
|
|
154
|
+
&& ['profile', 'security', 'users', 'invite', 'support'].includes(tab.value);
|
|
155
|
+
if (declaredGroups && (collidesWithBuiltIn || (declaredGroup && !declaredGroup.isVisible)))
|
|
156
|
+
return;
|
|
123
157
|
if (isVisible && !list.some((entry) => entry.value === tab.value)) {
|
|
124
|
-
//
|
|
125
|
-
const group =
|
|
158
|
+
// Legacy apps may join the three built-in groups; declared apps may use any declared group key.
|
|
159
|
+
const group = declaredGroups
|
|
160
|
+
? (declaredGroup ? tab.group : undefined)
|
|
161
|
+
: (['my-account', 'management', 'help'].includes(tab.group) ? tab.group : undefined);
|
|
126
162
|
list.push(Object.assign({ value: tab.value, label: typeof tab.label === 'function' ? tab.label(extensionContext) : tab.label }, (group ? { group } : {})));
|
|
127
163
|
}
|
|
128
164
|
});
|
|
129
165
|
return list;
|
|
130
|
-
}, [user, perms, t, isSuperUser, extraTabs, canViewUsers, canViewInvite]);
|
|
166
|
+
}, [user, perms, t, isSuperUser, extraTabs, canViewUsers, canViewInvite, declaredGroups]);
|
|
131
167
|
const groups = useMemo(() => {
|
|
168
|
+
if (declaredGroups) {
|
|
169
|
+
const placedValues = new Set();
|
|
170
|
+
const mappedGroups = declaredGroups.definitions
|
|
171
|
+
.filter((group) => group.isVisible)
|
|
172
|
+
.map((group) => {
|
|
173
|
+
const builtInValues = (Array.isArray(group.tabs) ? group.tabs : [])
|
|
174
|
+
.filter((value) => declaredGroups.builtInAssignments.get(value) === group.key);
|
|
175
|
+
const items = [
|
|
176
|
+
...builtInValues.map((value) => tabs.find((tab) => tab.value === value)).filter(Boolean),
|
|
177
|
+
...tabs.filter((tab) => tab.group === group.key),
|
|
178
|
+
].map((tab) => ({ key: tab.value, label: tab.label }));
|
|
179
|
+
items.forEach((item) => placedValues.add(item.key));
|
|
180
|
+
return {
|
|
181
|
+
key: group.key,
|
|
182
|
+
label: typeof group.label === 'function' ? group.label(extensionContext) : group.label,
|
|
183
|
+
items,
|
|
184
|
+
};
|
|
185
|
+
})
|
|
186
|
+
.filter((group) => group.items.length > 0);
|
|
187
|
+
const extraItems = tabs
|
|
188
|
+
.filter((tab) => !placedValues.has(tab.value))
|
|
189
|
+
.map((tab) => ({ key: tab.value, label: tab.label }));
|
|
190
|
+
if (extraItems.length > 0) {
|
|
191
|
+
mappedGroups.push({
|
|
192
|
+
key: 'more',
|
|
193
|
+
label: t('Account.GROUP_MORE', 'More'),
|
|
194
|
+
items: extraItems,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return mappedGroups;
|
|
198
|
+
}
|
|
132
199
|
const groupDefinitions = [
|
|
133
200
|
{
|
|
134
201
|
key: 'my-account',
|
|
@@ -168,7 +235,7 @@ export function AccountPage({ userListExtraColumns = [], userListExtraRowActions
|
|
|
168
235
|
});
|
|
169
236
|
}
|
|
170
237
|
return mappedGroups.filter((group) => group.items.length > 0);
|
|
171
|
-
}, [tabs, t]);
|
|
238
|
+
}, [tabs, t, declaredGroups, user, perms, isSuperUser]);
|
|
172
239
|
// 4. Loading & Auth Checks
|
|
173
240
|
if (loading) {
|
|
174
241
|
return (_jsx(Box, { sx: { display: 'flex', justifyContent: 'center', mt: 10 }, children: _jsx(CircularProgress, {}) }));
|
package/dist/pages/SignUpPage.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Box, Button, Typography } from '@mui/material';
|
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { NarrowPage } from '../layout/PageLayout';
|
|
7
7
|
import { AuthContext } from '../auth/AuthContext';
|
|
8
|
-
import { SIGN_UP_PAGE_ALERT_SX, SignUpContent, resolveSignupModes, } from '../components/SignUpContent';
|
|
8
|
+
import { SIGN_UP_PAGE_ALERT_SX, SignUpContent, orderSignupModes, resolveSignupModes, } from '../components/SignUpContent';
|
|
9
9
|
export { SIGN_UP_PAGE_ALERT_SX };
|
|
10
10
|
const MODE_SUBTITLES = {
|
|
11
11
|
self_signup_access_code: 'Auth.PAGE_SIGNUP_SUBTITLE_ACCESS_CODE',
|
|
@@ -15,12 +15,13 @@ const MODE_SUBTITLES = {
|
|
|
15
15
|
};
|
|
16
16
|
// The form and its sign-up logic live in SignUpContent (UCM-AUTH-14); the page
|
|
17
17
|
// keeps the route framing, the `?rt` QR token source and the login link.
|
|
18
|
-
export function SignUpPage() {
|
|
18
|
+
export function SignUpPage({ preferredSignupMode }) {
|
|
19
19
|
const navigate = useNavigate();
|
|
20
20
|
const location = useLocation();
|
|
21
21
|
const { t } = useTranslation();
|
|
22
22
|
const { authMethods } = useContext(AuthContext);
|
|
23
|
-
const
|
|
23
|
+
const serverSignupModes = useMemo(() => resolveSignupModes(authMethods), [authMethods]);
|
|
24
|
+
const signupModes = useMemo(() => orderSignupModes(serverSignupModes, preferredSignupMode), [preferredSignupMode, serverSignupModes]);
|
|
24
25
|
const query = new URLSearchParams(location.search);
|
|
25
26
|
const tokenFromUrl = query.get('rt') || '';
|
|
26
27
|
const [mode, setMode] = useState(() => (tokenFromUrl && signupModes.includes('self_signup_qr')
|
|
@@ -35,5 +36,5 @@ export function SignUpPage() {
|
|
|
35
36
|
const handleGoToLogin = () => {
|
|
36
37
|
navigate('/login');
|
|
37
38
|
};
|
|
38
|
-
return (_jsxs(NarrowPage, { title: t('Auth.LOGIN_SIGNUP_BUTTON'), subtitle: pageSubtitle, children: [_jsx("title", { children: `${t('App.NAME')} – ${t('Auth.LOGIN_SIGNUP_BUTTON')}` }), _jsx(SignUpContent, { registrationContextToken: tokenFromUrl, onModeChange: setMode }), _jsx(Box, { sx: { mt: 3 }, children: _jsxs(Typography, { variant: "body2", children: [t('Auth.SIGNUP_ALREADY_HAVE_ACCOUNT'), ' ', _jsx(Button, { onClick: handleGoToLogin, variant: "text", size: "small", children: t('Auth.SIGNUP_GO_TO_LOGIN') })] }) })] }));
|
|
39
|
+
return (_jsxs(NarrowPage, { title: t('Auth.LOGIN_SIGNUP_BUTTON'), subtitle: pageSubtitle, children: [_jsx("title", { children: `${t('App.NAME')} – ${t('Auth.LOGIN_SIGNUP_BUTTON')}` }), _jsx(SignUpContent, { registrationContextToken: tokenFromUrl, preferredSignupMode: preferredSignupMode, onModeChange: setMode }), _jsx(Box, { sx: { mt: 3 }, children: _jsxs(Typography, { variant: "body2", children: [t('Auth.SIGNUP_ALREADY_HAVE_ACCOUNT'), ' ', _jsx(Button, { onClick: handleGoToLogin, variant: "text", size: "small", children: t('Auth.SIGNUP_GO_TO_LOGIN') })] }) })] }));
|
|
39
40
|
}
|