Skip to content

Commit

Permalink
ref: separate ok ctor in prefill function
Browse files Browse the repository at this point in the history
  • Loading branch information
mantariksh committed Nov 16, 2020
1 parent 940abcf commit 0aa68dd
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/app/services/myinfo/myinfo.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,20 @@ export class MyInfoService {
myInfoData: IPersonBasic,
currFormFields: IFieldSchema[],
): Result<IPossiblyPrefilledField[], never> {
return ok(
currFormFields.map((field) => {
if (!field?.myInfo?.attr) return field
const prefilledFields = currFormFields.map((field) => {
if (!field?.myInfo?.attr) return field

const myInfoAttr = field.myInfo.attr
const myInfoValue = getMyInfoValue(myInfoAttr, myInfoData)
const isReadOnly = isFieldReadOnly(myInfoAttr, myInfoValue, myInfoData)
const prefilledField = cloneDeep(field) as IPossiblyPrefilledField
prefilledField.fieldValue = myInfoValue
const myInfoAttr = field.myInfo.attr
const myInfoValue = getMyInfoValue(myInfoAttr, myInfoData)
const isReadOnly = isFieldReadOnly(myInfoAttr, myInfoValue, myInfoData)
const prefilledField = cloneDeep(field) as IPossiblyPrefilledField
prefilledField.fieldValue = myInfoValue

// Disable field
prefilledField.disabled = isReadOnly
return prefilledField
}),
)
// Disable field
prefilledField.disabled = isReadOnly
return prefilledField
})
return ok(prefilledFields)
}

/**
Expand Down

0 comments on commit 0aa68dd

Please sign in to comment.