diff --git a/framework/local/api/index.ts b/framework/local/api/index.ts
index 0b2f529cd..0b1e4d417 100644
--- a/framework/local/api/index.ts
+++ b/framework/local/api/index.ts
@@ -33,10 +33,10 @@ const operations = {
export const provider = { config, operations }
export type Provider = typeof provider
-export type LocalAPI
= CommerceAPI
+export type LocalAPI
= CommerceAPI
export function getCommerceApi
(
customProvider: P = provider as any
): LocalAPI
{
- return commerceApi(customProvider)
+ return commerceApi(customProvider as any)
}
diff --git a/framework/local/api/operations/get-all-pages.ts b/framework/local/api/operations/get-all-pages.ts
index 153aa18b1..b258fe70a 100644
--- a/framework/local/api/operations/get-all-pages.ts
+++ b/framework/local/api/operations/get-all-pages.ts
@@ -1,4 +1,4 @@
-export type Page = any
+export type Page = { url: string }
export type GetAllPagesResult = { pages: Page[] }
import type { LocalConfig } from '../index'
diff --git a/framework/local/api/operations/get-all-products.ts b/framework/local/api/operations/get-all-products.ts
index 8605b833d..abb1c02ae 100644
--- a/framework/local/api/operations/get-all-products.ts
+++ b/framework/local/api/operations/get-all-products.ts
@@ -6,7 +6,7 @@ import data from '../../data.json'
export default function getAllProductsOperation({
commerce,
-}: OperationContext) {
+}: OperationContext) {
async function getAllProducts({
query = '',
variables,
diff --git a/framework/local/api/operations/get-product.ts b/framework/local/api/operations/get-product.ts
index a098ae9fd..7a47d08c2 100644
--- a/framework/local/api/operations/get-product.ts
+++ b/framework/local/api/operations/get-product.ts
@@ -1,9 +1,13 @@
import type { LocalConfig } from '../index'
import { Product } from '@commerce/types/product'
+import { GetProductOperation } from '@commerce/types/product'
import data from '../../data.json'
+import type { OperationContext } from '@commerce/api/operations'
-export default function getProductOperation() {
- async function getProduct({
+export default function getProductOperation({
+ commerce,
+}: OperationContext) {
+ async function getProduct({
query = '',
variables,
config,
diff --git a/framework/local/wishlist/use-remove-item.tsx b/framework/local/wishlist/use-remove-item.tsx
index 75f067c3a..a2d3a8a05 100644
--- a/framework/local/wishlist/use-remove-item.tsx
+++ b/framework/local/wishlist/use-remove-item.tsx
@@ -1,7 +1,11 @@
import { useCallback } from 'react'
-export function emptyHook() {
- const useEmptyHook = async (options = {}) => {
+type Options = {
+ includeProducts?: boolean
+}
+
+export function emptyHook(options?: Options) {
+ const useEmptyHook = async ({ id }: { id: string | number }) => {
return useCallback(async function () {
return Promise.resolve()
}, [])
diff --git a/framework/local/wishlist/use-wishlist.tsx b/framework/local/wishlist/use-wishlist.tsx
index 75f067c3a..9fe0e758f 100644
--- a/framework/local/wishlist/use-wishlist.tsx
+++ b/framework/local/wishlist/use-wishlist.tsx
@@ -1,13 +1,43 @@
-import { useCallback } from 'react'
+import { HookFetcher } from '@commerce/utils/types'
+import type { Product } from '@commerce/types/product'
-export function emptyHook() {
- const useEmptyHook = async (options = {}) => {
- return useCallback(async function () {
- return Promise.resolve()
- }, [])
- }
+const defaultOpts = {}
- return useEmptyHook
+export type Wishlist = {
+ items: [
+ {
+ product_id: number
+ variant_id: number
+ id: number
+ product: Product
+ }
+ ]
}
-export default emptyHook
+export interface UseWishlistOptions {
+ includeProducts?: boolean
+}
+
+export interface UseWishlistInput extends UseWishlistOptions {
+ customerId?: number
+}
+
+export const fetcher: HookFetcher = () => {
+ return null
+}
+
+export function extendHook(
+ customFetcher: typeof fetcher,
+ // swrOptions?: SwrOptions
+ swrOptions?: any
+) {
+ const useWishlist = ({ includeProducts }: UseWishlistOptions = {}) => {
+ return { data: null }
+ }
+
+ useWishlist.extend = extendHook
+
+ return useWishlist
+}
+
+export default extendHook(fetcher)
diff --git a/pages/[...pages].tsx b/pages/[...pages].tsx
index c63963ef6..7b2ec6ca3 100644
--- a/pages/[...pages].tsx
+++ b/pages/[...pages].tsx
@@ -8,6 +8,7 @@ import { Text } from '@components/ui'
import { Layout } from '@components/common'
import getSlug from '@lib/get-slug'
import { missingLocaleInPages } from '@lib/usage-warns'
+import type { Page } from '@commerce/types/page'
export async function getStaticProps({
preview,
@@ -20,7 +21,9 @@ export async function getStaticProps({
const { categories } = await commerce.getSiteInfo({ config, preview })
const path = params?.pages.join('/')
const slug = locale ? `${locale}/${path}` : path
- const pageItem = pages.find((p) => (p.url ? getSlug(p.url) === slug : false))
+ const pageItem = pages.find((p: Page) =>
+ p.url ? getSlug(p.url) === slug : false
+ )
const data =
pageItem &&
(await commerce.getPage({
@@ -43,7 +46,7 @@ export async function getStaticProps({
export async function getStaticPaths({ locales }: GetStaticPathsContext) {
const config = { locales }
- const { pages } = await commerce.getAllPages({ config })
+ const { pages }: { pages: Page[] } = await commerce.getAllPages({ config })
const [invalidPaths, log] = missingLocaleInPages()
const paths = pages
.map((page) => page.url)
diff --git a/tsconfig.json b/tsconfig.json
index eebfa8459..85dd239ca 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -27,5 +27,10 @@
}
},
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
- "exclude": ["node_modules", "framework/swell", "framework/vendure"]
+ "exclude": [
+ "node_modules",
+ "framework/swell",
+ "framework/vendure",
+ "framework/local"
+ ]
}