From 746028f25b26309583434ea24451fd4f16840f9b Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Tue, 25 May 2021 21:53:04 -0500 Subject: [PATCH] Updated urls to the API --- framework/bigcommerce/auth/use-login.tsx | 2 +- framework/bigcommerce/auth/use-logout.tsx | 2 +- framework/bigcommerce/auth/use-signup.tsx | 2 +- framework/bigcommerce/cart/use-add-item.tsx | 2 +- framework/bigcommerce/cart/use-cart.tsx | 2 +- framework/bigcommerce/cart/use-remove-item.tsx | 2 +- framework/bigcommerce/cart/use-update-item.tsx | 4 ++-- framework/bigcommerce/wishlist/use-wishlist.tsx | 2 +- framework/commerce/new-provider.md | 4 ++-- framework/commerce/utils/types.ts | 9 +++------ next.config.js | 4 ++-- 11 files changed, 16 insertions(+), 19 deletions(-) diff --git a/framework/bigcommerce/auth/use-login.tsx b/framework/bigcommerce/auth/use-login.tsx index bf2360af6..3ebacc9b7 100644 --- a/framework/bigcommerce/auth/use-login.tsx +++ b/framework/bigcommerce/auth/use-login.tsx @@ -9,7 +9,7 @@ export default useLogin as UseLogin export const handler: MutationHook = { fetchOptions: { - url: '/api/bigcommerce/customers/login', + url: '/api/login', method: 'POST', }, async fetcher({ input: { email, password }, options, fetch }) { diff --git a/framework/bigcommerce/auth/use-logout.tsx b/framework/bigcommerce/auth/use-logout.tsx index f704563e9..e75563e04 100644 --- a/framework/bigcommerce/auth/use-logout.tsx +++ b/framework/bigcommerce/auth/use-logout.tsx @@ -8,7 +8,7 @@ export default useLogout as UseLogout export const handler: MutationHook = { fetchOptions: { - url: '/api/bigcommerce/customers/logout', + url: '/api/logout', method: 'GET', }, useHook: ({ fetch }) => () => { diff --git a/framework/bigcommerce/auth/use-signup.tsx b/framework/bigcommerce/auth/use-signup.tsx index bcd6886a3..da06fd3eb 100644 --- a/framework/bigcommerce/auth/use-signup.tsx +++ b/framework/bigcommerce/auth/use-signup.tsx @@ -9,7 +9,7 @@ export default useSignup as UseSignup export const handler: MutationHook = { fetchOptions: { - url: '/api/bigcommerce/customers/signup', + url: '/api/signup', method: 'POST', }, async fetcher({ diff --git a/framework/bigcommerce/cart/use-add-item.tsx b/framework/bigcommerce/cart/use-add-item.tsx index de6ee226c..205ee82c1 100644 --- a/framework/bigcommerce/cart/use-add-item.tsx +++ b/framework/bigcommerce/cart/use-add-item.tsx @@ -9,7 +9,7 @@ export default useAddItem as UseAddItem export const handler: MutationHook = { fetchOptions: { - url: '/api/bigcommerce/cart', + url: '/api/cart', method: 'POST', }, async fetcher({ input: item, options, fetch }) { diff --git a/framework/bigcommerce/cart/use-cart.tsx b/framework/bigcommerce/cart/use-cart.tsx index b32f2d2ec..768c3ffd7 100644 --- a/framework/bigcommerce/cart/use-cart.tsx +++ b/framework/bigcommerce/cart/use-cart.tsx @@ -7,7 +7,7 @@ export default useCart as UseCart export const handler: SWRHook = { fetchOptions: { - url: '/api/bigcommerce/cart', + url: '/api/cart', method: 'GET', }, useHook: ({ useData }) => (input) => { diff --git a/framework/bigcommerce/cart/use-remove-item.tsx b/framework/bigcommerce/cart/use-remove-item.tsx index 44f8cadd5..8d0659ecb 100644 --- a/framework/bigcommerce/cart/use-remove-item.tsx +++ b/framework/bigcommerce/cart/use-remove-item.tsx @@ -20,7 +20,7 @@ export default useRemoveItem as UseRemoveItem export const handler = { fetchOptions: { - url: '/api/bigcommerce/cart', + url: '/api/cart', method: 'DELETE', }, async fetcher({ diff --git a/framework/bigcommerce/cart/use-update-item.tsx b/framework/bigcommerce/cart/use-update-item.tsx index 6d014cc24..cf1f98226 100644 --- a/framework/bigcommerce/cart/use-update-item.tsx +++ b/framework/bigcommerce/cart/use-update-item.tsx @@ -6,7 +6,7 @@ import type { } from '@commerce/utils/types' import { ValidationError } from '@commerce/utils/errors' import useUpdateItem, { UseUpdateItem } from '@commerce/cart/use-update-item' -import type { LineItem, UpdateItemHook } from '../types' +import type { LineItem, UpdateItemHook } from '../types/cart' import { handler as removeItemHandler } from './use-remove-item' import useCart from './use-cart' @@ -18,7 +18,7 @@ export default useUpdateItem as UseUpdateItem export const handler = { fetchOptions: { - url: '/api/bigcommerce/cart', + url: '/api/cart', method: 'PUT', }, async fetcher({ diff --git a/framework/bigcommerce/wishlist/use-wishlist.tsx b/framework/bigcommerce/wishlist/use-wishlist.tsx index 134e9cc24..b8fc946e3 100644 --- a/framework/bigcommerce/wishlist/use-wishlist.tsx +++ b/framework/bigcommerce/wishlist/use-wishlist.tsx @@ -8,7 +8,7 @@ export default useWishlist as UseWishlist export const handler: SWRHook = { fetchOptions: { - url: '/api/bigcommerce/wishlist', + url: '/api/wishlist', method: 'GET', }, async fetcher({ input: { customerId, includeProducts }, options, fetch }) { diff --git a/framework/commerce/new-provider.md b/framework/commerce/new-provider.md index 4051c0f01..511704af6 100644 --- a/framework/commerce/new-provider.md +++ b/framework/commerce/new-provider.md @@ -149,7 +149,7 @@ export const handler: SWRHook< { isEmpty?: boolean } > = { fetchOptions: { - url: '/api/bigcommerce/cart', + url: '/api/cart', method: 'GET', }, async fetcher({ input: { cartId }, options, fetch }) { @@ -197,7 +197,7 @@ export default useAddItem as UseAddItem export const handler: MutationHook = { fetchOptions: { - url: '/api/bigcommerce/cart', + url: '/api/cart', method: 'POST', }, async fetcher({ input: item, options, fetch }) { diff --git a/framework/commerce/utils/types.ts b/framework/commerce/utils/types.ts index e842df58c..f95d1148a 100644 --- a/framework/commerce/utils/types.ts +++ b/framework/commerce/utils/types.ts @@ -43,12 +43,9 @@ export type HookFetcherFn = ( export type HookFetcherContext = { options: HookFetcherOptions input: H['fetchInput'] - fetch: { - ( - options: FetcherOptions - ): Promise - (options: FetcherOptions): Promise - } + fetch: ( + options: FetcherOptions + ) => Promise } export type HookFetcherOptions = { method?: string } & ( diff --git a/next.config.js b/next.config.js index c8694f1e0..128849678 100644 --- a/next.config.js +++ b/next.config.js @@ -18,13 +18,13 @@ module.exports = withCommerceConfig({ return [ (isBC || isShopify) && { source: '/checkout', - destination: '/api/bigcommerce/checkout', + destination: '/api/checkout', }, // The logout is also an action so this route is not required, but it's also another way // you can allow a logout! isBC && { source: '/logout', - destination: '/api/bigcommerce/customers/logout?redirect_to=/', + destination: '/api/logout?redirect_to=/', }, // Rewrites for /search {