u
This commit is contained in:
@@ -86,7 +86,6 @@ export default class ArticleStockAdjustDialog extends PureComponent {
|
|||||||
warehouseId: prev.warehouseId || (warehouses.length > 0 ? warehouses[0].id : ''),
|
warehouseId: prev.warehouseId || (warehouses.length > 0 ? warehouses[0].id : ''),
|
||||||
}));
|
}));
|
||||||
}, ['warehouses']);
|
}, ['warehouses']);
|
||||||
void companyAutomat.actions.loadWarehouses().catch(() => {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
@@ -95,7 +94,6 @@ export default class ArticleStockAdjustDialog extends PureComponent {
|
|||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
if (this.props.open && !prevProps.open) {
|
if (this.props.open && !prevProps.open) {
|
||||||
void companyAutomat.actions.loadWarehouses().catch(() => {});
|
|
||||||
const initialWhId = this.resolveInitialWarehouseId(this.props);
|
const initialWhId = this.resolveInitialWarehouseId(this.props);
|
||||||
const isTrackStock =
|
const isTrackStock =
|
||||||
this.props.article?.track_stock !== false && this.props.article?.track_stock !== 0;
|
this.props.article?.track_stock !== false && this.props.article?.track_stock !== 0;
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ export default class ArticleSupplierTab extends PureComponent {
|
|||||||
this.state = {
|
this.state = {
|
||||||
loading: true,
|
loading: true,
|
||||||
assignedSuppliers: [],
|
assignedSuppliers: [],
|
||||||
companySuppliers: [],
|
companySuppliers: companyAutomat.state.suppliers ?? [],
|
||||||
company: null,
|
company: companyAutomat.state.current ?? null,
|
||||||
dialogOpen: false,
|
dialogOpen: false,
|
||||||
editItem: null,
|
editItem: null,
|
||||||
busyId: null,
|
busyId: null,
|
||||||
@@ -47,9 +47,14 @@ export default class ArticleSupplierTab extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.unsubCompany = companyAutomat.subscribe(this, (state) => ({
|
this.unsubCompany = companyAutomat.subscribe(
|
||||||
company: state.current ?? null,
|
this,
|
||||||
}));
|
(state) => ({
|
||||||
|
company: state.current ?? null,
|
||||||
|
companySuppliers: state.suppliers ?? [],
|
||||||
|
}),
|
||||||
|
['current', 'suppliers'],
|
||||||
|
);
|
||||||
this.initData();
|
this.initData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,15 +94,6 @@ export default class ArticleSupplierTab extends PureComponent {
|
|||||||
this.unwatchSignal = sseAutomat.actions.watchArticle(String(sku), () => {
|
this.unwatchSignal = sseAutomat.actions.watchArticle(String(sku), () => {
|
||||||
void articleSupplierAutomat.reload(String(sku)).catch(() => {});
|
void articleSupplierAutomat.reload(String(sku)).catch(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 2. Fetch available company suppliers
|
|
||||||
try {
|
|
||||||
const companySuppliers = await companyAutomat.actions.loadSuppliers();
|
|
||||||
this.setState({ companySuppliers: companySuppliers ?? [] });
|
|
||||||
} catch (err) {
|
|
||||||
notifyError(err);
|
|
||||||
this.setState({ loading: false });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Re-fetches the assigned suppliers for the current article. */
|
/** Re-fetches the assigned suppliers for the current article. */
|
||||||
|
|||||||
@@ -98,8 +98,7 @@ export default class BookDeliveryDialog extends PureComponent {
|
|||||||
loadSupplierArticlesIfNeeded() {
|
loadSupplierArticlesIfNeeded() {
|
||||||
const supplierId = this.props.delivery?.supplierId ?? this.props.delivery?.partyId;
|
const supplierId = this.props.delivery?.supplierId ?? this.props.delivery?.partyId;
|
||||||
if (supplierId && Object.keys(this.state.supplierArticlesMap).length === 0) {
|
if (supplierId && Object.keys(this.state.supplierArticlesMap).length === 0) {
|
||||||
void supplierApi.getArticles(supplierId).then((res) => {
|
void companyAutomat.actions.loadArticlesForSupplier(supplierId).then((articles) => {
|
||||||
const articles = res?.articles || res?.supplier?.articles || [];
|
|
||||||
const map = buildSupplierArticlesMap(articles);
|
const map = buildSupplierArticlesMap(articles);
|
||||||
this.setState({ supplierArticlesMap: map });
|
this.setState({ supplierArticlesMap: map });
|
||||||
}).catch(() => { });
|
}).catch(() => { });
|
||||||
@@ -122,7 +121,6 @@ export default class BookDeliveryDialog extends PureComponent {
|
|||||||
this.unsubArticle = artikelAutomat.subscribe(() => {
|
this.unsubArticle = artikelAutomat.subscribe(() => {
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
});
|
});
|
||||||
void companyAutomat.actions.loadWarehouses().catch(() => { });
|
|
||||||
this.loadSupplierArticlesIfNeeded();
|
this.loadSupplierArticlesIfNeeded();
|
||||||
|
|
||||||
if (this.props.open) {
|
if (this.props.open) {
|
||||||
@@ -225,7 +223,6 @@ export default class BookDeliveryDialog extends PureComponent {
|
|||||||
supplierArticlesMap: currentSupplierMap,
|
supplierArticlesMap: currentSupplierMap,
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
void companyAutomat.actions.loadWarehouses().catch(() => { });
|
|
||||||
this.loadSupplierArticlesIfNeeded();
|
this.loadSupplierArticlesIfNeeded();
|
||||||
if (this.props.summary) {
|
if (this.props.summary) {
|
||||||
this.initAmountsFromSummary(this.props.summary, this.props.prefillLineId);
|
this.initAmountsFromSummary(this.props.summary, this.props.prefillLineId);
|
||||||
|
|||||||
@@ -242,10 +242,6 @@ class ManifestForm extends PureComponent {
|
|||||||
['current', 'suppliers', 'suppliersStatus', 'customergroups', 'customergroupsStatus'],
|
['current', 'suppliers', 'suppliersStatus', 'customergroups', 'customergroupsStatus'],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (companyAutomat.state.warehousesStatus === 'idle') {
|
|
||||||
void companyAutomat.actions.loadWarehouses();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.props.mode === 'edit') {
|
if (this.props.mode === 'edit') {
|
||||||
void this.loadEdit();
|
void this.loadEdit();
|
||||||
if (this.props.kind === 'order' || this.props.kind === 'retoure') {
|
if (this.props.kind === 'order' || this.props.kind === 'retoure') {
|
||||||
|
|||||||
@@ -43,7 +43,11 @@ export default class CompanySettingsPanel extends Component {
|
|||||||
this.syncFormFromCompany(state.current);
|
this.syncFormFromCompany(state.current);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
void this.loadCompany();
|
if (companyAutomat.state.current) {
|
||||||
|
this.syncFormFromCompany(companyAutomat.state.current);
|
||||||
|
} else {
|
||||||
|
void this.loadCompany();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
|||||||
@@ -78,7 +78,9 @@ export default class PosTerminalSettingsPanel extends Component {
|
|||||||
if (categoryAutomat.state.treeStatus === 'idle') {
|
if (categoryAutomat.state.treeStatus === 'idle') {
|
||||||
void categoryAutomat.actions.loadTree();
|
void categoryAutomat.actions.loadTree();
|
||||||
}
|
}
|
||||||
void this.loadTerminals();
|
if (companyAutomat.state.terminalsStatus !== 'succeeded') {
|
||||||
|
void this.loadTerminals();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
|||||||
@@ -360,10 +360,6 @@ class ArtikelSearchPage extends Component {
|
|||||||
_suppliers: state.suppliers,
|
_suppliers: state.suppliers,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
void companyAutomat.actions.loadBrands().catch(() => {});
|
|
||||||
void companyAutomat.actions.loadSuppliers().catch(() => {});
|
|
||||||
void companyAutomat.actions.loadAllSupplierArticles().catch(() => {});
|
|
||||||
|
|
||||||
// Initial search: kicks off index loading if idle and derives current items
|
// Initial search: kicks off index loading if idle and derives current items
|
||||||
const {
|
const {
|
||||||
filter: urlFilter,
|
filter: urlFilter,
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class ArtikelSkuPage extends Component {
|
|||||||
await Promise.all([
|
await Promise.all([
|
||||||
artikelAutomat.actions.loadArticle(sku),
|
artikelAutomat.actions.loadArticle(sku),
|
||||||
whenCategoryTreeReady(),
|
whenCategoryTreeReady(),
|
||||||
companyAutomat.actions.load(),
|
companyAutomat.state.current ? Promise.resolve(companyAutomat.state.current) : companyAutomat.actions.load(),
|
||||||
bootstrapAuthMe(),
|
bootstrapAuthMe(),
|
||||||
]);
|
]);
|
||||||
if (this._mounted) this.setState({ ready: true });
|
if (this._mounted) this.setState({ ready: true });
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ class ArtikelKategorienPage extends PureComponent {
|
|||||||
companyId: s.current?.id ?? null,
|
companyId: s.current?.id ?? null,
|
||||||
}));
|
}));
|
||||||
this.ensureTreeLoaded();
|
this.ensureTreeLoaded();
|
||||||
this.ensurePosterminalsLoaded();
|
|
||||||
this.subscribeViewHandle();
|
this.subscribeViewHandle();
|
||||||
this.syncSortable();
|
this.syncSortable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,9 +184,7 @@ class ArtikelLagerPage extends PureComponent {
|
|||||||
error: state.warehousesError ? backendErrorFrom(state.warehousesError) : null,
|
error: state.warehousesError ? backendErrorFrom(state.warehousesError) : null,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (companyAutomat.state.warehousesStatus !== 'ready') {
|
if (this.state.status === 'ready') {
|
||||||
void companyAutomat.actions.loadWarehouses().catch((err) => notifyError(err));
|
|
||||||
} else {
|
|
||||||
this._initSortable();
|
this._initSortable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,9 +144,7 @@ class AuftragVersandartenPage extends PureComponent {
|
|||||||
error: state.carriersError ? backendErrorFrom(state.carriersError) : null,
|
error: state.carriersError ? backendErrorFrom(state.carriersError) : null,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (companyAutomat.state.carriersStatus !== 'ready') {
|
if (this.state.status === 'ready') {
|
||||||
void companyAutomat.actions.loadCarriers().catch((err) => notifyError(err));
|
|
||||||
} else {
|
|
||||||
this._initSortable();
|
this._initSortable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,9 +183,7 @@ class KundeGruppenPage extends PureComponent {
|
|||||||
error: state.customergroupsError ? backendErrorFrom(state.customergroupsError) : null,
|
error: state.customergroupsError ? backendErrorFrom(state.customergroupsError) : null,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (companyAutomat.state.customergroupsStatus !== 'ready') {
|
if (this.state.status === 'ready') {
|
||||||
void companyAutomat.actions.loadCustomergroups().catch((err) => notifyError(err));
|
|
||||||
} else {
|
|
||||||
this._initSortable();
|
this._initSortable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,18 +56,20 @@ class LieferungLieferantenPage extends PureComponent {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
const { prefill } = getInitialParams(props);
|
const { prefill } = getInitialParams(props);
|
||||||
|
const initialSuppliers = sortSuppliers(companyAutomat.state.suppliers ?? []);
|
||||||
this.state = {
|
this.state = {
|
||||||
status: 'loading',
|
status: companyAutomat.state.suppliersStatus,
|
||||||
error: null,
|
error: companyAutomat.state.suppliersError
|
||||||
suppliers: [],
|
? backendErrorFrom(companyAutomat.state.suppliersError)
|
||||||
drafts: {},
|
: null,
|
||||||
|
suppliers: initialSuppliers,
|
||||||
|
drafts: draftsFrom(initialSuppliers),
|
||||||
newName: prefill,
|
newName: prefill,
|
||||||
busyKey: null,
|
busyKey: null,
|
||||||
};
|
};
|
||||||
this._cancelled = false;
|
this._cancelled = false;
|
||||||
this.handleCreate = this.handleCreate.bind(this);
|
this.handleCreate = this.handleCreate.bind(this);
|
||||||
this.handleRetry = this.handleRetry.bind(this);
|
this.handleRetry = this.handleRetry.bind(this);
|
||||||
this.loadSuppliers = this.loadSuppliers.bind(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@@ -79,7 +81,20 @@ class LieferungLieferantenPage extends PureComponent {
|
|||||||
this.setState({ newName: prefill });
|
this.setState({ newName: prefill });
|
||||||
}
|
}
|
||||||
this._cancelled = false;
|
this._cancelled = false;
|
||||||
void this.loadSuppliers();
|
|
||||||
|
this.unsub = companyAutomat.subscribe(
|
||||||
|
this,
|
||||||
|
(state) => {
|
||||||
|
const sorted = sortSuppliers(state.suppliers ?? []);
|
||||||
|
return {
|
||||||
|
status: state.suppliersStatus,
|
||||||
|
error: state.suppliersError ? backendErrorFrom(state.suppliersError) : null,
|
||||||
|
suppliers: sorted,
|
||||||
|
drafts: draftsFrom(sorted),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
['suppliers', 'suppliersStatus', 'suppliersError'],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
@@ -91,41 +106,13 @@ class LieferungLieferantenPage extends PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this._cancelled = true;
|
this._cancelled = true;
|
||||||
}
|
this.unsub?.();
|
||||||
|
|
||||||
applySuppliers(suppliers) {
|
|
||||||
const sorted = sortSuppliers(suppliers);
|
|
||||||
this.setState({
|
|
||||||
status: 'ready',
|
|
||||||
error: null,
|
|
||||||
suppliers: sorted,
|
|
||||||
drafts: draftsFrom(sorted),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async loadSuppliers() {
|
|
||||||
this.setState({ status: 'loading', error: null });
|
|
||||||
try {
|
|
||||||
const list = await companyAutomat.actions.loadSuppliers();
|
|
||||||
if (this._cancelled) return;
|
|
||||||
this.applySuppliers(list);
|
|
||||||
} catch (err) {
|
|
||||||
if (this._cancelled) return;
|
|
||||||
this.setState({ status: 'failed', error: backendErrorFrom(err) });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRetry() {
|
handleRetry() {
|
||||||
void this.loadSuppliers();
|
void companyAutomat.actions.loadSuppliers().catch((err) => notifyError(err));
|
||||||
}
|
|
||||||
|
|
||||||
async refreshFromServer() {
|
|
||||||
const list = await companyAutomat.actions.reloadSuppliers();
|
|
||||||
if (this._cancelled) return;
|
|
||||||
this.applySuppliers(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleCreate() {
|
async handleCreate() {
|
||||||
@@ -142,7 +129,6 @@ class LieferungLieferantenPage extends PureComponent {
|
|||||||
deliveryDraftAutomat.actions.setDeliveryEntity(newSupplier.id);
|
deliveryDraftAutomat.actions.setDeliveryEntity(newSupplier.id);
|
||||||
deliveryDraftAutomat.actions.setUnmatchedSupplierName(null);
|
deliveryDraftAutomat.actions.setUnmatchedSupplierName(null);
|
||||||
|
|
||||||
await this.refreshFromServer();
|
|
||||||
if (this._cancelled) return;
|
if (this._cancelled) return;
|
||||||
this.setState({ newName: '', busyKey: null });
|
this.setState({ newName: '', busyKey: null });
|
||||||
enqueueSnackbar(`Lieferant „${newSupplier.name || name}“ angelegt.`, { variant: 'success' });
|
enqueueSnackbar(`Lieferant „${newSupplier.name || name}“ angelegt.`, { variant: 'success' });
|
||||||
@@ -157,7 +143,6 @@ class LieferungLieferantenPage extends PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async handleRename(supplier) {
|
async handleRename(supplier) {
|
||||||
const draft = String(this.state.drafts[supplier.id] ?? '').trim();
|
const draft = String(this.state.drafts[supplier.id] ?? '').trim();
|
||||||
if (!draft) {
|
if (!draft) {
|
||||||
@@ -171,7 +156,6 @@ class LieferungLieferantenPage extends PureComponent {
|
|||||||
this.setState({ busyKey: supplier.id });
|
this.setState({ busyKey: supplier.id });
|
||||||
try {
|
try {
|
||||||
await companyAutomat.actions.updateSupplier(supplier.id, { name: draft });
|
await companyAutomat.actions.updateSupplier(supplier.id, { name: draft });
|
||||||
await this.refreshFromServer();
|
|
||||||
if (this._cancelled) return;
|
if (this._cancelled) return;
|
||||||
this.setState({ busyKey: null });
|
this.setState({ busyKey: null });
|
||||||
enqueueSnackbar('Lieferant gespeichert.', { variant: 'success' });
|
enqueueSnackbar('Lieferant gespeichert.', { variant: 'success' });
|
||||||
@@ -194,7 +178,6 @@ class LieferungLieferantenPage extends PureComponent {
|
|||||||
this.setState({ busyKey: supplier.id });
|
this.setState({ busyKey: supplier.id });
|
||||||
try {
|
try {
|
||||||
await companyAutomat.actions.removeSupplier(supplier.id);
|
await companyAutomat.actions.removeSupplier(supplier.id);
|
||||||
await this.refreshFromServer();
|
|
||||||
if (this._cancelled) return;
|
if (this._cancelled) return;
|
||||||
this.setState({ busyKey: null });
|
this.setState({ busyKey: null });
|
||||||
enqueueSnackbar('Lieferant gelöscht.', { variant: 'success' });
|
enqueueSnackbar('Lieferant gelöscht.', { variant: 'success' });
|
||||||
@@ -211,7 +194,7 @@ class LieferungLieferantenPage extends PureComponent {
|
|||||||
|
|
||||||
const { returnTo } = getInitialParams(this.props);
|
const { returnTo } = getInitialParams(this.props);
|
||||||
|
|
||||||
if (status === 'loading') {
|
if (status === 'loading' || status === 'idle') {
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'center', py: 6 }}>
|
<Box sx={{ display: 'flex', justifyContent: 'center', py: 6 }}>
|
||||||
<CircularProgress />
|
<CircularProgress />
|
||||||
|
|||||||
@@ -191,7 +191,6 @@ class LieferungNeuPage extends PureComponent {
|
|||||||
warehouses: state.warehouses,
|
warehouses: state.warehouses,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
void companyAutomat.actions.loadWarehouses().catch(() => { });
|
|
||||||
this._cancelled = false;
|
this._cancelled = false;
|
||||||
if (this.props.docId != null) {
|
if (this.props.docId != null) {
|
||||||
setLastDeliveryPath(`/lieferung/${this.props.docId}`);
|
setLastDeliveryPath(`/lieferung/${this.props.docId}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user