From 5fb894dc216d1ce456bf575155a4e37ab993c78a Mon Sep 17 00:00:00 2001 From: cond0r Date: Fri, 26 Feb 2021 12:08:41 +0200 Subject: [PATCH] remove unused util --- framework/shopify/product/use-search.tsx | 4 +- .../shopify/utils/to-commerce-products.ts | 68 ------------------- 2 files changed, 2 insertions(+), 70 deletions(-) delete mode 100644 framework/shopify/utils/to-commerce-products.ts diff --git a/framework/shopify/product/use-search.tsx b/framework/shopify/product/use-search.tsx index 2ff98f25d..425df9e83 100644 --- a/framework/shopify/product/use-search.tsx +++ b/framework/shopify/product/use-search.tsx @@ -42,7 +42,7 @@ export const handler: SWRHook< variables: getSearchVariables(input), }) - let edges = [] + let edges if (categoryId) { edges = data.node?.products?.edges ?? [] @@ -52,7 +52,7 @@ export const handler: SWRHook< ) } } else { - edges = data.products?.edges + edges = data.products?.edges ?? [] } return { diff --git a/framework/shopify/utils/to-commerce-products.ts b/framework/shopify/utils/to-commerce-products.ts deleted file mode 100644 index 84925e001..000000000 --- a/framework/shopify/utils/to-commerce-products.ts +++ /dev/null @@ -1,68 +0,0 @@ -// TODO: Fix the types in this file -// import { Product, Image } from '../types' - -type Product = any -type Image = any - -export default function toCommerceProducts(products: Product[]) { - return products.map((product: Product) => { - return { - id: product.id, - entityId: product.id, - name: product.title, - slug: product.handle, - title: product.title, - vendor: product.vendor, - description: product.descriptionHtml, - path: `/${product.handle}`, - price: { - value: +product.variants[0].price, - currencyCode: 'USD', // TODO - }, - images: product.images.map((image: Image) => { - return { - url: image.src, - } - }), - // TODO: Fix the variant type - variants: product.variants.map((variant: any) => { - return { - id: variant.id, - // TODO: Fix the selectedOption type - options: variant.selectedOptions.map((selectedOption: any) => { - return { - __typename: 'MultipleChoiceOption', - displayName: selectedOption.name, - values: [ - { - node: { - id: variant.id, - label: selectedOption.value, - }, - }, - ], - } - }), - } - }), - // TODO: Fix the option type - productOptions: product.options.map((option: any) => { - return { - __typename: 'MultipleChoiceOption', - displayName: option.name, - // TODO: Fix the value type - values: option.values.map((value: any) => { - return { - node: { - entityId: 1, - label: value.value, - hexColors: [value.value], - }, - } - }), - } - }), - options: [], - } - }) -}