Fix build errors

This commit is contained in:
cond0r
2021-05-13 16:10:09 +03:00
parent e7d0f56e85
commit bff94e73ae
22 changed files with 87 additions and 458 deletions

View File

@@ -6,11 +6,10 @@ import {
SWELL_COOKIE_EXPIRE,
} from '../const'
import fetcher from '../fetcher'
import fetchSwellApi from './utils/fetch-swell-api'
import fetchApi from './utils/fetch-swell-api'
export interface SwellConfig extends CommerceAPIConfig {
fetchSwell: any
fetch: any
}
export class Config {
@@ -38,8 +37,7 @@ const config = new Config({
apiToken: ''!,
cartCookie: SWELL_CHECKOUT_ID_COOKIE,
cartCookieMaxAge: SWELL_COOKIE_EXPIRE,
fetchSwell: fetchSwellApi,
fetch: fetcher,
fetch: fetchApi,
customerCookie: SWELL_CUSTOMER_TOKEN_COOKIE,
})

View File

@@ -1,25 +0,0 @@
import { SwellConfig } from '..'
import { SwellProduct } from '../../types'
const fetchAllProducts = async ({
config,
query,
method,
variables,
acc = [],
}: {
config: SwellConfig
query: string
method: string
acc?: SwellProduct[]
variables?: any
cursor?: string
}): Promise<SwellProduct[]> => {
const response = await config.fetchSwell(query, method, variables)
acc = acc.concat(response.results)
return acc
}
export default fetchAllProducts

View File

@@ -1,11 +1,7 @@
import { swellConfig } from '../..'
const fetchSwellApi = async (
query: string,
method: string,
variables: [] = []
) => {
const fetchApi = async (query: string, method: string, variables: [] = []) => {
const { swell } = swellConfig
return await swell[query][method](...variables)
return swell[query][method](...variables)
}
export default fetchSwellApi
export default fetchApi