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OArBd,SAAC+E,MAAAA,CACCC,IAAKO,EAAAA,QACLL,IAAI,UACJ9E,UAAY,4CA2GtB,C","sources":["webpack://webstaurantstore/./productListing/ProductBox/GoodBetterBestRibbon.tsx"],"sourcesContent":["import React, { useEffect, useState, CSSProperties } from \"react\";\nimport {\n Popover,\n PopoverBody,\n PopoverHeader,\n PopoverContent,\n PopoverTrigger,\n} from \"@clarkinc/zest-design-system/ui\";\nimport debounce from \"lodash/debounce\";\nimport { cls } from \"@wss/cls\";\nimport formatAsCurrency from \"@wss/utilities/formatAsCurrency\";\nimport Ribbon, { RibbonProps } from \"./Ribbon\";\nimport loaderGif from \"~/common/loader.gif\";\nimport {\n QualityRatingItem,\n QualityRatingMembership,\n} from \"~/common/Store/models/QualityRating\";\nimport { getLowestPriceWithQuantityDiscounts } from \"~/ProductDetails/Pricing/getLowestPrice\";\nimport shouldDisplayQuantityDiscounts from \"~/ProductDetails/Pricing/shouldDisplayQuantityDiscounts\";\nimport { User } from \"~/common/Store/models/User\";\n\nconst colors = {\n Good: \"brown\",\n Better: \"gray\",\n Best: \"yellow\",\n} as const;\n\nexport type GoodBetterBestProps = {\n itemNumber: string;\n qualityRating: QualityRatingMembership;\n productListingView?: \"list\" | \"grid\" | undefined;\n showRibbonInline?: boolean;\n className?: string;\n style?: CSSProperties;\n user: User;\n};\nconst GoodBetterBestRibbon = ({\n itemNumber,\n qualityRating,\n productListingView,\n showRibbonInline,\n className,\n style,\n user,\n}: GoodBetterBestProps) => {\n const { label } = qualityRating;\n const [loadedQualityRatingGroup, setLoadedQualityRatingGroup] = useState(\n false\n );\n const [qualityRatingGroup, setqualityRatingGroup] = useState<\n QualityRatingItem[]\n >([]);\n\n const [isLargeScreen, setIsLargeScreen] = useState(true);\n\n useEffect(() => {\n if (!productListingView) {\n return undefined;\n }\n\n const handleResize = debounce(() => {\n setIsLargeScreen(window.innerWidth >= 768);\n }, 100);\n\n handleResize();\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [productListingView]);\n\n const loadQuantityRatingGroup = async () => {\n if (loadedQualityRatingGroup) {\n return;\n }\n\n const endpointUrl = \"/api/productlisting/qualityratinggroup/\";\n\n try {\n const result = await fetch(\n `${endpointUrl}?itemNumber=${encodeURIComponent(itemNumber)}`\n );\n\n const data: QualityRatingItem[] = await result.json<\n QualityRatingItem[]\n >();\n\n setqualityRatingGroup(data);\n } catch (error) {\n setqualityRatingGroup([]);\n } finally {\n setLoadedQualityRatingGroup(true);\n }\n };\n\n const color: RibbonProps[\"bgcolor\"] = colors[label];\n\n const getPriceDisplay = (item: QualityRatingItem) => {\n const lowestPricingProduct = {\n customizationRequired: false,\n customizationUrl: \"\",\n isCustomizable: false,\n minimumCustomizationPrice: 0,\n showBelowMinimumAdvertisedPriceForLoggedInCustomers:\n item.showBelowMinimumAdvertisedPriceForLoggedInCustomers,\n showBelowMinimumAdvertisedPriceForPlatinumAndPlusCustomers:\n item.showBelowMinimumAdvertisedPriceForPlatinumAndPlusCustomers,\n startBuy: item.startBuy,\n price: item.price,\n };\n\n const [displayQuantityDiscounts] = shouldDisplayQuantityDiscounts(\n lowestPricingProduct,\n user\n );\n\n // eslint-disable-next-line no-extra-boolean-cast\n if (\n item.price.minimumAdvertisedPriceProperties?.type?.trim() &&\n item.price.minimumAdvertisedPriceProperties.price < item.price.price\n ) {\n return <>View product for pricing details>;\n }\n\n const displayPrice = getLowestPriceWithQuantityDiscounts(\n lowestPricingProduct,\n user,\n false\n );\n\n if (displayQuantityDiscounts) {\n return (\n
\n Quality Ratings are currently unavailable for this product.\n
\n );\n }\n\n return (\n\n {item.itemNumber}\n
\n