@@ -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,23 @@ 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
+
51
+ interface MultiSelector {
52
+ referrals : Referral [ ] ;
53
+ error : ErrorDetails ;
54
+ }
55
+
56
+
57
+
39
58
/**
40
59
* signup page
41
60
* @date 4/6/2023 - 4:15:13 PM
@@ -56,7 +75,10 @@ export default function SignupWithInvite(): ReactElement {
56
75
const referralCodeValue = watch ( "referralCode" ) || "" ;
57
76
const { query, locale } = useRouter ( ) ;
58
77
const referrer = query . invite ;
59
- const referrals = useSelector ( ( state ) => state . referrals . list ) ;
78
+ const { referrals, error } = useMultiSelector < unknown , MultiSelector > ( {
79
+ referrals : ( state : IRootState ) => state . referrals . list ,
80
+ error : ( state : IRootState ) => state . store . error ,
81
+ } ) ;
60
82
const { t } = useTranslation ( ) ;
61
83
const [ loading , setLoading ] = useState ( false ) ;
62
84
const dispatch = useDispatch ( ) ;
@@ -122,7 +144,7 @@ export default function SignupWithInvite(): ReactElement {
122
144
value = { passwordValue }
123
145
placeholder = { `${ t ( "login-page.password.placeholde" ) } ` }
124
146
label = { `${ t ( "login-page.password.label" ) } ` }
125
- error = { errors . password ?. message }
147
+ error = { error ?. error ?. data ?. details ?. password }
126
148
{ ...register ( "password" , {
127
149
required : "This field is required" ,
128
150
minLength : { value : 3 , message : "The password is too short" } ,
0 commit comments