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'
|
import s from './WishlistCard.module.css'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string
|
|
||||||
children?: any
|
|
||||||
data?: ProductData
|
|
||||||
item: WishlistItem
|
item: WishlistItem
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ProductData {
|
const WishlistCard: FC<Props> = ({ item }) => {
|
||||||
name: string
|
|
||||||
images: any
|
|
||||||
prices: any
|
|
||||||
path: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const WishlistCard: FC<Props> = ({ className, item }) => {
|
|
||||||
const product = item.product!
|
const product = item.product!
|
||||||
const { price } = usePrice({
|
const { price } = usePrice({
|
||||||
amount: product.prices?.price?.value,
|
amount: product.prices?.price?.value,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import type { GetProductQuery, GetProductQueryVariables } from '../../schema'
|
import type { GetProductQuery, GetProductQueryVariables } from '../../schema'
|
||||||
import type { RecursivePartial, RecursiveRequired } from '../utils/types'
|
|
||||||
import setProductLocaleMeta from '../utils/set-product-locale-meta'
|
import setProductLocaleMeta from '../utils/set-product-locale-meta'
|
||||||
import { productInfoFragment } from '../fragments/product'
|
import { productInfoFragment } from '../fragments/product'
|
||||||
import { BigcommerceConfig, getConfig } from '..'
|
import { BigcommerceConfig, getConfig } from '..'
|
||||||
@ -103,20 +102,14 @@ async function getProduct({
|
|||||||
hasLocale: !!locale,
|
hasLocale: !!locale,
|
||||||
path: slug ? `/${slug}/` : vars.path!,
|
path: slug ? `/${slug}/` : vars.path!,
|
||||||
}
|
}
|
||||||
const { data } = await config.fetch<RecursivePartial<GetProductQuery>>(
|
const { data } = await config.fetch<GetProductQuery>(query, { variables })
|
||||||
query,
|
|
||||||
{ variables }
|
|
||||||
)
|
|
||||||
const product = data.site?.route?.node
|
const product = data.site?.route?.node
|
||||||
|
|
||||||
if (product?.__typename === 'Product') {
|
if (product?.__typename === 'Product') {
|
||||||
if (locale && config.applyLocale) {
|
if (locale && config.applyLocale) {
|
||||||
setProductLocaleMeta(product)
|
setProductLocaleMeta(product)
|
||||||
}
|
}
|
||||||
|
return { product }
|
||||||
return {
|
|
||||||
product: product as RecursiveRequired<typeof product>,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
30
lib/bigcommerce/schema.d.ts
vendored
30
lib/bigcommerce/schema.d.ts
vendored
@ -1701,7 +1701,7 @@ export type SwatchOptionFragment = { __typename?: 'SwatchOptionValue' } & Pick<
|
|||||||
|
|
||||||
export type MultipleChoiceOptionFragment = {
|
export type MultipleChoiceOptionFragment = {
|
||||||
__typename?: 'MultipleChoiceOption'
|
__typename?: 'MultipleChoiceOption'
|
||||||
} & Pick<MultipleChoiceOption, 'entityId'> & {
|
} & {
|
||||||
values: { __typename?: 'ProductOptionValueConnection' } & {
|
values: { __typename?: 'ProductOptionValueConnection' } & {
|
||||||
edges?: Maybe<
|
edges?: Maybe<
|
||||||
Array<
|
Array<
|
||||||
@ -1772,32 +1772,32 @@ export type ProductInfoFragment = { __typename?: 'Product' } & Pick<
|
|||||||
Maybe<
|
Maybe<
|
||||||
{ __typename?: 'ProductOptionEdge' } & {
|
{ __typename?: 'ProductOptionEdge' } & {
|
||||||
node:
|
node:
|
||||||
| ({ __typename?: 'CheckboxOption' } & Pick<
|
| ({ __typename: 'CheckboxOption' } & Pick<
|
||||||
CheckboxOption,
|
CheckboxOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
>)
|
>)
|
||||||
| ({ __typename?: 'DateFieldOption' } & Pick<
|
| ({ __typename: 'DateFieldOption' } & Pick<
|
||||||
DateFieldOption,
|
DateFieldOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
>)
|
>)
|
||||||
| ({ __typename?: 'FileUploadFieldOption' } & Pick<
|
| ({ __typename: 'FileUploadFieldOption' } & Pick<
|
||||||
FileUploadFieldOption,
|
FileUploadFieldOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
>)
|
>)
|
||||||
| ({ __typename?: 'MultiLineTextFieldOption' } & Pick<
|
| ({ __typename: 'MultiLineTextFieldOption' } & Pick<
|
||||||
MultiLineTextFieldOption,
|
MultiLineTextFieldOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
>)
|
>)
|
||||||
| ({ __typename?: 'MultipleChoiceOption' } & Pick<
|
| ({ __typename: 'MultipleChoiceOption' } & Pick<
|
||||||
MultipleChoiceOption,
|
MultipleChoiceOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
> &
|
> &
|
||||||
MultipleChoiceOptionFragment)
|
MultipleChoiceOptionFragment)
|
||||||
| ({ __typename?: 'NumberFieldOption' } & Pick<
|
| ({ __typename: 'NumberFieldOption' } & Pick<
|
||||||
NumberFieldOption,
|
NumberFieldOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
>)
|
>)
|
||||||
| ({ __typename?: 'TextFieldOption' } & Pick<
|
| ({ __typename: 'TextFieldOption' } & Pick<
|
||||||
TextFieldOption,
|
TextFieldOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
>)
|
>)
|
||||||
@ -1945,44 +1945,44 @@ export type GetProductQuery = { __typename?: 'Query' } & {
|
|||||||
{ __typename?: 'ProductOptionEdge' } & {
|
{ __typename?: 'ProductOptionEdge' } & {
|
||||||
node:
|
node:
|
||||||
| ({
|
| ({
|
||||||
__typename?: 'CheckboxOption'
|
__typename: 'CheckboxOption'
|
||||||
} & Pick<
|
} & Pick<
|
||||||
CheckboxOption,
|
CheckboxOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
>)
|
>)
|
||||||
| ({
|
| ({
|
||||||
__typename?: 'DateFieldOption'
|
__typename: 'DateFieldOption'
|
||||||
} & Pick<
|
} & Pick<
|
||||||
DateFieldOption,
|
DateFieldOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
>)
|
>)
|
||||||
| ({
|
| ({
|
||||||
__typename?: 'FileUploadFieldOption'
|
__typename: 'FileUploadFieldOption'
|
||||||
} & Pick<
|
} & Pick<
|
||||||
FileUploadFieldOption,
|
FileUploadFieldOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
>)
|
>)
|
||||||
| ({
|
| ({
|
||||||
__typename?: 'MultiLineTextFieldOption'
|
__typename: 'MultiLineTextFieldOption'
|
||||||
} & Pick<
|
} & Pick<
|
||||||
MultiLineTextFieldOption,
|
MultiLineTextFieldOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
>)
|
>)
|
||||||
| ({
|
| ({
|
||||||
__typename?: 'MultipleChoiceOption'
|
__typename: 'MultipleChoiceOption'
|
||||||
} & Pick<
|
} & Pick<
|
||||||
MultipleChoiceOption,
|
MultipleChoiceOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
> &
|
> &
|
||||||
MultipleChoiceOptionFragment)
|
MultipleChoiceOptionFragment)
|
||||||
| ({
|
| ({
|
||||||
__typename?: 'NumberFieldOption'
|
__typename: 'NumberFieldOption'
|
||||||
} & Pick<
|
} & Pick<
|
||||||
NumberFieldOption,
|
NumberFieldOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
>)
|
>)
|
||||||
| ({
|
| ({
|
||||||
__typename?: 'TextFieldOption'
|
__typename: 'TextFieldOption'
|
||||||
} & Pick<
|
} & Pick<
|
||||||
TextFieldOption,
|
TextFieldOption,
|
||||||
'entityId' | 'displayName'
|
'entityId' | 'displayName'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user