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' 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[] items?: WishlistItem[]
} }
@ -13,7 +21,7 @@ export type GetCustomerWishlistResult<
> = T > = T
export type GetCustomerWishlistVariables = { export type GetCustomerWishlistVariables = {
customerId: number customerId: string
} }
async function getCustomerWishlist(opts: { async function getCustomerWishlist(opts: {
@ -44,7 +52,7 @@ async function getCustomerWishlist({
}): Promise<GetCustomerWishlistResult> { }): Promise<GetCustomerWishlistResult> {
config = getConfig(config) config = getConfig(config)
return { wishlist: [] } return { wishlist: {} }
} }
export default getCustomerWishlist export default getCustomerWishlist

View File

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

View File

@ -1,6 +1,5 @@
import type { import type {
GetStaticPathsContext, GetStaticPathsContext,
GetStaticPathsResult,
GetStaticPropsContext, GetStaticPropsContext,
InferGetStaticPropsType, InferGetStaticPropsType,
} from 'next' } from 'next'
@ -41,9 +40,7 @@ export async function getStaticProps({
} }
} }
export async function getStaticPaths({ export async function getStaticPaths({ locales }: GetStaticPathsContext) {
locales,
}: GetStaticPathsContext): Promise<GetStaticPathsResult> {
const { pages } = await getAllPages() const { pages } = await getAllPages()
const [invalidPaths, log] = missingLocaleInPages() const [invalidPaths, log] = missingLocaleInPages()
const paths = pages const paths = pages
@ -56,6 +53,7 @@ export async function getStaticPaths({
invalidPaths.push(url) invalidPaths.push(url)
}) })
log() log()
return { return {
paths, paths,
// Fallback shouldn't be enabled here or otherwise this route // 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"], "include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
"exclude": [ "exclude": ["node_modules/*"]
"node_modules/*",
"components/wishlist",
"components/wishlist/WishlistButton",
"components/wishlist/WishlistCard",
"pages/api/bigcommerce/wishlist",
"pages/wishlist"
]
} }