Stubbed products to bypass error on start

This commit is contained in:
Matt Kern 2024-01-25 17:07:45 -08:00
parent 3a18f9a098
commit 10779012ae
3 changed files with 69 additions and 27 deletions

View File

@ -2,8 +2,8 @@
"typescript.tsdk": "node_modules/typescript/lib", "typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true, "typescript.enablePromptUseWorkspaceTsdk": true,
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.fixAll": true, "source.fixAll": "explicit",
"source.organizeImports": true, "source.organizeImports": "explicit",
"source.sortMembers": true "source.sortMembers": "explicit"
} }
} }

View File

@ -11,11 +11,7 @@ import {
removeFromCartMutation removeFromCartMutation
} from './mutations/cart'; } from './mutations/cart';
import { getCartQuery } from './queries/cart'; import { getCartQuery } from './queries/cart';
import { import { getCollectionQuery, getCollectionsQuery } from './queries/collection';
getCollectionProductsQuery,
getCollectionQuery,
getCollectionsQuery
} from './queries/collection';
import { getMenuQuery } from './queries/menu'; import { getMenuQuery } from './queries/menu';
import { getPageQuery, getPagesQuery } from './queries/page'; import { getPageQuery, getPagesQuery } from './queries/page';
import { import {
@ -36,7 +32,6 @@ import {
ShopifyCartOperation, ShopifyCartOperation,
ShopifyCollection, ShopifyCollection,
ShopifyCollectionOperation, ShopifyCollectionOperation,
ShopifyCollectionProductsOperation,
ShopifyCollectionsOperation, ShopifyCollectionsOperation,
ShopifyCreateCartOperation, ShopifyCreateCartOperation,
ShopifyMenuOperation, ShopifyMenuOperation,
@ -282,7 +277,7 @@ export async function getCollection(handle: string): Promise<Collection | undefi
return reshapeCollection(res.body.data.collection); return reshapeCollection(res.body.data.collection);
} }
export async function getCollectionProducts({ export function getCollectionProducts({
collection, collection,
reverse, reverse,
sortKey sortKey
@ -290,23 +285,50 @@ export async function getCollectionProducts({
collection: string; collection: string;
reverse?: boolean; reverse?: boolean;
sortKey?: string; sortKey?: string;
}): Promise<Product[]> { }): Product[] {
const res = await shopifyFetch<ShopifyCollectionProductsOperation>({ return [
query: getCollectionProductsQuery, {
tags: [TAGS.collections, TAGS.products], id: '123',
variables: { handle: 'foo',
handle: collection, availableForSale: true,
reverse, title: 'Thneed',
sortKey: sortKey === 'CREATED_AT' ? 'CREATED' : sortKey description: 'Something everyone needs',
} descriptionHtml: '<p>Something everyone needs</p>',
}); options: [],
priceRange: {
maxVariantPrice: { amount: '0.00', currencyCode: 'USD' },
minVariantPrice: { amount: '0.00', currencyCode: 'USD' }
},
if (!res.body.data.collection) { variants: [
console.log(`No collection found for \`${collection}\``); {
return []; id: '123',
title: 'Thneed',
availableForSale: true,
selectedOptions: [{ name: 'color', value: 'red' }],
price: { amount: '0.00', currencyCode: 'USD' }
} }
],
return reshapeProducts(removeEdgesAndNodes(res.body.data.collection.products)); 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'
}
];
} }
export async function getCollections(): Promise<Collection[]> { export async function getCollections(): Promise<Collection[]> {

View File

@ -61,7 +61,7 @@ export type Page = {
updatedAt: string; updatedAt: string;
}; };
export type Product = Omit<ShopifyProduct, 'variants' | 'images'> & { export type Product = Omit<LoticProduct, 'variants' | 'images'> & {
variants: ProductVariant[]; variants: ProductVariant[];
images: Image[]; images: Image[];
}; };
@ -108,6 +108,26 @@ export type ShopifyCollection = {
updatedAt: string; 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<ProductVariant>;
featuredImage: Image;
images: Connection<Image>;
seo: SEO;
tags: string[];
updatedAt: string;
};
export type ShopifyProduct = { export type ShopifyProduct = {
id: string; id: string;
handle: string; handle: string;