ferst-core 0.17.0 → 0.18.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/bin/ferst-modules.mjs +8 -13
- package/components/BlockRenderer.astro +0 -2
- package/components/SiteHeader.astro +1391 -1378
- package/components/islands/MembersAccount.tsx +395 -392
- package/content/blocks.ts +2 -19
- package/content/cookies.ts +2 -3
- package/content/recipe-questions.ts +0 -1
- package/examples/recipes.ts +0 -1
- package/lib/members-account.ts +283 -276
- package/lib/members.ts +21 -48
- package/package.json +80 -80
- package/components/recipes/MembersContent.astro +0 -176
package/lib/members-account.ts
CHANGED
|
@@ -1,276 +1,283 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The members' account page (`/account`): signing in with an emailed code, and the member's own
|
|
3
|
-
* details. The page is a React island (components/islands/MembersAccount.tsx); every decision it
|
|
4
|
-
* makes from the members service's answers is here, pure, so it's unit-tested.
|
|
5
|
-
*
|
|
6
|
-
* The service is the site's own `/ferst-api/members/…` (lib/members), same-origin, JSON. There is no
|
|
7
|
-
* password, ever: a code is sent to the visitor's email, and the same code signs them up when
|
|
8
|
-
* they're new and the organisation lets anyone join.
|
|
9
|
-
*/
|
|
10
|
-
import { ACCOUNT_PATH, MEMBERS_API, MEMBERS_ME, type MembersAnswer } from './members';
|
|
11
|
-
|
|
12
|
-
export const MEMBERS_SIGN_IN = `${MEMBERS_API}/sign-in`;
|
|
13
|
-
export const MEMBERS_START = `${MEMBERS_API}/sign-in/start`;
|
|
14
|
-
export const MEMBERS_VERIFY = `${MEMBERS_API}/sign-in/verify`;
|
|
15
|
-
export const MEMBERS_SIGN_OUT = `${MEMBERS_API}/sign-out`;
|
|
16
|
-
export const MEMBERS_JOIN = `${MEMBERS_API}/join`;
|
|
17
|
-
export { MEMBERS_ME };
|
|
18
|
-
|
|
19
|
-
/** Who can join the organisation: anyone, only people it invites, or anyone it approves. */
|
|
20
|
-
export type Joining = 'open' | 'invite' | 'approval';
|
|
21
|
-
/** A member's standing. A guest booked without joining; pending waits for the organisation's yes. */
|
|
22
|
-
export type MemberStatus = 'active' | 'pending' | 'guest' | 'invited' | 'suspended' | 'removed';
|
|
23
|
-
|
|
24
|
-
export interface Member {
|
|
25
|
-
id: string;
|
|
26
|
-
email: string;
|
|
27
|
-
displayName: string | null;
|
|
28
|
-
status: MemberStatus;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** What the sign-in card shows before anyone signs in. */
|
|
32
|
-
export interface SignInCard {
|
|
33
|
-
org: string;
|
|
34
|
-
joining: Joining;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
export
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
| { kind: '
|
|
105
|
-
|
|
106
|
-
| { kind: '
|
|
107
|
-
| { kind: '
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
| { kind: '
|
|
130
|
-
| { kind: '
|
|
131
|
-
| { kind: '
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
if (status ===
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
export
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The members' account page (`/account`): signing in with an emailed code, and the member's own
|
|
3
|
+
* details. The page is a React island (components/islands/MembersAccount.tsx); every decision it
|
|
4
|
+
* makes from the members service's answers is here, pure, so it's unit-tested.
|
|
5
|
+
*
|
|
6
|
+
* The service is the site's own `/ferst-api/members/…` (lib/members), same-origin, JSON. There is no
|
|
7
|
+
* password, ever: a code is sent to the visitor's email, and the same code signs them up when
|
|
8
|
+
* they're new and the organisation lets anyone join.
|
|
9
|
+
*/
|
|
10
|
+
import { ACCOUNT_PATH, MEMBERS_API, MEMBERS_ME, type MembersAnswer } from './members';
|
|
11
|
+
|
|
12
|
+
export const MEMBERS_SIGN_IN = `${MEMBERS_API}/sign-in`;
|
|
13
|
+
export const MEMBERS_START = `${MEMBERS_API}/sign-in/start`;
|
|
14
|
+
export const MEMBERS_VERIFY = `${MEMBERS_API}/sign-in/verify`;
|
|
15
|
+
export const MEMBERS_SIGN_OUT = `${MEMBERS_API}/sign-out`;
|
|
16
|
+
export const MEMBERS_JOIN = `${MEMBERS_API}/join`;
|
|
17
|
+
export { MEMBERS_ME };
|
|
18
|
+
|
|
19
|
+
/** Who can join the organisation: anyone, only people it invites, or anyone it approves. */
|
|
20
|
+
export type Joining = 'open' | 'invite' | 'approval';
|
|
21
|
+
/** A member's standing. A guest booked without joining; pending waits for the organisation's yes. */
|
|
22
|
+
export type MemberStatus = 'active' | 'pending' | 'guest' | 'invited' | 'suspended' | 'removed';
|
|
23
|
+
|
|
24
|
+
export interface Member {
|
|
25
|
+
id: string;
|
|
26
|
+
email: string;
|
|
27
|
+
displayName: string | null;
|
|
28
|
+
status: MemberStatus;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** What the sign-in card shows before anyone signs in. */
|
|
32
|
+
export interface SignInCard {
|
|
33
|
+
org: string;
|
|
34
|
+
joining: Joining;
|
|
35
|
+
/** The organisation's free members area is full: members sign in, nobody new joins for now. */
|
|
36
|
+
joiningPaused: boolean;
|
|
37
|
+
termsUrl: string | null;
|
|
38
|
+
privacyUrl: string | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const JOININGS: readonly Joining[] = ['open', 'invite', 'approval'];
|
|
42
|
+
const STATUSES: readonly MemberStatus[] = ['active', 'pending', 'guest', 'invited', 'suspended', 'removed'];
|
|
43
|
+
|
|
44
|
+
const str = (v: unknown): string | null => (typeof v === 'string' && v.trim() ? v : null);
|
|
45
|
+
const joiningOf = (v: unknown): Joining => (JOININGS.includes(v as Joining) ? (v as Joining) : 'open');
|
|
46
|
+
/** Only a link to a web page is shown (the portal accepts https: links alone). */
|
|
47
|
+
const webLink = (v: unknown): string | null => {
|
|
48
|
+
const s = str(v);
|
|
49
|
+
return s && /^https:\/\//i.test(s) ? s : null;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** A member from the service's answer, or null when the answer has none. */
|
|
53
|
+
export function readMember(v: unknown): Member | null {
|
|
54
|
+
if (!v || typeof v !== 'object') return null;
|
|
55
|
+
const m = v as Record<string, unknown>;
|
|
56
|
+
const email = str(m.email);
|
|
57
|
+
if (!email || !STATUSES.includes(m.status as MemberStatus)) return null;
|
|
58
|
+
return { id: str(m.id) ?? '', email, displayName: str(m.display_name)?.trim() ?? null, status: m.status as MemberStatus };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The organisation's name in an answer (`org: {name}`). */
|
|
62
|
+
const orgOf = (body: Record<string, unknown>): string => str((body.org as { name?: unknown } | undefined)?.name) ?? 'this organisation';
|
|
63
|
+
|
|
64
|
+
/** Where the page is when it can't talk to the service. */
|
|
65
|
+
type Unreachable = { kind: 'local' } | { kind: 'unavailable' };
|
|
66
|
+
/** No JSON answer at all: on the author's own computer the site has no /ferst-api; elsewhere it's down. */
|
|
67
|
+
const unreachable = (local: boolean): Unreachable => (local ? { kind: 'local' } : { kind: 'unavailable' });
|
|
68
|
+
|
|
69
|
+
/** The answer to `GET /members/me`: who is signed in, nobody, or the service can't say. */
|
|
70
|
+
export type MeView =
|
|
71
|
+
| { kind: 'member'; member: Member; org: string; joining: Joining }
|
|
72
|
+
| { kind: 'signed-out' }
|
|
73
|
+
| Unreachable;
|
|
74
|
+
|
|
75
|
+
export function readMe(answer: MembersAnswer | null, local = false): MeView {
|
|
76
|
+
if (!answer || !answer.body) return unreachable(local);
|
|
77
|
+
if (answer.status === 401) return { kind: 'signed-out' };
|
|
78
|
+
const member = answer.status === 200 ? readMember(answer.body.member) : null;
|
|
79
|
+
if (!member) return { kind: 'unavailable' };
|
|
80
|
+
return { kind: 'member', member, org: orgOf(answer.body), joining: joiningOf(answer.body.joining) };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The answer to `GET /members/sign-in`: the card, or the service can't say (`module_off` included). */
|
|
84
|
+
export type CardView = { kind: 'card'; card: SignInCard } | Unreachable;
|
|
85
|
+
|
|
86
|
+
export function readCard(answer: MembersAnswer | null, local = false): CardView {
|
|
87
|
+
if (!answer || !answer.body) return unreachable(local);
|
|
88
|
+
if (answer.status !== 200) return { kind: 'unavailable' };
|
|
89
|
+
const b = answer.body;
|
|
90
|
+
return { kind: 'card', card: { org: orgOf(b), joining: joiningOf(b.joining), joiningPaused: b.joining_paused === true, termsUrl: webLink(b.terms_url), privacyUrl: webLink(b.privacy_url) } };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The organisation asks people who join to agree to its terms or privacy notice. */
|
|
94
|
+
export const hasTerms = (card: SignInCard | null): boolean => Boolean(card && (card.termsUrl || card.privacyUrl));
|
|
95
|
+
|
|
96
|
+
/** The answer to `POST /members/sign-in/start`: always 200 with a sign-in id, whoever asks. */
|
|
97
|
+
export function readStart(answer: MembersAnswer | null): string | null {
|
|
98
|
+
if (!answer || answer.status !== 200 || !answer.body) return null;
|
|
99
|
+
return str(answer.body.signin_id);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** The answer to `POST /members/sign-in/verify`. */
|
|
103
|
+
export type VerifyOutcome =
|
|
104
|
+
| { kind: 'signed-in'; member: Member; welcome: string | null }
|
|
105
|
+
/** A sign-up confirmed, its code having been sent again: a sign-in code follows, same sign-in. */
|
|
106
|
+
| { kind: 'new-code' }
|
|
107
|
+
| { kind: 'wrong-code'; triesLeft: number | null }
|
|
108
|
+
| { kind: 'expired' }
|
|
109
|
+
| { kind: 'try-again' };
|
|
110
|
+
|
|
111
|
+
export function readVerify(answer: MembersAnswer | null): VerifyOutcome {
|
|
112
|
+
if (!answer || !answer.body) return { kind: 'try-again' };
|
|
113
|
+
const { status, body } = answer;
|
|
114
|
+
if (status === 200) {
|
|
115
|
+
const member = readMember(body.member);
|
|
116
|
+
return member ? { kind: 'signed-in', member, welcome: str(body.welcome) } : { kind: 'try-again' };
|
|
117
|
+
}
|
|
118
|
+
if (status === 409 && body.error === 'new_code_sent') return { kind: 'new-code' };
|
|
119
|
+
if (status === 400 && body.error === 'wrong_code') {
|
|
120
|
+
const left = typeof body.tries_left === 'number' && body.tries_left >= 0 ? Math.floor(body.tries_left) : null;
|
|
121
|
+
return { kind: 'wrong-code', triesLeft: left };
|
|
122
|
+
}
|
|
123
|
+
if (status === 410) return { kind: 'expired' };
|
|
124
|
+
return { kind: 'try-again' };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** The answer to `POST /members/join` (a signed-in guest joins). */
|
|
128
|
+
export type JoinOutcome =
|
|
129
|
+
| { kind: 'joined'; member: Member; welcome: string | null }
|
|
130
|
+
| { kind: 'agree' }
|
|
131
|
+
| { kind: 'invite-only' }
|
|
132
|
+
/** The organisation isn't taking new members just now (its free members area is full). */
|
|
133
|
+
| { kind: 'paused' }
|
|
134
|
+
| { kind: 'signed-out' }
|
|
135
|
+
| { kind: 'try-again' };
|
|
136
|
+
|
|
137
|
+
export function readJoin(answer: MembersAnswer | null): JoinOutcome {
|
|
138
|
+
if (!answer || !answer.body) return answer?.status === 401 ? { kind: 'signed-out' } : { kind: 'try-again' };
|
|
139
|
+
const { status, body } = answer;
|
|
140
|
+
if (status === 200) {
|
|
141
|
+
const member = readMember(body.member);
|
|
142
|
+
return member ? { kind: 'joined', member, welcome: str(body.welcome) } : { kind: 'try-again' };
|
|
143
|
+
}
|
|
144
|
+
if (status === 401) return { kind: 'signed-out' };
|
|
145
|
+
if (status === 400 && body.error === 'agree_required') return { kind: 'agree' };
|
|
146
|
+
if (status === 403 && body.error === 'not_for_you') return { kind: 'invite-only' };
|
|
147
|
+
if (status === 403 && body.error === 'joining_paused') return { kind: 'paused' };
|
|
148
|
+
return { kind: 'try-again' };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The answer to a change with no body to read (`DELETE /members/me`, `POST /members/sign-out`). */
|
|
152
|
+
export function readDone(answer: MembersAnswer | null): 'done' | 'signed-out' | 'try-again' {
|
|
153
|
+
if (!answer) return 'try-again';
|
|
154
|
+
if (answer.status === 204 || answer.status === 200) return 'done';
|
|
155
|
+
if (answer.status === 401) return 'signed-out';
|
|
156
|
+
return 'try-again';
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** The answer to `PATCH /members/me`. */
|
|
160
|
+
export function readRename(answer: MembersAnswer | null): { kind: 'saved'; member: Member } | { kind: 'signed-out' } | { kind: 'invalid' } | { kind: 'try-again' } {
|
|
161
|
+
if (!answer) return { kind: 'try-again' };
|
|
162
|
+
if (answer.status === 401) return { kind: 'signed-out' };
|
|
163
|
+
if (answer.status === 400) return { kind: 'invalid' };
|
|
164
|
+
const member = answer.status === 200 ? readMember(answer.body?.member) : null;
|
|
165
|
+
return member ? { kind: 'saved', member } : { kind: 'try-again' };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Where to go once signed in: `?next=` when it's a page of this same site, else nowhere (stay on the
|
|
170
|
+
* account page). Never another site (`//elsewhere`, `https://…`, `/\elsewhere`), never the account
|
|
171
|
+
* page itself, never the members service.
|
|
172
|
+
*/
|
|
173
|
+
export function safeNext(next: string | null | undefined): string | null {
|
|
174
|
+
if (typeof next !== 'string' || !next.startsWith('/') || next.startsWith('//')) return null;
|
|
175
|
+
// Browsers read a backslash as a slash, and drop tabs and newlines: none of them belong here.
|
|
176
|
+
if (/[\\\u0000-\u001f\u007f]/.test(next)) return null;
|
|
177
|
+
const here = 'https://site.invalid';
|
|
178
|
+
let url: URL;
|
|
179
|
+
try {
|
|
180
|
+
url = new URL(next, here);
|
|
181
|
+
} catch {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
if (url.origin !== here) return null;
|
|
185
|
+
const path = url.pathname.replace(/\/+$/, '') || '/';
|
|
186
|
+
if (path === ACCOUNT_PATH || path.startsWith(`${ACCOUNT_PATH}/`) || path.startsWith('/ferst-api')) return null;
|
|
187
|
+
return url.pathname + url.search + url.hash;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** An email address worth sending a code to (the service decides the rest). */
|
|
191
|
+
export function looksLikeEmail(value: string): boolean {
|
|
192
|
+
const v = value.trim();
|
|
193
|
+
return v.length <= 254 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** A code as typed (spaces and dashes dropped), or null when it can't be one: 4 to 8 digits. */
|
|
197
|
+
export function cleanCode(value: string): string | null {
|
|
198
|
+
const v = value.replace(/[\s-]/g, '');
|
|
199
|
+
return /^\d{4,8}$/.test(v) ? v : null;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** A name a member can give themselves: 1 to 60 characters once trimmed. */
|
|
203
|
+
export function cleanName(value: string): string | null {
|
|
204
|
+
const v = value.trim();
|
|
205
|
+
return v.length >= 1 && v.length <= 60 ? v : null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** A guest may join unless the organisation only lets in people it invites. */
|
|
209
|
+
export const canJoin = (member: Member, joining: Joining): boolean => member.status === 'guest' && joining !== 'invite';
|
|
210
|
+
|
|
211
|
+
/** "Sam Hill (sam@example.com)", or the email alone when they've no name yet. */
|
|
212
|
+
export function signedInAs(member: Member): string {
|
|
213
|
+
return member.displayName ? `${member.displayName} (${member.email})` : member.email;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** The words for the page, in one place: plain and warm, and never about the tools behind it. */
|
|
217
|
+
export const ACCOUNT_TEXT = {
|
|
218
|
+
title: 'Your account',
|
|
219
|
+
loading: 'Opening your account…',
|
|
220
|
+
noScript: 'Signing in needs JavaScript, which is switched off in this browser.',
|
|
221
|
+
local: 'Sign-in works on the published site.',
|
|
222
|
+
unavailable: 'Signing in isn’t available just now. Please try again later.',
|
|
223
|
+
signInTitle: (org: string, joining: Joining, paused = false) => (joining === 'invite' || paused ? `Sign in to ${org}` : `Sign in or join ${org}`),
|
|
224
|
+
signInIntro: (org: string, joining: Joining, paused = false) => {
|
|
225
|
+
const base = 'Enter your email and we’ll send you a code to sign in. No password needed.';
|
|
226
|
+
if (paused) return `${base} ${org} isn’t taking new members just now.`;
|
|
227
|
+
if (joining === 'open') return `${base} New here? The same code makes you a member.`;
|
|
228
|
+
if (joining === 'approval') return `${base} New here? You can ask to join, and ${org} will let you in.`;
|
|
229
|
+
return `${base} Joining ${org} is by invitation.`;
|
|
230
|
+
},
|
|
231
|
+
email: 'Email',
|
|
232
|
+
emailInvalid: 'Enter your email address, like name@example.com.',
|
|
233
|
+
agree: (org: string, card: SignInCard) =>
|
|
234
|
+
`I agree to ${org}’s ${[card.termsUrl && 'terms', card.privacyUrl && 'privacy notice'].filter(Boolean).join(' and ')}`,
|
|
235
|
+
agreeNeeded: 'Please tick the box to agree first.',
|
|
236
|
+
continue: 'Continue',
|
|
237
|
+
codeTitle: 'Check your email',
|
|
238
|
+
codeSent: (email: string) => `We’ve sent a code to ${email}. Enter it here.`,
|
|
239
|
+
codeHint: 'It can take a minute to arrive. If it hasn’t, check your junk folder.',
|
|
240
|
+
code: 'Code',
|
|
241
|
+
codeInvalid: 'Enter the code from the email: numbers only.',
|
|
242
|
+
signIn: 'Sign in',
|
|
243
|
+
newCode: 'Send a new code',
|
|
244
|
+
newCodeSent: 'We’ve sent a new code.',
|
|
245
|
+
otherEmail: 'Use a different email',
|
|
246
|
+
wrongCode: (left: number | null) =>
|
|
247
|
+
left === null ? 'That code isn’t right.' : left > 0 ? `That code isn’t right. ${left} ${left === 1 ? 'try' : 'tries'} left.` : 'That code isn’t right, and there are no tries left. Send a new one.',
|
|
248
|
+
expired: 'That code has expired. Send a new one.',
|
|
249
|
+
newCodeToFinish: 'Thanks. We’ve sent you a new code to finish signing in.',
|
|
250
|
+
tryAgain: 'Signing in isn’t working just now. Please try again in a moment.',
|
|
251
|
+
signedInAs: (member: Member) => `Signed in as ${signedInAs(member)}`,
|
|
252
|
+
status: (member: Member, org: string, joining: Joining) => {
|
|
253
|
+
if (member.status === 'pending') return `Thanks for joining. ${org} will let you in shortly.`;
|
|
254
|
+
if (member.status === 'guest') {
|
|
255
|
+
return joining === 'invite' ? `You’ve booked with ${org}. Joining is by invitation.` : `You’ve booked with ${org}, but haven’t joined.`;
|
|
256
|
+
}
|
|
257
|
+
return `You’re a member of ${org}.`;
|
|
258
|
+
},
|
|
259
|
+
join: (org: string) => `Join ${org}`,
|
|
260
|
+
inviteOnly: 'Joining is by invitation only.',
|
|
261
|
+
paused: (org: string) => `${org} isn’t taking new members just now.`,
|
|
262
|
+
back: 'Back to the page you were on',
|
|
263
|
+
nameTitle: 'Your name',
|
|
264
|
+
name: 'Your name',
|
|
265
|
+
nameHint: 'How the site greets you.',
|
|
266
|
+
nameInvalid: 'Your name needs 1 to 60 characters.',
|
|
267
|
+
saveName: 'Save name',
|
|
268
|
+
nameSaved: 'Saved.',
|
|
269
|
+
signOut: 'Sign out',
|
|
270
|
+
signedOut: 'You’ve signed out.',
|
|
271
|
+
signInAgain: 'Please sign in again.',
|
|
272
|
+
deleteTitle: 'Delete my account',
|
|
273
|
+
deleteOpen: 'Delete my account',
|
|
274
|
+
deleteWarning: (org: string) => `This removes your account with ${org}: you’re signed out, and your details are deleted. It can’t be undone.`,
|
|
275
|
+
deleteConfirm: 'Type “delete” to confirm',
|
|
276
|
+
deleteGo: 'Delete my account for good',
|
|
277
|
+
deleteKeep: 'Keep my account',
|
|
278
|
+
deleted: 'Your account has been deleted.',
|
|
279
|
+
deleteLater: 'This can’t be done just now. Please try again later.',
|
|
280
|
+
opensNewTab: '(opens in a new tab)',
|
|
281
|
+
terms: 'Terms',
|
|
282
|
+
privacy: 'Privacy notice',
|
|
283
|
+
} as const;
|