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 : ''),
|
||||
}));
|
||||
}, ['warehouses']);
|
||||
void companyAutomat.actions.loadWarehouses().catch(() => {});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -95,7 +94,6 @@ export default class ArticleStockAdjustDialog extends PureComponent {
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (this.props.open && !prevProps.open) {
|
||||
void companyAutomat.actions.loadWarehouses().catch(() => {});
|
||||
const initialWhId = this.resolveInitialWarehouseId(this.props);
|
||||
const isTrackStock =
|
||||
this.props.article?.track_stock !== false && this.props.article?.track_stock !== 0;
|
||||
|
||||
@@ -38,8 +38,8 @@ export default class ArticleSupplierTab extends PureComponent {
|
||||
this.state = {
|
||||
loading: true,
|
||||
assignedSuppliers: [],
|
||||
companySuppliers: [],
|
||||
company: null,
|
||||
companySuppliers: companyAutomat.state.suppliers ?? [],
|
||||
company: companyAutomat.state.current ?? null,
|
||||
dialogOpen: false,
|
||||
editItem: null,
|
||||
busyId: null,
|
||||
@@ -47,9 +47,14 @@ export default class ArticleSupplierTab extends PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.unsubCompany = companyAutomat.subscribe(this, (state) => ({
|
||||
company: state.current ?? null,
|
||||
}));
|
||||
this.unsubCompany = companyAutomat.subscribe(
|
||||
this,
|
||||
(state) => ({
|
||||
company: state.current ?? null,
|
||||
companySuppliers: state.suppliers ?? [],
|
||||
}),
|
||||
['current', 'suppliers'],
|
||||
);
|
||||
this.initData();
|
||||
}
|
||||
|
||||
@@ -89,15 +94,6 @@ export default class ArticleSupplierTab extends PureComponent {
|
||||
this.unwatchSignal = sseAutomat.actions.watchArticle(String(sku), () => {
|
||||
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. */
|
||||
|
||||
@@ -98,8 +98,7 @@ export default class BookDeliveryDialog extends PureComponent {
|
||||
loadSupplierArticlesIfNeeded() {
|
||||
const supplierId = this.props.delivery?.supplierId ?? this.props.delivery?.partyId;
|
||||
if (supplierId && Object.keys(this.state.supplierArticlesMap).length === 0) {
|
||||
void supplierApi.getArticles(supplierId).then((res) => {
|
||||
const articles = res?.articles || res?.supplier?.articles || [];
|
||||
void companyAutomat.actions.loadArticlesForSupplier(supplierId).then((articles) => {
|
||||
const map = buildSupplierArticlesMap(articles);
|
||||
this.setState({ supplierArticlesMap: map });
|
||||
}).catch(() => { });
|
||||
@@ -122,7 +121,6 @@ export default class BookDeliveryDialog extends PureComponent {
|
||||
this.unsubArticle = artikelAutomat.subscribe(() => {
|
||||
this.forceUpdate();
|
||||
});
|
||||
void companyAutomat.actions.loadWarehouses().catch(() => { });
|
||||
this.loadSupplierArticlesIfNeeded();
|
||||
|
||||
if (this.props.open) {
|
||||
@@ -225,7 +223,6 @@ export default class BookDeliveryDialog extends PureComponent {
|
||||
supplierArticlesMap: currentSupplierMap,
|
||||
},
|
||||
() => {
|
||||
void companyAutomat.actions.loadWarehouses().catch(() => { });
|
||||
this.loadSupplierArticlesIfNeeded();
|
||||
if (this.props.summary) {
|
||||
this.initAmountsFromSummary(this.props.summary, this.props.prefillLineId);
|
||||
|
||||
@@ -242,10 +242,6 @@ class ManifestForm extends PureComponent {
|
||||
['current', 'suppliers', 'suppliersStatus', 'customergroups', 'customergroupsStatus'],
|
||||
);
|
||||
|
||||
if (companyAutomat.state.warehousesStatus === 'idle') {
|
||||
void companyAutomat.actions.loadWarehouses();
|
||||
}
|
||||
|
||||
if (this.props.mode === 'edit') {
|
||||
void this.loadEdit();
|
||||
if (this.props.kind === 'order' || this.props.kind === 'retoure') {
|
||||
|
||||
@@ -43,7 +43,11 @@ export default class CompanySettingsPanel extends Component {
|
||||
this.syncFormFromCompany(state.current);
|
||||
}
|
||||
});
|
||||
void this.loadCompany();
|
||||
if (companyAutomat.state.current) {
|
||||
this.syncFormFromCompany(companyAutomat.state.current);
|
||||
} else {
|
||||
void this.loadCompany();
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -78,7 +78,9 @@ export default class PosTerminalSettingsPanel extends Component {
|
||||
if (categoryAutomat.state.treeStatus === 'idle') {
|
||||
void categoryAutomat.actions.loadTree();
|
||||
}
|
||||
void this.loadTerminals();
|
||||
if (companyAutomat.state.terminalsStatus !== 'succeeded') {
|
||||
void this.loadTerminals();
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
Reference in New Issue
Block a user