@@ -9,7 +9,7 @@ import Head from "next/head";
9
9
import Link from "next/link" ;
10
10
import { GetServerSideProps } from "next" ;
11
11
import i18Translate from "@/utilities/I18Translate" ;
12
- import { useSelector } from "@/hooks/useTypedSelector" ;
12
+ import { useMultiSelector } from "@/hooks/useTypedSelector" ;
13
13
import { useDispatch } from "@/hooks/useTypedDispatch" ;
14
14
import classNames from "classnames" ;
15
15
import Checkbox from "@/components/ui/Checkbox" ;
@@ -19,6 +19,8 @@ import LayoutWithoutFooter from "@/layouts/WithoutFooter";
19
19
import EmailInput from "@/components/ui/EmailInput" ;
20
20
import UsernameInput from "@/components/ui/UsernameInput" ;
21
21
import { setError } from "@/store/feature/index.slice" ;
22
+ import { IRootState } from "@/store" ;
23
+ import { Referral } from "@/types/community" ;
22
24
23
25
/**
24
26
* Signup form values
@@ -36,6 +38,20 @@ export interface FormValues {
36
38
checkTerms : boolean ;
37
39
}
38
40
41
+ interface ErrorDetails {
42
+ error : {
43
+ data : {
44
+ details : {
45
+ password ?: string ;
46
+ } ;
47
+ } ;
48
+ } ;
49
+ }
50
+ interface MultiSelector {
51
+ referrals : Referral [ ] ;
52
+ error : ErrorDetails ;
53
+ }
54
+
39
55
/**
40
56
* signup page
41
57
* @date 4/6/2023 - 4:15:13 PM
@@ -56,7 +72,10 @@ export default function SignupWithInvite(): ReactElement {
56
72
const referralCodeValue = watch ( "referralCode" ) || "" ;
57
73
const { query, locale } = useRouter ( ) ;
58
74
const referrer = query . invite ;
59
- const referrals = useSelector ( ( state ) => state . referrals . list ) ;
75
+ const { referrals, error } = useMultiSelector < unknown , MultiSelector > ( {
76
+ referrals : ( state : IRootState ) => state . referrals . list ,
77
+ error : ( state : IRootState ) => state . store . error ,
78
+ } ) ;
60
79
const { t } = useTranslation ( ) ;
61
80
const [ loading , setLoading ] = useState ( false ) ;
62
81
const dispatch = useDispatch ( ) ;
@@ -73,7 +92,7 @@ export default function SignupWithInvite(): ReactElement {
73
92
} ;
74
93
try {
75
94
if ( ! checkTerms ) return ;
76
- await dispatch ( signUp ( { locale, payload : { ...signupData } } ) ) ;
95
+ dispatch ( signUp ( { locale, payload : { ...signupData } } ) ) ;
77
96
} catch ( error ) {
78
97
setError ( error ) ;
79
98
console . error ( error ) ;
@@ -122,7 +141,7 @@ export default function SignupWithInvite(): ReactElement {
122
141
value = { passwordValue }
123
142
placeholder = { `${ t ( "login-page.password.placeholde" ) } ` }
124
143
label = { `${ t ( "login-page.password.label" ) } ` }
125
- error = { errors . password ?. message }
144
+ error = { error ?. error ?. data ?. details ?. password }
126
145
{ ...register ( "password" , {
127
146
required : "This field is required" ,
128
147
minLength : { value : 3 , message : "The password is too short" } ,
0 commit comments