Refactor user profile components and update styles
parent
565410da32
commit
a3e7578262
|
@ -48,7 +48,7 @@ const SystemVersionComponent = ({ data }) => {
|
||||||
return () => {
|
return () => {
|
||||||
mediaQuery.removeListener(handleMatches);
|
mediaQuery.removeListener(handleMatches);
|
||||||
};
|
};
|
||||||
}, []);
|
}, [styles.horizontally, styles.vertical]);
|
||||||
|
|
||||||
const lastReleaseDate = useMemo(() => {
|
const lastReleaseDate = useMemo(() => {
|
||||||
const format = "DD-MM-YYYY HH:mm:ss";
|
const format = "DD-MM-YYYY HH:mm:ss";
|
||||||
|
|
|
@ -2,14 +2,13 @@ import React, { useMemo } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import UserProfilePicture from "./UserProfilePicture";
|
import UserProfilePicture from "./UserProfilePicture";
|
||||||
import ContactOptions from "../contact/ContactOptions";
|
import ContactOptions from "../contact/ContactOptions";
|
||||||
import { makeStyles } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import styles from "../styles";
|
import { getStyles } from "../styles";
|
||||||
|
|
||||||
const useStyles = makeStyles(styles);
|
|
||||||
|
|
||||||
const UserProfileCardContent = ({ userData }) => {
|
const UserProfileCardContent = ({ userData }) => {
|
||||||
const { profilePictureUrl } = userData;
|
const { profilePictureUrl } = userData;
|
||||||
const classes = useStyles();
|
const theme = useTheme();
|
||||||
|
const styles = getStyles(theme);
|
||||||
|
|
||||||
const userName = useMemo(() => `${userData.firstName} ${userData.lastName}`, [userData.firstName, userData.lastName]);
|
const userName = useMemo(() => `${userData.firstName} ${userData.lastName}`, [userData.firstName, userData.lastName]);
|
||||||
const _contactOptions = useMemo(
|
const _contactOptions = useMemo(
|
||||||
|
@ -28,7 +27,7 @@ const UserProfileCardContent = ({ userData }) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.panel}>
|
<div style={styles.panel}>
|
||||||
<UserProfilePicture pictureUrl={userData.profilePictureUrl} />
|
<UserProfilePicture pictureUrl={userData.profilePictureUrl} />
|
||||||
<ContactOptions contactOptions={_contactOptions} userName={userName} />
|
<ContactOptions contactOptions={_contactOptions} userName={userName} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,14 +5,13 @@ import { Card, CardHeader, CardContent } from "@mui/material";
|
||||||
import PageTitle from "../../../../components/common/PageTitle";
|
import PageTitle from "../../../../components/common/PageTitle";
|
||||||
import UserProfileCardContent from "./UserProfileCardContent";
|
import UserProfileCardContent from "./UserProfileCardContent";
|
||||||
import SecurityComponent from "../security/SecurityComponent";
|
import SecurityComponent from "../security/SecurityComponent";
|
||||||
import styles from "../styles";
|
import { getStyles } from "../styles";
|
||||||
import { makeStyles } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
|
|
||||||
const useStyles = makeStyles(styles);
|
|
||||||
|
|
||||||
const UserProfileComponent = ({ userData }) => {
|
const UserProfileComponent = ({ userData }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const classes = useStyles();
|
const theme = useTheme();
|
||||||
|
const styles = getStyles(theme);
|
||||||
|
|
||||||
const userLoginDate = useMemo(
|
const userLoginDate = useMemo(
|
||||||
() =>
|
() =>
|
||||||
|
@ -37,7 +36,7 @@ const UserProfileComponent = ({ userData }) => {
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<div className={classes.section}>
|
<div style={styles.section}>
|
||||||
<SecurityComponent userGroups={userData.userGroups} userRoles={userData.userRoles} />
|
<SecurityComponent userGroups={userData.userGroups} userRoles={userData.userRoles} />
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { makeStyles } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import style from "../styles";
|
import { getStyles } from "../styles";
|
||||||
import Avatar from "@mui/material/Avatar";
|
import Avatar from "@mui/material/Avatar";
|
||||||
import DefaultUserProfilePicture from "../../../../assets/images/DefaultUserProfilePicture.png";
|
import DefaultUserProfilePicture from "../../../../assets/images/DefaultUserProfilePicture.png";
|
||||||
|
|
||||||
const useStyles = makeStyles(style);
|
|
||||||
|
|
||||||
const UserProfilePicture = ({ pictureUrl }) => {
|
const UserProfilePicture = ({ pictureUrl }) => {
|
||||||
const classes = useStyles();
|
const theme = useTheme();
|
||||||
|
const styles = getStyles(theme);
|
||||||
const url = pictureUrl ?? DefaultUserProfilePicture;
|
const url = pictureUrl ?? DefaultUserProfilePicture;
|
||||||
return <Avatar src={url} alt="..." className={classes.profilePicture} />;
|
return <Avatar src={url} alt="..." sx={styles.profilePicture} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
UserProfilePicture.propTypes = {
|
UserProfilePicture.propTypes = {
|
||||||
|
|
|
@ -1,38 +1,37 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { Paper, Grid, Chip, Typography } from "@mui/material";
|
import { Paper, Grid, Chip, Typography } from "@mui/material";
|
||||||
import styles from "../styles";
|
import { getStyles } from "../styles";
|
||||||
import { makeStyles } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const useStyles = makeStyles(styles);
|
|
||||||
|
|
||||||
const SecurityComponent = ({ userGroups, userRoles }) => {
|
const SecurityComponent = ({ userGroups, userRoles }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const classes = useStyles();
|
const theme = useTheme();
|
||||||
|
const styles = getStyles(theme);
|
||||||
return (
|
return (
|
||||||
<Paper>
|
<Paper>
|
||||||
<Grid container>
|
<Grid container>
|
||||||
<Grid item xs={12} md={6}>
|
<Grid item xs={12} md={6}>
|
||||||
<div className={classes.paper}>
|
<div style={styles.paper}>
|
||||||
<Typography gutterBottom variant="body1">
|
<Typography gutterBottom variant="body1">
|
||||||
{t("User.Profile.Security.UserGroups")}
|
{t("User.Profile.Security.UserGroups")}
|
||||||
</Typography>
|
</Typography>
|
||||||
<div>
|
<div>
|
||||||
{userGroups.map(g => (
|
{userGroups.map(g => (
|
||||||
<Chip key={g.code} className={classes.chip} label={g.name} />
|
<Chip key={g.code} style={styles.chip} label={g.name} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} md={6}>
|
<Grid item xs={12} md={6}>
|
||||||
<div className={classes.paper}>
|
<div style={styles.paper}>
|
||||||
<Typography gutterBottom variant="body1">
|
<Typography gutterBottom variant="body1">
|
||||||
{t("User.Profile.Security.UserRoles")}
|
{t("User.Profile.Security.UserRoles")}
|
||||||
</Typography>
|
</Typography>
|
||||||
<div>
|
<div>
|
||||||
{userRoles.map(r => (
|
{userRoles.map(r => (
|
||||||
<Chip key={r.code} className={classes.chip} color="primary" label={r.name} />
|
<Chip key={r.code} style={styles.chip} color="primary" label={r.name} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const style = theme => {
|
const getStyles = theme => {
|
||||||
return {
|
return {
|
||||||
section: {
|
section: {
|
||||||
marginTop: theme.spacing(2)
|
marginTop: theme.spacing(2)
|
||||||
|
@ -25,4 +25,4 @@ const style = theme => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default style;
|
export { getStyles };
|
||||||
|
|
Loading…
Reference in New Issue