Conflict Commits
This commit is contained in:
parent
79c1e02537
commit
5d310be430
|
@ -21,7 +21,7 @@
|
|||
"Stack": "link:@mui/material/Stack",
|
||||
"Tabs": "link:@mui/material/Tabs",
|
||||
"Toolbar": "link:@mui/material/Toolbar",
|
||||
"Typography": "link:@mui/material/Typography",
|
||||
"Typography": "link:@mui/material/Typog raphy",
|
||||
"add": "^2.0.6",
|
||||
"axios": "^1.7.9",
|
||||
"clsx": "^2.1.1",
|
||||
|
|
14685
pnpm-lock.yaml
14685
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
34
src/App.tsx
34
src/App.tsx
|
@ -1,28 +1,12 @@
|
|||
import AppRouter from "./router";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useMatch, useNavigate, useSearchParams } from "react-router-dom";
|
||||
import { useEffect } from "react";
|
||||
import { RootState } from "./redux/store";
|
||||
import { withCookies, ReactCookieProps } from "react-cookie";
|
||||
import { BrowserRouter as Router} from 'react-router-dom';
|
||||
import AppRouter from './router';
|
||||
|
||||
const App: React.FC<ReactCookieProps> = ({ cookies }) => {
|
||||
const navigate = useNavigate();
|
||||
const isPanel = useMatch("/auth/login");
|
||||
const isCookiePresent = !!cookies?.get("authToken");
|
||||
console.log("cookies present:", isCookiePresent);
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
const isAuthenticated = useSelector(
|
||||
(state: RootState) => state.authReducer.isAuthenticated
|
||||
function App() {
|
||||
return (
|
||||
<Router>
|
||||
<AppRouter />
|
||||
</Router>
|
||||
);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (isPanel && isCookiePresent) {
|
||||
navigate("/panel/dashboard");
|
||||
}
|
||||
}, [isPanel, isAuthenticated, searchParams]);
|
||||
|
||||
return <AppRouter />;
|
||||
};
|
||||
|
||||
export default withCookies(App);
|
||||
export default App;
|
|
@ -11,9 +11,6 @@ import LogoutRoundedIcon from '@mui/icons-material/LogoutRounded';
|
|||
import MoreVertRoundedIcon from '@mui/icons-material/MoreVertRounded';
|
||||
import MenuButton from '../MenuButton';
|
||||
import { Avatar } from '@mui/material';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { logoutUser } from '../../redux/slices/authSlice';
|
||||
import { useCookies } from 'react-cookie';
|
||||
|
||||
const MenuItem = styled(MuiMenuItem)({
|
||||
margin: '2px 0',
|
||||
|
@ -22,20 +19,12 @@ const MenuItem = styled(MuiMenuItem)({
|
|||
export default function OptionsMenu({ avatar }: { avatar?: boolean }) {
|
||||
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
||||
const open = Boolean(anchorEl);
|
||||
const dispatch = useDispatch();
|
||||
const [cookies, setCookie, removeCookie] = useCookies(['authToken']);
|
||||
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
|
||||
setAnchorEl(event.currentTarget);
|
||||
};
|
||||
const handleClose = () => {
|
||||
setAnchorEl(null);
|
||||
};
|
||||
|
||||
const handleLogout = () => {
|
||||
dispatch(logoutUser({ removeCookie }));
|
||||
console.log('click')
|
||||
handleClose();
|
||||
};
|
||||
return (
|
||||
<React.Fragment>
|
||||
<MenuButton
|
||||
|
@ -81,7 +70,7 @@ export default function OptionsMenu({ avatar }: { avatar?: boolean }) {
|
|||
<MenuItem onClick={handleClose}>Settings</MenuItem>
|
||||
<Divider />
|
||||
<MenuItem
|
||||
onClick={handleLogout}
|
||||
onClick={handleClose}
|
||||
sx={{
|
||||
[`& .${listItemIconClasses.root}`]: {
|
||||
ml: 'auto',
|
||||
|
|
|
@ -1,32 +1,29 @@
|
|||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import "./index.css";
|
||||
import App from "./App";
|
||||
import { Provider } from "react-redux";
|
||||
import store from "./redux/store";
|
||||
import { Slide, ToastContainer } from "react-toastify";
|
||||
import { BrowserRouter as Router } from "react-router-dom";
|
||||
import { CookiesProvider } from "react-cookie";
|
||||
|
||||
const root = ReactDOM.createRoot(
|
||||
document.getElementById("root") as HTMLElement
|
||||
);
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import './index.css';
|
||||
import reportWebVitals from './reportWebVitals';
|
||||
import App from './App';
|
||||
import { Provider } from 'react-redux';
|
||||
import store from './redux/store/store.ts';
|
||||
import { Slide, ToastContainer } from 'react-toastify';
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<CookiesProvider defaultSetOptions={{ path: "/" }}>
|
||||
<Provider store={store}>
|
||||
<Router>
|
||||
<App />
|
||||
</Router>
|
||||
<ToastContainer
|
||||
autoClose={2000}
|
||||
hideProgressBar
|
||||
theme="dark"
|
||||
transition={Slide}
|
||||
toastStyle={{ border: "1px solid dimgray" }}
|
||||
/>
|
||||
</Provider>
|
||||
</CookiesProvider>
|
||||
</React.StrictMode>
|
||||
<React.StrictMode>
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
<ToastContainer
|
||||
autoClose={2000}
|
||||
hideProgressBar
|
||||
theme="dark"
|
||||
transition={Slide}
|
||||
toastStyle={{ border: '1px solid dimgray' }}
|
||||
/>
|
||||
</Provider>
|
||||
</React.StrictMode>
|
||||
);
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||
reportWebVitals();
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import { configureStore } from '@reduxjs/toolkit';
|
||||
import authReducer from '../slices/authSlice.ts'
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
auth: authReducer,
|
||||
},
|
||||
});
|
||||
|
||||
import rootReducer from './reducers';
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: rootReducer,
|
||||
})
|
||||
export type RootState = ReturnType<typeof store.getState>;
|
||||
export type AppDispatch = typeof store.dispatch;
|
||||
export default store;
|
||||
|
||||
|
Loading…
Reference in a new issue