From 45c0f286394d1bf3e14dba1ccd86eeeeec8be340 Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Thu, 27 May 2021 13:37:57 +0200 Subject: [PATCH] Fix build errors --- framework/vendure/api/cart/index.ts | 1 + framework/vendure/api/catalog/index.ts | 1 + framework/vendure/api/catalog/products.ts | 1 + framework/vendure/api/customers/index.ts | 1 + framework/vendure/api/customers/login.ts | 1 + framework/vendure/api/customers/logout.ts | 1 + framework/vendure/api/customers/signup.ts | 1 + framework/vendure/api/wishlist/index.tsx | 2 ++ framework/vendure/auth/use-signup.tsx | 20 +++++++------- framework/vendure/cart/use-update-item.tsx | 2 +- framework/vendure/common/get-site-info.ts | 31 +++++++++++++++------- framework/vendure/types.ts | 5 ++++ 12 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 framework/vendure/api/cart/index.ts create mode 100644 framework/vendure/api/catalog/index.ts create mode 100644 framework/vendure/api/catalog/products.ts create mode 100644 framework/vendure/api/customers/index.ts create mode 100644 framework/vendure/api/customers/login.ts create mode 100644 framework/vendure/api/customers/logout.ts create mode 100644 framework/vendure/api/customers/signup.ts create mode 100644 framework/vendure/api/wishlist/index.tsx create mode 100644 framework/vendure/types.ts diff --git a/framework/vendure/api/cart/index.ts b/framework/vendure/api/cart/index.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/vendure/api/cart/index.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/vendure/api/catalog/index.ts b/framework/vendure/api/catalog/index.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/vendure/api/catalog/index.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/vendure/api/catalog/products.ts b/framework/vendure/api/catalog/products.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/vendure/api/catalog/products.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/vendure/api/customers/index.ts b/framework/vendure/api/customers/index.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/vendure/api/customers/index.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/vendure/api/customers/login.ts b/framework/vendure/api/customers/login.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/vendure/api/customers/login.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/vendure/api/customers/logout.ts b/framework/vendure/api/customers/logout.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/vendure/api/customers/logout.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/vendure/api/customers/signup.ts b/framework/vendure/api/customers/signup.ts new file mode 100644 index 000000000..ea9b101e1 --- /dev/null +++ b/framework/vendure/api/customers/signup.ts @@ -0,0 +1 @@ +export default function () {} diff --git a/framework/vendure/api/wishlist/index.tsx b/framework/vendure/api/wishlist/index.tsx new file mode 100644 index 000000000..a72856673 --- /dev/null +++ b/framework/vendure/api/wishlist/index.tsx @@ -0,0 +1,2 @@ +export type WishlistItem = { product: any; id: number } +export default function () {} diff --git a/framework/vendure/auth/use-signup.tsx b/framework/vendure/auth/use-signup.tsx index b9b461250..816b95738 100644 --- a/framework/vendure/auth/use-signup.tsx +++ b/framework/vendure/auth/use-signup.tsx @@ -12,21 +12,23 @@ import { signupMutation } from '../lib/mutations/sign-up-mutation' export default useSignup as UseSignup -export const handler: MutationHook< - null, - {}, - RegisterCustomerInput, - RegisterCustomerInput -> = { +export type SignupInput = { + email: string + firstName: string + lastName: string + password: string +} + +export const handler: MutationHook = { fetchOptions: { query: signupMutation, }, async fetcher({ - input: { firstName, lastName, emailAddress, password }, + input: { firstName, lastName, email, password }, options, fetch, }) { - if (!(firstName && lastName && emailAddress && password)) { + if (!(firstName && lastName && email && password)) { throw new CommerceError({ message: 'A first name, last name, email and password are required to signup', @@ -36,7 +38,7 @@ export const handler: MutationHook< input: { firstName, lastName, - emailAddress, + emailAddress: email, password, }, } diff --git a/framework/vendure/cart/use-update-item.tsx b/framework/vendure/cart/use-update-item.tsx index c87022d35..4e871514e 100644 --- a/framework/vendure/cart/use-update-item.tsx +++ b/framework/vendure/cart/use-update-item.tsx @@ -50,7 +50,7 @@ export const handler = { const { mutate } = useCart() return useCallback( - async function addItem(input: CartItemBody) { + async function addItem(input: Partial) { const itemId = item?.id const productId = input.productId ?? item?.productId const variantId = input.productId ?? item?.variantId diff --git a/framework/vendure/common/get-site-info.ts b/framework/vendure/common/get-site-info.ts index a56157310..9410c4493 100644 --- a/framework/vendure/common/get-site-info.ts +++ b/framework/vendure/common/get-site-info.ts @@ -3,6 +3,20 @@ import { GetCollectionsQuery } from '../schema' import { arrayToTree } from '../lib/array-to-tree' import { getCollectionsQuery } from '../lib/queries/get-collections-query' +export type Category = { + entityId: string + name: string + path: string + productCount: number +} + +export type GetSiteInfoResult< + T extends { categories: any[]; brands: any[] } = { + categories: Category[] + brands: any[] + } +> = T + async function getSiteInfo({ query = getCollectionsQuery, variables, @@ -12,19 +26,18 @@ async function getSiteInfo({ variables?: any config?: VendureConfig preview?: boolean -} = {}): Promise { +} = {}): Promise { config = getConfig(config) // RecursivePartial forces the method to check for every prop in the data, which is // required in case there's a custom `query` const { data } = await config.fetch(query, { variables }) - const categories = arrayToTree( - data.collections?.items.map((i) => ({ - ...i, - entityId: i.id, - path: i.slug, - productCount: i.productVariants.totalItems, - })) - ).children + const collections = data.collections?.items.map((i) => ({ + ...i, + entityId: i.id, + path: i.slug, + productCount: i.productVariants.totalItems, + })) + const categories = arrayToTree(collections).children const brands = [] as any[] return { diff --git a/framework/vendure/types.ts b/framework/vendure/types.ts new file mode 100644 index 000000000..ed39b5493 --- /dev/null +++ b/framework/vendure/types.ts @@ -0,0 +1,5 @@ +import * as Core from '@commerce/types' + +export interface LineItem extends Core.LineItem { + options?: any[] +}