import type { CartUserInputError } from '@graphcommerce/graphql-mesh' import { ApolloCartErrorSnackbar, type CartItemCountChangedFragment, } from '@graphcommerce/magento-cart' import type { ErrorSnackbarProps, MessageSnackbarProps } from '@graphcommerce/next-ui' import { Button, ErrorSnackbar, iconChevronRight, IconSvg, ListFormat, MessageSnackbar, } from '@graphcommerce/next-ui' import type { ErrorLike } from '@apollo/client' import { Plural, Trans } from '@lingui/react/macro' export type AddProductsToCartSnackbarMessageProps = { errorSnackbar?: Omit successSnackbar?: Omit error?: ErrorLike | null userErrors?: Pick[] showSuccess: boolean addedItems: string[] cart?: CartItemCountChangedFragment | null | undefined } export function AddProductsToCartSnackbarMessage(props: AddProductsToCartSnackbarMessageProps) { const { errorSnackbar, successSnackbar, error, userErrors, showSuccess, addedItems } = props const showErrorSnackbar = !!userErrors?.length return ( <> {error && } {showErrorSnackbar && ( <>{userErrors.map((e) => e?.message).join(', ')} )} {showSuccess && ( } sx={{ display: 'flex' }} > View shopping cart } > {addedItems} {' '} has been added to your shopping cart } two={ {addedItems} {' '} have been added to your shopping cart! } other={# products have been added to your shopping cart!} /> )} ) }