Skip to content

Commit

Permalink
fix: select delivery date for small package type INT-752
Browse files Browse the repository at this point in the history
  • Loading branch information
Clerise Swart committed Dec 10, 2024
1 parent 65a50ea commit 5bb691d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 10 additions & 4 deletions apps/delivery-options/src/composables/useFeatures.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import {computed} from 'vue';
import {useMemoize} from '@vueuse/core';
import {ConfigSetting, PACKAGE_TYPE_DEFAULT} from '@myparcel-do/shared';
import {ConfigSetting, LimitedPackageTypeName} from '@myparcel-do/shared';
import {useConfigStore} from '../stores';
import {SHOWN_SHIPMENT_OPTIONS} from '../data';

const PACKAGE_TYPE_DEFAULT = [LimitedPackageTypeName.Package, LimitedPackageTypeName.PackageSmall];

export const useFeatures = useMemoize(() => {
const config = useConfigStore();

return {
availableShipmentOptions: computed(() => {
return PACKAGE_TYPE_DEFAULT === config.packageType ? SHOWN_SHIPMENT_OPTIONS : [];
return PACKAGE_TYPE_DEFAULT.includes(config.packageType as unknown as LimitedPackageTypeName)
? SHOWN_SHIPMENT_OPTIONS
: [];

Check warning on line 15 in apps/delivery-options/src/composables/useFeatures.ts

View check run for this annotation

Codecov / codecov/patch

apps/delivery-options/src/composables/useFeatures.ts#L15

Added line #L15 was not covered by tests
}),

showDeliveryDate: computed(() => {
return PACKAGE_TYPE_DEFAULT === config.packageType && config[ConfigSetting.ShowDeliveryDate];
return (
PACKAGE_TYPE_DEFAULT.includes(config.packageType as unknown as LimitedPackageTypeName) &&
config[ConfigSetting.ShowDeliveryDate]
);
}),
};
});
5 changes: 5 additions & 0 deletions libs/shared/src/data/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,8 @@ export enum CustomDeliveryType {
Monday = 'monday',
Saturday = 'saturday',
}

export enum LimitedPackageTypeName {
Package = 'package',
PackageSmall = 'package_small',
}

0 comments on commit 5bb691d

Please sign in to comment.