This commit is contained in:
seb
2026-09-19 18:33:27 +02:00
parent d3b4743b66
commit 4011ebfc61
13 changed files with 290 additions and 24 deletions

View File

@@ -11,13 +11,34 @@ import UserMenu from './UserMenu';
import { NAV_ITEMS, SUB_NAV, resolveActiveNav, resolveActiveSub } from '../nav';
import { artikelQueryPath } from '../pages/artikel/artikelQuery';
import { defaultCategoryPath } from '../pages/artikel/categoryRoute';
import { navigationAutomat } from '../automats';
const SIDEBAR_WIDTH = 144;
const SUB_NAV_WIDTH = 88;
class AppSidebar extends PureComponent {
constructor(props) {
super(props);
this.state = {
lastDeliveryPath: navigationAutomat.state.lastDeliveryPath,
lastArticleSku: navigationAutomat.state.lastArticleSku,
};
}
componentDidMount() {
this.unsub = navigationAutomat.subscribe(this, (state) => ({
lastDeliveryPath: state.lastDeliveryPath,
lastArticleSku: state.lastArticleSku,
}));
}
componentWillUnmount() {
this.unsub?.();
}
render() {
const { activeNav, navigate } = this.props;
const { lastDeliveryPath, lastArticleSku } = this.state;
return (
<Box
@@ -45,7 +66,21 @@ class AppSidebar extends PureComponent {
selected={active}
onMouseDown={(e) => e.preventDefault()}
onClick={() => {
navigate(path === '/artikel' ? artikelQueryPath() : path);
if (path === '/artikel') {
if (lastArticleSku) {
navigate(`/artikel/${lastArticleSku}`);
} else {
navigate(artikelQueryPath());
}
} else if (path === '/lieferung') {
if (lastDeliveryPath) {
navigate(lastDeliveryPath);
} else {
navigate(path);
}
} else {
navigate(path);
}
}}
sx={(theme) => ({
borderRadius: 0,