feat(MED-100): update cart checkout flow and views

This commit is contained in:
2025-07-17 10:16:52 +03:00
parent ea3fb22f1d
commit 6426e2a79b
33 changed files with 1505 additions and 138 deletions

View File

@@ -3,24 +3,34 @@
import { deleteLineItem } from "@lib/data/cart";
import { Spinner, Trash } from "@medusajs/icons";
import { clx } from "@medusajs/ui";
import { useRouter } from "next/navigation";
import { useState } from "react";
const DeleteButton = ({
id,
children,
className,
Icon,
}: {
id: string;
children?: React.ReactNode;
className?: string;
Icon?: React.ReactNode;
}) => {
const [isDeleting, setIsDeleting] = useState(false);
const router = useRouter();
const handleDelete = async (id: string) => {
setIsDeleting(true);
await deleteLineItem(id).catch((err) => {
try {
await deleteLineItem(id);
router.refresh();
} catch (err) {
// TODO: display a toast notification with the error
setIsDeleting(false);
});
}
};
return (
@@ -34,7 +44,7 @@ const DeleteButton = ({
className="flex gap-x-1 text-ui-fg-subtle hover:text-ui-fg-base cursor-pointer"
onClick={() => handleDelete(id)}
>
{isDeleting ? <Spinner className="animate-spin" /> : <Trash />}
{isDeleting ? <Spinner className="animate-spin" /> : (Icon ?? <Trash />)}
<span>{children}</span>
</button>
</div>