From e4bbb9cf1b1918ce33e6c2ee22acf17b49d0fcd1 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 2 Aug 2024 11:19:10 +0700 Subject: add delete all cart button --- src-migrate/pages/shop/cart/index.tsx | 58 +++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 13 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/pages/shop/cart/index.tsx b/src-migrate/pages/shop/cart/index.tsx index 0eb9c554..cb0156f1 100644 --- a/src-migrate/pages/shop/cart/index.tsx +++ b/src-migrate/pages/shop/cart/index.tsx @@ -2,7 +2,7 @@ import style from './cart.module.css'; import React, { useEffect, useMemo, useState } from 'react'; import Link from 'next/link'; -import { Button, Checkbox, Tooltip } from '@chakra-ui/react'; +import { Button, Checkbox, Spinner, Tooltip } from '@chakra-ui/react'; import { toast } from 'react-hot-toast'; import { useRouter } from 'next/router'; import { getAuth } from '~/libs/auth'; @@ -24,6 +24,7 @@ const CartPage = () => { const [isSelectedAll, setIsSelectedAll] = useState(false); const [isButtonChek, setIsButtonChek] = useState(false); const [buttonSelectNow, setButtonSelectNow] = useState(true); + const [isLoad, setIsLoad] = useState(false) const { loadCart, cart, summary } = useCartStore(); const useDivvice = useDevice(); @@ -69,7 +70,7 @@ const CartPage = () => { const handleChange = async (e: React.ChangeEvent) => { if (typeof auth !== 'object' || !cart) return; - + setIsLoad(true) const newSelected = e.target.checked; setIsSelectedAll(newSelected); @@ -83,23 +84,54 @@ const CartPage = () => { }); } await loadCart(auth.id); + setIsLoad(false) + } + + const handleDelete = () => { + console.log("delete data"); } return ( <>
Keranjang Belanja
-
- -

- {hasSelectedAll ? "Unchek all" : "Select all"} -

+
+
+ {isLoad && ( + + )} + {!isLoad && ( + + )} +

+ {hasSelectedAll ? "Unchek all" : "Select all"} +

+
+
+ + + +
-- cgit v1.2.3