Skip to content

Commit

Permalink
fix: use relevant date format
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikhaugstulen committed Aug 26, 2024
1 parent 3dcc8da commit 5d5a113
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { parseDate } from '../../parsers';
*
* @export
* @param {string} value
* @param {string} format
* @returns {boolean}
*/
export function isValidDate(value: string, format: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import log from 'loglevel';
import { generateUID } from '../../../../utils/uid/generateUID';
import { actions as RelatedStageModes } from '../../../WidgetRelatedStages/constants';
import type { ConvertedRelatedStageEventProps } from './getConvertedRelatedStageEvent.types';
import { errorCreator } from '../../../../../capture-core-utils';
import { errorCreator, pipe } from '../../../../../capture-core-utils';
import { type LinkedRequestEvent } from '../validated.types';
import { convertClientToServer, convertFormToClient } from '../../../../converters';
import { dataElementTypes } from '../../../../metaData';

const convertFn = pipe(convertFormToClient, convertClientToServer);

const getEventDetailsByLinkMode = ({
relatedStageDataValues,
Expand Down Expand Up @@ -47,17 +51,17 @@ const getEventDetailsByLinkMode = ({
return ({
linkedEvent: {
...baseEventDetails,
scheduledAt: linkedEventScheduledAt,
orgUnit: linkedEventOrgUnit.id,
scheduledAt: convertFn(linkedEventScheduledAt, dataElementTypes.DATE),
orgUnit: convertFn(linkedEventOrgUnit, dataElementTypes.ORGANISATION_UNIT),
},
linkedEventId: baseEventDetails.event,
});
} else if (linkMode === RelatedStageModes.ENTER_DATA) {
return ({
linkedEvent: {
...baseEventDetails,
scheduledAt: clientRequestEvent.occurredAt,
orgUnit: clientRequestEvent.orgUnit,
scheduledAt: convertFn(clientRequestEvent.scheduledAt, dataElementTypes.DATE),
orgUnit: convertFn(clientRequestEvent.orgUnit, dataElementTypes.ORGANISATION_UNIT),
},
linkedEventId: baseEventDetails.event,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ import { systemSettingsStore } from '../../../metaDataMemoryStores';
export function convertStringToDateFormat(date: string) {
if (!date || !date.length) { return ''; }
const dateFormat = systemSettingsStore.get().dateFormat;
const formattedDateString = moment(date, dateFormat).format('YYYY-MM-DD');
const formattedDateString = moment(date, dateFormat).format(dateFormat);
return formattedDateString;
}

0 comments on commit 5d5a113

Please sign in to comment.