@@ -18,7 +18,7 @@ function addToCart(id) { // Add product to cart function
1818 let product = getProductDetails ( Number ( id ) ) ; // Get the product details
1919
2020 if ( product . stock <= 0 ) { // If stock is 0 or less
21- notification ( `Il n'y a plus de stock dispo` ) ; // Alert the user with notification
21+ notification ( `Il n'y a plus de stock dispo` , `danger` ) ; // Alert the user with notification
2222 return ; // Return
2323 } else { // Otherwise
2424 product . stock -- ; // Decrease 1 to the product in cart
@@ -53,10 +53,10 @@ function addToCart(id) { // Add product to cart function
5353// All Functions
5454////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5555
56- function notification ( message ) { // Function to show notification
56+ function notification ( message , type = 'success' ) { // Function to show notification
5757 // Show notification
5858 document . querySelector ( '#notification_container' ) . innerHTML += `
59- <div class="content">
59+ <div class="content ${ type } ">
6060 <img src="https://img.icons8.com/color/48/000000/info.png" alt="">
6161 <p>${ message } </p>
6262 </div>
@@ -150,6 +150,7 @@ document.addEventListener('click', function (e) { // On click, execute the follo
150150
151151 localStorage . clear ( ) ; // Clear the localStorage
152152 document . querySelector ( '#cart-table tbody' ) . innerHTML = "" ; // Clear cart
153+ notification ( `Le panier à été totalement vidé` , `danger` ) ; // Alert the user with notification
153154
154155 } else if ( e . target . classList . contains ( 'fa-trash' ) ) { // If the user clicks on the fr-trash button, execute the following code
155156 //----------------------------------------------------//
@@ -168,10 +169,12 @@ document.addEventListener('click', function (e) { // On click, execute the follo
168169 if ( getItem . productsInCart <= 1 ) { // If only 1 product is in the cart
169170 localStorage . removeItem ( `inCart-${ idTrash } ` ) ; // Remove the product from the localStorage
170171 document . querySelector ( `.${ e . target . parentNode . parentNode . classList [ 0 ] } ` ) . remove ( ) ; // Remove the product from the cart
172+ notification ( `${ product . title } à totalement été supprimé du panier` , `danger` ) ; // Alert the user with notification
171173 } else { // Otherwise
172174 getItem . productsInCart -- ; // Decrease 1 to the product in cart
173175 localStorage . setItem ( `inCart-${ idTrash } ` , JSON . stringify ( getItem ) ) ; // Remove the product from the localStorage
174176 document . querySelector ( `.${ product . slug } -inCart` ) . innerHTML = getItem . productsInCart ; // Remove the product from the cart
177+ notification ( `1 cours "${ product . title } " à été supprimé du panier` , `danger` ) ; // Alert the user with notification
175178 }
176179 } else if ( e . target . classList . contains ( 'noteOrdre' ) ) { // If the user clicks on the noteOrdre button, execuse the following code
177180 filtre ( "noteCroissant" ) ;
0 commit comments