From 4ee24671bc23979d7ac18a5390082c0007928540 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 16 Jul 2024 15:17:17 +0700 Subject: add select all cart --- src-migrate/pages/shop/cart/index.tsx | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'src-migrate/pages') diff --git a/src-migrate/pages/shop/cart/index.tsx b/src-migrate/pages/shop/cart/index.tsx index 7de96425..1f89c7a3 100644 --- a/src-migrate/pages/shop/cart/index.tsx +++ b/src-migrate/pages/shop/cart/index.tsx @@ -1,8 +1,8 @@ import style from './cart.module.css'; -import React, { useEffect, useMemo } from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; import Link from 'next/link'; -import { Button, Toast, Tooltip } from '@chakra-ui/react'; +import { Button, Checkbox, Toast, Tooltip } from '@chakra-ui/react'; import { toast } from 'react-hot-toast'; import { useRouter } from 'next/router'; import { getAuth } from '~/libs/auth'; @@ -19,6 +19,9 @@ const CartPage = () => { const router = useRouter(); const auth = getAuth(); const [isStepApproval, setIsStepApproval] = React.useState(false); + const [isSelectedAll, setIsSelectedAll] = useState(false); + const [isButtonChek, setIsButtonChek] = useState(false); + const [buttonSelectNow, setButtonSelectNow] = useState(true); const { loadCart, cart, summary } = useCartStore(); @@ -29,8 +32,9 @@ const CartPage = () => { loadCart(auth.id); setIsStepApproval(auth?.feature?.soApproval); } - }, [auth, loadCart, cart]); - + }, [auth, loadCart, cart, isButtonChek, ]); + + const hasSelectedPromo = useMemo(() => { if (!cart) return false; for (const item of cart.products) { @@ -67,10 +71,26 @@ const CartPage = () => { } }) + const handleChange = (()=>{ + setButtonSelectNow(!buttonSelectNow) + setIsSelectedAll(!isSelectedAll) + setIsButtonChek(!isButtonChek) + }) + return ( <>
Keranjang Belanja
- +
+

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

+
@@ -81,8 +101,9 @@ const CartPage = () => {
{cart?.products.map((item) => ( - + ))} + {cart?.products?.length === 0 && (
-- cgit v1.2.3