|
1 |
| -import { useState } from "react"; |
2 |
| -import reactLogo from "./assets/react.svg"; |
3 |
| -import viteLogo from "/vite.svg"; |
| 1 | +import React, { lazy, Suspense, useEffect, useState } from "react"; |
| 2 | +import { Route, Routes, Navigate } from "react-router-dom"; |
4 | 3 | import { useDispatch, useSelector } from "react-redux";
|
5 | 4 | import { userLogin } from "@app/store/authReducer/actions";
|
6 |
| -import MailApp from "@app/components"; |
| 5 | +import { red } from "@mui/material/colors"; |
| 6 | +import { ThemeProvider, createTheme } from "@mui/material/styles"; |
| 7 | +import { indigo, pink } from "@mui/material/colors"; |
7 | 8 |
|
8 |
| -function App() { |
| 9 | +const theme = createTheme({ |
| 10 | + breakpoints: { |
| 11 | + values: { |
| 12 | + xs: 0, |
| 13 | + sm: 600, |
| 14 | + md: 960, |
| 15 | + lg: 1280, |
| 16 | + xl: 1920, |
| 17 | + }, |
| 18 | + }, |
| 19 | + spacing: 2, |
| 20 | + direction: "ltr", |
| 21 | + palette: { |
| 22 | + mode: "light", |
| 23 | + primary: { |
| 24 | + main: "#1976D2", |
| 25 | + }, |
| 26 | + secondary: { |
| 27 | + main: "#F50057", |
| 28 | + }, |
| 29 | + background: { |
| 30 | + paper: "#FFFFFF", |
| 31 | + default: "#F4F4F7", |
| 32 | + }, |
| 33 | + common: { |
| 34 | + dark: "#080808", |
| 35 | + }, |
| 36 | + text: { |
| 37 | + primary: "rgba(0, 0, 0, 0.87)", |
| 38 | + secondary: "rgba(0, 0, 0, 0.6)", |
| 39 | + disabled: "rgba(0, 0, 0, 0.38)", |
| 40 | + hint: "rgba(0, 0, 0, 0.3)", |
| 41 | + white: "#fff", |
| 42 | + }, |
| 43 | + btn: { |
| 44 | + hover: "rgba(0, 0, 0, 0.08)", |
| 45 | + }, |
| 46 | + lightBtn: { |
| 47 | + bgColor: "#F5F5F5", |
| 48 | + textColor: "rgba(0, 0, 0, 0.54)", |
| 49 | + }, |
| 50 | + borderColor: { |
| 51 | + main: "rgba(0, 0, 0, 0.06)", |
| 52 | + dark: "rgba(0, 0, 0, 0.12)", |
| 53 | + }, |
| 54 | + popupColor: { |
| 55 | + main: "#F9F9F9", |
| 56 | + }, |
| 57 | + }, |
| 58 | + components: { |
| 59 | + MuiTypography: { |
| 60 | + styleOverrides: { |
| 61 | + h1: { |
| 62 | + fontSize: 24, |
| 63 | + fontWeight: "bold", |
| 64 | + "@media (min-width: 960px)": { |
| 65 | + fontSize: 28, |
| 66 | + }, |
| 67 | + }, |
| 68 | + h2: { |
| 69 | + fontSize: 20, |
| 70 | + fontWeight: "bold", |
| 71 | + "@media (min-width: 960px)": { |
| 72 | + fontSize: 24, |
| 73 | + }, |
| 74 | + }, |
| 75 | + h3: { |
| 76 | + fontSize: 18, |
| 77 | + fontWeight: "bold", |
| 78 | + "@media (min-width: 960px)": { |
| 79 | + fontSize: 20, |
| 80 | + }, |
| 81 | + }, |
| 82 | + h4: { |
| 83 | + fontSize: 16, |
| 84 | + fontWeight: "bold", |
| 85 | + }, |
| 86 | + h5: { |
| 87 | + fontSize: 14, |
| 88 | + fontWeight: 500, |
| 89 | + }, |
| 90 | + h6: { |
| 91 | + fontSize: 14, |
| 92 | + fontWeight: "bold", |
| 93 | + letterSpacing: "0.5px", |
| 94 | + }, |
| 95 | + subtitle1: { |
| 96 | + fontSize: 16, |
| 97 | + fontWeight: 400, |
| 98 | + letterSpacing: "0.15px", |
| 99 | + }, |
| 100 | + subtitle2: { |
| 101 | + fontSize: 14, |
| 102 | + fontWeight: "bold", |
| 103 | + letterSpacing: "0.1px", |
| 104 | + }, |
| 105 | + body1: { |
| 106 | + fontSize: 16, |
| 107 | + fontWeight: 400, |
| 108 | + letterSpacing: "0.5px", |
| 109 | + }, |
| 110 | + body2: { |
| 111 | + fontSize: 14, |
| 112 | + fontWeight: 400, |
| 113 | + letterSpacing: "0.25px", |
| 114 | + }, |
| 115 | + }, |
| 116 | + }, |
| 117 | + MuiButton: { |
| 118 | + styleOverrides: { |
| 119 | + root: { |
| 120 | + fontWeight: "bold", |
| 121 | + letterSpacing: "1px", |
| 122 | + fontSize: 14, |
| 123 | + }, |
| 124 | + }, |
| 125 | + }, |
| 126 | + MuiToggleButton: { |
| 127 | + styleOverrides: { |
| 128 | + root: { |
| 129 | + borderRadius: 8, |
| 130 | + }, |
| 131 | + }, |
| 132 | + }, |
| 133 | + MuiCardLg: { |
| 134 | + styleOverrides: { |
| 135 | + root: { |
| 136 | + borderRadius: 12, |
| 137 | + }, |
| 138 | + }, |
| 139 | + }, |
| 140 | + MuiCard: { |
| 141 | + styleOverrides: { |
| 142 | + root: { |
| 143 | + borderRadius: 8, |
| 144 | + boxShadow: "0px 3px 6px rgba(0, 0, 0, 0.1)", |
| 145 | + }, |
| 146 | + }, |
| 147 | + }, |
| 148 | + MuiTab: { |
| 149 | + styleOverrides: { |
| 150 | + textColorPrimary: { |
| 151 | + color: "rgba(0, 0, 0, 0.87)", |
| 152 | + }, |
| 153 | + }, |
| 154 | + }, |
| 155 | + MuiPopover: { |
| 156 | + styleOverrides: { |
| 157 | + paper: { |
| 158 | + backgroundColor: "#FFFFFF", |
| 159 | + }, |
| 160 | + }, |
| 161 | + }, |
| 162 | + MuiDialog: { |
| 163 | + styleOverrides: { |
| 164 | + paper: { |
| 165 | + backgroundColor: "#FFFFFF", |
| 166 | + }, |
| 167 | + }, |
| 168 | + }, |
| 169 | + }, |
| 170 | + typography: { |
| 171 | + fontWeightExtraLight: 200, |
| 172 | + fontWeightLight: 300, |
| 173 | + fontWeightRegular: 400, |
| 174 | + fontWeightBold: "bold", |
| 175 | + fontWeightExtraBold: 800, |
| 176 | + }, |
| 177 | + status: { |
| 178 | + danger: "red", |
| 179 | + }, |
| 180 | +}); |
| 181 | + |
| 182 | +const darkTheme = createTheme({ |
| 183 | + ...theme, |
| 184 | + palette: { |
| 185 | + ...theme.palette, |
| 186 | + common: { |
| 187 | + dark: "#080808", |
| 188 | + }, |
| 189 | + mode: "dark", |
| 190 | + primary: { |
| 191 | + main: "#1976D2", |
| 192 | + }, |
| 193 | + secondary: { |
| 194 | + main: "#F50057", |
| 195 | + }, |
| 196 | + background: { |
| 197 | + paper: "#121212", |
| 198 | + default: "#080808", |
| 199 | + }, |
| 200 | + text: { |
| 201 | + primary: "#FFFFFF", |
| 202 | + secondary: "rgba(255, 255, 255, 0.6)", |
| 203 | + disabled: "rgba(255, 255, 255, 0.38)", |
| 204 | + hint: "rgba(255, 255, 255, 0.3)", |
| 205 | + white: "#fff", |
| 206 | + }, |
| 207 | + btn: { |
| 208 | + hover: "rgba(255, 255, 255, 0.08)", |
| 209 | + }, |
| 210 | + lightBtn: { |
| 211 | + bgColor: "#212121", |
| 212 | + textColor: "rgba(255, 255, 255, 0.6)", |
| 213 | + }, |
| 214 | + borderColor: { |
| 215 | + main: "rgba(255, 255, 255, 0.12)", |
| 216 | + dark: "rgba(255, 255, 255, 0.2)", |
| 217 | + }, |
| 218 | + popupColor: { |
| 219 | + main: "#121212", |
| 220 | + }, |
| 221 | + }, |
| 222 | +}); |
| 223 | + |
| 224 | +const App = () => { |
9 | 225 | const { loading, userInfo, error } = useSelector((state) => state.auth);
|
| 226 | + const [currentTheme, setCurrentTheme] = useState("light"); |
| 227 | + |
10 | 228 | const dispatch = useDispatch();
|
11 | 229 |
|
12 | 230 | const submitForm = (data) => {
|
13 | 231 | dispatch(userLogin({ email: "test", password: "test" }));
|
14 | 232 | };
|
15 | 233 |
|
| 234 | + const Landing = lazy(() => import("@app/pages/Landing")); |
| 235 | + |
| 236 | + useEffect(() => { |
| 237 | + setCurrentTheme(localStorage.getItem("theme")); |
| 238 | + }, [dispatch, localStorage.getItem("user"), localStorage.getItem("theme")]); |
| 239 | + |
16 | 240 | return (
|
17 |
| - <> |
18 |
| - <MailApp /> |
19 |
| - </> |
| 241 | + <ThemeProvider theme={currentTheme === "light" ? theme : darkTheme}> |
| 242 | + <Suspense> |
| 243 | + <Routes> |
| 244 | + <Route exact path="/" element={<Landing />} /> |
| 245 | + <Route exact path="/home" element={<Navigate to={"/"} replace />} /> |
| 246 | + </Routes> |
| 247 | + </Suspense> |
| 248 | + </ThemeProvider> |
20 | 249 | );
|
21 |
| -} |
| 250 | +}; |
22 | 251 |
|
23 | 252 | export default App;
|
0 commit comments