u
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
|||||||
emptyLine,
|
emptyLine,
|
||||||
lineFromApi,
|
lineFromApi,
|
||||||
dateInputValue,
|
dateInputValue,
|
||||||
|
todayInputValue,
|
||||||
parseNum,
|
parseNum,
|
||||||
} from '../components/manifest/manifestConfig';
|
} from '../components/manifest/manifestConfig';
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ export function createInitialManifestDraftState(kind) {
|
|||||||
kind,
|
kind,
|
||||||
mode: 'create',
|
mode: 'create',
|
||||||
id: null,
|
id: null,
|
||||||
date: '',
|
date: kind === 'quote' ? todayInputValue() : '',
|
||||||
partyId: null,
|
partyId: null,
|
||||||
number: '',
|
number: '',
|
||||||
externalNumber: '',
|
externalNumber: '',
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
buildManifestBody,
|
buildManifestBody,
|
||||||
restoreAttachmentsFromApi,
|
restoreAttachmentsFromApi,
|
||||||
dateInputValue,
|
dateInputValue,
|
||||||
|
todayInputValue,
|
||||||
emptyLine,
|
emptyLine,
|
||||||
lineFromApi,
|
lineFromApi,
|
||||||
loadParties,
|
loadParties,
|
||||||
@@ -55,12 +56,25 @@ class ManifestForm extends PureComponent {
|
|||||||
: null;
|
: null;
|
||||||
const initialDoc = initialDraft || initialEdit;
|
const initialDoc = initialDraft || initialEdit;
|
||||||
|
|
||||||
|
const initialDate =
|
||||||
|
initialDoc?.date ||
|
||||||
|
(props.mode === 'create' && props.kind === 'quote' ? todayInputValue() : '');
|
||||||
|
|
||||||
|
if (
|
||||||
|
props.mode === 'create' &&
|
||||||
|
props.kind === 'quote' &&
|
||||||
|
this.draftAutomat &&
|
||||||
|
!this.draftAutomat.state.date
|
||||||
|
) {
|
||||||
|
this.draftAutomat.setState({ date: initialDate });
|
||||||
|
}
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
status: props.mode === 'edit' && !initialEdit ? 'loading' : (partiesReady ? 'ready' : 'loadingParties'),
|
status: props.mode === 'edit' && !initialEdit ? 'loading' : (partiesReady ? 'ready' : 'loadingParties'),
|
||||||
error: null,
|
error: null,
|
||||||
parties: initialParties,
|
parties: initialParties,
|
||||||
partiesLoading: !partiesReady,
|
partiesLoading: !partiesReady,
|
||||||
date: initialDoc?.date || '',
|
date: initialDate,
|
||||||
partyId: initialDoc?.partyId ?? null,
|
partyId: initialDoc?.partyId ?? null,
|
||||||
number: initialDoc?.number || '',
|
number: initialDoc?.number || '',
|
||||||
externalNumber: initialDoc?.externalNumber || '',
|
externalNumber: initialDoc?.externalNumber || '',
|
||||||
|
|||||||
@@ -29,4 +29,5 @@ export {
|
|||||||
collectFilesForUpload,
|
collectFilesForUpload,
|
||||||
restoreAttachmentsFromApi,
|
restoreAttachmentsFromApi,
|
||||||
dateInputValue,
|
dateInputValue,
|
||||||
|
todayInputValue,
|
||||||
} from './manifestConfig';
|
} from './manifestConfig';
|
||||||
|
|||||||
@@ -77,6 +77,14 @@ export function numberDisplay(value) {
|
|||||||
return String(value);
|
return String(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function todayInputValue() {
|
||||||
|
const d = new Date();
|
||||||
|
const year = d.getFullYear();
|
||||||
|
const month = String(d.getMonth() + 1).padStart(2, '0');
|
||||||
|
const day = String(d.getDate()).padStart(2, '0');
|
||||||
|
return `${year}-${month}-${day}`;
|
||||||
|
}
|
||||||
|
|
||||||
export function dateInputValue(iso) {
|
export function dateInputValue(iso) {
|
||||||
if (!iso) return '';
|
if (!iso) return '';
|
||||||
const d = new Date(iso);
|
const d = new Date(iso);
|
||||||
|
|||||||
Reference in New Issue
Block a user