Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
devisscher committed Apr 18, 2024
1 parent 456cb0f commit a9cf0ca
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 57 deletions.
24 changes: 1 addition & 23 deletions src/components/CombinationCard/CombinationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import {
import {I18n, useI18n} from '@shopify/react-i18n';

import {DiscountClass} from '../../constants';
import type {
CombinableDiscountTypes,
CombinableDiscountCounts,
Field,
} from '../../types';
import type {CombinableDiscountTypes, Field} from '../../types';

const I18N_SCOPE = {
scope: 'DiscountAppComponents.CombinationCard',
Expand All @@ -37,24 +33,12 @@ export interface CombinationCardProps {
* Field used for setting which discount classes may be combined with this discount
*/
combinableDiscountTypes: Field<CombinableDiscountTypes>;

/**
* (optional) The number of existing product, order, and shipping discount classes in the shop which can be combined with this discount
*/
combinableDiscountCounts?: CombinableDiscountCounts;

/**
* (optional) The full GID of the current discount. Used to filter out the current discount from the combinations modal.
*/
discountId?: string;
}

export function CombinationCard({
discountClass,
discountDescriptor,
combinableDiscountTypes,
combinableDiscountCounts,
discountId,
}: CombinationCardProps) {
const [i18n] = useI18n();

Expand Down Expand Up @@ -123,10 +107,7 @@ export function CombinationCard({
allowMultiple
choices={buildChoices({
discountClass,
discountId,
discountDescriptor,
i18n,
combinableDiscountCounts,
})}
selected={getSelectedChoices(combinableDiscountTypes.value)}
onChange={handleDiscountCombinesWithChange}
Expand All @@ -142,10 +123,7 @@ function buildChoices({
i18n,
}: {
discountClass: DiscountClass;
discountId?: string;
discountDescriptor: string;
i18n: I18n;
combinableDiscountCounts?: CombinableDiscountCounts;
}): ChoiceListProps['choices'] {
const productOption = {
label: i18n.translate('options.productLabel', I18N_SCOPE),
Expand Down
11 changes: 0 additions & 11 deletions src/components/CombinationCard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ The CombinationCard enables merchants to control how they wish a discount to com
```jsx
<CombinationCard
combinableDiscountTypes={combinableDiscountTypesField}
combinableDiscountCounts={{
orderDiscountsCount: 0,
productDiscountsCount: 3,
shippingDiscountsCount: 0,
}}
discountClass={DiscountClass.Product}
discountDescriptor="Spring Sale - 20% off"
/>
Expand All @@ -34,13 +29,7 @@ When the discount page is in a `editing` (rather than `creating`) state, pass th
```jsx
<CombinationCard
combinableDiscountTypes={combinableDiscountTypesField}
combinableDiscountCounts={{
orderDiscountsCount: 0,
productDiscountsCount: 3,
shippingDiscountsCount: 0,
}}
discountClass={DiscountClass.Product}
discountDescriptor="Spring Sale - 20% off"
discountId="gid://Shopify/DiscountNode/1"
/>
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ describe('<CombinationCard />', () => {
productDiscounts: true,
shippingDiscounts: false,
}),
combinableDiscountCounts: {
orderDiscountsCount: 0,
productDiscountsCount: 3,
shippingDiscountsCount: 0,
},

discountId: composeGid('DiscountNode', '1'),
};

Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export type {
Customer,
CustomerSegment,
CombinableDiscountTypes,
CombinableDiscountCounts,
} from './types';

// constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ export default function CombinationCardPattern({
value: combinesWith,
onChange: setCombinesWith,
}}
combinableDiscountCounts={{
orderDiscountsCount: 0,
productDiscountsCount: 3,
shippingDiscountsCount: 0,
}}
discountClass={discountClass}
discountDescriptor={discountDescriptor}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,6 @@ export default function DiscountPage({id = '1'}) {
value: combinesWith,
onChange: setCombinesWith,
}}
combinableDiscountCounts={{
orderDiscountsCount: 0,
productDiscountsCount: 3,
shippingDiscountsCount: 0,
}}
discountClass={discountData.discountClass}
discountDescriptor={discountDescriptor}
/>
Expand All @@ -236,7 +231,7 @@ export default function DiscountPage({id = '1'}) {
timezoneAbbreviation={timezoneAbbreviation}
/>
</Layout.Section>
<Layout.Section variant='oneThird'>
<Layout.Section variant="oneThird">
<SummaryCard
header={{
discountMethod: discountMethod,
Expand Down
6 changes: 0 additions & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ export interface CombinableDiscountTypes {
shippingDiscounts: boolean;
}

export interface CombinableDiscountCounts {
productDiscountsCount: number;
orderDiscountsCount: number;
shippingDiscountsCount: number;
}

export type CountryCode = SupportedCountryCode | typeof REST_OF_WORLD;

export interface ProductOrCollectionResource extends Resource {
Expand Down

0 comments on commit a9cf0ca

Please sign in to comment.