u
This commit is contained in:
@@ -16,7 +16,12 @@ import { enqueueSnackbar } from 'notistack';
|
||||
import RestoreIcon from '@mui/icons-material/Restore';
|
||||
import FileDropzone from '../FileDropzone';
|
||||
import AttachmentList from './AttachmentList';
|
||||
import { hasArticleLines, manifestConfig, partyDisplayName } from './manifestConfig';
|
||||
import {
|
||||
hasArticleLines,
|
||||
manifestConfig,
|
||||
partyDisplayName,
|
||||
getLowestSortNonSupplierCustomerGroup,
|
||||
} from './manifestConfig';
|
||||
import { notifyError, notifyErrorMessage } from '../../utils/notify';
|
||||
import entityAutomat from '../../automats/entityAutomat';
|
||||
import customergroupAutomat from '../../automats/customergroupAutomat';
|
||||
@@ -29,7 +34,11 @@ class ManifestHeader extends PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const selected =
|
||||
(props.parties || []).find((row) => row.id === props.partyId) ?? null;
|
||||
(props.parties || []).find((row) => row.id === props.partyId) ??
|
||||
(props.kind === 'delivery'
|
||||
? (supplierAutomat.state.suppliers || []).find((row) => row.id === props.partyId)
|
||||
: (entityAutomat.state.items || []).find((row) => row.id === props.partyId)) ??
|
||||
null;
|
||||
this.state = {
|
||||
partyInput: selected ? partyDisplayName(props.kind, selected) : '',
|
||||
creatingParty: false,
|
||||
@@ -48,10 +57,13 @@ class ManifestHeader extends PureComponent {
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (prevProps.partyId !== this.props.partyId) {
|
||||
if (prevProps.partyId !== this.props.partyId || prevProps.parties !== this.props.parties) {
|
||||
const selected =
|
||||
(this.props.parties || []).find((row) => row.id === this.props.partyId) ??
|
||||
(this.state.createdParty?.id === this.props.partyId ? this.state.createdParty : null);
|
||||
(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)
|
||||
: (entityAutomat.state.items || []).find((row) => row.id === this.props.partyId));
|
||||
if (selected) {
|
||||
this.setState({ partyInput: partyDisplayName(this.props.kind, selected) });
|
||||
} else if (this.props.partyId == null) {
|
||||
@@ -137,8 +149,8 @@ class ManifestHeader extends PureComponent {
|
||||
} else {
|
||||
await customergroupAutomat.actions.ensureLoaded();
|
||||
const groups = customergroupAutomat.state.items ?? [];
|
||||
const defaultGroup = groups.find((g) => g.editable !== false) ?? groups[0];
|
||||
if (!defaultGroup) {
|
||||
const targetGroup = getLowestSortNonSupplierCustomerGroup(groups) ?? groups[0];
|
||||
if (!targetGroup) {
|
||||
throw new Error('Keine Kundengruppe vorhanden.');
|
||||
}
|
||||
|
||||
@@ -156,7 +168,7 @@ class ManifestHeader extends PureComponent {
|
||||
}
|
||||
|
||||
const body = {
|
||||
customergroupId: defaultGroup.id,
|
||||
customergroupId: targetGroup.id,
|
||||
name,
|
||||
};
|
||||
if (firstName) body.firstName = firstName;
|
||||
|
||||
Reference in New Issue
Block a user