Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ const GordonNavButtonsRightCorner = ({ onClose, openDialogBox, open, anchorEl })
/>
);

const settingsButton = (
<GordonNavButton onLinkClick={onClose} linkName={'Settings'} linkPath={'/settings'} />
);

const adminButton =
isAuthenticated && isSiteAdmin ? (
<GordonNavButton
Expand Down Expand Up @@ -117,6 +121,7 @@ const GordonNavButtonsRightCorner = ({ onClose, openDialogBox, open, anchorEl })
{aboutButton}
{feedbackButton}
{adminButton}
{settingsButton}
{signOutButton}
</List>
</Popover>
Expand Down
10 changes: 10 additions & 0 deletions src/components/Nav/components/NavLinks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ const GordonNavLinks = ({ onLinkClick }) => {
/>
);

const settingButton = (
<GordonNavButton
unavailable={isOnline ? null : 'offline'}
linkName={'Settings'}
linkPath={'/settings'}
divider={false}
/>
);

const adminButton =
isAuthenticated && isSiteAdmin ? (
<GordonNavButton
Expand Down Expand Up @@ -197,6 +206,7 @@ const GordonNavLinks = ({ onLinkClick }) => {
{aboutButton}
{feedbackButton}
{adminButton}
{settingButton}
{signOutButton}
</List>

Expand Down
73 changes: 73 additions & 0 deletions src/components/Settings/components/ProfileOptions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import {
Grid,
Card,
List,
CardHeader,
CardContent,
Typography,
FormControlLabel,
Switch,
} from '@material-ui/core';
import { useEffect, useState } from 'react';
import userService from 'services/user';
import styles from './ProfileOptions.module.css';
import SettingsListItem from '../SettingsListItem';

const ProfileOptions = ({ isOnline, settings, createSnackbar }) => {
const [isMobilePhonePrivate, setIsMobilePhonePrivate] = useState(settings);

const handleChangeMobilePhonePrivacy = async () => {
try {
await userService.setMobilePhonePrivacy(!isMobilePhonePrivate);
setIsMobilePhonePrivate(!isMobilePhonePrivate);

createSnackbar(
isMobilePhonePrivate ? 'Mobile Phone Visible' : 'Mobile Phone Hidden',
'success',
);
} catch {
createSnackbar('Privacy Change Failed', 'error');
}
};

const MobilePhone = (
<SettingsListItem
title="Mobile Phone"
ContentIcon={
<FormControlLabel
control={
<Switch onChange={handleChangeMobilePhonePrivacy} checked={!isMobilePhonePrivate} />
}
label={isMobilePhonePrivate ? 'Private' : 'Public'}
labelPlacement="bottom"
disabled={!isOnline}
/>
}
// privateInfo={profile.CliftonStrengths.Private}
/>
);

return (
<Grid container justifyContent="center">
<Grid item xs={12} lg={8}>
<Card className={styles.settings}>
<CardHeader
className={styles.settings_title}
title="Gordon 360 Settings"
titleTypographyProps={{ variant: 'h4' }}
/>
<CardContent>
<Card className={styles.settings_section}>
<CardHeader className={styles.settings_header} title="Profile Options" />
<CardContent>
<List>{MobilePhone}</List>
</CardContent>
</Card>
</CardContent>
</Card>
</Grid>
</Grid>
);
};

export default ProfileOptions;
41 changes: 41 additions & 0 deletions src/components/Settings/components/SettingsListItem/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Divider, ListItem, Grid, Typography } from '@material-ui/core';
import styles from './SettingsListItem.module.css';

const SettingsListItem = ({
title,
ContentText,
ContentIcon = null,
privateInfo = false,
myProf = false,
}) => {
const gridSizeProps = ContentIcon ? { xs: 4, md: 3, lg: 4 } : { xs: 7 };

return (
<>
<ListItem className={styles.settings_list_item}>
<Grid container alignItems="center">
<Grid
container
item
xs={5}
alignItems="center"
className={privateInfo ? (myProf ? styles.private : styles.privateNotMine) : null}
>
<Typography>{title}</Typography>
</Grid>
<Grid container item {...gridSizeProps} alignItems="center">
{ContentText}
</Grid>
{ContentIcon && (
<Grid container item xs={3} md={4} lg={3} justifyContent="center">
{ContentIcon}
</Grid>
)}
</Grid>
</ListItem>
<Divider />
</>
);
};

export default SettingsListItem;
1 change: 1 addition & 0 deletions src/components/Settings/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as ProfileOptions } from './ProfileOptions';
35 changes: 35 additions & 0 deletions src/components/Settings/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Grid } from '@material-ui/core';
import Profile from 'components/Profile';
import GordonSnackbar from 'components/Snackbar';
import { useAuthGroups } from 'hooks';
import useNetworkStatus from 'hooks/useNetworkStatus';
import { useCallback, useEffect, useState } from 'react';
import { AuthGroup } from 'services/auth';
import { ProfileOptions } from './components';

const Settings = ({ setting, myProf }) => {
const [snackbar, setSnackbar] = useState({ message: '', severity: null, open: false });
const isOnline = useNetworkStatus();

const createSnakbar = useCallback((message, severity) => {
setSnackbar({ message, severity, open: true });
}, []);

return (
<Grid container justifyContent="center" spacing={2}>
<Grid item xs={12} md={myProf ? 16 : 24} lg={myProf ? 12 : 20}>
<ProfileOptions isOnline={isOnline} createSnackbar={createSnakbar} myProf={myProf} />
</Grid>

<GordonSnackbar
open={snackbar.open}
text={snackbar.message}
severity={snackbar.severity}
anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }}
onClose={() => setSnackbar((s) => ({ ...s, open: false }))}
/>
</Grid>
);
};

export default Settings;
6 changes: 6 additions & 0 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Page404 from './views/Page404';
import PeopleSearch from './views/PeopleSearch';
import ProfileNotFound from './views/ProfileNotFound';
import PublicProfile from './views/PublicProfile';
import MySettings from './views/MySettings';
import Timesheets from './views/Timesheets';
import WellnessCheck from './views/WellnessCheck';

Expand Down Expand Up @@ -129,6 +130,11 @@ const routes = [
path: '/news',
component: News,
},
{
name: 'Settings',
path: '/settings',
component: MySettings,
},
{
name: 'Page Not Found',
path: '*',
Expand Down
26 changes: 26 additions & 0 deletions src/views/MySettings/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useIsAuthenticated } from '@azure/msal-react';
import GordonUnauthorized from 'components/GordonUnauthorized';
import GordonLoader from 'components/Loader';
import Settings from 'components/Settings';
import { useNetworkStatus, useUser } from 'hooks';
import { useEffect, useRef, useState } from 'react';

const MySettings = () => {
const [settings, setSettings] = useState([]);
const [error, setError] = useState(null);
const isAuthenticated = useIsAuthenticated();

const { profile, loading } = useUser();

if (loading) {
return <GordonLoader />;
}

if (Settings) {
return <Settings setting={profile.IsMobilePhonePrivate} myProf />;
}

return <GordonUnauthorized feature={'your settings'} />;
};

export default MySettings;