Skip to content

Commit

Permalink
fix: bug on AML and lLTL when submit primaryId and secondaryId (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
duong-se authored Feb 12, 2020
1 parent 3e515f2 commit 873e2d7
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 39 deletions.
2 changes: 1 addition & 1 deletion packages/aml-checklist/src/tests/badges/badge-branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/aml-checklist/src/tests/badges/badge-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/aml-checklist/src/utils/__tests__/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('daytime', () => {
const { identityDocument1, identityDocument2 } = idCheck
expect(result).toEqual({
...idCheck,
checkDate: '1-01-01',
checkDate: '1-01-01T00:00:00+00:00',
identityDocument1: {
...identityDocument1,
expiry: toLocalTime(identityDocument1?.expiry as dayjs.ConfigType, DATE_TIME_FORMAT.RFC3339),
Expand Down
34 changes: 22 additions & 12 deletions packages/aml-checklist/src/utils/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ import { IdentityCheckModel } from '@reapit/foundations-ts-definitions'
*/
export const changeTimeZoneLocalForIdentityCheck = (identityChecks: IdentityCheckModel): IdentityCheckModel => {
const { identityDocument1, identityDocument2 } = identityChecks
return {
const newIdentity = {
...identityChecks,
identityDocument1: {
checkDate: toLocalTime(identityChecks.checkDate as dayjs.ConfigType, DATE_TIME_FORMAT.RFC3339),
}
if (identityDocument1) {
newIdentity.identityDocument1 = {
...identityDocument1,
expiry: toLocalTime(identityDocument1?.expiry as dayjs.ConfigType, DATE_TIME_FORMAT.RFC3339),
},
identityDocument2: {
}
}
if (identityDocument2) {
newIdentity.identityDocument2 = {
...identityDocument2,
expiry: toLocalTime(identityDocument2?.expiry as dayjs.ConfigType, DATE_TIME_FORMAT.RFC3339),
},
checkDate: toLocalTime(identityChecks.checkDate as dayjs.ConfigType, DATE_TIME_FORMAT.YYYY_MM_DD),
}
}
return newIdentity
}

/**
Expand All @@ -28,16 +33,21 @@ export const changeTimeZoneLocalForIdentityCheck = (identityChecks: IdentityChec
*/
export const changeTimeZoneUTCForIdentityCheck = (identityChecks: IdentityCheckModel): IdentityCheckModel => {
const { identityDocument1, identityDocument2 } = identityChecks
return {
const newIdentity = {
...identityChecks,
identityDocument1: {
checkDate: toUTCTime(identityChecks.checkDate as dayjs.ConfigType, DATE_TIME_FORMAT.YYYY_MM_DD),
}
if (identityDocument1) {
newIdentity.identityDocument1 = {
...identityDocument1,
expiry: toUTCTime(identityDocument1?.expiry as dayjs.ConfigType, DATE_TIME_FORMAT.YYYY_MM_DD),
},
identityDocument2: {
}
}
if (identityDocument2) {
newIdentity.identityDocument2 = {
...identityDocument2,
expiry: toUTCTime(identityDocument2?.expiry as dayjs.ConfigType, DATE_TIME_FORMAT.YYYY_MM_DD),
},
checkDate: toUTCTime(identityChecks.checkDate as dayjs.ConfigType, DATE_TIME_FORMAT.YYYY_MM_DD),
}
}
return newIdentity
}
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-branches.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/elements/src/tests/badges/badge-statements.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/elements/src/utils/datetime/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export function closestTo(dateCompare: dayjs.ConfigType, datesArray: Array<dayjs
}

export function toUTCTime(value: dayjs.ConfigType, format: string | undefined = DATE_TIME_FORMAT.RFC3339): string {
if (!value) {
return ''
}
const date = dayjs(value)
return date.utc().format(format)
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/lifetime-legal/src/tests/badges/badge-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 873e2d7

Please sign in to comment.