From 5505d9b44ec84a941423f649f28e74b4ce88d59a Mon Sep 17 00:00:00 2001 From: Sergio Garcia Date: Wed, 10 Feb 2021 12:41:43 -0600 Subject: [PATCH] Refactors to make use of emailToInitials util --- .../src/layouts/DashboardLayout/TopBar.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/moped-editor/src/layouts/DashboardLayout/TopBar.js b/moped-editor/src/layouts/DashboardLayout/TopBar.js index 01972a91c2..72a3bf07e1 100644 --- a/moped-editor/src/layouts/DashboardLayout/TopBar.js +++ b/moped-editor/src/layouts/DashboardLayout/TopBar.js @@ -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: {}, @@ -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 (