feat(auth): add optional email to signup form
This commit is contained in:
@@ -63,6 +63,7 @@ export const registerWithOtp = async (
|
|||||||
re_password: string,
|
re_password: string,
|
||||||
first_name = "",
|
first_name = "",
|
||||||
last_name = "",
|
last_name = "",
|
||||||
|
email = "",
|
||||||
) => {
|
) => {
|
||||||
const normalizedMobile = normalizeDigits(mobile)
|
const normalizedMobile = normalizeDigits(mobile)
|
||||||
const normalizedCode = normalizeDigits(code)
|
const normalizedCode = normalizeDigits(code)
|
||||||
@@ -75,6 +76,7 @@ export const registerWithOtp = async (
|
|||||||
re_password,
|
re_password,
|
||||||
first_name,
|
first_name,
|
||||||
last_name,
|
last_name,
|
||||||
|
email,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
if (!response.ok) throw await buildApiError(response)
|
if (!response.ok) throw await buildApiError(response)
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ interface SignupDetailsState {
|
|||||||
confirmation: string
|
confirmation: string
|
||||||
firstName: string
|
firstName: string
|
||||||
lastName: string
|
lastName: string
|
||||||
|
email: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AuthFlowContextValue {
|
interface AuthFlowContextValue {
|
||||||
@@ -87,6 +88,7 @@ const defaultSignupDetails: SignupDetailsState = {
|
|||||||
confirmation: "",
|
confirmation: "",
|
||||||
firstName: "",
|
firstName: "",
|
||||||
lastName: "",
|
lastName: "",
|
||||||
|
email: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
const AuthFlowContext = createContext<AuthFlowContextValue | null>(null)
|
const AuthFlowContext = createContext<AuthFlowContextValue | null>(null)
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ export const en = {
|
|||||||
passwordReuse: "New password must be different from your previous password.",
|
passwordReuse: "New password must be different from your previous password.",
|
||||||
firstNamePlaceholder: "First name",
|
firstNamePlaceholder: "First name",
|
||||||
lastNamePlaceholder: "Last name",
|
lastNamePlaceholder: "Last name",
|
||||||
|
emailPlaceholder: "Email (optional)",
|
||||||
enterPassword: "Enter your password",
|
enterPassword: "Enter your password",
|
||||||
verifyNumber: "Verify your number",
|
verifyNumber: "Verify your number",
|
||||||
enterMobileDesc: "Enter your mobile number to continue",
|
enterMobileDesc: "Enter your mobile number to continue",
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ export const fa = {
|
|||||||
passwordReuse: "رمز عبور جدید نباید با رمز عبور قبلی یکسان باشد.",
|
passwordReuse: "رمز عبور جدید نباید با رمز عبور قبلی یکسان باشد.",
|
||||||
firstNamePlaceholder: "نام",
|
firstNamePlaceholder: "نام",
|
||||||
lastNamePlaceholder: "نام خانوادگی",
|
lastNamePlaceholder: "نام خانوادگی",
|
||||||
|
emailPlaceholder: "ایمیل (اختیاری)",
|
||||||
welcome: (title: string = "Qlockifiy") => `به ${title} خوش آمدید`,
|
welcome: (title: string = "Qlockifiy") => `به ${title} خوش آمدید`,
|
||||||
enterPassword: "رمز عبور خود را وارد کنید",
|
enterPassword: "رمز عبور خود را وارد کنید",
|
||||||
verifyNumber: "تایید شماره موبایل",
|
verifyNumber: "تایید شماره موبایل",
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ export function SignupOtpPage() {
|
|||||||
signupDetails.confirmation,
|
signupDetails.confirmation,
|
||||||
signupDetails.firstName,
|
signupDetails.firstName,
|
||||||
signupDetails.lastName,
|
signupDetails.lastName,
|
||||||
|
signupDetails.email,
|
||||||
)
|
)
|
||||||
clearCooldown("signupOtpSend")
|
clearCooldown("signupOtpSend")
|
||||||
clearSignupDetails()
|
clearSignupDetails()
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export function SignupPasswordPage() {
|
|||||||
const isRtl = lang === "fa"
|
const isRtl = lang === "fa"
|
||||||
const [firstName, setFirstName] = useState(signupDetails.firstName)
|
const [firstName, setFirstName] = useState(signupDetails.firstName)
|
||||||
const [lastName, setLastName] = useState(signupDetails.lastName)
|
const [lastName, setLastName] = useState(signupDetails.lastName)
|
||||||
|
const [email, setEmail] = useState(signupDetails.email)
|
||||||
const [password, setPassword] = useState(signupDetails.password)
|
const [password, setPassword] = useState(signupDetails.password)
|
||||||
const [confirmation, setConfirmation] = useState(signupDetails.confirmation)
|
const [confirmation, setConfirmation] = useState(signupDetails.confirmation)
|
||||||
const textFallbackDirection = isRtl ? "rtl" : "ltr"
|
const textFallbackDirection = isRtl ? "rtl" : "ltr"
|
||||||
@@ -75,6 +76,7 @@ export function SignupPasswordPage() {
|
|||||||
confirmation,
|
confirmation,
|
||||||
firstName: firstName.trim(),
|
firstName: firstName.trim(),
|
||||||
lastName: lastName.trim(),
|
lastName: lastName.trim(),
|
||||||
|
email: email.trim(),
|
||||||
})
|
})
|
||||||
setCode("signup", "")
|
setCode("signup", "")
|
||||||
clearOtpDelivery("signup")
|
clearOtpDelivery("signup")
|
||||||
@@ -100,7 +102,7 @@ export function SignupPasswordPage() {
|
|||||||
placeholder={t.login.firstNamePlaceholder}
|
placeholder={t.login.firstNamePlaceholder}
|
||||||
dir={firstNameDirection}
|
dir={firstNameDirection}
|
||||||
required
|
required
|
||||||
className={'h-11'}
|
className={`h-11 ${firstNameDirection === "rtl" ? "text-end" : "text-start"}`}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
id="signup-last-name"
|
id="signup-last-name"
|
||||||
@@ -109,9 +111,18 @@ export function SignupPasswordPage() {
|
|||||||
placeholder={t.login.lastNamePlaceholder}
|
placeholder={t.login.lastNamePlaceholder}
|
||||||
dir={lastNameDirection}
|
dir={lastNameDirection}
|
||||||
required
|
required
|
||||||
className={'h-11'}
|
className={`h-11 ${lastNameDirection === "rtl" ? "text-end" : "text-start"}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<Input
|
||||||
|
id="signup-email"
|
||||||
|
value={email}
|
||||||
|
onChange={(event) => setEmail(event.target.value)}
|
||||||
|
placeholder={t.login.emailPlaceholder}
|
||||||
|
type="email"
|
||||||
|
dir="ltr"
|
||||||
|
className="h-11 text-start"
|
||||||
|
/>
|
||||||
<AuthPasswordField
|
<AuthPasswordField
|
||||||
id="signup-password"
|
id="signup-password"
|
||||||
value={password}
|
value={password}
|
||||||
|
|||||||
Reference in New Issue
Block a user