-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fdc08cd
commit 8bda58d
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
apps/admin/src/forms/shipmentOptions/fields/createReceiptCodeField.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {TriState} from '@myparcel-pdk/common'; | ||
import {type InteractiveElementConfiguration} from '@myparcel/vue-form-builder'; | ||
import {CarrierName} from '@myparcel/constants'; | ||
import {type ShipmentOptionsRefs} from '../types'; | ||
import {FIELD_AGE_CHECK, FIELD_RECEIPT_CODE} from '../field'; | ||
import {getFormCarrierName, hasPostNlAgeCheck} from '../../helpers'; | ||
import {createShipmentOptionField} from './createShipmentOptionField'; | ||
|
||
export const createReceiptCodeField = (refs: ShipmentOptionsRefs): InteractiveElementConfiguration => { | ||
return createShipmentOptionField(refs, FIELD_RECEIPT_CODE, { | ||
readOnlyWhen: ({form}) => hasPostNlAgeCheck(form), | ||
|
||
afterUpdate({form}, value) { | ||
if (!(CarrierName.DhlForYou === getFormCarrierName(form) && TriState.On === value)) { | ||
return; | ||
} | ||
|
||
form.setValue(FIELD_AGE_CHECK, TriState.Off); | ||
}, | ||
}); | ||
}; | ||