Skip to content

Commit

Permalink
feat: add receipt code to admin
Browse files Browse the repository at this point in the history
  • Loading branch information
GravendeelJochem committed Dec 13, 2024
1 parent fdc08cd commit 8bda58d
Showing 1 changed file with 21 additions and 0 deletions.
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),

Check warning on line 11 in apps/admin/src/forms/shipmentOptions/fields/createReceiptCodeField.ts

View check run for this annotation

Codecov / codecov/patch

apps/admin/src/forms/shipmentOptions/fields/createReceiptCodeField.ts#L10-L11

Added lines #L10 - L11 were not covered by tests

afterUpdate({form}, value) {
if (!(CarrierName.DhlForYou === getFormCarrierName(form) && TriState.On === value)) {
return;
}

Check warning on line 16 in apps/admin/src/forms/shipmentOptions/fields/createReceiptCodeField.ts

View check run for this annotation

Codecov / codecov/patch

apps/admin/src/forms/shipmentOptions/fields/createReceiptCodeField.ts#L13-L16

Added lines #L13 - L16 were not covered by tests

form.setValue(FIELD_AGE_CHECK, TriState.Off);
},
});
};

Check warning on line 21 in apps/admin/src/forms/shipmentOptions/fields/createReceiptCodeField.ts

View check run for this annotation

Codecov / codecov/patch

apps/admin/src/forms/shipmentOptions/fields/createReceiptCodeField.ts#L18-L21

Added lines #L18 - L21 were not covered by tests

0 comments on commit 8bda58d

Please sign in to comment.