This commit is contained in:
seb
2026-10-28 00:08:45 +01:00
parent fab291f68e
commit 96d0ae6742
88 changed files with 3871 additions and 5334 deletions

View File

@@ -13,8 +13,8 @@ import { PanelTile, PanelTileGrid } from 'dashgui/panels';
import withNavigate from '../../components/withNavigate';
import { backendErrorFrom } from '../../utils/backendError';
import { notifyError } from '../../utils/notify';
import { setLastArticleSku } from '../../automats';
import warehouseAutomat from '../../automats/warehouseAutomat';
import { setLastArticleSku } from '../../automats/navigationAutomat';
import companyAutomat from '../../automats/companyAutomat';
import { ArtikelLager } from '../../components/warehouse';
import { GREEN_PANEL } from '../../colors';
@@ -37,20 +37,20 @@ function getInitialParams(props) {
class ArtikelLagerSearchField extends PureComponent {
constructor(props) {
super(props);
const initial = warehouseAutomat.state.filter || props.prefill || '';
const initial = companyAutomat.state.warehouseFilter || props.prefill || '';
this.state = {
input: initial,
submitting: false,
};
if (props.prefill && !warehouseAutomat.state.filter) {
warehouseAutomat.actions.filter(props.prefill);
if (props.prefill && !companyAutomat.state.warehouseFilter) {
companyAutomat.actions.filterWarehouses(props.prefill);
}
this.handleSubmit = this.handleSubmit.bind(this);
}
componentDidMount() {
this.unsub = warehouseAutomat.subscribe(this, (state) => ({
input: state.filter,
this.unsub = companyAutomat.subscribe(this, (state) => ({
input: state.warehouseFilter,
}));
}
@@ -60,7 +60,7 @@ class ArtikelLagerSearchField extends PureComponent {
onInputChange(input) {
this.setState({ input });
warehouseAutomat.actions.filter(input);
companyAutomat.actions.filterWarehouses(input);
}
async handleSubmit() {
@@ -69,10 +69,10 @@ class ArtikelLagerSearchField extends PureComponent {
this.setState({ submitting: true });
try {
const row = await warehouseAutomat.actions.create({ name });
const row = await companyAutomat.actions.createWarehouse({ name });
enqueueSnackbar(`Lager „${row.name || name}“ angelegt.`, { variant: 'success' });
this.setState({ input: '', submitting: false });
warehouseAutomat.actions.filter('');
companyAutomat.actions.filterWarehouses('');
if (this.props.returnTo && this.props.navigate) {
this.props.navigate(this.props.returnTo);
}
@@ -157,12 +157,12 @@ class ArtikelLagerPage extends PureComponent {
constructor(props) {
super(props);
const initialWarehouses =
warehouseAutomat.state.filteredWarehouses ?? warehouseAutomat.state.warehouses ?? [];
companyAutomat.state.filteredWarehouses ?? companyAutomat.state.warehouses ?? [];
this.state = {
status: warehouseAutomat.state.status === 'ready' ? 'ready' : 'loading',
error: warehouseAutomat.state.error ? backendErrorFrom(warehouseAutomat.state.error) : null,
status: companyAutomat.state.warehousesStatus === 'ready' ? 'ready' : 'loading',
error: companyAutomat.state.warehousesError ? backendErrorFrom(companyAutomat.state.warehousesError) : null,
warehouses: initialWarehouses,
filter: warehouseAutomat.state.filter ?? '',
filter: companyAutomat.state.warehouseFilter ?? '',
};
this.searchRef = createRef();
this.listRef = createRef();
@@ -177,15 +177,15 @@ class ArtikelLagerPage extends PureComponent {
setLastArticleSku(null);
this._cancelled = false;
this.unsub = warehouseAutomat.subscribe(this, (state) => ({
this.unsub = companyAutomat.subscribe(this, (state) => ({
warehouses: state.filteredWarehouses ?? state.warehouses,
filter: state.filter ?? '',
status: state.status,
error: state.error ? backendErrorFrom(state.error) : null,
filter: state.warehouseFilter ?? '',
status: state.warehousesStatus,
error: state.warehousesError ? backendErrorFrom(state.warehousesError) : null,
}));
if (warehouseAutomat.state.status !== 'ready') {
void warehouseAutomat.actions.load().catch((err) => notifyError(err));
if (companyAutomat.state.warehousesStatus !== 'ready') {
void companyAutomat.actions.loadWarehouses().catch((err) => notifyError(err));
} else {
this._initSortable();
}
@@ -249,16 +249,16 @@ class ArtikelLagerPage extends PureComponent {
async _persistOrder(warehouseIds) {
try {
await warehouseAutomat.actions.reorder(warehouseIds);
await companyAutomat.actions.reorderWarehouses(warehouseIds);
} catch (err) {
if (this._cancelled) return;
notifyError(err);
void warehouseAutomat.actions.reload();
void companyAutomat.actions.reloadWarehouses();
}
}
handleRetry() {
void warehouseAutomat.actions.load().catch((err) => notifyError(err));
void companyAutomat.actions.loadWarehouses().catch((err) => notifyError(err));
}
render() {