fix dayjs not setting locale on load
This commit is contained in:
parent
7c80ae20b2
commit
08f6d2943e
|
@ -58,6 +58,8 @@ import { MangoAccountLookup } from 'components/account_page/MangoAccountLookup'
|
|||
import NftProfilePicModal from 'components/NftProfilePicModal'
|
||||
import ProfileImage from 'components/ProfileImage'
|
||||
import SwipeableTabs from 'components/mobile/SwipeableTabs'
|
||||
import useLocalStorageState from 'hooks/useLocalStorageState'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
export async function getStaticProps({ locale }) {
|
||||
return {
|
||||
|
@ -106,6 +108,7 @@ export default function Account() {
|
|||
const [viewIndex, setViewIndex] = useState(0)
|
||||
const [activeTab, setActiveTab] = useState(TABS[0])
|
||||
const [showProfilePicModal, setShowProfilePicModal] = useState(false)
|
||||
const [savedLanguage] = useLocalStorageState('language', '')
|
||||
const loadingTransaction = useMangoStore(
|
||||
(s) => s.wallet.nfts.loadingTransaction
|
||||
)
|
||||
|
@ -147,6 +150,10 @@ export default function Account() {
|
|||
}
|
||||
}, [wallet])
|
||||
|
||||
useEffect(() => {
|
||||
dayjs.locale(savedLanguage == 'zh_tw' ? 'zh-tw' : savedLanguage)
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
async function loadUnownedMangoAccount() {
|
||||
try {
|
||||
|
|
|
@ -23,6 +23,7 @@ import { PublicKey } from '@solana/web3.js'
|
|||
import FavoritesShortcutBar from '../components/FavoritesShortcutBar'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import AccountsModal from 'components/AccountsModal'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
const DISMISS_CREATE_ACCOUNT_KEY = 'show-create-account'
|
||||
|
||||
|
@ -57,10 +58,15 @@ const PerpMarket: React.FC = () => {
|
|||
const marketConfig = useMangoStore(marketConfigSelector)
|
||||
const actions = useMangoStore(actionsSelector)
|
||||
const router = useRouter()
|
||||
const [savedLanguage] = useLocalStorageState('language', '')
|
||||
const { pubkey } = router.query
|
||||
const { width } = useViewport()
|
||||
const hideTips = width ? width < breakpoints.md : false
|
||||
|
||||
useEffect(() => {
|
||||
dayjs.locale(savedLanguage == 'zh_tw' ? 'zh-tw' : savedLanguage)
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (connected && !mangoAccount && !dismissCreateAccount) {
|
||||
setShowCreateAccount(true)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { useState } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import TopBar from '../components/TopBar'
|
||||
import PageBodyContainer from '../components/PageBodyContainer'
|
||||
import StatsTotals from '../components/stats_page/StatsTotals'
|
||||
|
@ -12,6 +12,8 @@ import { useViewport } from '../hooks/useViewport'
|
|||
import { breakpoints } from '../components/TradePageGrid'
|
||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import useLocalStorageState from 'hooks/useLocalStorageState'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
export async function getStaticProps({ locale }) {
|
||||
return {
|
||||
|
@ -36,7 +38,12 @@ export default function StatsPage() {
|
|||
const [activeTab, setActiveTab] = useState(TABS[0])
|
||||
const { width } = useViewport()
|
||||
const isMobile = width ? width < breakpoints.sm : false
|
||||
const [savedLanguage] = useLocalStorageState('language', '')
|
||||
|
||||
useEffect(() => {
|
||||
dayjs.locale(savedLanguage == 'zh_tw' ? 'zh-tw' : savedLanguage)
|
||||
})
|
||||
|
||||
const handleChangeViewIndex = (index) => {
|
||||
setViewIndex(index)
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import JupiterForm from '../components/JupiterForm'
|
|||
import { zeroKey } from '@blockworks-foundation/mango-client'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import useLocalStorageState from 'hooks/useLocalStorageState'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
export async function getStaticProps({ locale }) {
|
||||
return {
|
||||
|
@ -24,7 +26,12 @@ export default function Swap() {
|
|||
const connection = useMangoStore(connectionSelector)
|
||||
const { connected, publicKey, wallet } = useWallet()
|
||||
const actions = useMangoStore(actionsSelector)
|
||||
const [savedLanguage] = useLocalStorageState('language', '')
|
||||
|
||||
useEffect(() => {
|
||||
dayjs.locale(savedLanguage == 'zh_tw' ? 'zh-tw' : savedLanguage)
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (wallet && connected) {
|
||||
actions.fetchWalletTokens(wallet)
|
||||
|
|
Loading…
Reference in New Issue