mirror of
https://github.com/vercel/commerce.git
synced 2025-03-27 15:55:54 +00:00
* 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>
38 lines
925 B
TypeScript
38 lines
925 B
TypeScript
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
|
|
}
|