fix: clarify the confirmation page and collect first and last names
The confirmation told volunteers an email was queued and to open "this signup." It now says the email is on the way and the link cancels or switches shifts. The public form asks for a first and last name so the stored name stays one person.
This commit is contained in:
1 parent
03da30dbbc
commit
322c575fcb
11 files changed
+126
-26
No files matched your search
@@ -1519,6 +1519,8 @@ function isAttendanceMark(value: string): value is AttendanceMark {
|
||||
function signupValuesFrom(body: Record<string, unknown>): SignupValues {
|
||||
return {
|
||||
name: textField(body, 'name'),
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
email: textField(body, 'email'),
|
||||
phone: textField(body, 'phone'),
|
||||
notes: textField(body, 'notes'),
|
||||
|
||||
+31
-8
@@ -288,23 +288,23 @@ export function ConfirmationPage(props: {
|
||||
<h1>{props.cancelled ? 'This signup is cancelled' : "You're signed up"}</h1>
|
||||
<p>
|
||||
{props.cancelled
|
||||
? `${props.name ? `${props.name} is no longer signed up for ` : 'This signup is no longer for '}${props.shift.role}.`
|
||||
: `${props.name ? `${props.name} is signed up for ` : 'This signup is for '}${props.shift.role}.`}
|
||||
? `${props.name ? `${props.name} is no longer on the ` : 'This signup is no longer for the '}${props.shift.role} shift.`
|
||||
: `${props.name ? `${props.name} is on the ` : 'This signup is for the '}${props.shift.role} shift.`}
|
||||
</p>
|
||||
<ShiftWhen shift={props.shift} />
|
||||
{props.managePath ? (
|
||||
<>
|
||||
<p>
|
||||
{props.cancelled
|
||||
? 'A cancellation email is queued. This link still opens the cancelled signup.'
|
||||
: 'A confirmation email is queued. Save this link too, in case the email is delayed. It opens this signup, where you can cancel it or switch it to another open shift.'}
|
||||
? 'A cancellation email is on the way. The link below still opens this cancelled signup.'
|
||||
: 'A confirmation email is on the way. Save the link below in case the email is late. Use it to cancel or switch to a different shift.'}
|
||||
</p>
|
||||
<p>
|
||||
<a href={props.managePath}>Open this signup</a>
|
||||
<a href={props.managePath}>{props.cancelled ? 'View this signup' : 'Cancel or switch shifts'}</a>
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
<p>If you just signed up, the link stays in this browser for a few minutes. A confirmation email is queued.</p>
|
||||
<p>If you just signed up, the link stays in this browser for a few minutes. A confirmation email is on the way.</p>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
@@ -329,7 +329,7 @@ export function ManagePage(props: {
|
||||
return (
|
||||
<>
|
||||
<h1>Your signup</h1>
|
||||
<p class="status">{signup.status === 'confirmed' ? 'Confirmed' : 'Cancelled'}</p>
|
||||
<p class={signup.status === 'confirmed' ? 'status is-confirmed' : 'status'}>{signup.status === 'confirmed' ? 'Confirmed' : 'Cancelled'}</p>
|
||||
<p>{signup.eventTitle}</p>
|
||||
<h2>{signup.role}</h2>
|
||||
<p class="when">
|
||||
@@ -739,7 +739,28 @@ function SignupForm(props: { config: AppConfig; shiftId: number; form: SignupFor
|
||||
<input name="company_website" type="text" tabindex={-1} autocomplete="off" value="" />
|
||||
</label>
|
||||
</div>
|
||||
<Field id="signup-name" label="Name" name="name" type="text" value={form.values.name} error={errors.name} autoComplete="name" />
|
||||
<div class="name-pair">
|
||||
<Field
|
||||
id="signup-firstName"
|
||||
label="First name"
|
||||
name="first_name"
|
||||
type="text"
|
||||
value={form.values.firstName}
|
||||
error={errors.firstName}
|
||||
autoComplete="given-name"
|
||||
required
|
||||
/>
|
||||
<Field
|
||||
id="signup-lastName"
|
||||
label="Last name"
|
||||
name="last_name"
|
||||
type="text"
|
||||
value={form.values.lastName}
|
||||
error={errors.lastName}
|
||||
autoComplete="family-name"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<Field id="signup-email" label="Email" name="email" type="email" value={form.values.email} error={errors.email} autoComplete="email" />
|
||||
<Field
|
||||
id="signup-phone"
|
||||
@@ -803,6 +824,7 @@ function Field(props: {
|
||||
error?: string;
|
||||
autoComplete: string;
|
||||
hint?: string;
|
||||
required?: boolean;
|
||||
}) {
|
||||
const errorId = `${props.id}-error`;
|
||||
const hintId = `${props.id}-hint`;
|
||||
@@ -816,6 +838,7 @@ function Field(props: {
|
||||
type={props.type}
|
||||
value={props.value}
|
||||
autocomplete={props.autoComplete}
|
||||
required={props.required ? true : undefined}
|
||||
aria-invalid={props.error ? 'true' : undefined}
|
||||
aria-describedby={describedBy}
|
||||
/>
|
||||
|
||||
+35
-7
@@ -8,6 +8,8 @@ const NOTES_MAX = 500;
|
||||
|
||||
export type SignupValues = {
|
||||
name: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
notes: string;
|
||||
@@ -16,7 +18,9 @@ export type SignupValues = {
|
||||
guardianEmail: string;
|
||||
};
|
||||
|
||||
export type SignupErrors = Partial<Record<'name' | 'email' | 'phone' | 'notes' | 'guardianName' | 'guardianEmail' | 'form', string>>;
|
||||
export type SignupErrors = Partial<
|
||||
Record<'name' | 'firstName' | 'lastName' | 'email' | 'phone' | 'notes' | 'guardianName' | 'guardianEmail' | 'form', string>
|
||||
>;
|
||||
|
||||
export type SignupDraft = {
|
||||
name: string;
|
||||
@@ -32,6 +36,8 @@ export type SignupDraft = {
|
||||
|
||||
export const EMPTY_SIGNUP: SignupValues = {
|
||||
name: '',
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
notes: '',
|
||||
@@ -42,6 +48,15 @@ export const EMPTY_SIGNUP: SignupValues = {
|
||||
|
||||
const controlChars = /[\u0000-\u001F\u007F]/;
|
||||
|
||||
function personPart(raw: string, label: string): { value: string; error?: string } {
|
||||
const trimmed = raw.normalize('NFC').trim();
|
||||
const value = capitalizeName(trimmed);
|
||||
if (trimmed.length === 0 || value.length === 0) return { value: '', error: `Enter your ${label}.` };
|
||||
if (trimmed.length > NAME_MAX || value.length > NAME_MAX) return { value, error: `Use ${NAME_MAX} characters or fewer.` };
|
||||
if (controlChars.test(trimmed)) return { value, error: `Enter your ${label} without line breaks.` };
|
||||
return { value };
|
||||
}
|
||||
|
||||
export function parseSignupForm(
|
||||
input: SignupValues,
|
||||
voice: 'volunteer' | 'coordinator' = 'volunteer',
|
||||
@@ -49,6 +64,8 @@ export function parseSignupForm(
|
||||
const parsed = z
|
||||
.object({
|
||||
name: z.string(),
|
||||
firstName: z.string(),
|
||||
lastName: z.string(),
|
||||
email: z.string(),
|
||||
phone: z.string(),
|
||||
notes: z.string(),
|
||||
@@ -59,12 +76,23 @@ export function parseSignupForm(
|
||||
.safeParse(input);
|
||||
if (!parsed.success) return { ok: false, errors: { form: 'Check the signup fields and try again.' } };
|
||||
const errors: SignupErrors = {};
|
||||
const nameRaw = parsed.data.name.normalize('NFC').trim();
|
||||
const name = capitalizeName(nameRaw);
|
||||
const nameLabel = voice === 'coordinator' ? 'their name' : 'your name';
|
||||
if (nameRaw.length === 0 || name.length === 0) errors.name = `Enter ${nameLabel}.`;
|
||||
else if (nameRaw.length > NAME_MAX || name.length > NAME_MAX) errors.name = `Use ${NAME_MAX} characters or fewer.`;
|
||||
else if (controlChars.test(nameRaw)) errors.name = `Enter ${nameLabel} without line breaks.`;
|
||||
let name = '';
|
||||
if (voice === 'coordinator') {
|
||||
const nameRaw = parsed.data.name.normalize('NFC').trim();
|
||||
name = capitalizeName(nameRaw);
|
||||
if (nameRaw.length === 0 || name.length === 0) errors.name = 'Enter their name.';
|
||||
else if (nameRaw.length > NAME_MAX || name.length > NAME_MAX) errors.name = `Use ${NAME_MAX} characters or fewer.`;
|
||||
else if (controlChars.test(nameRaw)) errors.name = 'Enter their name without line breaks.';
|
||||
} else {
|
||||
const first = personPart(parsed.data.firstName, 'first name');
|
||||
const last = personPart(parsed.data.lastName, 'last name');
|
||||
if (first.error) errors.firstName = first.error;
|
||||
if (last.error) errors.lastName = last.error;
|
||||
if (!first.error && !last.error && `${first.value} ${last.value}`.length > NAME_MAX) {
|
||||
errors.lastName = `Use ${NAME_MAX} characters or fewer for the full name.`;
|
||||
}
|
||||
name = first.error || last.error || errors.lastName ? '' : `${first.value} ${last.value}`;
|
||||
}
|
||||
|
||||
let emailNorm = '';
|
||||
try {
|
||||
|
||||
+3
-1
@@ -277,7 +277,9 @@ function loadShift(services: SignupServices, rawId: string): PublicShift | null
|
||||
|
||||
function valuesFrom(body: Record<string, unknown>): SignupValues {
|
||||
return {
|
||||
name: textField(body, 'name'),
|
||||
name: '',
|
||||
firstName: textField(body, 'first_name'),
|
||||
lastName: textField(body, 'last_name'),
|
||||
email: textField(body, 'email'),
|
||||
phone: textField(body, 'phone'),
|
||||
notes: textField(body, 'notes'),
|
||||
|
||||
Reference in new issue
Block a user