Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add receipt code to admin #228

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
createPackageTypeField,
createSameDayDeliveryField,
createSignatureField,
createReceiptCodeField,
} from './fields';
import {ALL_FIELDS, FIELD_CARRIER} from './field';

Expand Down Expand Up @@ -70,7 +71,7 @@
createLargeFormatField(refs),
createHideSenderField(refs),
createSameDayDeliveryField(refs),

createReceiptCodeField(refs),

Check warning on line 74 in apps/admin/src/forms/shipmentOptions/createShipmentOptionsForm.ts

View check run for this annotation

Codecov / codecov/patch

apps/admin/src/forms/shipmentOptions/createShipmentOptionsForm.ts#L74

Added line #L74 was not covered by tests
createInsuranceField(refs),
],
});
Expand Down
4 changes: 4 additions & 0 deletions apps/admin/src/forms/shipmentOptions/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const PACKAGE_TYPE = 'packageType' satisfies keyof Shipment.ModelDelivery

export const AGE_CHECK = 'ageCheck' satisfies keyof Shipment.ModelShipmentOptions;

export const RECEIPT_CODE = 'receiptCode' satisfies keyof Shipment.ModelShipmentOptions;
export const DIRECT_RETURN = 'return' satisfies keyof Shipment.ModelShipmentOptions;

export const HIDE_SENDER = 'hideSender' satisfies keyof Shipment.ModelShipmentOptions;
Expand Down Expand Up @@ -64,6 +65,8 @@ export const FIELD_INSURANCE: FieldName = `${SHIPMENT_OPTIONS_PREFIX}.${INSURANC

export const FIELD_MANUAL_WEIGHT: FieldName = `${PHYSICAL_PROPERTIES_PREFIX}.${MANUAL_WEIGHT}`;

export const FIELD_RECEIPT_CODE: FieldName = `${SHIPMENT_OPTIONS_PREFIX}.${RECEIPT_CODE}`;

export const ALL_FIELDS = [
FIELD_AGE_CHECK,
FIELD_CARRIER,
Expand All @@ -77,4 +80,5 @@ export const ALL_FIELDS = [
FIELD_PACKAGE_TYPE,
FIELD_SAME_DAY_DELIVERY,
FIELD_SIGNATURE,
FIELD_RECEIPT_CODE,
] as const;
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)) {
GravendeelJochem marked this conversation as resolved.
Show resolved Hide resolved
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
1 change: 1 addition & 0 deletions apps/admin/src/forms/shipmentOptions/fields/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from './createRef';
export * from './createSameDayDeliveryField';
export * from './createShipmentOptionField';
export * from './createSignatureField';
export * from './createReceiptCodeField';
GravendeelJochem marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions libs/common/src/types/php-pdk.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ export namespace Shipment {
return?: boolean;
sameDayDelivery?: boolean;
signature?: boolean;
receiptCode?: boolean;
};

export type PostReturnShipmentsRequest = Base.Request;
Expand Down