30112023
This commit is contained in:
10
src/App.js
10
src/App.js
@@ -16,11 +16,11 @@ import { useEffect } from 'react';
|
||||
const App = () =>{
|
||||
let navigate=useNavigate()
|
||||
|
||||
// useEffect(()=>{
|
||||
// if (!localStorage.getItem("firstname")) {
|
||||
// navigate('/login')
|
||||
// }
|
||||
// },[])
|
||||
useEffect(()=>{
|
||||
if (!localStorage.getItem("authname")) {
|
||||
navigate('/login')
|
||||
}
|
||||
},[])
|
||||
|
||||
|
||||
return <>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.1 KiB |
BIN
src/assets/images/logo-nearle1.png
Normal file
BIN
src/assets/images/logo-nearle1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
@@ -36,19 +36,19 @@ const ProfileTab = ({ handleLogout }) => {
|
||||
<ListItemIcon>
|
||||
<ProfileOutlined />
|
||||
</ListItemIcon>
|
||||
<ListItemText primary="Social Profile" />
|
||||
<ListItemText primary="Account Settings" />
|
||||
</ListItemButton>
|
||||
<ListItemButton selected={selectedIndex === 4} onClick={(event) => handleListItemClick(event, 4)}>
|
||||
{/* <ListItemButton selected={selectedIndex === 4} onClick={(event) => handleListItemClick(event, 4)}>
|
||||
<ListItemIcon>
|
||||
<WalletOutlined />
|
||||
</ListItemIcon>
|
||||
<ListItemText primary="Billing" />
|
||||
</ListItemButton>
|
||||
</ListItemButton> */}
|
||||
<ListItemButton selected={selectedIndex === 2}
|
||||
// onClick={handleLogout}
|
||||
onClick={()=>{
|
||||
navigate('/login')
|
||||
}}
|
||||
onClick={handleLogout}
|
||||
// onClick={()=>{
|
||||
// navigate('/login')
|
||||
// }}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<LogoutOutlined />
|
||||
|
||||
@@ -52,12 +52,20 @@ const Profile = () => {
|
||||
// const { logout, user } = useAuth();
|
||||
const handleLogout = async () => {
|
||||
try {
|
||||
await logout();
|
||||
navigate(`/login`, {
|
||||
state: {
|
||||
from: ''
|
||||
}
|
||||
});
|
||||
// await logout();
|
||||
|
||||
// navigate(`/login`, {
|
||||
// state: {
|
||||
// from: ''
|
||||
// }
|
||||
// });
|
||||
localStorage.removeItem('firstname');
|
||||
localStorage.removeItem('appuserid');
|
||||
localStorage.removeItem('authname');
|
||||
localStorage.removeItem('roleid');
|
||||
|
||||
navigate('/login')
|
||||
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
@@ -153,14 +161,20 @@ const Profile = () => {
|
||||
{/* {user?.name} */}
|
||||
</Typography>
|
||||
<Typography variant="body2" color="textSecondary">
|
||||
UI/UX Designer
|
||||
{/* UI/UX Designer */}
|
||||
user
|
||||
</Typography>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Tooltip title="Logout">
|
||||
<IconButton size="large" sx={{ color: 'text.primary' }} onClick={handleLogout}>
|
||||
<IconButton size="large" sx={{ color: 'text.primary' }}
|
||||
// onClick={handleLogout}>
|
||||
onClick={()=>{
|
||||
handleLogout()
|
||||
}}>
|
||||
|
||||
<LogoutOutlined />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
@@ -182,7 +196,7 @@ const Profile = () => {
|
||||
label="Profile"
|
||||
{...a11yProps(0)}
|
||||
/>
|
||||
<Tab
|
||||
{/* <Tab
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
@@ -193,7 +207,7 @@ const Profile = () => {
|
||||
icon={<SettingOutlined style={{ marginBottom: 0, marginRight: '10px' }} />}
|
||||
label="Setting"
|
||||
{...a11yProps(1)}
|
||||
/>
|
||||
/> */}
|
||||
</Tabs>
|
||||
</Box>
|
||||
<TabPanel value={value} index={0} dir={theme.direction}>
|
||||
|
||||
@@ -29,7 +29,7 @@ const HeaderContent = () => {
|
||||
{matchesXs && <Box sx={{ width: '100%', ml: 1 }} />}
|
||||
|
||||
<Notification />
|
||||
<Message />
|
||||
{/* <Message /> */}
|
||||
{!matchesXs && <Profile />}
|
||||
{matchesXs && <MobileSection />}
|
||||
</Stack>
|
||||
|
||||
@@ -63,11 +63,13 @@ const Login = () => {
|
||||
// }, [toast])
|
||||
|
||||
useEffect(() => {
|
||||
if (localStorage.getItem("firstname") || localStorage.getItem("appuserid")) {
|
||||
if (localStorage.getItem("authname")
|
||||
// || localStorage.getItem("appuserid")
|
||||
) {
|
||||
navigate('/dashboard')
|
||||
}
|
||||
|
||||
console.log(alertmessage)
|
||||
// console.log(alertmessage)
|
||||
}, [])
|
||||
|
||||
const usernamecheck = async (e) => {
|
||||
@@ -78,17 +80,20 @@ const Login = () => {
|
||||
// await axios.post(`${process.env.REACT_APP_URL}/auth/login`, {
|
||||
// "authname": e.target.value
|
||||
// })
|
||||
await axios.post(`${process.env.REACT_APP_URL2}/users/login`, {
|
||||
await axios.post(`${process.env.REACT_APP_URL}/users/login`, {
|
||||
"authname": e.target.value,
|
||||
"configid":3,
|
||||
// "password":'admi'
|
||||
"configid":1,
|
||||
"password":'admin'
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
if (res.data.userinfo.authname === e.target.value) {
|
||||
console.log(res.data)
|
||||
if (res.data.details.authname === e.target.value) {
|
||||
|
||||
setUsername(e.target.value);
|
||||
setCheckusername(false);
|
||||
}else{
|
||||
setCheckusername(true);
|
||||
|
||||
}
|
||||
// if (res.data.authname === e.target.value) {
|
||||
|
||||
@@ -96,10 +101,10 @@ const Login = () => {
|
||||
// setCheckusername(false);
|
||||
// }
|
||||
}).catch((err) => {
|
||||
if (err.response.data.message === 'No user found') {
|
||||
// if (err.response.data.message === 'No user found') {
|
||||
|
||||
setCheckusername(true);
|
||||
}
|
||||
// }
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
@@ -115,13 +120,13 @@ const Login = () => {
|
||||
if (password && username) {
|
||||
setSubmitting(true)
|
||||
try {
|
||||
await axios.post(`${process.env.REACT_APP_URL2}/users/login`, {
|
||||
await axios.post(`${process.env.REACT_APP_URL}/users/login`, {
|
||||
"authname": username,
|
||||
"configid":3,
|
||||
"configid":1,
|
||||
"password": password
|
||||
}).then((res) => {
|
||||
console.log(res.data)
|
||||
if (res.data.userinfo.authname === username) {
|
||||
if (res.data.details.authname === username) {
|
||||
// setAlertmessage('login Successfull');
|
||||
setLoading(false)
|
||||
// dispatch(
|
||||
@@ -141,12 +146,14 @@ const Login = () => {
|
||||
})
|
||||
setUsername('');
|
||||
setPassword('');
|
||||
localStorage.setItem("firstname", res.data.userinfo.firstname);
|
||||
localStorage.setItem("appuserid", res.data.userinfo.userid);
|
||||
localStorage.setItem("roleid", res.data.userinfo.roleid);
|
||||
localStorage.setItem("firstname", res.data.details.firstname);
|
||||
localStorage.setItem("authname", res.data.details.authname);
|
||||
|
||||
localStorage.setItem("appuserid", res.data.details.userid);
|
||||
localStorage.setItem("roleid", res.data.details.roleid);
|
||||
|
||||
|
||||
navigate('/dashboard', { state: { firstname: res.data.userinfo.firstname } });
|
||||
navigate('/dashboard');
|
||||
setSubmitting(false)
|
||||
}
|
||||
}).catch((err) => {
|
||||
@@ -226,7 +233,9 @@ const Login = () => {
|
||||
container
|
||||
justifyContent="center"
|
||||
alignItems="center"
|
||||
sx={{ minHeight: { xs: 'calc(100vh - 210px)', sm: 'calc(100vh - 134px)', md: 'calc(100vh - 112px)' } }}
|
||||
// sx={{ minHeight: { xs: 'calc(100vh - 210px)', sm: 'calc(100vh - 134px)', md: 'calc(100vh - 112px)' } }}
|
||||
sx={{ minHeight: { xs: 'calc(100vh - 210px)', sm: 'calc(100vh - 134px)', md: 'calc(100vh - 132px)' } }}
|
||||
|
||||
>
|
||||
<Grid item>
|
||||
{/* <AuthCard>{children}</AuthCard> */}
|
||||
@@ -398,8 +407,8 @@ const Login = () => {
|
||||
disabled={submitting}
|
||||
|
||||
onClick={()=>{
|
||||
// loginsend()
|
||||
navigate('/dashboard')
|
||||
loginsend()
|
||||
// navigate('/dashboard')
|
||||
}}
|
||||
fullWidth size="large" type="submit" variant="contained" color="primary">
|
||||
Login
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// import { lazy } from 'react';
|
||||
import { lazy } from 'react';
|
||||
|
||||
// project import
|
||||
// import GuestGuard from 'utils/route-guard/GuestGuard';
|
||||
import CommonLayout from 'layout/CommonLayout';
|
||||
// import Loadable from 'components/Loadable';
|
||||
import Loadable from 'components/Loadable';
|
||||
|
||||
// render - login
|
||||
// const AuthLogin = Loadable(lazy(() => import('pages/auth/login')));
|
||||
@@ -12,6 +12,7 @@ import CommonLayout from 'layout/CommonLayout';
|
||||
// const AuthCheckMail = Loadable(lazy(() => import('pages/auth/check-mail')));
|
||||
// const AuthResetPassword = Loadable(lazy(() => import('pages/auth/reset-password')));
|
||||
// const AuthCodeVerification = Loadable(lazy(() => import('pages/auth/code-verification')));
|
||||
const Login = Loadable(lazy(() => import('pages/nearle/login')));
|
||||
|
||||
// ==============================|| AUTH ROUTING ||============================== //
|
||||
|
||||
@@ -26,6 +27,14 @@ const LoginRoutes = {
|
||||
// </GuestGuard>
|
||||
),
|
||||
children: [
|
||||
{
|
||||
path: '/',
|
||||
element: <Login />
|
||||
},
|
||||
{
|
||||
path: 'login',
|
||||
element: <Login />
|
||||
},
|
||||
// {
|
||||
// path: '/',
|
||||
// element: <AuthLogin />
|
||||
@@ -55,7 +64,8 @@ const LoginRoutes = {
|
||||
// element: <AuthCodeVerification />
|
||||
// }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
@@ -32,10 +32,10 @@ const MainRoutes = {
|
||||
// </AuthGuard>
|
||||
),
|
||||
children: [
|
||||
{
|
||||
path: 'sample-page',
|
||||
element: <SamplePage />
|
||||
},
|
||||
// {
|
||||
// path: 'sample-page',
|
||||
// element: <SamplePage />
|
||||
// },
|
||||
{
|
||||
path: 'dashboard',
|
||||
element: <Dashboard />
|
||||
@@ -43,6 +43,7 @@ const MainRoutes = {
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
path:'/login',
|
||||
element:<Login />
|
||||
|
||||
Reference in New Issue
Block a user