fix: Wishlist type

chore: exclude only node_modules from tsconfig
This commit is contained in:
Gérard Le Cloerec 2021-04-13 15:36:12 +02:00
parent a0475cb183
commit 8be640e90f
5 changed files with 43 additions and 21 deletions

View File

@ -0,0 +1,28 @@
import type { ItemBody as WishlistItemBody } from '../wishlist'
import type { CartItemBody, OptionSelections } from '../../types'
type BCWishlistItemBody = {
product_id: number
variant_id: number
}
type BCCartItemBody = {
product_id: number
variant_id: number
quantity?: number
option_selections?: OptionSelections
}
export const parseWishlistItem = (
item: WishlistItemBody
): BCWishlistItemBody => ({
product_id: Number(item.productId),
variant_id: Number(item.variantId),
})
export const parseCartItem = (item: CartItemBody): BCCartItemBody => ({
quantity: item.quantity,
product_id: Number(item.productId),
variant_id: Number(item.variantId),
option_selections: item.optionSelections,
})

View File

@ -1,6 +1,14 @@
import { AquilacmsConfig, getConfig } from '../api'
export type Wishlist = Omit<any, 'items'> & {
type wishlist_Full = {
id?: number
customer_id?: number
name?: string
is_public?: boolean
token?: string
}
export type Wishlist = wishlist_Full & {
items?: WishlistItem[]
}
@ -13,7 +21,7 @@ export type GetCustomerWishlistResult<
> = T
export type GetCustomerWishlistVariables = {
customerId: number
customerId: string
}
async function getCustomerWishlist(opts: {
@ -44,7 +52,7 @@ async function getCustomerWishlist({
}): Promise<GetCustomerWishlistResult> {
config = getConfig(config)
return { wishlist: [] }
return { wishlist: {} }
}
export default getCustomerWishlist

View File

@ -3,11 +3,6 @@ const commerce = require('./commerce.config.json')
module.exports = {
commerce,
images: {
domains: [
'recdem.hosting-ns.com',
'providers.aquila-cms.com',
'provider-vercel.aquila-cms.com',
'localhost',
],
domains: [new URL(process.env.AQUILACMS_URL).hostname],
},
}

View File

@ -1,6 +1,5 @@
import type {
GetStaticPathsContext,
GetStaticPathsResult,
GetStaticPropsContext,
InferGetStaticPropsType,
} from 'next'
@ -41,9 +40,7 @@ export async function getStaticProps({
}
}
export async function getStaticPaths({
locales,
}: GetStaticPathsContext): Promise<GetStaticPathsResult> {
export async function getStaticPaths({ locales }: GetStaticPathsContext) {
const { pages } = await getAllPages()
const [invalidPaths, log] = missingLocaleInPages()
const paths = pages
@ -56,6 +53,7 @@ export async function getStaticPaths({
invalidPaths.push(url)
})
log()
return {
paths,
// Fallback shouldn't be enabled here or otherwise this route

View File

@ -27,12 +27,5 @@
}
},
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
"exclude": [
"node_modules/*",
"components/wishlist",
"components/wishlist/WishlistButton",
"components/wishlist/WishlistCard",
"pages/api/bigcommerce/wishlist",
"pages/wishlist"
]
"exclude": ["node_modules/*"]
}