|
1 | 1 | import "./App.css"; |
| 2 | +import "@codepod/ui/src/custom.css"; |
2 | 3 |
|
3 | | -import { Test } from "@codepod/ui"; |
| 4 | +import { |
| 5 | + createBrowserRouter, |
| 6 | + createRoutesFromElements, |
| 7 | + Route, |
| 8 | + RouterProvider, |
| 9 | +} from "react-router-dom"; |
4 | 10 |
|
5 | | -function App() { |
6 | | - return <Test />; |
| 11 | +import { createTheme, ThemeProvider } from "@mui/material/styles"; |
| 12 | + |
| 13 | +import { Dashboard, Repo, Test, Profile, Docs } from "@codepod/ui"; |
| 14 | + |
| 15 | +import { Header, Footer } from "@codepod/ui"; |
| 16 | +import { AuthProvider } from "@codepod/ui"; |
| 17 | + |
| 18 | +import Box from "@mui/material/Box"; |
| 19 | +import { SnackbarProvider } from "notistack"; |
| 20 | + |
| 21 | +const yjsWsUrl = import.meta.env.VITE_APP_YJS_WS_URL; |
| 22 | +const apiUrl = import.meta.env.VITE_APP_API_URL; |
| 23 | +const spawnerApiUrl = import.meta.env.VITE_APP_SPAWNER_API_URL; |
| 24 | + |
| 25 | +if (!yjsWsUrl) { |
| 26 | + throw new Error("VITE_APP_YJS_WS_URL is not defined"); |
| 27 | +} |
| 28 | +if (!apiUrl) { |
| 29 | + throw new Error("VITE_APP_API_URL is not defined"); |
7 | 30 | } |
| 31 | +if (!spawnerApiUrl) { |
| 32 | + throw new Error("VITE_APP_RUNTIME_API_URL is not defined"); |
| 33 | +} |
| 34 | + |
| 35 | +const theme = createTheme({ |
| 36 | + typography: { |
| 37 | + button: { |
| 38 | + textTransform: "none", |
| 39 | + }, |
| 40 | + }, |
| 41 | +}); |
| 42 | + |
| 43 | +type NormalLayoutProps = { |
| 44 | + currentPage?: string | null; |
| 45 | + children: React.ReactNode; |
| 46 | +}; |
8 | 47 |
|
9 | | -export default App; |
| 48 | +const NormalLayout: React.FC<NormalLayoutProps> = ({ |
| 49 | + currentPage, |
| 50 | + children, |
| 51 | +}) => { |
| 52 | + return ( |
| 53 | + <Box> |
| 54 | + <Header currentPage={currentPage} /> |
| 55 | + <Box pt="50px">{children}</Box> |
| 56 | + {/* <Footer /> */} |
| 57 | + </Box> |
| 58 | + ); |
| 59 | +}; |
| 60 | + |
| 61 | +const router = createBrowserRouter([ |
| 62 | + { |
| 63 | + path: "repo/:id", |
| 64 | + element: ( |
| 65 | + <Box height="100vh" width="100%" boxSizing={"border-box"}> |
| 66 | + <Repo yjsWsUrl={yjsWsUrl} /> |
| 67 | + </Box> |
| 68 | + ), |
| 69 | + }, |
| 70 | + { |
| 71 | + path: "test", |
| 72 | + element: ( |
| 73 | + <NormalLayout> |
| 74 | + <Test /> |
| 75 | + </NormalLayout> |
| 76 | + ), |
| 77 | + }, |
| 78 | + { |
| 79 | + path: "/", |
| 80 | + element: ( |
| 81 | + <NormalLayout> |
| 82 | + <Dashboard /> |
| 83 | + </NormalLayout> |
| 84 | + ), |
| 85 | + }, |
| 86 | +]); |
| 87 | + |
| 88 | +export default function App() { |
| 89 | + return ( |
| 90 | + <ThemeProvider theme={theme}> |
| 91 | + <AuthProvider apiUrl={apiUrl} spawnerApiUrl={spawnerApiUrl}> |
| 92 | + <SnackbarProvider maxSnack={5}> |
| 93 | + <RouterProvider router={router} /> |
| 94 | + </SnackbarProvider> |
| 95 | + </AuthProvider> |
| 96 | + </ThemeProvider> |
| 97 | + ); |
| 98 | +} |
0 commit comments