From 10779012aecb23db1fc8ca0cc2c0910cc8954065 Mon Sep 17 00:00:00 2001 From: Matt Kern Date: Thu, 25 Jan 2024 17:07:45 -0800 Subject: [PATCH] Stubbed products to bypass error on start --- .vscode/settings.json | 6 ++-- lib/shopify/index.ts | 68 ++++++++++++++++++++++++++++--------------- lib/shopify/types.ts | 22 +++++++++++++- 3 files changed, 69 insertions(+), 27 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3fbb4ab25..8345c107c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,8 +2,8 @@ "typescript.tsdk": "node_modules/typescript/lib", "typescript.enablePromptUseWorkspaceTsdk": true, "editor.codeActionsOnSave": { - "source.fixAll": true, - "source.organizeImports": true, - "source.sortMembers": true + "source.fixAll": "explicit", + "source.organizeImports": "explicit", + "source.sortMembers": "explicit" } } diff --git a/lib/shopify/index.ts b/lib/shopify/index.ts index e8b6637c8..17910f062 100644 --- a/lib/shopify/index.ts +++ b/lib/shopify/index.ts @@ -11,11 +11,7 @@ import { removeFromCartMutation } from './mutations/cart'; import { getCartQuery } from './queries/cart'; -import { - getCollectionProductsQuery, - getCollectionQuery, - getCollectionsQuery -} from './queries/collection'; +import { getCollectionQuery, getCollectionsQuery } from './queries/collection'; import { getMenuQuery } from './queries/menu'; import { getPageQuery, getPagesQuery } from './queries/page'; import { @@ -36,7 +32,6 @@ import { ShopifyCartOperation, ShopifyCollection, ShopifyCollectionOperation, - ShopifyCollectionProductsOperation, ShopifyCollectionsOperation, ShopifyCreateCartOperation, ShopifyMenuOperation, @@ -282,7 +277,7 @@ export async function getCollection(handle: string): Promise { - const res = await shopifyFetch({ - query: getCollectionProductsQuery, - tags: [TAGS.collections, TAGS.products], - variables: { - handle: collection, - reverse, - sortKey: sortKey === 'CREATED_AT' ? 'CREATED' : sortKey +}): Product[] { + return [ + { + id: '123', + handle: 'foo', + availableForSale: true, + title: 'Thneed', + description: 'Something everyone needs', + descriptionHtml: '

Something everyone needs

', + options: [], + priceRange: { + maxVariantPrice: { amount: '0.00', currencyCode: 'USD' }, + minVariantPrice: { amount: '0.00', currencyCode: 'USD' } + }, + + variants: [ + { + id: '123', + title: 'Thneed', + availableForSale: true, + selectedOptions: [{ name: 'color', value: 'red' }], + price: { amount: '0.00', currencyCode: 'USD' } + } + ], + + featuredImage: { + url: 'https://static.wikia.nocookie.net/universalstudios/images/e/e5/ThneedSeuss.png/revision/latest?cb=20220704024251', + altText: 'Thneed', + width: 100, + height: 100 + }, + images: [ + { + url: 'https://static.wikia.nocookie.net/universalstudios/images/e/e5/ThneedSeuss.png/revision/latest?cb=20220704024251', + altText: 'Thneed', + width: 100, + height: 100 + } + ], + seo: { title: 'Thneed', description: 'Something everyone needs' }, + tags: [], + updatedAt: '2021-05-18T18:52:13Z' } - }); - - if (!res.body.data.collection) { - console.log(`No collection found for \`${collection}\``); - return []; - } - - return reshapeProducts(removeEdgesAndNodes(res.body.data.collection.products)); + ]; } export async function getCollections(): Promise { diff --git a/lib/shopify/types.ts b/lib/shopify/types.ts index 23dc02d46..1418a4061 100644 --- a/lib/shopify/types.ts +++ b/lib/shopify/types.ts @@ -61,7 +61,7 @@ export type Page = { updatedAt: string; }; -export type Product = Omit & { +export type Product = Omit & { variants: ProductVariant[]; images: Image[]; }; @@ -108,6 +108,26 @@ export type ShopifyCollection = { updatedAt: string; }; +export type LoticProduct = { + id: string; + handle: string; + availableForSale: boolean; + title: string; + description: string; + descriptionHtml: string; + options: ProductOption[]; + priceRange: { + maxVariantPrice: Money; + minVariantPrice: Money; + }; + variants: Connection; + featuredImage: Image; + images: Connection; + seo: SEO; + tags: string[]; + updatedAt: string; +}; + export type ShopifyProduct = { id: string; handle: string;