matias-delavega-dg-dmi 716b540966
TEC-252 and TEC-256: Implementing fetchers, products list and search (#5)
* TEC-252: Base integration with commercetools using fetchers for REST and GraphQL endpoints

* TEC-252: WIP commenting some components that are failing while we don't have all the hooks defined

* add sdk integration

* TEC-256: Implementing product search

* TEC-256: removing unnecessary env variables

* TEC-256: review comments

* TEC-256: other remaining review fixes

Co-authored-by: nicossosa93 <nicolas.sosa@devgurus.io>
2021-06-30 10:05:26 -03:00

46 lines
1.0 KiB
TypeScript

import { CommercetoolsConfig, Provider } from '@framework/api'
import { OperationContext } from '@commerce/api/operations'
export type Page = any
export type GetPageResult<T extends { page?: any } = { page?: Page }> = T
export type PageVariables = {
id: number
}
export default function getPageOperation({
commerce,
}: OperationContext<Provider>) {
async function getPage(opts: {
url?: string
variables: PageVariables
config?: Partial<CommercetoolsConfig>
preview?: boolean
}): Promise<GetPageResult>
async function getPage<T extends { page?: any }, V = any>(opts: {
url: string
variables: V
config?: Partial<CommercetoolsConfig>
preview?: boolean
}): Promise<GetPageResult<T>>
async function getPage({
url,
variables,
config: cfg,
preview,
}: {
url?: string
variables: PageVariables
config?: Partial<CommercetoolsConfig>
preview?: boolean
}): Promise<GetPageResult> {
const config = commerce.getConfig(cfg)
return {}
}
return getPage
}