feat(auth): referrer code at signup and agent code in profile
Optional referrer agent code in registration with field validation UX. Show read-only agent referral code in profile edit and desktop overview. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -10,6 +10,7 @@ type PendingOtp = {
|
||||
isRegister: boolean
|
||||
firstName?: string
|
||||
lastName?: string
|
||||
referrerAgentCode?: string
|
||||
}
|
||||
|
||||
let memoryPending: PendingOtp | null = null
|
||||
@@ -50,7 +51,12 @@ function setPendingOtp(value: PendingOtp | null) {
|
||||
|
||||
export async function sendOtp(
|
||||
phone: string,
|
||||
options: { firstName?: string; lastName?: string; isRegister: boolean },
|
||||
options: {
|
||||
firstName?: string
|
||||
lastName?: string
|
||||
isRegister: boolean
|
||||
referrerAgentCode?: string
|
||||
},
|
||||
): Promise<{ success: boolean; message: string }> {
|
||||
const normalized = normalizePhone(phone)
|
||||
if (!/^09\d{9}$/.test(normalized)) {
|
||||
@@ -62,11 +68,13 @@ export async function sendOtp(
|
||||
}
|
||||
|
||||
try {
|
||||
const referrerAgentCode = options.referrerAgentCode?.trim() || undefined
|
||||
setPendingOtp({
|
||||
phone: normalized,
|
||||
isRegister: options.isRegister,
|
||||
firstName: options.firstName,
|
||||
lastName: options.lastName,
|
||||
referrerAgentCode,
|
||||
})
|
||||
const res = await apiRequest<{ success: boolean; message: string; debugCode?: string }>(
|
||||
'/auth/otp/request',
|
||||
@@ -78,6 +86,7 @@ export async function sendOtp(
|
||||
firstName: options.firstName,
|
||||
lastName: options.lastName,
|
||||
isRegister: options.isRegister,
|
||||
referrerAgentCode,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user