/
MainLayout.tsx
54 lines (51 loc) · 1.27 KB
/
MainLayout.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Config } from "@/config";
import {
Box,
CssBaseline,
MenuItem,
Select,
SelectChangeEvent,
StyledEngineProvider,
ThemeProvider,
} from "@mui/material";
import React, { useContext } from "react";
import { Content } from "./Content";
import { Footer } from "./Footer";
import { Header } from "./Header";
import { I18nContext, LOCALES } from "@/libs/i18n";
const LanguageSelect = () => {
const { locale, setLocale } = useContext(I18nContext);
const handleChange = (event: SelectChangeEvent) => {
setLocale(event.target.value);
};
return (
<Box
sx={{
position: "fixed",
bottom: "1rem",
right: "0.5rem",
}}
>
<Select value={locale} onChange={handleChange} size="small">
{LOCALES.map((locale: string) => (
<MenuItem key={locale} value={locale}>
{locale.toUpperCase()}
</MenuItem>
))}
</Select>
</Box>
);
};
export const MainLayout = ({ children }: { children: React.ReactNode }) => {
return (
<StyledEngineProvider injectFirst>
<ThemeProvider theme={Config.theme}>
<CssBaseline />
<Header />
<Content>{children}</Content>
<Footer />
<LanguageSelect />
</ThemeProvider>
</StyledEngineProvider>
);
};