Merge branch 'feature/update_profile_sidebar' into 'develop'
Feature/update profile sidebar See merge request witel-front-end/rms!19
This commit is contained in:
@@ -19,32 +19,23 @@ const HeaderMenu = ({ menu }) => {
|
|||||||
<Button
|
<Button
|
||||||
color="inherit"
|
color="inherit"
|
||||||
aria-haspopup="true"
|
aria-haspopup="true"
|
||||||
aria-expanded={open ? 'true' : undefined}
|
aria-expanded={open ? "true" : undefined}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
endIcon={open ? <ExpandLess /> : <ExpandMore />}
|
endIcon={open ? <ExpandLess /> : <ExpandMore />}
|
||||||
>
|
>
|
||||||
{menu.title}
|
{menu.title}
|
||||||
</Button>
|
</Button>
|
||||||
<Menu
|
<Menu anchorEl={anchorEl} open={open} onClose={handleClose}>
|
||||||
anchorEl={anchorEl}
|
|
||||||
open={open}
|
|
||||||
onClose={handleClose}
|
|
||||||
>
|
|
||||||
{menu.subMenu.flatMap((subMenu, index) => [
|
{menu.subMenu.flatMap((subMenu, index) => [
|
||||||
...subMenu.map(sub => (
|
...subMenu.map((sub) => (
|
||||||
<MenuItem
|
<MenuItem component={NextLink} href={sub.href} key={sub.title} onClick={handleClose}>
|
||||||
component={NextLink}
|
|
||||||
href={sub.href}
|
|
||||||
key={sub.title}
|
|
||||||
onClick={handleClose}
|
|
||||||
>
|
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<Link fontSize="small" />
|
<Link fontSize="small" />
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText>{sub.title}</ListItemText>
|
<ListItemText>{sub.title}</ListItemText>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
)),
|
)),
|
||||||
index < menu.subMenu.length - 1 && <Divider key={`divider-${index}`} />
|
index < menu.subMenu.length - 1 && <Divider key={`divider-${index}`} />,
|
||||||
])}
|
])}
|
||||||
</Menu>
|
</Menu>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,22 +1,19 @@
|
|||||||
import { getValueByPath } from "@/core/utils/getValueByPath";
|
import { getValueByPath } from "@/core/utils/getValueByPath";
|
||||||
import { useSidebarBadge } from "@/lib/hooks/useSidebarBadge"
|
import { useSidebarBadge } from "@/lib/hooks/useSidebarBadge";
|
||||||
import { Chip } from "@mui/material"
|
import { Chip } from "@mui/material";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
const SidebarBadge = ({ badge, chipProps = {} }) => {
|
const SidebarBadge = ({ badge, chipProps = {} }) => {
|
||||||
const { data } = useSidebarBadge()
|
const { data } = useSidebarBadge();
|
||||||
const [value, setValue] = useState()
|
const [value, setValue] = useState();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setValue(getValueByPath(data, badge))
|
setValue(getValueByPath(data, badge));
|
||||||
}, [data, badge])
|
}, [data, badge]);
|
||||||
|
|
||||||
|
if (!data) return null;
|
||||||
|
if (!value) return null;
|
||||||
|
|
||||||
if (!data) return null
|
return <Chip label={value.toLocaleString("fa-IR")} size="small" {...chipProps} />;
|
||||||
if (!value) return null
|
};
|
||||||
|
export default SidebarBadge;
|
||||||
return (
|
|
||||||
<Chip label={(value).toLocaleString("fa-IR")} size="small" {...chipProps} />
|
|
||||||
)
|
|
||||||
}
|
|
||||||
export default SidebarBadge
|
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ const SidebarListItems = ({ menuItem, dispatch }) => {
|
|||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText primary={menuItem.label} />
|
<ListItemText primary={menuItem.label} />
|
||||||
{menuItem.badges && (
|
{menuItem.badges && (
|
||||||
<Stack direction={'row'} sx={{ px: .5 }} spacing={.5}>
|
<Stack direction={"row"} sx={{ px: 0.5 }} spacing={0.5}>
|
||||||
{menuItem.badges.map((badge, i) => <SidebarBadge chipProps={{ color: 'primary' }} key={i} badge={badge} />)}
|
{menuItem.badges.map((badge, i) => (
|
||||||
|
<SidebarBadge chipProps={{ color: "primary" }} key={i} badge={badge} />
|
||||||
|
))}
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
{menuItem.hasSubitems ? menuItem.showSubitems ? <ExpandLess /> : <ExpandMore /> : null}
|
{menuItem.hasSubitems ? menuItem.showSubitems ? <ExpandLess /> : <ExpandMore /> : null}
|
||||||
|
|||||||
@@ -28,9 +28,7 @@ function selectPage(item, route) {
|
|||||||
|
|
||||||
function toggleSubitems(items, actionId) {
|
function toggleSubitems(items, actionId) {
|
||||||
return items.map((item) =>
|
return items.map((item) =>
|
||||||
actionId === item.id
|
actionId === item.id ? { ...item, showSubitems: !item.showSubitems } : { ...item, showSubitems: false }
|
||||||
? { ...item, showSubitems: !item.showSubitems }
|
|
||||||
: { ...item, showSubitems: false }
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,28 +46,23 @@ function reducer(state, action) {
|
|||||||
|
|
||||||
case "COLLAPSE_SUB_ITEMS":
|
case "COLLAPSE_SUB_ITEMS":
|
||||||
return state.map((item) =>
|
return state.map((item) =>
|
||||||
item.hasSubitems
|
item.hasSubitems ? { ...item, Subitems: toggleSubitems(item.Subitems, action.id) } : item
|
||||||
? { ...item, Subitems: toggleSubitems(item.Subitems, action.id) }
|
|
||||||
: item
|
|
||||||
);
|
);
|
||||||
|
|
||||||
case "COLLAPSE_SUB_SECOND_ITEMS":
|
case "COLLAPSE_SUB_SECOND_ITEMS":
|
||||||
return state.map((item) =>
|
return state.map((item) =>
|
||||||
item.hasSubitems
|
item.hasSubitems
|
||||||
? {
|
? {
|
||||||
...item,
|
...item,
|
||||||
Subitems: item.Subitems.map((subitem) =>
|
Subitems: item.Subitems.map((subitem) =>
|
||||||
subitem.hasSubitems
|
subitem.hasSubitems
|
||||||
? {
|
? {
|
||||||
...subitem,
|
...subitem,
|
||||||
Subitems: toggleSubitems(
|
Subitems: toggleSubitems(subitem.Subitems, action.id),
|
||||||
subitem.Subitems,
|
}
|
||||||
action.id
|
: subitem
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
: subitem
|
|
||||||
),
|
|
||||||
}
|
|
||||||
: item
|
: item
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -108,15 +101,13 @@ const SidebarMenu = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Profile />
|
<Profile />
|
||||||
{
|
{userPermissions && (
|
||||||
userPermissions && (
|
<List sx={{ overflow: "auto", flex: 1 }} disablePadding dense>
|
||||||
<List sx={{ overflow: "auto", flex: 1 }} disablePadding dense>
|
{menuItems.map((menuItem) => {
|
||||||
{menuItems.map((menuItem) => {
|
return <SidebarListItems dispatch={dispatch} key={menuItem.id} menuItem={menuItem} />;
|
||||||
return <SidebarListItems dispatch={dispatch} key={menuItem.id} menuItem={menuItem} />;
|
})}
|
||||||
})}
|
</List>
|
||||||
</List>
|
)}
|
||||||
)
|
|
||||||
}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,11 +29,21 @@ const SidebarSubitems = ({ subitem, dispatch }) => {
|
|||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText primary={subitem.label} />
|
<ListItemText primary={subitem.label} />
|
||||||
{subitem.badges && (
|
{subitem.badges && (
|
||||||
<Stack direction={'row'} sx={{ px: .5 }} spacing={.5}>
|
<Stack direction={"row"} sx={{ px: 0.5 }} spacing={0.5}>
|
||||||
{subitem.badges.map((badge, i) => <SidebarBadge key={i} badge={badge} />)}
|
{subitem.badges.map((badge, i) => (
|
||||||
|
<SidebarBadge key={i} badge={badge} />
|
||||||
|
))}
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
{subitem.hasSubitems ? subitem.showSubitems ? <ExpandLess /> : <ExpandMore /> : <Box sx={{ width: 29 }} />}
|
{subitem.hasSubitems ? (
|
||||||
|
subitem.showSubitems ? (
|
||||||
|
<ExpandLess />
|
||||||
|
) : (
|
||||||
|
<ExpandMore />
|
||||||
|
)
|
||||||
|
) : (
|
||||||
|
<Box sx={{ width: 29 }} />
|
||||||
|
)}
|
||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<Collapse in={subitem.showSubitems} timeout="auto" mountOnEnter={true} unmountOnExit={true}>
|
<Collapse in={subitem.showSubitems} timeout="auto" mountOnEnter={true} unmountOnExit={true}>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { headerMenu } from "@/core/utils/headerMenu";
|
|||||||
import SidebarMenu from "./Sidebar/SidebarMenu";
|
import SidebarMenu from "./Sidebar/SidebarMenu";
|
||||||
|
|
||||||
const drawerWidth = 300;
|
const drawerWidth = 300;
|
||||||
const headersHeight = 136
|
const headersHeight = 136;
|
||||||
|
|
||||||
const Main = styled(Stack, { shouldForwardProp: (prop) => prop !== "open" })(({ theme, open }) => ({
|
const Main = styled(Stack, { shouldForwardProp: (prop) => prop !== "open" })(({ theme, open }) => ({
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
@@ -66,9 +66,14 @@ const HeaderWithSidebar = ({ children }) => {
|
|||||||
setOpen(false);
|
setOpen(false);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Box sx={{
|
<Box
|
||||||
display: "flex", height: `calc(100% - ${headersHeight}px)`, width: "100%", mt: `${headersHeight}px`
|
sx={{
|
||||||
}}>
|
display: "flex",
|
||||||
|
height: `calc(100% - ${headersHeight}px)`,
|
||||||
|
width: "100%",
|
||||||
|
mt: `${headersHeight}px`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<AppBar sx={{ position: "fixed", top: "unset" }} elevation={0} open={open}>
|
<AppBar sx={{ position: "fixed", top: "unset" }} elevation={0} open={open}>
|
||||||
<Toolbar variant="dense" sx={{ minHeight: 40 }}>
|
<Toolbar variant="dense" sx={{ minHeight: 40 }}>
|
||||||
<IconButton
|
<IconButton
|
||||||
@@ -81,7 +86,9 @@ const HeaderWithSidebar = ({ children }) => {
|
|||||||
<MenuIcon />
|
<MenuIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Box sx={{ flexGrow: 1, display: { xs: "none", md: "flex" } }}>
|
<Box sx={{ flexGrow: 1, display: { xs: "none", md: "flex" } }}>
|
||||||
{headerMenu.map(menu => <HeaderMenu key={menu.title} menu={menu} />)}
|
{headerMenu.map((menu) => (
|
||||||
|
<HeaderMenu key={menu.title} menu={menu} />
|
||||||
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
@@ -104,7 +111,9 @@ const HeaderWithSidebar = ({ children }) => {
|
|||||||
open={open}
|
open={open}
|
||||||
>
|
>
|
||||||
<DrawerHeader sx={{ display: "flex", alignItems: "center", justifyContent: "space-between" }}>
|
<DrawerHeader sx={{ display: "flex", alignItems: "center", justifyContent: "space-between" }}>
|
||||||
<Typography variant="subtitle2" color="#757575" sx={{ px: 1 }}>تاریخ امروز: {now}</Typography>
|
<Typography variant="subtitle2" color="#757575" sx={{ px: 1 }}>
|
||||||
|
تاریخ امروز: {now}
|
||||||
|
</Typography>
|
||||||
<IconButton onClick={handleDrawerClose}>
|
<IconButton onClick={handleDrawerClose}>
|
||||||
<ChevronRightIcon />
|
<ChevronRightIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ const DataTable_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, sta
|
|||||||
{tableCellProps.children ?? (
|
{tableCellProps.children ?? (
|
||||||
<>
|
<>
|
||||||
{cell.getIsPlaceholder() ? (
|
{cell.getIsPlaceholder() ? (
|
||||||
columnDef.PlaceholderCell?.({ cell, column, row, table }) ?? null
|
(columnDef.PlaceholderCell?.({ cell, column, row, table }) ?? null)
|
||||||
) : showSkeletons !== false && (isLoading || showSkeletons) ? (
|
) : showSkeletons !== false && (isLoading || showSkeletons) ? (
|
||||||
<Skeleton animation="wave" height={20} width={skeletonWidth} {...skeletonProps} />
|
<Skeleton animation="wave" height={20} width={skeletonWidth} {...skeletonProps} />
|
||||||
) : columnDefType === "display" &&
|
) : columnDefType === "display" &&
|
||||||
|
|||||||
@@ -27,9 +27,10 @@ const DataTable_TableContainer = ({ table, ...rest }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useIsomorphicLayoutEffect(() => {
|
useIsomorphicLayoutEffect(() => {
|
||||||
const topToolbarHeight = typeof document !== "undefined" ? topToolbarRef.current?.offsetHeight ?? 0 : 0;
|
const topToolbarHeight = typeof document !== "undefined" ? (topToolbarRef.current?.offsetHeight ?? 0) : 0;
|
||||||
|
|
||||||
const bottomToolbarHeight = typeof document !== "undefined" ? bottomToolbarRef?.current?.offsetHeight ?? 0 : 0;
|
const bottomToolbarHeight =
|
||||||
|
typeof document !== "undefined" ? (bottomToolbarRef?.current?.offsetHeight ?? 0) : 0;
|
||||||
|
|
||||||
setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
|
setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,13 +24,11 @@ import VisibilityOff from "@mui/icons-material/VisibilityOff";
|
|||||||
const validationSchema = object({
|
const validationSchema = object({
|
||||||
current_password: string().required("اجباری"),
|
current_password: string().required("اجباری"),
|
||||||
new_password: string().required("اجباری"),
|
new_password: string().required("اجباری"),
|
||||||
repeat_new_password: string().required("اجباری").test(
|
repeat_new_password: string()
|
||||||
"password-match",
|
.required("اجباری")
|
||||||
"رمز عبور جدید و تکرار آن باید یکسان باشند",
|
.test("password-match", "رمز عبور جدید و تکرار آن باید یکسان باشند", function (value) {
|
||||||
function(value) {
|
|
||||||
return this.parent.new_password === value;
|
return this.parent.new_password === value;
|
||||||
},
|
}),
|
||||||
),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const Form = ({ handleCloseForm, setLoading }) => {
|
const Form = ({ handleCloseForm, setLoading }) => {
|
||||||
@@ -61,8 +59,7 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
|||||||
try {
|
try {
|
||||||
await request(CHANGE_USER_PASSWORD, "post", { data: formData, signal: controller.signal });
|
await request(CHANGE_USER_PASSWORD, "post", { data: formData, signal: controller.signal });
|
||||||
handleCloseForm();
|
handleCloseForm();
|
||||||
} catch (error) {
|
} catch (error) {}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -152,4 +149,4 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default Form;
|
export default Form;
|
||||||
|
|||||||
@@ -19,19 +19,29 @@ const ChangePass = ({ open, setOpen }) => {
|
|||||||
<Form handleCloseForm={handleCloseForm} setLoading={setLoading} />
|
<Form handleCloseForm={handleCloseForm} setLoading={setLoading} />
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<LoadingButton loading={loading} variant="outlined" color="error" size="large"
|
<LoadingButton
|
||||||
onClick={handleCloseForm}>
|
loading={loading}
|
||||||
|
variant="outlined"
|
||||||
|
color="error"
|
||||||
|
size="large"
|
||||||
|
onClick={handleCloseForm}
|
||||||
|
>
|
||||||
بستن
|
بستن
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
<LoadingButton type="submit" loading={loading} form="ChangePassword"
|
<LoadingButton
|
||||||
size="large" autoFocus
|
type="submit"
|
||||||
variant="contained"
|
loading={loading}
|
||||||
loadingPosition="end"
|
form="ChangePassword"
|
||||||
endIcon={<SaveIcon />}>
|
size="large"
|
||||||
|
autoFocus
|
||||||
|
variant="contained"
|
||||||
|
loadingPosition="end"
|
||||||
|
endIcon={<SaveIcon />}
|
||||||
|
>
|
||||||
ثبت
|
ثبت
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default ChangePass;
|
export default ChangePass;
|
||||||
|
|||||||
@@ -35,9 +35,13 @@ const ProfileActions = () => {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Divider orientation="vertical" variant="middle" flexItem sx={{ mx: 1 }} />
|
<Divider orientation="vertical" variant="middle" flexItem sx={{ mx: 1 }} />
|
||||||
<Tooltip title="تغییر رمز عبور" arrow>
|
<Tooltip title="تغییر رمز عبور" arrow>
|
||||||
<IconButton aria-label="تغییر رمز عبور" color="primary" onClick={() => {
|
<IconButton
|
||||||
setOpenChangePass(true);
|
aria-label="تغییر رمز عبور"
|
||||||
}}>
|
color="primary"
|
||||||
|
onClick={() => {
|
||||||
|
setOpenChangePass(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<VpnKeyIcon />
|
<VpnKeyIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@@ -1,31 +1,35 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { useAuth } from "@/lib/contexts/auth";
|
||||||
import { Avatar, Box, Chip, Divider, Stack, Typography } from "@mui/material";
|
import { Avatar, Box, Chip, Divider, Stack, Typography } from "@mui/material";
|
||||||
|
import moment from "jalali-moment";
|
||||||
|
|
||||||
const ProfileInfo = () => {
|
const ProfileInfo = () => {
|
||||||
|
const { user } = useAuth();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box sx={{ display: "flex", alignItems: "center", my: 0.5 }}>
|
<Box sx={{ display: "flex", alignItems: "center", my: 0.5 }}>
|
||||||
<Avatar
|
<Avatar alt="User Image" src={user?.avatar} sx={{ width: 56, height: 56 }} />
|
||||||
alt="User Image"
|
|
||||||
src=""
|
|
||||||
sx={{ width: 56, height: 56 }}
|
|
||||||
/>
|
|
||||||
<Stack sx={{ ml: 1 }}>
|
<Stack sx={{ ml: 1 }}>
|
||||||
<Box sx={{ display: "flex", alignItems: "end", gap: 0.7 }}>
|
<Box sx={{ display: "flex", alignItems: "end", gap: 0.7 }}>
|
||||||
<Typography variant="h6">حسن محمد زاده عبدالله</Typography>
|
<Typography variant="h6">{`${user.first_name} ${user.last_name}`}</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Typography variant="caption">.: اداره کل ستاد :.</Typography>
|
<Typography variant="caption">.: {user.name} :.</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ display: "flex", alignItems: "center", my: 0.5 }}>
|
<Box sx={{ display: "flex", alignItems: "center", my: 0.5 }}>
|
||||||
<Typography variant="button" color="#757575">آخرین ورود</Typography>
|
<Typography variant="button" color="#757575">
|
||||||
|
آخرین ورود
|
||||||
|
</Typography>
|
||||||
<Divider sx={{ mx: 2, flexGrow: 1 }} />
|
<Divider sx={{ mx: 2, flexGrow: 1 }} />
|
||||||
<Typography variant="subtitle2" color="#757575">1 ساعت پیش</Typography>
|
<Typography variant="subtitle2" color="#757575">
|
||||||
|
{moment(user.last_login).locale("fa").fromNow()}
|
||||||
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ my: 0.5 }}>
|
<Box sx={{ my: 0.5 }}>
|
||||||
<Divider>
|
<Divider>
|
||||||
<Chip size="small" label="userName" color="success" variant="outlined" />
|
<Chip size="small" label={user.username} color="success" variant="outlined" />
|
||||||
</Divider>
|
</Divider>
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -53,11 +53,11 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
|||||||
const { user, getUser } = useAuth();
|
const { user, getUser } = useAuth();
|
||||||
const [uploadBackDrop, setUploadBackDrop] = useState(false);
|
const [uploadBackDrop, setUploadBackDrop] = useState(false);
|
||||||
const defaultValues = {
|
const defaultValues = {
|
||||||
first_name: user.data.first_name,
|
first_name: user.first_name,
|
||||||
last_name: user.data.last_name,
|
last_name: user.last_name,
|
||||||
major: user.data.major,
|
major: user.major,
|
||||||
degree: user.data.degree,
|
degree: user.degree,
|
||||||
mobile: user.data.mobile,
|
mobile: user.mobile,
|
||||||
avatar: null,
|
avatar: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -89,8 +89,7 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
|||||||
await request(UPDATE_USER_ROUTE, "post", { data: formData });
|
await request(UPDATE_USER_ROUTE, "post", { data: formData });
|
||||||
getUser();
|
getUser();
|
||||||
handleCloseForm();
|
handleCloseForm();
|
||||||
} catch (error) {
|
} catch (error) {}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -99,15 +98,17 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
|||||||
<Chip color="success" variant="outlined" label="ویرایش پروفایل" />
|
<Chip color="success" variant="outlined" label="ویرایش پروفایل" />
|
||||||
</Divider>
|
</Divider>
|
||||||
<StyledForm onSubmit={handleSubmit(onSubmit)} id={"UpdateProfile"}>
|
<StyledForm onSubmit={handleSubmit(onSubmit)} id={"UpdateProfile"}>
|
||||||
<Box sx={{
|
<Box
|
||||||
display: "flex",
|
sx={{
|
||||||
flexDirection: "column",
|
display: "flex",
|
||||||
alignItems: "center",
|
flexDirection: "column",
|
||||||
justifyContent: "center",
|
alignItems: "center",
|
||||||
mb: 4,
|
justifyContent: "center",
|
||||||
position: "relative",
|
mb: 4,
|
||||||
borderRadius: "50%",
|
position: "relative",
|
||||||
}}>
|
borderRadius: "50%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
component="label"
|
component="label"
|
||||||
sx={{
|
sx={{
|
||||||
@@ -123,15 +124,16 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
|||||||
onMouseEnter={() => setUploadBackDrop(true)}
|
onMouseEnter={() => setUploadBackDrop(true)}
|
||||||
onMouseLeave={() => setUploadBackDrop(false)}
|
onMouseLeave={() => setUploadBackDrop(false)}
|
||||||
>
|
>
|
||||||
<Avatar
|
<Avatar src={user?.avatar} sx={{ width: 120, height: 120, border: "1px solid #e1e1e1" }} />
|
||||||
src={`${process.env.NEXT_PUBLIC_API_URL}/${user.data.avatar}`}
|
|
||||||
sx={{ width: 120, height: 120, border: "1px solid #e1e1e1" }}
|
|
||||||
/>
|
|
||||||
<Backdrop
|
<Backdrop
|
||||||
sx={{
|
sx={{
|
||||||
color: "#fff", zIndex: (theme) => theme.zIndex.drawer + 1,
|
color: "#fff",
|
||||||
position: "absolute", width: 120, height: 120,
|
zIndex: (theme) => theme.zIndex.drawer + 1,
|
||||||
marginLeft: "auto", marginRight: "auto",
|
position: "absolute",
|
||||||
|
width: 120,
|
||||||
|
height: 120,
|
||||||
|
marginLeft: "auto",
|
||||||
|
marginRight: "auto",
|
||||||
borderRadius: "50%",
|
borderRadius: "50%",
|
||||||
}}
|
}}
|
||||||
open={uploadBackDrop}
|
open={uploadBackDrop}
|
||||||
@@ -139,8 +141,11 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
|||||||
<CloudUploadIcon sx={{ fontSize: "2rem" }} color="inherit" />
|
<CloudUploadIcon sx={{ fontSize: "2rem" }} color="inherit" />
|
||||||
</Backdrop>
|
</Backdrop>
|
||||||
</Box>
|
</Box>
|
||||||
<VisuallyHiddenInput type="file" accept="image/*"
|
<VisuallyHiddenInput
|
||||||
onChange={(event) => setValue("avatar", event.target.files[0])} />
|
type="file"
|
||||||
|
accept="image/*"
|
||||||
|
onChange={(event) => setValue("avatar", event.target.files[0])}
|
||||||
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
<Grid container columns={{ xs: 1, sm: 2 }} spacing={2}>
|
<Grid container columns={{ xs: 1, sm: 2 }} spacing={2}>
|
||||||
@@ -156,8 +161,9 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
|||||||
fullWidth
|
fullWidth
|
||||||
type="text"
|
type="text"
|
||||||
/>
|
/>
|
||||||
<FormHelperText
|
<FormHelperText id="first_name">
|
||||||
id="first_name">{errors.first_name ? errors.first_name.message : null}</FormHelperText>
|
{errors.first_name ? errors.first_name.message : null}
|
||||||
|
</FormHelperText>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={1}>
|
<Grid item xs={1}>
|
||||||
@@ -172,8 +178,9 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
|||||||
fullWidth
|
fullWidth
|
||||||
type="text"
|
type="text"
|
||||||
/>
|
/>
|
||||||
<FormHelperText
|
<FormHelperText id="last_name">
|
||||||
id="last_name">{errors.last_name ? errors.last_name.message : null}</FormHelperText>
|
{errors.last_name ? errors.last_name.message : null}
|
||||||
|
</FormHelperText>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={1}>
|
<Grid item xs={1}>
|
||||||
@@ -188,8 +195,7 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
|||||||
fullWidth
|
fullWidth
|
||||||
type="text"
|
type="text"
|
||||||
/>
|
/>
|
||||||
<FormHelperText
|
<FormHelperText id="major">{errors.major ? errors.major.message : null}</FormHelperText>
|
||||||
id="major">{errors.major ? errors.major.message : null}</FormHelperText>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={1}>
|
<Grid item xs={1}>
|
||||||
@@ -217,9 +223,7 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<FormHelperText>
|
<FormHelperText>{error ? error.message : null}</FormHelperText>
|
||||||
{error ? error.message : null}
|
|
||||||
</FormHelperText>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
@@ -236,8 +240,7 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
|||||||
fullWidth
|
fullWidth
|
||||||
type="text"
|
type="text"
|
||||||
/>
|
/>
|
||||||
<FormHelperText
|
<FormHelperText id="mobile">{errors.mobile ? errors.mobile.message : null}</FormHelperText>
|
||||||
id="mobile">{errors.mobile ? errors.mobile.message : null}</FormHelperText>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
@@ -245,4 +248,4 @@ const Form = ({ handleCloseForm, setLoading }) => {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default Form;
|
export default Form;
|
||||||
|
|||||||
@@ -25,14 +25,20 @@ const Update = ({ open, setOpen }) => {
|
|||||||
<Button autoFocus variant="outlined" color="error" size="large" onClick={handleCloseForm}>
|
<Button autoFocus variant="outlined" color="error" size="large" onClick={handleCloseForm}>
|
||||||
بستن
|
بستن
|
||||||
</Button>
|
</Button>
|
||||||
<LoadingButton type="submit" loading={loading} form="UpdateProfile" size="large" autoFocus
|
<LoadingButton
|
||||||
variant="contained"
|
type="submit"
|
||||||
loadingPosition="end"
|
loading={loading}
|
||||||
endIcon={<SaveIcon />}>
|
form="UpdateProfile"
|
||||||
|
size="large"
|
||||||
|
autoFocus
|
||||||
|
variant="contained"
|
||||||
|
loadingPosition="end"
|
||||||
|
endIcon={<SaveIcon />}
|
||||||
|
>
|
||||||
ثبت
|
ثبت
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default Update;
|
export default Update;
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import ProfileActions from "./ProfileActions";
|
|||||||
|
|
||||||
const Profile = () => {
|
const Profile = () => {
|
||||||
return (
|
return (
|
||||||
<Stack sx={{
|
<Stack
|
||||||
px: 2,
|
sx={{
|
||||||
background: "#f7f7f7",
|
px: 2,
|
||||||
borderTop: "1px dashed #e1e1e1",
|
background: "#f7f7f7",
|
||||||
borderBottom: "1px dashed #e1e1e1",
|
borderTop: "1px dashed #e1e1e1",
|
||||||
}}>
|
borderBottom: "1px dashed #e1e1e1",
|
||||||
|
}}
|
||||||
|
>
|
||||||
<ProfileInfo />
|
<ProfileInfo />
|
||||||
<ProfileActions />
|
<ProfileActions />
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ export const getValueByPath = (obj, path) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,80 +1,80 @@
|
|||||||
export const headerMenu = [
|
export const headerMenu = [
|
||||||
{
|
{
|
||||||
title: 'تصادفات',
|
title: "تصادفات",
|
||||||
subMenu: [
|
subMenu: [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
title: 'تصادفات روزانه',
|
title: "تصادفات روزانه",
|
||||||
href: 'https://rms.witel.ir/v2/daily_accidents/create'
|
href: "https://rms.witel.ir/v2/daily_accidents/create",
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'گزارش های جامع',
|
title: "گزارش های جامع",
|
||||||
subMenu: [
|
subMenu: [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
title: 'گزارش محوری',
|
title: "گزارش محوری",
|
||||||
href: 'https://rms.witel.ir/v2/axis_reports'
|
href: "https://rms.witel.ir/v2/axis_reports",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'هوش تجاری (BI)',
|
title: "هوش تجاری (BI)",
|
||||||
href: 'https://rms.witel.ir/v2/axis_reports'
|
href: "https://rms.witel.ir/v2/axis_reports",
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'زیرساخت و ناوگان',
|
title: "زیرساخت و ناوگان",
|
||||||
subMenu: [
|
subMenu: [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
title: 'پراکندگی بر روی نقشه راهدارخانه ها',
|
title: "پراکندگی بر روی نقشه راهدارخانه ها",
|
||||||
href: 'https://rms.witel.ir/v2/map?type=rahdar'
|
href: "https://rms.witel.ir/v2/map?type=rahdar",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'راهدارخانه ها',
|
title: "راهدارخانه ها",
|
||||||
href: 'https://rms.witel.ir/v2/rahdari_points'
|
href: "https://rms.witel.ir/v2/rahdari_points",
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
title: 'ممیزی ماشین آلات راهداری کشور',
|
title: "ممیزی ماشین آلات راهداری کشور",
|
||||||
href: 'https://rms.witel.ir/cmms-audit'
|
href: "https://rms.witel.ir/cmms-audit",
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'سامانه های راهداری',
|
title: "سامانه های راهداری",
|
||||||
subMenu: [
|
subMenu: [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
title: 'تحقیق و توسعه',
|
title: "تحقیق و توسعه",
|
||||||
href: 'https://rms.witel.ir/RandD'
|
href: "https://rms.witel.ir/RandD",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'سامانه مدیریت یکپارچه زیرساخت های راه (PMS,BMS,SMS)',
|
title: "سامانه مدیریت یکپارچه زیرساخت های راه (PMS,BMS,SMS)",
|
||||||
href: 'http://roadams.rmto.ir'
|
href: "http://roadams.rmto.ir",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'سامانه مدیریت ناوگان (FMS)',
|
title: "سامانه مدیریت ناوگان (FMS)",
|
||||||
href: 'http://fms.141.ir'
|
href: "http://fms.141.ir",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'سامانه جامع مدیریت سوانح و حوادث جاده ای',
|
title: "سامانه جامع مدیریت سوانح و حوادث جاده ای",
|
||||||
href: 'https://items.rmto.ir'
|
href: "https://items.rmto.ir",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'سامانه مدیریت نگهداری ماشین آلات (CMMS)',
|
title: "سامانه مدیریت نگهداری ماشین آلات (CMMS)",
|
||||||
href: 'https://cmms.rmto.ir/Login.aspx?ReturnUrl=%2f'
|
href: "https://cmms.rmto.ir/Login.aspx?ReturnUrl=%2f",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'درگاه کاتالوگ داده',
|
title: "درگاه کاتالوگ داده",
|
||||||
href: 'https://roadams.rmto.ir:8080'
|
href: "https://roadams.rmto.ir:8080",
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
]
|
];
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export const pageMenu = [
|
|||||||
type: "menu",
|
type: "menu",
|
||||||
icon: <FactCheckIcon sx={{ width: "inherit", height: "inherit" }} />,
|
icon: <FactCheckIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
hasSubitems: true,
|
hasSubitems: true,
|
||||||
badges: ['road_items.total'],
|
badges: ["road_items.total"],
|
||||||
Subitems: [
|
Subitems: [
|
||||||
{
|
{
|
||||||
id: "roadItemManagmentSupervisor",
|
id: "roadItemManagmentSupervisor",
|
||||||
@@ -99,7 +99,7 @@ export const pageMenu = [
|
|||||||
type: "menu",
|
type: "menu",
|
||||||
icon: <SpeedIcon sx={{ width: "inherit", height: "inherit" }} />,
|
icon: <SpeedIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
hasSubitems: true,
|
hasSubitems: true,
|
||||||
badges: ['road_items.supervise_cnt'],
|
badges: ["road_items.supervise_cnt"],
|
||||||
Subitems: [
|
Subitems: [
|
||||||
{
|
{
|
||||||
id: "roadItemManagmentSupervisorCartable",
|
id: "roadItemManagmentSupervisorCartable",
|
||||||
@@ -119,7 +119,7 @@ export const pageMenu = [
|
|||||||
type: "menu",
|
type: "menu",
|
||||||
icon: <EngineeringIcon sx={{ width: "inherit", height: "inherit" }} />,
|
icon: <EngineeringIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
hasSubitems: true,
|
hasSubitems: true,
|
||||||
badges: ['road_items.operation_cnt'],
|
badges: ["road_items.operation_cnt"],
|
||||||
Subitems: [
|
Subitems: [
|
||||||
{
|
{
|
||||||
id: "roadItemManagmentOparationCreate",
|
id: "roadItemManagmentOparationCreate",
|
||||||
@@ -169,7 +169,7 @@ export const pageMenu = [
|
|||||||
type: "menu",
|
type: "menu",
|
||||||
icon: <FireTruckIcon sx={{ width: "inherit", height: "inherit" }} />,
|
icon: <FireTruckIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
hasSubitems: true,
|
hasSubitems: true,
|
||||||
badges: ['road_patrols.total'],
|
badges: ["road_patrols.total"],
|
||||||
Subitems: [
|
Subitems: [
|
||||||
{
|
{
|
||||||
id: "roadPatrolManagmentSupervisor",
|
id: "roadPatrolManagmentSupervisor",
|
||||||
@@ -177,7 +177,7 @@ export const pageMenu = [
|
|||||||
type: "menu",
|
type: "menu",
|
||||||
icon: <SpeedIcon sx={{ width: "inherit", height: "inherit" }} />,
|
icon: <SpeedIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
hasSubitems: true,
|
hasSubitems: true,
|
||||||
badges: ['road_patrols.supervise_cnt'],
|
badges: ["road_patrols.supervise_cnt"],
|
||||||
Subitems: [
|
Subitems: [
|
||||||
{
|
{
|
||||||
id: "roadPatrolManagmentSupervisorCartable",
|
id: "roadPatrolManagmentSupervisorCartable",
|
||||||
@@ -197,7 +197,7 @@ export const pageMenu = [
|
|||||||
type: "menu",
|
type: "menu",
|
||||||
icon: <EngineeringIcon sx={{ width: "inherit", height: "inherit" }} />,
|
icon: <EngineeringIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
hasSubitems: true,
|
hasSubitems: true,
|
||||||
badges: ['road_patrols.operation_cnt'],
|
badges: ["road_patrols.operation_cnt"],
|
||||||
Subitems: [
|
Subitems: [
|
||||||
{
|
{
|
||||||
id: "roadPatrolManagmentOparationCreate",
|
id: "roadPatrolManagmentOparationCreate",
|
||||||
@@ -277,7 +277,7 @@ export const pageMenu = [
|
|||||||
type: "menu",
|
type: "menu",
|
||||||
icon: <RouteIcon sx={{ width: "inherit", height: "inherit" }} />,
|
icon: <RouteIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
hasSubitems: true,
|
hasSubitems: true,
|
||||||
badges: ['safety_and_privacy.step_one', 'safety_and_privacy.step_two'],
|
badges: ["safety_and_privacy.step_one", "safety_and_privacy.step_two"],
|
||||||
Subitems: [
|
Subitems: [
|
||||||
{
|
{
|
||||||
id: "safetyAndPrivacyManagmentOparation",
|
id: "safetyAndPrivacyManagmentOparation",
|
||||||
@@ -340,7 +340,7 @@ export const pageMenu = [
|
|||||||
type: "menu",
|
type: "menu",
|
||||||
icon: <ElectricBoltIcon sx={{ width: "inherit", height: "inherit" }} />,
|
icon: <ElectricBoltIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
hasSubitems: true,
|
hasSubitems: true,
|
||||||
badges: ['road_observations.total'],
|
badges: ["road_observations.total"],
|
||||||
Subitems: [
|
Subitems: [
|
||||||
{
|
{
|
||||||
id: "roadObservationsManagmentSupervisor",
|
id: "roadObservationsManagmentSupervisor",
|
||||||
@@ -348,7 +348,7 @@ export const pageMenu = [
|
|||||||
type: "menu",
|
type: "menu",
|
||||||
icon: <SpeedIcon sx={{ width: "inherit", height: "inherit" }} />,
|
icon: <SpeedIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
hasSubitems: true,
|
hasSubitems: true,
|
||||||
badges: ['road_observations.supervise_cnt'],
|
badges: ["road_observations.supervise_cnt"],
|
||||||
Subitems: [
|
Subitems: [
|
||||||
{
|
{
|
||||||
id: "roadObservationsManagmentSupervisorCartable",
|
id: "roadObservationsManagmentSupervisorCartable",
|
||||||
@@ -373,7 +373,7 @@ export const pageMenu = [
|
|||||||
type: "menu",
|
type: "menu",
|
||||||
icon: <EngineeringIcon sx={{ width: "inherit", height: "inherit" }} />,
|
icon: <EngineeringIcon sx={{ width: "inherit", height: "inherit" }} />,
|
||||||
hasSubitems: true,
|
hasSubitems: true,
|
||||||
badges: ['road_observations.operation_cnt'],
|
badges: ["road_observations.operation_cnt"],
|
||||||
Subitems: [
|
Subitems: [
|
||||||
{
|
{
|
||||||
id: "roadObservationsManagmentOparationCartable",
|
id: "roadObservationsManagmentOparationCartable",
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export const AuthProvider = ({ children }) => {
|
|||||||
const getUser = useCallback(async () => {
|
const getUser = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.get(GET_USER_ROUTE, { withCredentials: true });
|
const { data } = await axios.get(GET_USER_ROUTE, { withCredentials: true });
|
||||||
changeUser(data);
|
changeUser(data.data);
|
||||||
changeAuthState(true);
|
changeAuthState(true);
|
||||||
changeInitAuth(true);
|
changeInitAuth(true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user