Skip to content

Commit

Permalink
Refactors to make use of emailToInitials util
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiogcx committed Feb 10, 2021
1 parent 6f3391d commit 5505d9b
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions moped-editor/src/layouts/DashboardLayout/TopBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import MenuIcon from "@material-ui/icons/Menu";
import { LogOut as LogOutIcon } from "react-feather";
import Logo from "src/components/Logo";
import { useUser } from "../../auth/user";
import emailToInitials from "../../utils/emailToInitials";

const useStyles = makeStyles(() => ({
root: {},
Expand All @@ -27,20 +28,6 @@ const TopBar = ({ className, onMobileNavOpen, ...rest }) => {
const classes = useStyles();
const { user, logout } = useUser();

const emailToInitials = email => {
try {
const subdomain = "austintexas.gov";
if (!email.endsWith(subdomain)) return null;
const [first, last] = email
.replace("azure_ad", "")
.replace(subdomain, "")
.split(".");
return String(first.charAt(0) + last.charAt(0)).toUpperCase();
} catch {
return null;
}
};

return (
<AppBar className={clsx(classes.root, className)} elevation={0} {...rest}>
<Toolbar>
Expand Down

0 comments on commit 5505d9b

Please sign in to comment.