@@ -30,7 +30,7 @@ import { useForm } from "@tanstack/react-form";
30
30
import { ConfirmationResult , RecaptchaVerifier } from "firebase/auth" ;
31
31
import { useCallback , useEffect , useMemo , useRef , useState } from "react" ;
32
32
import { z } from "zod" ;
33
- import { useAuth , useUI } from "~/hooks" ;
33
+ import { useUI } from "~/hooks" ;
34
34
import { Button } from "../../components/button" ;
35
35
import { CountrySelector } from "../../components/country-selector" ;
36
36
import { FieldInfo } from "../../components/field-info" ;
@@ -46,6 +46,7 @@ interface PhoneNumberFormProps {
46
46
function PhoneNumberForm ( { onSubmit, formError, recaptchaVerifier, recaptchaContainerRef } : PhoneNumberFormProps ) {
47
47
const ui = useUI ( ) ;
48
48
49
+ // TODO(ehesp): How does this support allowed countries?
49
50
const [ selectedCountry , setSelectedCountry ] = useState < CountryData > ( countryData [ 0 ] ) ;
50
51
const [ firstValidationOccured , setFirstValidationOccured ] = useState ( false ) ;
51
52
@@ -71,6 +72,8 @@ function PhoneNumberForm({ onSubmit, formError, recaptchaVerifier, recaptchaCont
71
72
} ,
72
73
} ) ;
73
74
75
+ // TODO(ehesp): Country data onChange types are not matching
76
+
74
77
return (
75
78
< form
76
79
className = "fui-form"
@@ -91,7 +94,7 @@ function PhoneNumberForm({ onSubmit, formError, recaptchaVerifier, recaptchaCont
91
94
< div className = "fui-phone-input" >
92
95
< CountrySelector
93
96
value = { selectedCountry }
94
- onChange = { setSelectedCountry }
97
+ onChange = { ( country ) => setSelectedCountry ( country as CountryData ) }
95
98
className = "fui-phone-input__country-selector"
96
99
/>
97
100
< input
@@ -291,13 +294,12 @@ function VerificationForm({
291
294
) ;
292
295
}
293
296
294
- export interface PhoneFormProps {
297
+ export type PhoneAuthFormProps = {
295
298
resendDelay ?: number ;
296
299
}
297
300
298
- export function PhoneForm ( { resendDelay = 30 } : PhoneFormProps ) {
301
+ export function PhoneAuthForm ( { resendDelay = 30 } : PhoneAuthFormProps ) {
299
302
const ui = useUI ( ) ;
300
- const auth = useAuth ( ui ) ;
301
303
302
304
const [ formError , setFormError ] = useState < string | null > ( null ) ;
303
305
const [ confirmationResult , setConfirmationResult ] = useState < ConfirmationResult | null > ( null ) ;
@@ -310,8 +312,9 @@ export function PhoneForm({ resendDelay = 30 }: PhoneFormProps) {
310
312
useEffect ( ( ) => {
311
313
if ( ! recaptchaContainerRef . current ) return ;
312
314
313
- const verifier = new RecaptchaVerifier ( auth , recaptchaContainerRef . current , {
314
- size : ui . recaptchaMode ?? "normal" ,
315
+ const verifier = new RecaptchaVerifier ( ui . auth , recaptchaContainerRef . current , {
316
+ // size: ui.recaptchaMode ?? "normal", TODO(ehesp): Get this from the useRecaptchaVerifier hook once implemented
317
+ size : "normal" ,
315
318
} ) ;
316
319
317
320
setRecaptchaVerifier ( verifier ) ;
@@ -320,7 +323,7 @@ export function PhoneForm({ resendDelay = 30 }: PhoneFormProps) {
320
323
verifier . clear ( ) ;
321
324
setRecaptchaVerifier ( null ) ;
322
325
} ;
323
- } , [ auth , ui . recaptchaMode ] ) ;
326
+ } , [ ui ] ) ;
324
327
325
328
const handlePhoneSubmit = async ( number : string ) => {
326
329
setFormError ( null ) ;
@@ -356,8 +359,9 @@ export function PhoneForm({ resendDelay = 30 }: PhoneFormProps) {
356
359
recaptchaVerifier . clear ( ) ;
357
360
}
358
361
359
- const verifier = new RecaptchaVerifier ( auth , recaptchaContainerRef . current , {
360
- size : ui . recaptchaMode ?? "normal" ,
362
+ const verifier = new RecaptchaVerifier ( ui . auth , recaptchaContainerRef . current , {
363
+ // size: ui.recaptchaMode ?? "normal", // TODO(ehesp): Get this from the useRecaptchaVerifier hook once implemented
364
+ size : "normal" ,
361
365
} ) ;
362
366
setRecaptchaVerifier ( verifier ) ;
363
367
0 commit comments