mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 15:06:59 +00:00
Fix types
This commit is contained in:
parent
99f48c1db6
commit
130352b515
@ -1,6 +1,12 @@
|
||||
import { useCallback } from 'react'
|
||||
import type { MutationHookContext, HookFetcherContext, MutationHook } from '@vercel/commerce/utils/types'
|
||||
import useRemoveItem, { UseRemoveItem } from '@vercel/commerce/cart/use-remove-item'
|
||||
import type {
|
||||
MutationHookContext,
|
||||
HookFetcherContext,
|
||||
MutationHook,
|
||||
} from '@vercel/commerce/utils/types'
|
||||
import useRemoveItem, {
|
||||
UseRemoveItem,
|
||||
} from '@vercel/commerce/cart/use-remove-item'
|
||||
import useCart from './use-cart'
|
||||
import * as mutation from '../utils/mutations'
|
||||
import { getCheckoutId, checkoutToCart } from '../utils'
|
||||
@ -11,7 +17,11 @@ export default useRemoveItem as UseRemoveItem<typeof handler>
|
||||
|
||||
export const handler = {
|
||||
fetchOptions: { query: mutation.CheckoutLineDelete },
|
||||
async fetcher({ input: { itemId }, options, fetch }: HookFetcherContext<RemoveItemHook>) {
|
||||
async fetcher({
|
||||
input: { itemId },
|
||||
options,
|
||||
fetch,
|
||||
}: HookFetcherContext<RemoveItemHook>) {
|
||||
const data = await fetch<Mutation, MutationCheckoutLineDeleteArgs>({
|
||||
...options,
|
||||
variables: {
|
||||
@ -27,7 +37,7 @@ export const handler = {
|
||||
const { mutate } = useCart()
|
||||
|
||||
return useCallback(
|
||||
async function removeItem(input) {
|
||||
async function removeItem(input: { id: string }) {
|
||||
const data = await fetch({ input: { itemId: input.id } })
|
||||
await mutate(data, false)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { ComponentType, FunctionComponent } from 'react'
|
||||
import type { FC, ReactNode } from 'react'
|
||||
import {
|
||||
Provider,
|
||||
CommerceProviderProps,
|
||||
@ -14,7 +14,9 @@ import useLogout from '@vercel/commerce/auth/use-logout'
|
||||
export { spreeProvider }
|
||||
export type { SpreeProvider }
|
||||
|
||||
export const WithTokenErrorsHandling: FunctionComponent = ({ children }) => {
|
||||
export const WithTokenErrorsHandling: FC<{ children?: ReactNode }> = ({
|
||||
children,
|
||||
}) => {
|
||||
const logout = useLogout()
|
||||
|
||||
return (
|
||||
|
@ -45,7 +45,7 @@ export const handler = {
|
||||
const { mutate } = useCart()
|
||||
|
||||
return useCallback(
|
||||
async function removeItem(input) {
|
||||
async function removeItem(input: { id: string }) {
|
||||
const data = await fetch({ input: { itemId: input.id } })
|
||||
await mutate(data, false)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user