1
1
import { useEffect , useRef , useState } from "react"
2
- import { GetStaticProps } from "next"
2
+ import { GetStaticProps , InferGetStaticPropsType } from "next"
3
3
import { useRouter } from "next/router"
4
4
import { useTranslation } from "next-i18next"
5
5
import { serverSideTranslations } from "next-i18next/serverSideTranslations"
@@ -56,6 +56,10 @@ const Subtitle = ({ children }: ChildOnlyProp) => (
56
56
</ Text >
57
57
)
58
58
59
+ type Props = BasePageProps & {
60
+ wallets : WalletData [ ]
61
+ }
62
+
59
63
export const getStaticProps = ( async ( { locale } ) => {
60
64
const lastDeployDate = getLastDeployDate ( )
61
65
@@ -65,18 +69,24 @@ export const getStaticProps = (async ({ locale }) => {
65
69
66
70
const contentNotTranslated = ! existsNamespace ( locale ! , requiredNamespaces [ 2 ] )
67
71
72
+ const supportedLocaleWallets = getSupportedLocaleWallets ( locale ! )
73
+ const noSupportedLocaleWallets = getNonSupportedLocaleWallets ( locale ! )
74
+ const wallets = supportedLocaleWallets . concat ( noSupportedLocaleWallets )
75
+
68
76
return {
69
77
props : {
70
78
...( await serverSideTranslations ( locale ! , requiredNamespaces ) ) ,
71
79
contentNotTranslated,
72
80
lastDeployDate,
81
+ wallets,
73
82
} ,
74
83
}
75
- } ) satisfies GetStaticProps < BasePageProps >
84
+ } ) satisfies GetStaticProps < Props >
76
85
77
- const FindWalletPage = ( ) => {
78
- const { pathname, locale } = useRouter ( )
79
- const theme = useTheme ( )
86
+ const FindWalletPage = ( {
87
+ wallets,
88
+ } : InferGetStaticPropsType < typeof getStaticProps > ) => {
89
+ const { pathname } = useRouter ( )
80
90
const { t } = useTranslation ( "page-wallets-find-wallet" )
81
91
82
92
const resetWalletFilter = useRef ( ( ) => { } )
@@ -87,24 +97,6 @@ const FindWalletPage = () => {
87
97
88
98
const { isOpen : showMobileSidebar , onOpen, onClose } = useDisclosure ( )
89
99
90
- const supportedLocaleWallets = getSupportedLocaleWallets ( locale ! )
91
- const noSupportedLocaleWallets = getNonSupportedLocaleWallets ( locale ! )
92
- const [ randomizedWalletData , setRandomizedWalletData ] = useState <
93
- WalletData [ ]
94
- > ( supportedLocaleWallets . concat ( noSupportedLocaleWallets ) )
95
-
96
- // If any wallet supports user's locale, show them (shuffled) at the top and then the remaining ones
97
- useEffect ( ( ) => {
98
- const supportedLocaleWallets = getSupportedLocaleWallets ( locale ! )
99
-
100
- const noSupportedLocaleWallets = getNonSupportedLocaleWallets ( locale ! )
101
-
102
- setRandomizedWalletData (
103
- supportedLocaleWallets . concat ( noSupportedLocaleWallets )
104
- )
105
- // eslint-disable-next-line react-hooks/exhaustive-deps
106
- } , [ locale ] )
107
-
108
100
const updateFilterOption = ( key ) => {
109
101
const updatedFilters = { ...filters }
110
102
updatedFilters [ key ] = ! updatedFilters [ key ]
@@ -242,7 +234,7 @@ const FindWalletPage = () => {
242
234
filters = { filters }
243
235
resetFilters = { resetFilters }
244
236
resetWalletFilter = { resetWalletFilter }
245
- walletData = { randomizedWalletData }
237
+ walletData = { wallets }
246
238
onOpen = { onOpen }
247
239
/>
248
240
</ Box >
0 commit comments