mirror of
https://github.com/vercel/commerce.git
synced 2025-07-04 20:21:21 +00:00
Updated swell-js usage
This commit is contained in:
parent
e8f51a4f01
commit
412d6f3b02
@ -1,7 +1,7 @@
|
|||||||
import { swellConfig } from '../..'
|
import swell from '../../swell'
|
||||||
|
|
||||||
const fetchApi = async (query: string, method: string, variables: [] = []) => {
|
const fetchApi = async (query: string, method: string, variables: [] = []) => {
|
||||||
const { swell } = swellConfig
|
|
||||||
return swell[query][method](...variables)
|
return swell[query][method](...variables)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default fetchApi
|
export default fetchApi
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
import { Fetcher } from '@commerce/utils/types'
|
import { Fetcher } from '@commerce/utils/types'
|
||||||
import { handleFetchResponse } from './utils'
|
|
||||||
import { swellConfig } from './index'
|
|
||||||
import { CommerceError } from '@commerce/utils/errors'
|
import { CommerceError } from '@commerce/utils/errors'
|
||||||
|
import { handleFetchResponse } from './utils'
|
||||||
|
import swell from './swell'
|
||||||
|
|
||||||
const fetcher: Fetcher = async ({ method = 'get', variables, query }) => {
|
const fetcher: Fetcher = async ({ method = 'get', variables, query }) => {
|
||||||
const { swell } = swellConfig
|
|
||||||
|
|
||||||
async function callSwell() {
|
async function callSwell() {
|
||||||
if (Array.isArray(variables)) {
|
if (Array.isArray(variables)) {
|
||||||
const arg1 = variables[0]
|
const arg1 = variables[0]
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
import swell from 'swell-js'
|
|
||||||
import { Provider } from '@commerce'
|
import { Provider } from '@commerce'
|
||||||
import {
|
import { SWELL_CHECKOUT_ID_COOKIE } from './const'
|
||||||
SWELL_CHECKOUT_ID_COOKIE,
|
|
||||||
SWELL_STORE_ID,
|
|
||||||
SWELL_PUBLIC_KEY,
|
|
||||||
} from './const'
|
|
||||||
|
|
||||||
import { handler as useCart } from './cart/use-cart'
|
import { handler as useCart } from './cart/use-cart'
|
||||||
import { handler as useAddItem } from './cart/use-add-item'
|
import { handler as useAddItem } from './cart/use-add-item'
|
||||||
@ -19,8 +14,7 @@ import { handler as useLogout } from './auth/use-logout'
|
|||||||
import { handler as useSignup } from './auth/use-signup'
|
import { handler as useSignup } from './auth/use-signup'
|
||||||
|
|
||||||
import fetcher from './fetcher'
|
import fetcher from './fetcher'
|
||||||
|
import swell from './swell'
|
||||||
swell.init(SWELL_STORE_ID, SWELL_PUBLIC_KEY)
|
|
||||||
|
|
||||||
export const swellProvider: Provider & { swell: any } = {
|
export const swellProvider: Provider & { swell: any } = {
|
||||||
locale: 'en-us',
|
locale: 'en-us',
|
||||||
|
6
framework/swell/swell.ts
Normal file
6
framework/swell/swell.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import swell from 'swell-js'
|
||||||
|
import { SWELL_STORE_ID, SWELL_PUBLIC_KEY } from './const'
|
||||||
|
|
||||||
|
swell.init(SWELL_STORE_ID, SWELL_PUBLIC_KEY)
|
||||||
|
|
||||||
|
export default swell
|
Loading…
x
Reference in New Issue
Block a user