mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 23:16:59 +00:00
Updates
This commit is contained in:
parent
41f8a651f7
commit
aad0a909ac
@ -50,7 +50,7 @@ export function normalizeProduct(productNode: any): Product {
|
|||||||
alt: altText,
|
alt: altText,
|
||||||
...rest,
|
...rest,
|
||||||
})),
|
})),
|
||||||
|
// merge variant default image with product images
|
||||||
...productNode.variants?.edges
|
...productNode.variants?.edges
|
||||||
?.map(({ node: { defaultImage } }: any) =>
|
?.map(({ node: { defaultImage } }: any) =>
|
||||||
defaultImage
|
defaultImage
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Fetcher } from '@vercel/commerce/utils/types'
|
import type { Fetcher } from '@vercel/commerce/utils/types'
|
||||||
import { API_TOKEN, API_URL } from './const'
|
import { API_TOKEN, API_URL } from './const'
|
||||||
import { handleFetchResponse } from './utils/handle-fetch-response'
|
import { handleFetchResponse } from './utils/handle-fetch-response'
|
||||||
|
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
export { throwUserErrors } from './throw-user-errors'
|
export { throwUserErrors } from './throw-user-errors'
|
||||||
export { handleFetchResponse } from './handle-fetch-response'
|
export { handleFetchResponse } from './handle-fetch-response'
|
||||||
|
|
||||||
export {
|
|
||||||
handleLogin,
|
|
||||||
handleAutomaticLogin,
|
|
||||||
handleAccountActivation,
|
|
||||||
} from './auth'
|
|
||||||
|
|
||||||
export * from './auth'
|
export * from './auth'
|
||||||
export * from './cart'
|
export * from './cart'
|
||||||
export * from './metafields'
|
export * from './metafields'
|
||||||
|
@ -10,7 +10,7 @@ const Head: VFC = () => {
|
|||||||
content="width=device-width, initial-scale=1"
|
content="width=device-width, initial-scale=1"
|
||||||
/>
|
/>
|
||||||
<link rel="manifest" href="/site.webmanifest" key="site-manifest" />
|
<link rel="manifest" href="/site.webmanifest" key="site-manifest" />
|
||||||
{process.env.COMMERCE_PROVIDER === '@vercel/commerce-shopify' && (
|
{process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN && (
|
||||||
<link
|
<link
|
||||||
rel="preconnect"
|
rel="preconnect"
|
||||||
href={`https://${process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN?.replace(
|
href={`https://${process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN?.replace(
|
||||||
|
@ -2,10 +2,10 @@ import type { ProductCustomField } from '@commerce/types/product'
|
|||||||
|
|
||||||
const ProductCustomFields = ({ fields }: { fields: ProductCustomField[] }) => {
|
const ProductCustomFields = ({ fields }: { fields: ProductCustomField[] }) => {
|
||||||
return (
|
return (
|
||||||
<ul className="flex flex-col space-y-2.5 divide-y divide-accent-2 divide-dashed">
|
<ul className="flex flex-col space-y-3 divide-y divide-accent-2 divide-dashed">
|
||||||
{fields.map((m) => (
|
{fields.map((m) => (
|
||||||
<li
|
<li
|
||||||
className="flex space-x-2 justify-start items-start pt-2.5 text-sm"
|
className="flex space-x-2 justify-start items-start pt-3 text-sm"
|
||||||
key={m.key}
|
key={m.key}
|
||||||
>
|
>
|
||||||
<span className="font-bold capitalize whitespace-nowrap">
|
<span className="font-bold capitalize whitespace-nowrap">
|
||||||
|
@ -22,7 +22,7 @@ const ProductSidebar: FC<ProductSidebarProps> = ({ className }) => {
|
|||||||
try {
|
try {
|
||||||
await addItem({
|
await addItem({
|
||||||
productId: String(product.id),
|
productId: String(product.id),
|
||||||
variantId: String(variant ? variant.id : product.variants[0]?.id),
|
variantId: String(variant.id),
|
||||||
})
|
})
|
||||||
setSidebarView('CART_VIEW')
|
setSidebarView('CART_VIEW')
|
||||||
openSidebar()
|
openSidebar()
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
import { useMemo, useState, useEffect, useContext, createContext } from 'react'
|
import { useMemo, useState, useEffect, useContext, createContext } from 'react'
|
||||||
|
|
||||||
import type { FC, ReactNode, Dispatch, SetStateAction } from 'react'
|
import type { FC, ReactNode, Dispatch, SetStateAction } from 'react'
|
||||||
|
import type { SelectedOptions } from './helpers'
|
||||||
import type {
|
import type {
|
||||||
Product,
|
Product,
|
||||||
ProductImage,
|
ProductImage,
|
||||||
ProductVariant,
|
ProductVariant,
|
||||||
} from '@commerce/types/product'
|
} from '@commerce/types/product'
|
||||||
|
|
||||||
import type { SelectedOptions } from './helpers'
|
|
||||||
|
|
||||||
import usePrice from '@framework/product/use-price'
|
import usePrice from '@framework/product/use-price'
|
||||||
import { getProductVariant, selectDefaultOptionFromProduct } from './helpers'
|
import { getProductVariant, selectDefaultOptionFromProduct } from './helpers'
|
||||||
|
|
||||||
@ -36,8 +34,8 @@ export const ProductProvider: FC<ProductProviderProps> = ({
|
|||||||
product,
|
product,
|
||||||
children,
|
children,
|
||||||
}) => {
|
}) => {
|
||||||
const [selectedOptions, setSelectedOptions] = useState<SelectedOptions>({})
|
|
||||||
const [imageIndex, setImageIndex] = useState<number | null>(null)
|
const [imageIndex, setImageIndex] = useState<number | null>(null)
|
||||||
|
const [selectedOptions, setSelectedOptions] = useState<SelectedOptions>({})
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => selectDefaultOptionFromProduct(product, setSelectedOptions),
|
() => selectDefaultOptionFromProduct(product, setSelectedOptions),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user