@@ -3,6 +3,7 @@ import { AppContext } from '../context';
3
3
import CartItem from './cart-item' ;
4
4
5
5
import Link from 'next/link' ;
6
+ import { clearCart } from '../../utils/cart' ;
6
7
7
8
const CartItemsContainer = ( ) => {
8
9
const [ cart , setCart ] = useContext ( AppContext ) ;
@@ -40,18 +41,12 @@ const CartItemsContainer = () => {
40
41
const handleClearCart = ( event ) => {
41
42
event . stopPropagation ( ) ;
42
43
43
- // if (isClearCartProcessing) {
44
- // return;
45
- // }
46
- //
47
- // clearCart({
48
- // variables: {
49
- // input: {
50
- // clientMutationId: v4(),
51
- // all: true,
52
- // },
53
- // },
54
- // });
44
+ if ( isClearCartProcessing ) {
45
+ return ;
46
+ }
47
+
48
+ clearCart ( setCart , setClearCartProcessing ) ;
49
+
55
50
} ;
56
51
57
52
return (
@@ -73,46 +68,44 @@ const CartItemsContainer = () => {
73
68
</ div >
74
69
75
70
{ /*Cart Total*/ }
76
- < div className = "woo-next-cart-total-container lg:col-span-1 p-5" >
71
+ < div className = "woo-next-cart-total-container lg:col-span-1 p-5 pt-0 " >
77
72
< h2 > Cart Total</ h2 >
78
- < table className = "table table-hover" >
79
- < tbody >
80
- < tr className = "table-light" >
81
- < td className = "woo-next-cart-element-total" > Total</ td >
82
- < td className = "woo-next-cart-element-amt" > { totalPrice } </ td >
83
- </ tr >
84
- </ tbody >
85
- </ table >
86
- < Link href = "/checkout" >
87
- < button className = "btn btn-dark woo-next-large-black-btn" >
73
+ < div className = "flex grid grid-cols-3 bg-gray-100 mb-4" >
74
+ < p className = "col-span-2 p-2 mb-0" > Total</ p >
75
+ < p className = "col-span-1 p-2 mb-0" > { totalPrice } </ p >
76
+ </ div >
77
+
78
+ < div className = "flex justify-between" >
79
+ { /*Clear entire cart*/ }
80
+ < div className = "clear-cart" >
81
+ < button
82
+ className = "text-gray-900 bg-white border border-gray-300 hover:bg-gray-100 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2 dark:bg-gray-600 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-700 dark:focus:ring-gray-800"
83
+ onClick = { ( event ) => handleClearCart ( event ) }
84
+ disabled = { isClearCartProcessing }
85
+ >
86
+ < span className = "woo-next-cart" > { ! isClearCartProcessing ? "Clear Cart" : "Clearing..." } </ span >
87
+ </ button >
88
+ </ div >
89
+ { /*Checkout*/ }
90
+ < Link href = "/checkout" >
91
+ < button className = "text-white duration-500 bg-brand-orange hover:bg-brand-royal-blue focus:ring-4 focus:text-brand-gunsmoke-grey font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2 dark:focus:ring-yellow-900" >
88
92
< span className = "woo-next-cart-checkout-txt" >
89
93
Proceed to Checkout
90
94
</ span >
91
- < i className = "fas fa-long-arrow-alt-right" />
92
- </ button >
93
- </ Link >
94
- { /*Clear entire cart*/ }
95
- < div className = "clear-cart" >
96
- < button
97
- className = "btn btn-light "
98
- onClick = { ( event ) => handleClearCart ( event ) }
99
- disabled = { isClearCartProcessing }
100
- >
101
- < span className = "woo-next-cart" > Clear Cart</ span >
102
- < i className = "fa fa-arrow-alt-right" />
103
- </ button >
104
- { isClearCartProcessing ? < p > Clearing...</ p > : "" }
95
+ < i className = "fas fa-long-arrow-alt-right" />
96
+ </ button >
97
+ </ Link >
105
98
</ div >
106
99
</ div >
107
100
</ div >
108
101
) : (
109
- < div className = "container mt-5" style = { { height : '72vh' } } >
102
+ < div className = "mt-14" >
110
103
< h2 > No items in the cart</ h2 >
111
104
< Link href = "/" >
112
- < button className = "btn btn-secondary woo-next-large-black-btn " >
113
- < span className = "woo-next-cart-checkout-txt" >
114
- Add New Products
115
- </ span >
105
+ < button className = "text-white duration-500 bg-brand-orange hover:bg-brand-royal-blue font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2 dark:focus:ring-yellow-900 " >
106
+ < span className = "woo-next-cart-checkout-txt" >
107
+ Add New Products
108
+ </ span >
116
109
< i className = "fas fa-long-arrow-alt-right" />
117
110
</ button >
118
111
</ Link >
0 commit comments