Make invite code optional in frontend when backend allows it

- Remove required attribute from invite code field
- Only validate invite code if one is entered
- Only include invite_code in request if provided

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Michael Chihlas
2026-02-01 00:27:09 -05:00
parent 20c4c40a1f
commit 068c691773

View File

@@ -40,12 +40,8 @@ export function RegisterPage() {
setLocalError('')
clearError()
if (!inviteCode.trim()) {
setLocalError('Invite code is required')
return
}
if (inviteCodeStatus !== 'valid') {
// Only validate invite code if one was entered
if (inviteCode.trim() && inviteCodeStatus === 'invalid') {
setLocalError('Please enter a valid invite code')
return
}
@@ -66,7 +62,11 @@ export function RegisterPage() {
}
try {
await register({ email, password, name, invite_code: inviteCode.trim() })
// Only include invite_code if provided
const userData = inviteCode.trim()
? { email, password, name, invite_code: inviteCode.trim() }
: { email, password, name }
await register(userData)
navigate('/trees', { replace: true })
} catch {
// Error is set in the store
@@ -97,7 +97,6 @@ export function RegisterPage() {
id="inviteCode"
name="inviteCode"
type="text"
required
value={inviteCode}
onChange={(e) => {
setInviteCode(e.target.value.toUpperCase())