Skip to content

Commit

Permalink
FEAT: ORV2-2064 shopping cart header icon (#1248)
Browse files Browse the repository at this point in the history
Co-authored-by: Praveen Raju <[email protected]>
  • Loading branch information
erikataot and praju-aot authored Mar 13, 2024
1 parent b1a1438 commit 25742e4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
1 change: 0 additions & 1 deletion frontend/src/common/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export const Header = () => {
const { companyId } = useContext(OnRouteBCContext);
const username = getLoginUsernameFromSession();
const isIdir = user?.profile?.identity_provider === IDPS.IDIR;

const shouldDisplayNavBar = Boolean(companyId);

const toggleMenu = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@import "../../../../themes/orbcStyles";

.shopping-cart-button {
padding: 0 30px 0 20px;

&__badge {
& .MuiBadge-badge {
right: -15px;
top: 15px;
padding: 0 4px;
background-color: transparent;
color: white;
}
}

&__icon {
color: white;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { faShoppingCart } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import Badge from '@mui/material/Badge';
import { IconButton } from "@mui/material";
import "./ShoppingCartButton.scss";

export const ShoppingCartButton = ({cartItemCount} : {cartItemCount: number}) => {

const onClick = () => {
// TODO: useNavigate to the /shopping-cart
}

return (
<div className={"shopping-cart-button"}>
<IconButton aria-label="cart" onClick={onClick}>
<Badge badgeContent={cartItemCount} color="secondary" className={"shopping-cart-button__badge"}>
<FontAwesomeIcon icon={faShoppingCart} className={"shopping-cart-button__icon"} />
</Badge>
</IconButton>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import "./UserSection.scss";
import { LogoutButton } from "./LogoutButton";
import { UserSectionInfo } from "./UserSectionInfo";
import { ShoppingCartButton } from "./ShoppingCartButton";
import { useFeatureFlagsQuery } from "../../../hooks/hooks";

export const UserSection = ({ username }: { username: string }) => {
const { data: featureFlags } = useFeatureFlagsQuery();

return (
<div className="user-section">
<UserSectionInfo username={username} />
{featureFlags?.["SHOPPING_CART"] === "ENABLED" && <ShoppingCartButton cartItemCount={4} />}
<LogoutButton />
</div>
);
Expand Down

0 comments on commit 25742e4

Please sign in to comment.