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:
@@ -40,12 +40,8 @@ export function RegisterPage() {
|
|||||||
setLocalError('')
|
setLocalError('')
|
||||||
clearError()
|
clearError()
|
||||||
|
|
||||||
if (!inviteCode.trim()) {
|
// Only validate invite code if one was entered
|
||||||
setLocalError('Invite code is required')
|
if (inviteCode.trim() && inviteCodeStatus === 'invalid') {
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inviteCodeStatus !== 'valid') {
|
|
||||||
setLocalError('Please enter a valid invite code')
|
setLocalError('Please enter a valid invite code')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -66,7 +62,11 @@ export function RegisterPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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 })
|
navigate('/trees', { replace: true })
|
||||||
} catch {
|
} catch {
|
||||||
// Error is set in the store
|
// Error is set in the store
|
||||||
@@ -97,7 +97,6 @@ export function RegisterPage() {
|
|||||||
id="inviteCode"
|
id="inviteCode"
|
||||||
name="inviteCode"
|
name="inviteCode"
|
||||||
type="text"
|
type="text"
|
||||||
required
|
|
||||||
value={inviteCode}
|
value={inviteCode}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setInviteCode(e.target.value.toUpperCase())
|
setInviteCode(e.target.value.toUpperCase())
|
||||||
|
|||||||
Reference in New Issue
Block a user