Skip to content

Commit

Permalink
Implement Logout on store front app
Browse files Browse the repository at this point in the history
  • Loading branch information
vczb committed Jun 11, 2024
1 parent 822f57d commit 612bcab
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/javascript/StorefrontApp/components/Wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { HTMLAttributes, ReactNode } from "react";
import { Box } from "@mui/system";
import LogoutButton from "features/company/LogoutButton";

type HTMLDIVElementTypes = HTMLAttributes<HTMLDivElement>;

type WrapperTypes = {
children: ReactNode | string | null;
fullVH?: boolean;
bgColor?: "primary.main" | "primary.white";
showLogout?: boolean
} & HTMLDIVElementTypes;

const Wrapper = ({
children,
fullVH = false,
showLogout = false,
bgColor = "primary.main",
...props
}: WrapperTypes) => {
Expand All @@ -23,12 +26,14 @@ const Wrapper = ({
height: fullVH ? "100vh" : "100%",
overflowX: "hidden",
backgroundColor: bgColor,
position: "relative",
}}
{...props}
>
{children}
{showLogout ? <LogoutButton /> : <></>}
</Box>
);
};

export default Wrapper;
export default Wrapper
23 changes: 23 additions & 0 deletions app/javascript/StorefrontApp/features/company/LogoutButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { useCompany } from './companySlice';
import OffIcon from '@mui/icons-material/PowerSettingsNewRounded'
import { IconButton } from '@mui/material';

const LogoutButton = () => {
const { onLogout } = useCompany();

return (
<IconButton
style={{
position: 'absolute',
left: '1rem',
bottom: '1rem',
}}
aria-label="Log Out"
size='small'
onClick={() => onLogout()}
>
<OffIcon fontSize='inherit' />
</IconButton>
);
};
export default LogoutButton;
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function Onboarding() {
});

return (
<Wrapper fullVH>
<Wrapper fullVH showLogout>
<Grid
container
direction="row"
Expand Down

0 comments on commit 612bcab

Please sign in to comment.