From a3fc343418ceca6dd970bde48c4735591e748747 Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 30 Mar 2022 12:48:08 -0400 Subject: [PATCH] Fix CatalogLayoutPetView --- .../page/layout/pets/CatalogLayoutPetView.tsx | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/components/catalog/views/page/layout/pets/CatalogLayoutPetView.tsx b/src/components/catalog/views/page/layout/pets/CatalogLayoutPetView.tsx index f2b27f03..1ad6cba2 100644 --- a/src/components/catalog/views/page/layout/pets/CatalogLayoutPetView.tsx +++ b/src/components/catalog/views/page/layout/pets/CatalogLayoutPetView.tsx @@ -26,7 +26,7 @@ export const CatalogLayoutPetView: FC = props => const [ approvalPending, setApprovalPending ] = useState(true); const [ approvalResult, setApprovalResult ] = useState(-1); const { currentOffer = null, setCurrentOffer = null, setPurchaseOptions = null, catalogOptions = null, roomPreviewer = null } = useCatalogContext(); - const { petPalettes = [] } = catalogOptions; + const { petPalettes = null } = catalogOptions; const getColor = useMemo(() => { @@ -138,26 +138,29 @@ export const CatalogLayoutPetView: FC = props => if(!productData) return; - for(const paletteData of petPalettes) + if(petPalettes) { - if(paletteData.breed !== productData.type) continue; - - const palettes: SellablePetPaletteData[] = []; - - for(const palette of paletteData.palettes) + for(const paletteData of petPalettes) { - if(!palette.sellable) continue; - - palettes.push(palette); + if(paletteData.breed !== productData.type) continue; + + const palettes: SellablePetPaletteData[] = []; + + for(const palette of paletteData.palettes) + { + if(!palette.sellable) continue; + + palettes.push(palette); + } + + BatchUpdates(() => + { + setSelectedPaletteIndex((palettes.length ? 0 : -1)); + setSellablePalettes(palettes); + }); + + return; } - - BatchUpdates(() => - { - setSelectedPaletteIndex((palettes.length ? 0 : -1)); - setSellablePalettes(palettes); - }); - - return; } BatchUpdates(() =>