Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
shouldAddToCart = true,
shouldOpenMinicart = false,
showTooltipOnSkuNotSelected = true,
checkoutUrl,
customToastURL = checkoutUrl,
}) => {
const handles = useCssHandles(CSS_HANDLES)
const [isAddingToCart, setAddingToCart] = useState(false)
const { showToast } = useContext(ToastContext)
const {
skuSelector = {
areAllVariationsSelected: true,
},
} = useProduct()
const dispatch = useProductDispatch()
const { settings = {}, showInstallPrompt } = usePWA() || {}
const { promptOnCustomEvent } = settings
const translateMessage = useCallback(id => intl.formatMessage({ id: id }), [
intl,
])
const orderFormItems = path(['orderForm', 'items'], orderFormContext)
const { utmParams, utmiParams } = useMarketingSessionParams()
const resolveToastMessage = (success, isNewItem) => {
if (!success) return translateMessage(CONSTANTS.ERROR_MESSAGE_ID)
if (!isNewItem) return translateMessage(CONSTANTS.DUPLICATE_CART_ITEM_ID)
const isOffline = window && window.navigator && !window.navigator.onLine
const checkForOffline = !isOffline
? translateMessage(CONSTANTS.SUCCESS_MESSAGE_ID)
: translateMessage(CONSTANTS.OFFLINE_BUY_MESSAGE_ID)