forked from crowetic/commerce
Fixed types
This commit is contained in:
parent
46ae76c67f
commit
e90d9a2121
@ -1,7 +1,5 @@
|
||||
import { Page } from '../../schema'
|
||||
import { ShopifyConfig, getConfig } from '..'
|
||||
import type { Page } from '../../types'
|
||||
|
||||
export type { Page }
|
||||
|
||||
export type GetPageResult<T extends { page?: any } = { page?: Page }> = T
|
||||
|
||||
|
@ -40,7 +40,8 @@ export const handler: MutationHook<Cart, {}, CartItemBody> = {
|
||||
},
|
||||
})
|
||||
|
||||
return checkoutToCart(checkoutLineItemsAdd)
|
||||
// TODO: Fix this Cart type here
|
||||
return checkoutToCart(checkoutLineItemsAdd) as any
|
||||
},
|
||||
useHook: ({ fetch }) => () => {
|
||||
const { mutate } = useCart()
|
||||
|
@ -1,6 +1,4 @@
|
||||
import { useMemo } from 'react'
|
||||
import type { ShopifyProvider } from '..'
|
||||
|
||||
import useCommerceCart, {
|
||||
FetchCartInput,
|
||||
UseCart,
|
||||
@ -11,7 +9,7 @@ import { SWRHook } from '@commerce/utils/types'
|
||||
import { checkoutCreate, checkoutToCart } from './utils'
|
||||
import getCheckoutQuery from '../utils/queries/get-checkout-query'
|
||||
|
||||
export default useCommerceCart as UseCart<ShopifyProvider>
|
||||
export default useCommerceCart as UseCart<typeof handler>
|
||||
|
||||
export const handler: SWRHook<
|
||||
Cart | null,
|
||||
@ -38,7 +36,8 @@ export const handler: SWRHook<
|
||||
checkout = await checkoutCreate(fetch)
|
||||
}
|
||||
|
||||
return checkoutToCart({ checkout })
|
||||
// TODO: Fix this type
|
||||
return checkoutToCart({ checkout } as any)
|
||||
},
|
||||
useHook: ({ useData }) => (input) => {
|
||||
const response = useData({
|
||||
|
@ -24,7 +24,8 @@ const fetcher: HookFetcherFn<Cart | null, FetchCartInput> = async ({
|
||||
checkout = await checkoutCreate(fetch)
|
||||
}
|
||||
|
||||
return checkoutToCart({ checkout })
|
||||
// TODO: Fix this type
|
||||
return checkoutToCart({ checkout } as any)
|
||||
}
|
||||
|
||||
export default fetcher
|
||||
|
@ -2,9 +2,9 @@ import useCustomer, { UseCustomer } from '@commerce/customer/use-customer'
|
||||
import { Customer } from '@commerce/types'
|
||||
import { SWRHook } from '@commerce/utils/types'
|
||||
import { getCustomerQuery, getCustomerToken } from '../utils'
|
||||
import type { ShopifyProvider } from '..'
|
||||
|
||||
export default useCustomer as UseCustomer<ShopifyProvider>
|
||||
export default useCustomer as UseCustomer<typeof handler>
|
||||
|
||||
export const handler: SWRHook<Customer | null> = {
|
||||
fetchOptions: {
|
||||
query: getCustomerQuery,
|
||||
|
@ -30,9 +30,6 @@ export type CartItemBody = Core.CartItemBody & {
|
||||
optionSelections?: OptionSelections
|
||||
}
|
||||
|
||||
type X = Core.CartItemBody extends CartItemBody ? any : never
|
||||
type Y = CartItemBody extends Core.CartItemBody ? any : never
|
||||
|
||||
export type GetCartHandlerBody = Core.GetCartHandlerBody
|
||||
|
||||
export type AddCartItemBody = Core.AddCartItemBody<CartItemBody>
|
||||
|
@ -1,4 +1,8 @@
|
||||
import { Product, Image } from '../types'
|
||||
// TODO: Fix the types in this file
|
||||
// import { Product, Image } from '../types'
|
||||
|
||||
type Product = any
|
||||
type Image = any
|
||||
|
||||
export default function toCommerceProducts(products: Product[]) {
|
||||
return products.map((product: Product) => {
|
||||
@ -20,10 +24,12 @@ export default function toCommerceProducts(products: Product[]) {
|
||||
url: image.src,
|
||||
}
|
||||
}),
|
||||
variants: product.variants.map((variant) => {
|
||||
// TODO: Fix the variant type
|
||||
variants: product.variants.map((variant: any) => {
|
||||
return {
|
||||
id: variant.id,
|
||||
options: variant.selectedOptions.map((selectedOption) => {
|
||||
// TODO: Fix the selectedOption type
|
||||
options: variant.selectedOptions.map((selectedOption: any) => {
|
||||
return {
|
||||
__typename: 'MultipleChoiceOption',
|
||||
displayName: selectedOption.name,
|
||||
@ -39,11 +45,13 @@ export default function toCommerceProducts(products: Product[]) {
|
||||
}),
|
||||
}
|
||||
}),
|
||||
productOptions: product.options.map((option) => {
|
||||
// TODO: Fix the option type
|
||||
productOptions: product.options.map((option: any) => {
|
||||
return {
|
||||
__typename: 'MultipleChoiceOption',
|
||||
displayName: option.name,
|
||||
values: option.values.map((value) => {
|
||||
// TODO: Fix the value type
|
||||
values: option.values.map((value: any) => {
|
||||
return {
|
||||
node: {
|
||||
entityId: 1,
|
||||
|
@ -1,5 +1,7 @@
|
||||
// TODO: replace this hook and other wishlist hooks with a handler, or remove them if
|
||||
// Shopify doesn't have a wishlist
|
||||
|
||||
import { HookFetcher } from '@commerce/utils/types'
|
||||
import { SwrOptions } from '@commerce/utils/use-data'
|
||||
import useCommerceWishlist from '@commerce/wishlist/use-wishlist'
|
||||
import { Product } from '../schema'
|
||||
import useCustomer from '../customer/use-customer'
|
||||
@ -31,7 +33,8 @@ export const fetcher: HookFetcher<Wishlist | null, UseWishlistInput> = () => {
|
||||
|
||||
export function extendHook(
|
||||
customFetcher: typeof fetcher,
|
||||
swrOptions?: SwrOptions<Wishlist | null, UseWishlistInput>
|
||||
// swrOptions?: SwrOptions<Wishlist | null, UseWishlistInput>
|
||||
swrOptions?: any
|
||||
) {
|
||||
const useWishlist = ({ includeProducts }: UseWishlistOptions = {}) => {
|
||||
return { data: null }
|
||||
|
@ -39,5 +39,3 @@ module.exports = withCommerceConfig({
|
||||
].filter((x) => x)
|
||||
},
|
||||
})
|
||||
|
||||
console.log('configs', module.exports)
|
||||
|
Loading…
x
Reference in New Issue
Block a user