nav
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user