Skip to content

Commit

Permalink
feat: add util for extracting image
Browse files Browse the repository at this point in the history
  • Loading branch information
field123 committed Aug 26, 2024
1 parent 7ef7094 commit ca90991
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/sdks/shopper/src/utils/extract-product-image.ts
Original file line number Diff line number Diff line change
@@ -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
}
})
}
1 change: 1 addition & 0 deletions packages/sdks/shopper/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { extractProductImage } from "./extract-product-image"

0 comments on commit ca90991

Please sign in to comment.