Update Swell Provider (#359)

* fix update cart item

* update types

* update checkout

* update get-page, cleanup types

* revert change to incorrect file

* cleanup

Co-authored-by: Greg Hoskin <greghoskin@Gregs-MacBook-Pro.local>
This commit is contained in:
ghoskin
2021-06-14 13:37:18 -07:00
committed by GitHub
parent ddd4631ade
commit 4d85b43a30
55 changed files with 503 additions and 545 deletions

View File

@@ -0,0 +1,37 @@
import getCategories from '../../utils/get-categories'
import getVendors, { Brands } from '../../utils/get-vendors'
import { Provider, SwellConfig } from '../'
import { OperationContext } from '@commerce/api/operations'
import { Category } from '@commerce/types/site'
export type GetSiteInfoResult<
T extends { categories: any[]; brands: any[] } = {
categories: Category[]
brands: Brands
}
> = T
export default function getSiteInfoOperation({
commerce,
}: OperationContext<Provider>) {
async function getSiteInfo({
variables,
config: cfg,
}: {
query?: string
variables?: any
config?: Partial<SwellConfig>
preview?: boolean
} = {}): Promise<GetSiteInfoResult> {
const config = commerce.getConfig(cfg)
const categories = await getCategories(config)
const brands = await getVendors(config)
return {
categories,
brands,
}
}
return getSiteInfo
}