From bcbe987497ecde3b31411aa3d35c5ae96867983c Mon Sep 17 00:00:00 2001 From: Ainun Nadhifah Syamsiyah Date: Mon, 2 Dec 2024 01:23:20 +0700 Subject: [PATCH] fix: cart cant checkout one item --- resources/js/Pages/Cart/Index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/js/Pages/Cart/Index.tsx b/resources/js/Pages/Cart/Index.tsx index 7b3a207..c7e39ce 100644 --- a/resources/js/Pages/Cart/Index.tsx +++ b/resources/js/Pages/Cart/Index.tsx @@ -27,7 +27,13 @@ const CartIndex = ({ cart }: { cart: CartType[] }) => { const readyToCheckout = cart.filter((item) => checkedOut.includes(item.id.toString())) ?? []; - transform((data) => ({ ...data, ...getValues() })); + transform((data) => ({ + ...data, + product_id: + typeof getValues("product_id") === "string" + ? [getValues("product_id")] + : getValues("product_id"), + })); const onSubmit: SubmitHandler = async () => { post(route("cart.checkout"), {