forked from crowetic/commerce
Losing my mind, but always fixing the types 🕺
This commit is contained in:
parent
9ad0f0ef6b
commit
6fb5b412a8
@ -13,20 +13,10 @@ import { Trash } from '@components/icons'
|
||||
import s from './WishlistCard.module.css'
|
||||
|
||||
interface Props {
|
||||
className?: string
|
||||
children?: any
|
||||
data?: ProductData
|
||||
item: WishlistItem
|
||||
}
|
||||
|
||||
interface ProductData {
|
||||
name: string
|
||||
images: any
|
||||
prices: any
|
||||
path: string
|
||||
}
|
||||
|
||||
const WishlistCard: FC<Props> = ({ className, item }) => {
|
||||
const WishlistCard: FC<Props> = ({ item }) => {
|
||||
const product = item.product!
|
||||
const { price } = usePrice({
|
||||
amount: product.prices?.price?.value,
|
||||
|
@ -1,5 +1,4 @@
|
||||
import type { GetProductQuery, GetProductQueryVariables } from '../../schema'
|
||||
import type { RecursivePartial, RecursiveRequired } from '../utils/types'
|
||||
import setProductLocaleMeta from '../utils/set-product-locale-meta'
|
||||
import { productInfoFragment } from '../fragments/product'
|
||||
import { BigcommerceConfig, getConfig } from '..'
|
||||
@ -103,20 +102,14 @@ async function getProduct({
|
||||
hasLocale: !!locale,
|
||||
path: slug ? `/${slug}/` : vars.path!,
|
||||
}
|
||||
const { data } = await config.fetch<RecursivePartial<GetProductQuery>>(
|
||||
query,
|
||||
{ variables }
|
||||
)
|
||||
const { data } = await config.fetch<GetProductQuery>(query, { variables })
|
||||
const product = data.site?.route?.node
|
||||
|
||||
if (product?.__typename === 'Product') {
|
||||
if (locale && config.applyLocale) {
|
||||
setProductLocaleMeta(product)
|
||||
}
|
||||
|
||||
return {
|
||||
product: product as RecursiveRequired<typeof product>,
|
||||
}
|
||||
return { product }
|
||||
}
|
||||
|
||||
return {}
|
||||
|
74
lib/bigcommerce/schema.d.ts
vendored
74
lib/bigcommerce/schema.d.ts
vendored
@ -1701,32 +1701,32 @@ export type SwatchOptionFragment = { __typename?: 'SwatchOptionValue' } & Pick<
|
||||
|
||||
export type MultipleChoiceOptionFragment = {
|
||||
__typename?: 'MultipleChoiceOption'
|
||||
} & Pick<MultipleChoiceOption, 'entityId'> & {
|
||||
values: { __typename?: 'ProductOptionValueConnection' } & {
|
||||
edges?: Maybe<
|
||||
Array<
|
||||
Maybe<
|
||||
{ __typename?: 'ProductOptionValueEdge' } & {
|
||||
node:
|
||||
| ({ __typename?: 'MultipleChoiceOptionValue' } & Pick<
|
||||
MultipleChoiceOptionValue,
|
||||
'label'
|
||||
>)
|
||||
| ({ __typename?: 'ProductPickListOptionValue' } & Pick<
|
||||
ProductPickListOptionValue,
|
||||
'label'
|
||||
>)
|
||||
| ({ __typename?: 'SwatchOptionValue' } & Pick<
|
||||
SwatchOptionValue,
|
||||
'label'
|
||||
> &
|
||||
SwatchOptionFragment)
|
||||
}
|
||||
>
|
||||
} & {
|
||||
values: { __typename?: 'ProductOptionValueConnection' } & {
|
||||
edges?: Maybe<
|
||||
Array<
|
||||
Maybe<
|
||||
{ __typename?: 'ProductOptionValueEdge' } & {
|
||||
node:
|
||||
| ({ __typename?: 'MultipleChoiceOptionValue' } & Pick<
|
||||
MultipleChoiceOptionValue,
|
||||
'label'
|
||||
>)
|
||||
| ({ __typename?: 'ProductPickListOptionValue' } & Pick<
|
||||
ProductPickListOptionValue,
|
||||
'label'
|
||||
>)
|
||||
| ({ __typename?: 'SwatchOptionValue' } & Pick<
|
||||
SwatchOptionValue,
|
||||
'label'
|
||||
> &
|
||||
SwatchOptionFragment)
|
||||
}
|
||||
>
|
||||
>
|
||||
}
|
||||
>
|
||||
}
|
||||
}
|
||||
|
||||
export type ProductInfoFragment = { __typename?: 'Product' } & Pick<
|
||||
Product,
|
||||
@ -1772,32 +1772,32 @@ export type ProductInfoFragment = { __typename?: 'Product' } & Pick<
|
||||
Maybe<
|
||||
{ __typename?: 'ProductOptionEdge' } & {
|
||||
node:
|
||||
| ({ __typename?: 'CheckboxOption' } & Pick<
|
||||
| ({ __typename: 'CheckboxOption' } & Pick<
|
||||
CheckboxOption,
|
||||
'entityId' | 'displayName'
|
||||
>)
|
||||
| ({ __typename?: 'DateFieldOption' } & Pick<
|
||||
| ({ __typename: 'DateFieldOption' } & Pick<
|
||||
DateFieldOption,
|
||||
'entityId' | 'displayName'
|
||||
>)
|
||||
| ({ __typename?: 'FileUploadFieldOption' } & Pick<
|
||||
| ({ __typename: 'FileUploadFieldOption' } & Pick<
|
||||
FileUploadFieldOption,
|
||||
'entityId' | 'displayName'
|
||||
>)
|
||||
| ({ __typename?: 'MultiLineTextFieldOption' } & Pick<
|
||||
| ({ __typename: 'MultiLineTextFieldOption' } & Pick<
|
||||
MultiLineTextFieldOption,
|
||||
'entityId' | 'displayName'
|
||||
>)
|
||||
| ({ __typename?: 'MultipleChoiceOption' } & Pick<
|
||||
| ({ __typename: 'MultipleChoiceOption' } & Pick<
|
||||
MultipleChoiceOption,
|
||||
'entityId' | 'displayName'
|
||||
> &
|
||||
MultipleChoiceOptionFragment)
|
||||
| ({ __typename?: 'NumberFieldOption' } & Pick<
|
||||
| ({ __typename: 'NumberFieldOption' } & Pick<
|
||||
NumberFieldOption,
|
||||
'entityId' | 'displayName'
|
||||
>)
|
||||
| ({ __typename?: 'TextFieldOption' } & Pick<
|
||||
| ({ __typename: 'TextFieldOption' } & Pick<
|
||||
TextFieldOption,
|
||||
'entityId' | 'displayName'
|
||||
>)
|
||||
@ -1945,44 +1945,44 @@ export type GetProductQuery = { __typename?: 'Query' } & {
|
||||
{ __typename?: 'ProductOptionEdge' } & {
|
||||
node:
|
||||
| ({
|
||||
__typename?: 'CheckboxOption'
|
||||
__typename: 'CheckboxOption'
|
||||
} & Pick<
|
||||
CheckboxOption,
|
||||
'entityId' | 'displayName'
|
||||
>)
|
||||
| ({
|
||||
__typename?: 'DateFieldOption'
|
||||
__typename: 'DateFieldOption'
|
||||
} & Pick<
|
||||
DateFieldOption,
|
||||
'entityId' | 'displayName'
|
||||
>)
|
||||
| ({
|
||||
__typename?: 'FileUploadFieldOption'
|
||||
__typename: 'FileUploadFieldOption'
|
||||
} & Pick<
|
||||
FileUploadFieldOption,
|
||||
'entityId' | 'displayName'
|
||||
>)
|
||||
| ({
|
||||
__typename?: 'MultiLineTextFieldOption'
|
||||
__typename: 'MultiLineTextFieldOption'
|
||||
} & Pick<
|
||||
MultiLineTextFieldOption,
|
||||
'entityId' | 'displayName'
|
||||
>)
|
||||
| ({
|
||||
__typename?: 'MultipleChoiceOption'
|
||||
__typename: 'MultipleChoiceOption'
|
||||
} & Pick<
|
||||
MultipleChoiceOption,
|
||||
'entityId' | 'displayName'
|
||||
> &
|
||||
MultipleChoiceOptionFragment)
|
||||
| ({
|
||||
__typename?: 'NumberFieldOption'
|
||||
__typename: 'NumberFieldOption'
|
||||
} & Pick<
|
||||
NumberFieldOption,
|
||||
'entityId' | 'displayName'
|
||||
>)
|
||||
| ({
|
||||
__typename?: 'TextFieldOption'
|
||||
__typename: 'TextFieldOption'
|
||||
} & Pick<
|
||||
TextFieldOption,
|
||||
'entityId' | 'displayName'
|
||||
|
Loading…
x
Reference in New Issue
Block a user