diff --git a/packages/sdks/shopper/src/utils/extract-product-image.ts b/packages/sdks/shopper/src/utils/extract-product-image.ts new file mode 100644 index 00000000..4290be26 --- /dev/null +++ b/packages/sdks/shopper/src/utils/extract-product-image.ts @@ -0,0 +1,12 @@ +import { Included, Product } from "../client" + +export const extractProductImage = ( + product: Product, + images: Included["main_images"], +) => { + return images?.find((file) => { + if (file.id === product.relationships?.main_image?.data?.id) { + return file + } + }) +} diff --git a/packages/sdks/shopper/src/utils/index.ts b/packages/sdks/shopper/src/utils/index.ts new file mode 100644 index 00000000..a3175f1d --- /dev/null +++ b/packages/sdks/shopper/src/utils/index.ts @@ -0,0 +1 @@ +export { extractProductImage } from "./extract-product-image"