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