Refactored to use app folder.

This commit is contained in:
Mike Cao 2023-09-29 05:29:22 -07:00
parent 40cfcd41e9
commit 9a52cdd2e1
258 changed files with 2025 additions and 2258 deletions

View file

@ -1,5 +1,4 @@
import { useEffect } from 'react';
import { useRouter } from 'next/router';
import { httpGet, setItem } from 'next-basics';
import { LOCALE_CONFIG } from 'lib/constants';
import { getDateLocale, getTextDirection } from 'lib/lang';
@ -15,13 +14,12 @@ const selector = state => state.locale;
export function useLocale() {
const locale = useStore(selector);
const { basePath } = useRouter();
const forceUpdate = useForceUpdate();
const dir = getTextDirection(locale);
const dateLocale = getDateLocale(locale);
async function loadMessages(locale) {
const { ok, data } = await httpGet(`${basePath}/intl/messages/${locale}.json`);
const { ok, data } = await httpGet(`${process.env.basePath}/intl/messages/${locale}.json`);
if (ok) {
messages[locale] = data;