forked from crowetic/commerce
* 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>
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import type { ServerResponse } from 'http'
|
|
import type {
|
|
OperationContext,
|
|
OperationOptions,
|
|
} from '@commerce/api/operations'
|
|
import type { LoginOperation } from '../../types/login'
|
|
import { Provider, SwellConfig } from '..'
|
|
|
|
export default function loginOperation({
|
|
commerce,
|
|
}: OperationContext<Provider>) {
|
|
async function login<T extends LoginOperation>(opts: {
|
|
variables: T['variables']
|
|
config?: Partial<SwellConfig>
|
|
res: ServerResponse
|
|
}): Promise<T['data']>
|
|
|
|
async function login<T extends LoginOperation>(
|
|
opts: {
|
|
variables: T['variables']
|
|
config?: Partial<SwellConfig>
|
|
res: ServerResponse
|
|
} & OperationOptions
|
|
): Promise<T['data']>
|
|
|
|
async function login<T extends LoginOperation>({
|
|
variables,
|
|
res: response,
|
|
config: cfg,
|
|
}: {
|
|
query?: string
|
|
variables: T['variables']
|
|
res: ServerResponse
|
|
config?: Partial<SwellConfig>
|
|
}): Promise<T['data']> {
|
|
const config = commerce.getConfig(cfg)
|
|
|
|
const { data } = await config.fetch('account', 'login', [variables])
|
|
|
|
return {
|
|
result: data,
|
|
}
|
|
}
|
|
|
|
return login
|
|
}
|