@@ -6,7 +6,8 @@ import { SocialLoginsConfig } from "../../interfaces";
66import { t } from "../../localeImport" ;
77import { cn , getIcons } from "../../utils/common" ;
88import { validatePhoneNumber } from "../../utils/modal" ;
9- import OtpInput from "../Otp/Otp" ;
9+ import { LoginOtp } from "../LoginOtp" ;
10+ import { LoginPasswordLess } from "../LoginPasswordLess" ;
1011import SocialLoginList from "../SocialLoginList" ;
1112
1213export interface LoginProps {
@@ -55,16 +56,15 @@ const Login = (props: LoginProps) => {
5556 const [ canShowMore , setCanShowMore ] = createSignal ( false ) ;
5657 const [ visibleRow , setVisibleRow ] = createSignal < rowType [ ] > ( [ ] ) ;
5758 const [ otherRow , setOtherRow ] = createSignal < rowType [ ] > ( [ ] ) ;
58- const [ isPasswordlessCtaClicked , setIsPasswordlessCtaClicked ] = createSignal ( false ) ;
59- const [ isInputFocused , setIsInputFocused ] = createSignal ( false ) ;
59+ const [ isPasswordLessCtaClicked , setIsPasswordLessCtaClicked ] = createSignal ( false ) ;
6060 const [ showOtpFlow , setShowOtpFlow ] = createSignal ( false ) ;
6161 const [ otpLoading , setOtpLoading ] = createSignal ( true ) ;
6262 const [ isMobileOtp , setIsMobileOtp ] = createSignal ( false ) ;
6363 const [ otpSuccess , setOtpSuccess ] = createSignal ( false ) ;
6464
6565 const handleExpand = ( ) => {
6666 setExpand ( ( prev ) => ! prev ) ;
67- setIsPasswordlessCtaClicked ( false ) ;
67+ setIsPasswordLessCtaClicked ( false ) ;
6868 props . handleSocialLoginHeight ( ) ;
6969 } ;
7070
@@ -120,7 +120,6 @@ const Login = (props: LoginProps) => {
120120
121121 const handleFormSubmit = async ( e : Event ) => {
122122 e . preventDefault ( ) ;
123-
124123 // setShowOtpFlow(true);
125124 // setTimeout(() => {
126125 // setOtpLoading(false);
@@ -154,8 +153,9 @@ const Login = (props: LoginProps) => {
154153 return undefined ;
155154 } ;
156155
157- const handleInputChange = ( e : { target : { value : string } } ) => {
158- setFieldValue ( e . target . value ) ;
156+ const handleInputChange = ( e : InputEvent ) => {
157+ const target = e . target as HTMLInputElement ;
158+ setFieldValue ( target . value ) ;
159159 if ( isValidInput ( ) === false ) setIsValidInput ( true ) ;
160160 } ;
161161
@@ -178,7 +178,7 @@ const Login = (props: LoginProps) => {
178178 } ) ;
179179
180180 const handleConnectWallet = ( e : MouseEvent ) => {
181- setIsPasswordlessCtaClicked ( false ) ;
181+ setIsPasswordLessCtaClicked ( false ) ;
182182 e . preventDefault ( ) ;
183183 if ( mergedProps . handleExternalWalletBtnClick ) mergedProps . handleExternalWalletBtnClick ( true ) ;
184184 } ;
@@ -199,63 +199,13 @@ const Login = (props: LoginProps) => {
199199 < Suspense >
200200 < Switch >
201201 < Match when = { showOtpFlow ( ) } >
202- < div class = "w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-4 w3a--w-full w3a--h-full w3a--flex-1" >
203- < Show
204- when = { ! otpLoading ( ) }
205- fallback = {
206- < div class = "w3a--flex w3a--items-center w3a--justify-center w3a--gap-y-4 w3a--w-full w3a--h-full w3a--flex-1 w3a--gap-x-2" >
207- < div class = "w3a--w-3 w3a--h-3 w3a--rounded-full w3a--bg-app-primary-600 dark:w3a--bg-app-primary-500 w3a--animate-pulse" />
208- < div class = "w3a--w-3 w3a--h-3 w3a--rounded-full w3a--bg-app-primary-500 dark:w3a--bg-app-primary-400 w3a--animate-pulse" />
209- < div class = "w3a--w-3 w3a--h-3 w3a--rounded-full w3a--bg-app-primary-400 dark:w3a--bg-app-primary-300 w3a--animate-pulse" />
210- </ div >
211- }
212- >
213- < Show
214- when = { ! otpSuccess ( ) }
215- fallback = {
216- < div class = "w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-4 w3a--w-full w3a--h-full w3a--flex-1" >
217- < img src = { getIcons ( "success-light" ) } alt = "success" class = "w3a--w-auto w3a--h-auto" />
218- < p class = "w3a--text-base w3a--font-medium w3a--text-app-gray-900 dark:w3a--text-app-white w3a--w-[80%] w3a--mx-auto w3a--text-center" >
219- You are connected to your account!
220- </ p >
221- </ div >
222- }
223- >
224- < div class = "w3a--flex w3a--items-start w3a--justify-start w3a--mr-auto w3a--w-full" >
225- < button
226- class = "w3a--w-5 w3a--h-5 w3a--rounded-full w3a--cursor-pointer w3a--flex w3a--items-center w3a--justify-center w3a--z-20"
227- onClick = { ( ) => setShowOtpFlow ( false ) }
228- >
229- < svg xmlns = "http://www.w3.org/2000/svg" fill = "none" viewBox = "0 0 20 20" class = "w3a--text-app-gray-900 dark:w3a--text-app-white" >
230- < path
231- fill = "currentColor"
232- fill-rule = "evenodd"
233- d = "M9.707 16.707a1 1 0 0 1-1.414 0l-6-6a1 1 0 0 1 0-1.414l6-6a1 1 0 0 1 1.414 1.414L5.414 9H17a1 1 0 1 1 0 2H5.414l4.293 4.293a1 1 0 0 1 0 1.414"
234- clip-rule = "evenodd"
235- />
236- </ svg >
237- </ button >
238- </ div >
239- < div class = "w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-4 w3a--w-full w3a--h-full w3a--flex-1" >
240- < img src = { getIcons ( isMobileOtp ( ) ? "sms-otp-light" : "email-otp-light" ) } alt = "otp" class = "w3a--w-auto w3a--h-auto" />
241- < div class = "w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-2" >
242- < p class = "w3a--text-lg w3a--font-bold w3a--text-app-gray-900 dark:w3a--text-app-white" >
243- { isMobileOtp ( ) ? "OTP verification" : "Email verification" }
244- </ p >
245- < div class = "w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-1" >
246- < p class = "w3a--text-sm w3a--font-normal w3a--text-app-gray-900 dark:w3a--text-app-white" >
247- { isMobileOtp ( ) ? "Enter the OTP sent to" : "Please enter the 6-digit verification code " }
248- </ p >
249- < p class = "w3a--text-sm w3a--font-normal w3a--text-app-gray-900 dark:w3a--text-app-white" >
250- { isMobileOtp ( ) ? "🇸🇬+91 ****0999" : "that was sent to your email ja****@email.com" }
251- </ p >
252- </ div >
253- </ div >
254- < OtpInput length = { 6 } onComplete = { handleOtpComplete } />
255- </ div >
256- </ Show >
257- </ Show >
258- </ div >
202+ < LoginOtp
203+ otpLoading = { otpLoading ( ) }
204+ otpSuccess = { otpSuccess ( ) }
205+ setShowOtpFlow = { setShowOtpFlow }
206+ isMobileOtp = { isMobileOtp ( ) }
207+ handleOtpComplete = { handleOtpComplete }
208+ />
259209 </ Match >
260210 < Match when = { ! showOtpFlow ( ) } >
261211 < div class = "w3a--flex w3a--flex-col w3a--items-center w3a--gap-y-4 w3a--p-4" >
@@ -292,43 +242,18 @@ const Login = (props: LoginProps) => {
292242 />
293243 </ Show >
294244 < Show when = { mergedProps . showPasswordLessInput } >
295- < Show
296- when = { isPasswordlessCtaClicked ( ) }
297- fallback = {
298- < button class = { cn ( "w3a--btn !w3a--justify-between" ) } onClick = { ( ) => setIsPasswordlessCtaClicked ( true ) } >
299- < p class = "w3a--text-app-gray-900 dark:w3a--text-app-white" > Continue with { title ( ) } </ p >
300- </ button >
301- }
302- >
303- < div class = { cn ( "w3a--input" , isInputFocused ( ) && "!w3a--border-app-primary-600" ) } >
304- < input
305- onInput = { handleInputChange }
306- value = { fieldValue ( ) }
307- placeholder = { placeholder ( ) }
308- onFocus = { ( e ) => {
309- e . target . placeholder = "" ;
310- setIsInputFocused ( true ) ;
311- } }
312- onBlur = { ( e ) => {
313- e . target . placeholder = `${ placeholder ( ) } ` ;
314- setIsInputFocused ( false ) ;
315- } }
316- type = "text"
317- autofocus
318- class = "w-full w3a--appearance-none w3a--outline-none active:w3a--outline-none focus:w3a--outline-none w3a--bg-transparent placeholder:w3a--text-xs placeholder:w3a--text-app-gray-400 dark:placeholder:w3a--text-app-gray-500 w3a--text-app-gray-900 dark:w3a--text-app-white"
319- />
320- < Show when = { fieldValue ( ) && isValidInput ( ) && isInputFocused ( ) } >
321- < button class = "w3a--appearance-none w3a--icon-animation" onClick = { handleFormSubmit } >
322- < img src = { getIcons ( props . isDark ? "chevron-right-dark" : "chevron-right-light" ) } alt = "arrow" />
323- </ button >
324- </ Show >
325- </ div >
326- < Show when = { ! isValidInput ( ) && isPasswordlessCtaClicked ( ) } >
327- < p class = "w3a--text-xs w3a--font-normal w3a--text-app-red-500 dark:w3a--text-app-red-400 w3a--text-start -w3a--mt-2 w3a--w-full w3a--pl-6" >
328- { invalidInputErrorMessage ( ) }
329- </ p >
330- </ Show >
331- </ Show >
245+ < LoginPasswordLess
246+ isPasswordLessCtaClicked = { isPasswordLessCtaClicked ( ) }
247+ setIsPasswordLessCtaClicked = { setIsPasswordLessCtaClicked }
248+ title = { title ( ) }
249+ fieldValue = { fieldValue ( ) }
250+ handleInputChange = { handleInputChange }
251+ placeholder = { placeholder ( ) }
252+ handleFormSubmit = { handleFormSubmit }
253+ invalidInputErrorMessage = { invalidInputErrorMessage ( ) }
254+ isValidInput = { isValidInput ( ) }
255+ isDark = { props . isDark }
256+ />
332257 </ Show >
333258 < Show when = { mergedProps . showExternalWalletButton && mergedProps . showPasswordLessInput } >
334259 < div class = "w3a--flex w3a--items-center w3a--gap-x-2 w3a--w-full" >
@@ -354,7 +279,6 @@ const Login = (props: LoginProps) => {
354279 />
355280 </ button >
356281 </ Show >
357- { /* <OtpInput length={6} onComplete={() => {}} /> */ }
358282 </ Show >
359283 </ div >
360284 </ Match >
0 commit comments