mirror of
https://github.com/vercel/commerce.git
synced 2025-06-19 05:31:22 +00:00
Fix build errors
This commit is contained in:
parent
a6cfea0d28
commit
45c0f28639
1
framework/vendure/api/cart/index.ts
Normal file
1
framework/vendure/api/cart/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
1
framework/vendure/api/catalog/index.ts
Normal file
1
framework/vendure/api/catalog/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
1
framework/vendure/api/catalog/products.ts
Normal file
1
framework/vendure/api/catalog/products.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
1
framework/vendure/api/customers/index.ts
Normal file
1
framework/vendure/api/customers/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
1
framework/vendure/api/customers/login.ts
Normal file
1
framework/vendure/api/customers/login.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
1
framework/vendure/api/customers/logout.ts
Normal file
1
framework/vendure/api/customers/logout.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
1
framework/vendure/api/customers/signup.ts
Normal file
1
framework/vendure/api/customers/signup.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function () {}
|
2
framework/vendure/api/wishlist/index.tsx
Normal file
2
framework/vendure/api/wishlist/index.tsx
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export type WishlistItem = { product: any; id: number }
|
||||||
|
export default function () {}
|
@ -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,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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,
|
}))
|
||||||
}))
|
const categories = arrayToTree(collections).children
|
||||||
).children
|
|
||||||
const brands = [] as any[]
|
const brands = [] as any[]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
5
framework/vendure/types.ts
Normal file
5
framework/vendure/types.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import * as Core from '@commerce/types'
|
||||||
|
|
||||||
|
export interface LineItem extends Core.LineItem {
|
||||||
|
options?: any[]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user