feat: Add invite code field to registration form
Some checks failed
ParentFlow CI/CD Pipeline / Backend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Frontend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Security Scanning (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-app/maternal-app-backend dockerfile:Dockerfile.production name:backend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-web dockerfile:Dockerfile.production name:frontend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Development (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Lint and Test (push) Has been cancelled
CI/CD Pipeline / E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Application (push) Has been cancelled
Some checks failed
ParentFlow CI/CD Pipeline / Backend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Frontend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Security Scanning (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-app/maternal-app-backend dockerfile:Dockerfile.production name:backend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-web dockerfile:Dockerfile.production name:frontend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Development (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Lint and Test (push) Has been cancelled
CI/CD Pipeline / E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Application (push) Has been cancelled
Frontend Changes: - Added inviteCode field to registration schema (optional) - Added invite code TextField to registration form UI - Updated RegisterData interface in AuthContext to include inviteCode - Pass inviteCode to backend during registration - Added helpful placeholder text indicating field is optional User Experience: - Invite code field appears after email in registration form - Helper text explains it's optional and can be left blank if registration is open - Backend will validate the code if REGISTRATION_MODE=invite_only 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,7 @@ const registerSchema = z.object({
|
||||
.regex(/[a-z]/, 'Password must contain at least one lowercase letter')
|
||||
.regex(/[0-9]/, 'Password must contain at least one number'),
|
||||
confirmPassword: z.string(),
|
||||
inviteCode: z.string().optional(),
|
||||
dateOfBirth: z.string().min(1, 'Date of birth is required'),
|
||||
parentalEmail: z.string().email('Invalid email address').optional().or(z.literal('')),
|
||||
agreeToTerms: z.boolean().refine(val => val === true, {
|
||||
@@ -129,6 +130,7 @@ export default function RegisterPage() {
|
||||
name: data.name,
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
inviteCode: data.inviteCode || undefined,
|
||||
dateOfBirth: data.dateOfBirth,
|
||||
parentalEmail: data.parentalEmail || undefined,
|
||||
coppaConsentGiven: data.coppaConsent || false,
|
||||
@@ -242,6 +244,27 @@ export default function RegisterPage() {
|
||||
}}
|
||||
/>
|
||||
|
||||
<TextField
|
||||
fullWidth
|
||||
label="Invite Code (Optional)"
|
||||
margin="normal"
|
||||
error={!!errors.inviteCode}
|
||||
helperText={errors.inviteCode?.message || 'Leave blank if registration is open'}
|
||||
{...register('inviteCode')}
|
||||
disabled={isLoading}
|
||||
inputProps={{
|
||||
'aria-invalid': !!errors.inviteCode,
|
||||
'aria-describedby': errors.inviteCode ? 'invite-code-error' : 'invite-code-helper',
|
||||
}}
|
||||
InputProps={{
|
||||
sx: { borderRadius: 3 },
|
||||
}}
|
||||
FormHelperTextProps={{
|
||||
id: errors.inviteCode ? 'invite-code-error' : 'invite-code-helper',
|
||||
role: errors.inviteCode ? 'alert' : undefined,
|
||||
}}
|
||||
/>
|
||||
|
||||
<TextField
|
||||
fullWidth
|
||||
label="Password"
|
||||
|
||||
@@ -31,6 +31,7 @@ export interface RegisterData {
|
||||
password: string;
|
||||
name: string;
|
||||
role?: string;
|
||||
inviteCode?: string; // Required if REGISTRATION_MODE=invite_only
|
||||
dateOfBirth: string; // COPPA compliance - required
|
||||
parentalEmail?: string; // For users 13-17
|
||||
coppaConsentGiven?: boolean; // For users 13-17
|
||||
@@ -240,6 +241,11 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
|
||||
deviceInfo,
|
||||
};
|
||||
|
||||
// Add optional invite code if provided
|
||||
if (data.inviteCode) {
|
||||
payload.inviteCode = data.inviteCode;
|
||||
}
|
||||
|
||||
// Add optional COPPA fields if provided
|
||||
if (data.parentalEmail) {
|
||||
payload.parentalEmail = data.parentalEmail;
|
||||
|
||||
Reference in New Issue
Block a user