@@ -2,9 +2,10 @@ import * as React from 'react'
22import { useQuery , useQueryClient } from '@tanstack/react-query'
33import { twMerge } from 'tailwind-merge'
44import { getProduct } from '~/utils/shop.functions'
5- import type {
6- ProductDetail ,
7- ProductDetailVariant ,
5+ import {
6+ hasAvailableVariant ,
7+ type ProductDetail ,
8+ type ProductDetailVariant ,
89} from '~/utils/shopify-queries'
910import { formatMoney } from '~/utils/shopify-format'
1011import { resolveShopProductColor , shopColorContrast } from '~/utils/shop-color'
@@ -474,15 +475,16 @@ function DrawerContent({
474475 Select { option . name }
475476 </ option >
476477 { option . values . map ( ( value ) => {
477- const match = findMatchingVariant (
478- variants ,
479- getCandidate ( value ) ,
480- )
481478 return (
482479 < option
483480 key = { value }
484481 value = { value }
485- disabled = { ! match ?. availableForSale }
482+ disabled = {
483+ ! hasAvailableVariant (
484+ variants ,
485+ getCandidate ( value ) ,
486+ )
487+ }
486488 >
487489 { value }
488490 </ option >
@@ -505,11 +507,10 @@ function DrawerContent({
505507 < div className = "flex flex-wrap gap-1.5" >
506508 { option . values . map ( ( value ) => {
507509 const isSelected = selected [ option . name ] === value
508- const match = findMatchingVariant (
510+ const isUnavailable = ! hasAvailableVariant (
509511 variants ,
510512 getCandidate ( value ) ,
511513 )
512- const isUnavailable = ! match ?. availableForSale
513514 return (
514515 < ShopSize
515516 key = { value }
@@ -545,11 +546,10 @@ function DrawerContent({
545546 < div className = "flex flex-wrap gap-1.5" >
546547 { option . values . map ( ( value ) => {
547548 const isSelected = selected [ option . name ] === value
548- const match = findMatchingVariant (
549+ const isUnavailable = ! hasAvailableVariant (
549550 variants ,
550551 getCandidate ( value ) ,
551552 )
552- const isUnavailable = ! match ?. availableForSale
553553 const hex = resolveShopProductColor ( value )
554554 return (
555555 < ShopChip
0 commit comments