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 default useSignup as UseSignup<typeof handler>
export const handler: MutationHook< export type SignupInput = {
null, email: string
{}, firstName: string
RegisterCustomerInput, lastName: string
RegisterCustomerInput password: string
> = { }
export const handler: MutationHook<null, {}, SignupInput, SignupInput> = {
fetchOptions: { fetchOptions: {
query: signupMutation, query: signupMutation,
}, },
async fetcher({ async fetcher({
input: { firstName, lastName, emailAddress, password }, input: { firstName, lastName, email, password },
options, options,
fetch, fetch,
}) { }) {
if (!(firstName && lastName && emailAddress && password)) { if (!(firstName && lastName && email && password)) {
throw new CommerceError({ throw new CommerceError({
message: message:
'A first name, last name, email and password are required to signup', 'A first name, last name, email and password are required to signup',
@ -36,7 +38,7 @@ export const handler: MutationHook<
input: { input: {
firstName, firstName,
lastName, lastName,
emailAddress, emailAddress: email,
password, password,
}, },
} }

View File

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

View File

@ -3,6 +3,20 @@ import { GetCollectionsQuery } from '../schema'
import { arrayToTree } from '../lib/array-to-tree' import { arrayToTree } from '../lib/array-to-tree'
import { getCollectionsQuery } from '../lib/queries/get-collections-query' 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({ async function getSiteInfo({
query = getCollectionsQuery, query = getCollectionsQuery,
variables, variables,
@ -12,19 +26,18 @@ async function getSiteInfo({
variables?: any variables?: any
config?: VendureConfig config?: VendureConfig
preview?: boolean preview?: boolean
} = {}): Promise<any> { } = {}): Promise<GetSiteInfoResult> {
config = getConfig(config) config = getConfig(config)
// RecursivePartial forces the method to check for every prop in the data, which is // RecursivePartial forces the method to check for every prop in the data, which is
// required in case there's a custom `query` // required in case there's a custom `query`
const { data } = await config.fetch<GetCollectionsQuery>(query, { variables }) const { data } = await config.fetch<GetCollectionsQuery>(query, { variables })
const categories = arrayToTree( const collections = data.collections?.items.map((i) => ({
data.collections?.items.map((i) => ({
...i, ...i,
entityId: i.id, entityId: i.id,
path: i.slug, path: i.slug,
productCount: i.productVariants.totalItems, productCount: i.productVariants.totalItems,
})) }))
).children const categories = arrayToTree(collections).children
const brands = [] as any[] const brands = [] as any[]
return { return {

View File

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