Skip to content

Commit

Permalink
Merge pull request #70 from MakairaIO/61-clientcartremoveitem-not-wor…
Browse files Browse the repository at this point in the history
…king-in-typescript-component

fix(removeItemFromCart-Type): allow product parameter for shopify to …
  • Loading branch information
Jan authored Aug 31, 2022
2 parents c9f111e + 40a6aef commit 471ca4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ export class StorefrontShopAdapterShopifyCart
}

removeItem: MakairaRemoveItemFromCart<
{ product: never; lineItemIds: string[] },
{
product?: never
lineItemIds: string[]
},
ShopifyRemoveItemRaw,
Error
> = async ({ input: { lineItemIds } }) => {
Expand Down
11 changes: 8 additions & 3 deletions packages/storefront-types/src/providers/cart.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { MakairaShopProviderInteractor } from '../general/shop-provider-interactor'
import { MakairaProduct } from '../product'

type MergeBy<T, K> = Omit<T, keyof K> & K

//#region type definition: add-to-cart
export type MakairaAddItemToCartInput<AdditionalInput = unknown> = {
product: { id: string; attributes?: { key: string; value: string }[] }
Expand Down Expand Up @@ -43,9 +45,12 @@ export type MakairaGetCart<
//#endregion

//#region type definition: remove-item-from-cart
export type MakairaRemoveItemFromCartInput<AdditionalInput = unknown> = {
product: { id: string; attributes?: { key: string; value: string }[] }
} & AdditionalInput
export type MakairaRemoveItemFromCartInput<AdditionalInput = unknown> = MergeBy<
{
product: { id: string; attributes?: { key: string; value: string }[] }
},
AdditionalInput
>

export type MakairaRemoveItemFromCartResData = {
items: { product: MakairaProduct; quantity: number }[]
Expand Down

0 comments on commit 471ca4b

Please sign in to comment.