Fix build errors

This commit is contained in:
Michael Bromley 2021-05-27 13:37:57 +02:00
parent a6cfea0d28
commit 45c0f28639
12 changed files with 48 additions and 19 deletions

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1,2 @@
export type WishlistItem = { product: any; id: number }
export default function () {}

View File

@ -12,21 +12,23 @@ import { signupMutation } from '../lib/mutations/sign-up-mutation'
export default useSignup as UseSignup<typeof handler>
export const handler: MutationHook<
null,
{},
RegisterCustomerInput,
RegisterCustomerInput
> = {
export type SignupInput = {
email: string
firstName: string
lastName: string
password: string
}
export const handler: MutationHook<null, {}, SignupInput, SignupInput> = {
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,
},
}

View File

@ -50,7 +50,7 @@ export const handler = {
const { mutate } = useCart()
return useCallback(
async function addItem(input: CartItemBody) {
async function addItem(input: Partial<CartItemBody>) {
const itemId = item?.id
const productId = input.productId ?? item?.productId
const variantId = input.productId ?? item?.variantId

View File

@ -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<any> {
} = {}): Promise<GetSiteInfoResult> {
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<GetCollectionsQuery>(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 {

View File

@ -0,0 +1,5 @@
import * as Core from '@commerce/types'
export interface LineItem extends Core.LineItem {
options?: any[]
}