Skip to content

Commit

Permalink
chore: change url to page
Browse files Browse the repository at this point in the history
  • Loading branch information
zdravkov committed Nov 18, 2024
1 parent cc9cccb commit 27815ff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
18 changes: 11 additions & 7 deletions examples/ecommerce-jewellery-store/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useNavigate } from "react-router-dom";
import { Menu, MenuSelectEvent } from "@progress/kendo-react-layout";
import { Menu, MenuItemModel, MenuSelectEvent } from "@progress/kendo-react-layout";
import { Button } from "@progress/kendo-react-buttons";
import { SvgIcon } from "@progress/kendo-react-common";
import { InputPrefix, InputSeparator, TextBox, Switch } from "@progress/kendo-react-inputs";
Expand All @@ -12,6 +12,11 @@ import { AppBar, AppBarSection } from "@progress/kendo-react-layout";
import { useAdminContext } from "../helpers/AdminContext";
import { useCategoriesContext } from "../helpers/CategoriesContext";

interface CustomMenuItemModel extends MenuItemModel {
page?: string;
}


const Header: React.FC = () => {
const navigate = useNavigate();
const { toggleRole } = useAdminContext();
Expand All @@ -26,10 +31,10 @@ const Header: React.FC = () => {
};

const handleMenuSelect = (event: MenuSelectEvent) => {
const selectedItem = event.item;
if (selectedItem.url) {
navigate(selectedItem.url);
const selectedItem: CustomMenuItemModel = event.item;

if (selectedItem.page) {
navigate(selectedItem.page);
return;
}

Expand All @@ -43,7 +48,6 @@ const Header: React.FC = () => {
};

return (
<>
<AppBar themeColor="inherit">
<AppBarSection className="k-flex-basis-0 k-flex-grow k-gap-2 k-align-items-center" style={{ paddingLeft: "50px" }}>
<a href="#" className="k-d-sm-flex" style={{ marginRight: "50px" }}>
Expand Down Expand Up @@ -75,14 +79,14 @@ const Header: React.FC = () => {
onClick={handleCartClick}
/>
<Switch
className="switch-width"
onLabel="Admin"
offLabel="Client"
onChange={handleSwitchChange}
/>
<Menu items={languageItems} onSelect={handleMenuSelect} />
</AppBarSection>
</AppBar>
</>
);
};

Expand Down
4 changes: 2 additions & 2 deletions examples/ecommerce-jewellery-store/src/data/items.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const items = [
{
"text": "Home",
"url": "/"
"page": "/"
},
{
"text": "Jewelry",
"items": [{ "text": "Bracelets" }, { "text": "Rings" }, { "text": "Earings" }, { "text": "Watches" },{ "text": "All" }],
},
{
"text": "Contacts",
"url": "contacts"
"page": "contacts"
}
];

Expand Down
4 changes: 4 additions & 0 deletions examples/ecommerce-jewellery-store/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ html, body {
position: fixed !important;
top: auto !important;
z-index: 1000;
}

.switch-width {
width: 72px !important;
}

0 comments on commit 27815ff

Please sign in to comment.