Skip to content

Commit 37d2705

Browse files
authored
Merge pull request #2696 from telerik/router-fix
Router fix
2 parents cc9cccb + b8f1daa commit 37d2705

File tree

6 files changed

+18
-39
lines changed

6 files changed

+18
-39
lines changed

examples/ecommerce-jewellery-store/index.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@
1717
<body>
1818
<div id="root"></div>
1919
<script type="module" src="/src/main.tsx"></script>
20-
<script>
21-
(() => {
22-
const redirect = sessionStorage.redirect;
23-
delete sessionStorage.redirect;
24-
if (redirect && redirect !== location.href) {
25-
history.replaceState(null, null, redirect);
26-
}
27-
})();
28-
</script>
2920
</body>
3021

3122
</html>

examples/ecommerce-jewellery-store/public/404.html

Lines changed: 0 additions & 13 deletions
This file was deleted.

examples/ecommerce-jewellery-store/src/components/Header.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import { useNavigate } from "react-router-dom";
3-
import { Menu, MenuSelectEvent } from "@progress/kendo-react-layout";
3+
import { Menu, MenuItemModel, MenuSelectEvent } from "@progress/kendo-react-layout";
44
import { Button } from "@progress/kendo-react-buttons";
55
import { SvgIcon } from "@progress/kendo-react-common";
66
import { InputPrefix, InputSeparator, TextBox, Switch } from "@progress/kendo-react-inputs";
@@ -12,6 +12,11 @@ import { AppBar, AppBarSection } from "@progress/kendo-react-layout";
1212
import { useAdminContext } from "../helpers/AdminContext";
1313
import { useCategoriesContext } from "../helpers/CategoriesContext";
1414

15+
interface CustomMenuItemModel extends MenuItemModel {
16+
page?: string;
17+
}
18+
19+
1520
const Header: React.FC = () => {
1621
const navigate = useNavigate();
1722
const { toggleRole } = useAdminContext();
@@ -26,10 +31,10 @@ const Header: React.FC = () => {
2631
};
2732

2833
const handleMenuSelect = (event: MenuSelectEvent) => {
29-
const selectedItem = event.item;
30-
31-
if (selectedItem.url) {
32-
navigate(selectedItem.url);
34+
const selectedItem: CustomMenuItemModel = event.item;
35+
36+
if (selectedItem.page) {
37+
navigate(selectedItem.page);
3338
return;
3439
}
3540

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

4550
return (
46-
<>
4751
<AppBar themeColor="inherit">
4852
<AppBarSection className="k-flex-basis-0 k-flex-grow k-gap-2 k-align-items-center" style={{ paddingLeft: "50px" }}>
4953
<a href="#" className="k-d-sm-flex" style={{ marginRight: "50px" }}>
@@ -75,14 +79,14 @@ const Header: React.FC = () => {
7579
onClick={handleCartClick}
7680
/>
7781
<Switch
82+
className="switch-width"
7883
onLabel="Admin"
7984
offLabel="Client"
8085
onChange={handleSwitchChange}
8186
/>
8287
<Menu items={languageItems} onSelect={handleMenuSelect} />
8388
</AppBarSection>
8489
</AppBar>
85-
</>
8690
);
8791
};
8892

examples/ecommerce-jewellery-store/src/data/items.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
const items = [
22
{
33
"text": "Home",
4-
"url": "/"
4+
"page": "/"
55
},
66
{
77
"text": "Jewelry",
88
"items": [{ "text": "Bracelets" }, { "text": "Rings" }, { "text": "Earings" }, { "text": "Watches" },{ "text": "All" }],
99
},
1010
{
1111
"text": "Contacts",
12-
"url": "contacts"
12+
"page": "contacts"
1313
}
1414
];
1515

examples/ecommerce-jewellery-store/src/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ html, body {
2323
position: fixed !important;
2424
top: auto !important;
2525
z-index: 1000;
26+
}
27+
28+
.switch-width {
29+
width: 72px !important;
2630
}
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
33
import path from 'path';
4-
import { resolve } from 'path';
54
import { fileURLToPath } from 'url';
65

76
const __filename = fileURLToPath(import.meta.url);
@@ -17,12 +16,6 @@ export default defineConfig({
1716
},
1817
},
1918
build: {
20-
outDir: 'build',
21-
rollupOptions: {
22-
input: {
23-
main: resolve(__dirname, "index.html"),
24-
404: resolve(__dirname, "public/404.html"),
25-
},
26-
},
19+
outDir: 'build'
2720
},
2821
});

0 commit comments

Comments
 (0)