Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
rename hasCollectableRate to hasCollectibleRate
Browse files Browse the repository at this point in the history
  • Loading branch information
opr committed Feb 3, 2023
1 parent 220c2b1 commit 2fcb7d1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions assets/js/base/context/hooks/shipping/use-shipping-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
import { isObject } from '@woocommerce/types';
import { useEffect, useRef, useCallback } from '@wordpress/element';
import {
hasCollectableRate,
hasCollectibleRate,
deriveSelectedShippingRates,
} from '@woocommerce/base-utils';
import isShallowEqual from '@wordpress/is-shallow-equal';
Expand Down Expand Up @@ -47,7 +47,7 @@ export const useShippingData = (): ShippingData => {
isCollectable: rates.every(
( { shipping_rates: packageShippingRates } ) =>
packageShippingRates.find( ( { method_id: methodId } ) =>
hasCollectableRate( methodId )
hasCollectibleRate( methodId )
)
),
isSelectingRate: isEditor
Expand Down Expand Up @@ -80,7 +80,7 @@ export const useShippingData = (): ShippingData => {
) => Promise< unknown >;
};

const hasSelectedLocalPickup = hasCollectableRate(
const hasSelectedLocalPickup = hasCollectibleRate(
Object.values( selectedRates.current ).map(
( rate ) => rate.split( ':' )[ 0 ]
)
Expand All @@ -101,7 +101,7 @@ export const useShippingData = (): ShippingData => {
* Forces pickup location to be selected for all packages since we don't allow a mix of shipping and pickup.
*/
if (
hasCollectableRate( newShippingRateId.split( ':' )[ 0 ] ) ||
hasCollectibleRate( newShippingRateId.split( ':' )[ 0 ] ) ||
hasSelectedLocalPickup
) {
selectPromise = dispatchSelectShippingRate( newShippingRateId );
Expand Down
2 changes: 1 addition & 1 deletion assets/js/base/utils/shipping-rates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const isPackageRateCollectible = (
/**
* Check if the specified rates are collectible. Accepts either an array of rate names, or a single string.
*/
export const hasCollectableRate = (
export const hasCollectibleRate = (
chosenRates: string[] | string
): boolean => {
if ( Array.isArray( chosenRates ) ) {
Expand Down
6 changes: 3 additions & 3 deletions assets/js/base/utils/test/shipping-rates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import {
hasCollectableRate,
hasCollectibleRate,
isPackageRateCollectible,
} from '@woocommerce/base-utils';
import { CartShippingRate } from '@woocommerce/type-defs/cart';
Expand All @@ -23,9 +23,9 @@ jest.mock( '@woocommerce/settings', () => {
describe( 'hasCollectableRate', () => {
it( 'correctly identifies if an array contains a collectible rate', () => {
const ratesToTest = [ 'flat_rate', 'local_pickup' ];
expect( hasCollectableRate( ratesToTest ) ).toBe( true );
expect( hasCollectibleRate( ratesToTest ) ).toBe( true );
const ratesToTest2 = [ 'flat_rate', 'free_shipping' ];
expect( hasCollectableRate( ratesToTest2 ) ).toBe( false );
expect( hasCollectibleRate( ratesToTest2 ) ).toBe( false );
} );
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import type { CartShippingPackageShippingRate } from '@woocommerce/type-defs/cart';
import { hasCollectableRate } from '@woocommerce/base-utils';
import { hasCollectibleRate } from '@woocommerce/base-utils';

export interface minMaxPrices {
min: CartShippingPackageShippingRate | undefined;
Expand All @@ -26,7 +26,7 @@ export function getShippingPrices(
lowestRate: CartShippingPackageShippingRate | undefined,
currentRate: CartShippingPackageShippingRate
) => {
if ( hasCollectableRate( currentRate.method_id ) ) {
if ( hasCollectibleRate( currentRate.method_id ) ) {
return lowestRate;
}
if (
Expand All @@ -45,7 +45,7 @@ export function getShippingPrices(
highestRate: CartShippingPackageShippingRate | undefined,
currentRate: CartShippingPackageShippingRate
) => {
if ( hasCollectableRate( currentRate.method_id ) ) {
if ( hasCollectibleRate( currentRate.method_id ) ) {
return highestRate;
}
if (
Expand Down Expand Up @@ -84,7 +84,7 @@ export function getLocalPickupPrices(
lowestRate: CartShippingPackageShippingRate | undefined,
currentRate: CartShippingPackageShippingRate
) => {
if ( hasCollectableRate( currentRate.method_id ) ) {
if ( hasCollectibleRate( currentRate.method_id ) ) {
return lowestRate;
}
if (
Expand All @@ -102,7 +102,7 @@ export function getLocalPickupPrices(
highestRate: CartShippingPackageShippingRate | undefined,
currentRate: CartShippingPackageShippingRate
) => {
if ( hasCollectableRate( currentRate.method_id ) ) {
if ( hasCollectibleRate( currentRate.method_id ) ) {
return highestRate;
}
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useShippingData } from '@woocommerce/base-context/hooks';
import { ShippingRatesControl } from '@woocommerce/base-components/cart-checkout';
import {
getShippingRatesPackageCount,
hasCollectableRate,
hasCollectibleRate,
} from '@woocommerce/base-utils';
import { getCurrencyFromPriceResponse } from '@woocommerce/price-format';
import FormattedMonetaryAmount from '@woocommerce/base-components/formatted-monetary-amount';
Expand Down Expand Up @@ -69,7 +69,7 @@ const Block = (): JSX.Element | null => {
...shippingRatesPackage,
shipping_rates: shippingRatesPackage.shipping_rates.filter(
( shippingRatesPackageRate ) =>
! hasCollectableRate(
! hasCollectibleRate(
shippingRatesPackageRate.method_id
)
),
Expand Down
4 changes: 2 additions & 2 deletions assets/js/data/checkout/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import { select } from '@wordpress/data';
import { hasCollectableRate } from '@woocommerce/base-utils';
import { hasCollectibleRate } from '@woocommerce/base-utils';
import { isString, objectHasProp } from '@woocommerce/types';

/**
Expand Down Expand Up @@ -89,7 +89,7 @@ export const prefersCollection = ( state: CheckoutState ) => {
objectHasProp( selectedRate, 'method_id' ) &&
isString( selectedRate.method_id )
) {
return hasCollectableRate( selectedRate?.method_id );
return hasCollectibleRate( selectedRate?.method_id );
}
}
return state.prefersCollection;
Expand Down

0 comments on commit 2fcb7d1

Please sign in to comment.