mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
updates
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useCallback } from 'react'
|
||||
import type { MutationHook } from '@commerce/utils/types'
|
||||
import { CommerceError } from '@commerce/utils/errors'
|
||||
import useLogin, { UseLogin } from '@commerce/use-login'
|
||||
import useLogin, { UseLogin } from '@commerce/auth/use-login'
|
||||
import type { LoginBody } from '../api/customers/login'
|
||||
import useCustomer from '../customer/use-customer'
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { useCallback } from 'react'
|
||||
import type { MutationHook } from '@commerce/utils/types'
|
||||
import useLogout, { UseLogout } from '@commerce/use-logout'
|
||||
import useLogout, { UseLogout } from '@commerce/auth/use-logout'
|
||||
import useCustomer from '../customer/use-customer'
|
||||
|
||||
export default useLogout as UseLogout<typeof handler>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { useCallback } from 'react'
|
||||
import type { MutationHook } from '@commerce/utils/types'
|
||||
import { CommerceError } from '@commerce/utils/errors'
|
||||
import useSignup, { UseSignup } from '@commerce/use-signup'
|
||||
import useSignup, { UseSignup } from '@commerce/auth/use-signup'
|
||||
import type { SignupBody } from '../api/customers/signup'
|
||||
import useCustomer from '../customer/use-customer'
|
||||
|
||||
|
37
framework/bigcommerce/next.config.js
Normal file
37
framework/bigcommerce/next.config.js
Normal file
@@ -0,0 +1,37 @@
|
||||
module.exports = {
|
||||
images: {
|
||||
domains: ['cdn11.bigcommerce.com'],
|
||||
},
|
||||
i18n: {
|
||||
locales: ['en-US', 'es'],
|
||||
defaultLocale: 'en-US',
|
||||
},
|
||||
rewrites() {
|
||||
return [
|
||||
{
|
||||
source: '/checkout',
|
||||
destination: '/api/bigcommerce/checkout',
|
||||
},
|
||||
// The logout is also an action so this route is not required, but it's also another way
|
||||
// you can allow a logout!
|
||||
{
|
||||
source: '/logout',
|
||||
destination: '/api/bigcommerce/customers/logout?redirect_to=/',
|
||||
},
|
||||
// Rewrites for /search
|
||||
{
|
||||
source: '/search/designers/:name',
|
||||
destination: '/search',
|
||||
},
|
||||
{
|
||||
source: '/search/designers/:name/:category',
|
||||
destination: '/search',
|
||||
},
|
||||
{
|
||||
// This rewrite will also handle `/search/designers`
|
||||
source: '/search/:category',
|
||||
destination: '/search',
|
||||
},
|
||||
]
|
||||
},
|
||||
}
|
@@ -1,2 +1,2 @@
|
||||
export * from '@commerce/use-price'
|
||||
export { default } from '@commerce/use-price'
|
||||
export * from '@commerce/product/use-price'
|
||||
export { default } from '@commerce/product/use-price'
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { useHook, useMutationHook } from './utils/use-hook'
|
||||
import { mutationFetcher } from './utils/default-fetcher'
|
||||
import type { MutationHook, HookFetcherFn } from './utils/types'
|
||||
import type { Provider } from '.'
|
||||
import { useHook, useMutationHook } from '../utils/use-hook'
|
||||
import { mutationFetcher } from '../utils/default-fetcher'
|
||||
import type { MutationHook, HookFetcherFn } from '../utils/types'
|
||||
import type { Provider } from '..'
|
||||
|
||||
export type UseLogin<
|
||||
H extends MutationHook<any, any, any> = MutationHook<null, {}, {}>
|
@@ -1,7 +1,7 @@
|
||||
import { useHook, useMutationHook } from './utils/use-hook'
|
||||
import { mutationFetcher } from './utils/default-fetcher'
|
||||
import type { HookFetcherFn, MutationHook } from './utils/types'
|
||||
import type { Provider } from '.'
|
||||
import { useHook, useMutationHook } from '../utils/use-hook'
|
||||
import { mutationFetcher } from '../utils/default-fetcher'
|
||||
import type { HookFetcherFn, MutationHook } from '../utils/types'
|
||||
import type { Provider } from '..'
|
||||
|
||||
export type UseLogout<
|
||||
H extends MutationHook<any, any, any> = MutationHook<null>
|
@@ -1,7 +1,7 @@
|
||||
import { useHook, useMutationHook } from './utils/use-hook'
|
||||
import { mutationFetcher } from './utils/default-fetcher'
|
||||
import type { HookFetcherFn, MutationHook } from './utils/types'
|
||||
import type { Provider } from '.'
|
||||
import { useHook, useMutationHook } from '../utils/use-hook'
|
||||
import { mutationFetcher } from '../utils/default-fetcher'
|
||||
import type { HookFetcherFn, MutationHook } from '../utils/types'
|
||||
import type { Provider } from '..'
|
||||
|
||||
export type UseSignup<
|
||||
H extends MutationHook<any, any, any> = MutationHook<null>
|
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"features": {
|
||||
"wishlist": true
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
import { useMemo } from 'react'
|
||||
import { useCommerce } from '.'
|
||||
import { useCommerce } from '..'
|
||||
|
||||
export function formatPrice({
|
||||
amount,
|
@@ -2,8 +2,10 @@ import type { Wishlist as BCWishlist } from '@framework/api/wishlist'
|
||||
import type { Customer as BCCustomer } from '@framework/api/customers'
|
||||
import type { SearchProductsData as BCSearchProductsData } from '@framework/api/catalog/products'
|
||||
|
||||
export type Features = 'wishlist' | 'checkout' | string
|
||||
|
||||
export type CommerceProviderConfig = {
|
||||
features: Record<string, boolean>
|
||||
features: Record<Features, boolean>
|
||||
}
|
||||
|
||||
export type Discount = {
|
||||
|
11
framework/commerce/utils/bootstrap.js
vendored
Normal file
11
framework/commerce/utils/bootstrap.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
module.exports = ({ features }) => {
|
||||
let output = {
|
||||
env: {},
|
||||
}
|
||||
if (!!Object.keys(features).length) {
|
||||
Object.keys(features).map(
|
||||
(r) => (output.env[`COMMERCE_${r.toUpperCase()}_ENABLED`] = features[r])
|
||||
)
|
||||
}
|
||||
return output
|
||||
}
|
@@ -14,6 +14,16 @@ function isFeatureEnabled(config: CommerceProviderConfig) {
|
||||
.includes(desideredFeature)
|
||||
}
|
||||
|
||||
export function toEnvConfig(
|
||||
configMap: CommerceProviderConfig['features']
|
||||
): Map<string, boolean> {
|
||||
let toEnvConfigMap = new Map<string, boolean>()
|
||||
Object.keys(configMap).map((r) =>
|
||||
toEnvConfigMap.set(`${r.toUpperCase()}_ENABLED`, configMap[r])
|
||||
)
|
||||
return toEnvConfigMap
|
||||
}
|
||||
|
||||
function boostrap(): FeaturesAPI {
|
||||
const basis = {
|
||||
isEnabled: () => false,
|
||||
|
Reference in New Issue
Block a user