u
This commit is contained in:
@@ -25,9 +25,7 @@ import {
|
||||
} from './manifestConfig';
|
||||
import { notifyError, notifyErrorMessage } from '../../utils/notify';
|
||||
import entityAutomat from '../../automats/entityAutomat';
|
||||
import customergroupAutomat from '../../automats/customergroupAutomat';
|
||||
import supplierAutomat from '../../automats/supplierAutomat';
|
||||
import numberAutomat from '../../automats/numberAutomat';
|
||||
import companyAutomat from '../../automats/companyAutomat';
|
||||
import quoteAutomat from '../../automats/quoteAutomat';
|
||||
import orderAutomat from '../../automats/orderAutomat';
|
||||
import deliveryAutomat from '../../automats/deliveryAutomat';
|
||||
@@ -42,7 +40,7 @@ class ManifestHeader extends PureComponent {
|
||||
const selected =
|
||||
(props.parties || []).find((row) => row.id === props.partyId) ??
|
||||
(props.kind === 'delivery'
|
||||
? (supplierAutomat.state.suppliers || []).find((row) => row.id === props.partyId)
|
||||
? (companyAutomat.state.suppliers || []).find((row) => row.id === props.partyId)
|
||||
: (entityAutomat.state.items || []).find((row) => row.id === props.partyId)) ??
|
||||
null;
|
||||
this.state = {
|
||||
@@ -68,7 +66,7 @@ class ManifestHeader extends PureComponent {
|
||||
(this.props.parties || []).find((row) => row.id === this.props.partyId) ??
|
||||
(this.state.createdParty?.id === this.props.partyId ? this.state.createdParty : null) ??
|
||||
(this.props.kind === 'delivery'
|
||||
? (supplierAutomat.state.suppliers || []).find((row) => row.id === this.props.partyId)
|
||||
? (companyAutomat.state.suppliers || []).find((row) => row.id === this.props.partyId)
|
||||
: (entityAutomat.state.items || []).find((row) => row.id === this.props.partyId));
|
||||
if (selected) {
|
||||
this.setState({ partyInput: partyDisplayName(this.props.kind, selected) });
|
||||
@@ -147,14 +145,14 @@ class ManifestHeader extends PureComponent {
|
||||
try {
|
||||
const { kind, onPartyChange } = this.props;
|
||||
if (kind === 'delivery') {
|
||||
const row = await supplierAutomat.actions.create({ name: raw });
|
||||
const row = await companyAutomat.actions.createSupplier({ name: raw });
|
||||
const displayName = row?.name || raw;
|
||||
enqueueSnackbar(`Lieferant „${displayName}“ angelegt.`, { variant: 'success' });
|
||||
this.setState({ creatingParty: false, createdParty: row, partyInput: displayName });
|
||||
onPartyChange?.(row.id);
|
||||
} else {
|
||||
await customergroupAutomat.actions.ensureLoaded();
|
||||
const groups = customergroupAutomat.state.items ?? [];
|
||||
await companyAutomat.actions.ensureCustomergroupsLoaded();
|
||||
const groups = companyAutomat.state.customergroups ?? [];
|
||||
const targetGroup = getLowestSortNonSupplierCustomerGroup(groups) ?? groups[0];
|
||||
if (!targetGroup) {
|
||||
throw new Error('Keine Kundengruppe vorhanden.');
|
||||
@@ -257,11 +255,15 @@ class ManifestHeader extends PureComponent {
|
||||
|
||||
componentDidMount() {
|
||||
this._cancelled = false;
|
||||
this.unsubNumber = numberAutomat.subscribe(this, () => {
|
||||
this.forceUpdate();
|
||||
});
|
||||
this.unsubNumber = companyAutomat.subscribe(
|
||||
this,
|
||||
() => {
|
||||
this.forceUpdate();
|
||||
},
|
||||
['numbers'],
|
||||
);
|
||||
this.subscribeListAutomat(this.props.kind);
|
||||
void numberAutomat.actions.ensureLoaded().catch(() => {});
|
||||
void companyAutomat.actions.ensureNumbersLoaded().catch(() => {});
|
||||
if (!this.props.number && this.props.docId == null) {
|
||||
void ensureDocumentNumber(this.props.kind)
|
||||
.then(() => {
|
||||
|
||||
Reference in New Issue
Block a user