From 7bec0ceaa7de91f1ba1c9ef18fca3c53d9a7155a Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 12 Jul 2024 16:52:14 +0700
Subject: <iman> update bug button quotation on cart

---
 src-migrate/pages/shop/cart/index.tsx | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

(limited to 'src-migrate/pages/shop/cart/index.tsx')

diff --git a/src-migrate/pages/shop/cart/index.tsx b/src-migrate/pages/shop/cart/index.tsx
index d89707d2..7de96425 100644
--- a/src-migrate/pages/shop/cart/index.tsx
+++ b/src-migrate/pages/shop/cart/index.tsx
@@ -2,8 +2,9 @@ import style from './cart.module.css';
 
 import React, { useEffect, useMemo } from 'react';
 import Link from 'next/link';
-import { Button, Tooltip } from '@chakra-ui/react';
-
+import { Button, Toast, Tooltip } from '@chakra-ui/react';
+import { toast } from 'react-hot-toast';
+import { useRouter } from 'next/router';
 import { getAuth } from '~/libs/auth';
 import { useCartStore } from '~/modules/cart/stores/useCartStore';
 
@@ -15,6 +16,7 @@ import CartSummaryMobile from '~/modules/cart/components/CartSummaryMobile';
 import Image from '~/components/ui/image';
 
 const CartPage = () => {
+  const router = useRouter();
   const auth = getAuth();
   const [isStepApproval, setIsStepApproval] = React.useState(false);
 
@@ -52,6 +54,18 @@ const CartPage = () => {
     }
     return false;
   }, [cart]);
+  
+  const handleCheckout = (()=>{
+      router.push('/shop/checkout');
+  })
+
+  const handleQuotation = (()=>{
+    if(hasSelectedPromo || !hasSelected){
+      toast.error('Maaf, Barang promo tidak dapat dibuat quotation');
+    }else{
+      router.push('/shop/quotation');
+    }
+  })
 
   return (
     <>
@@ -121,8 +135,7 @@ const CartPage = () => {
                   colorScheme='yellow'
                   w='full'
                   isDisabled={hasSelectedPromo || !hasSelected}
-                  as={Link}
-                  href='/shop/quotation'
+                  onClick={handleQuotation}
                 >
                   Quotation
                 </Button>
@@ -138,8 +151,7 @@ const CartPage = () => {
                     colorScheme='red'
                     w='full'
                     isDisabled={!hasSelected || hasSelectNoPrice}
-                    as={Link}
-                    href='/shop/checkout'
+                    onClick={handleCheckout}
                   >
                     Checkout
                   </Button>
-- 
cgit v1.2.3

