import { useAppState } from '@components/common/context/app.js'; import { Image } from '@components/common/Image.js'; import { ProductNoThumbnail } from '@components/common/ProductNoThumbnail.js'; import { Button, buttonVariants } from '@components/common/ui/Button.js'; import { _ } from '@evershop/evershop/lib/locale/translate/_'; import React from 'react'; interface SavedCartItem { cartItemId: string; productName: string; thumbnail?: string | null; qty: number; variantOptions?: Array<{ optionId: number; attributeName: string; optionText: string; }>; lineTotal?: { text: string }; lineTotalInclTax?: { text: string }; } interface CartRecoverConfirmProps { cartRecoveryStatus: 'ready' | 'restored' | 'invalid' | null; cartRecoveryItems?: SavedCartItem[]; homeUrl: string; cartUrl: string; } /** * `/cart/recover` (`index.ts` decides): for a valid link, the saved cart's * products and the "Restore my cart" button (opening the link changes * nothing, only the button does); for a link used already, a way to the * cart; otherwise the message for a link that no longer works. A plain * form, so the button works before the page is hydrated. */ export default function CartRecoverConfirm({ cartRecoveryStatus, cartRecoveryItems = [], homeUrl, cartUrl }: CartRecoverConfirmProps) { const { config } = useAppState() ?? {}; const inclTax = Boolean( (config as { tax?: { priceIncludingTax?: boolean } } | undefined)?.tax ?.priceIncludingTax ); if (cartRecoveryStatus === 'ready') { return (
{_( 'The products from your saved cart will be added to your current cart.' )}
{cartRecoveryItems.length > 0 && ({_( 'Its products were added to a cart the first time this link was used.' )}
{_('Go to your cart')}{_('The link may have expired or already been used.')}
{_('Continue shopping')}