diff --git a/_dev/js/theme/core/cart/handler/cart/addToCartHandler.js b/_dev/js/theme/core/cart/handler/cart/addToCartHandler.js index e20325d1..82ad31a6 100644 --- a/_dev/js/theme/core/cart/handler/cart/addToCartHandler.js +++ b/_dev/js/theme/core/cart/handler/cart/addToCartHandler.js @@ -6,9 +6,11 @@ import sprintf from '../../../../utils/sprintf'; const { danger } = useAlertToast(); /** - * Handle add to cart event on form submit - * @param event {Event} - submit event - * @returns {Promise} + * Handles the "add to cart" event on form submission, updating the cart accordingly. + * @param {Event} event - The submit event that triggered the "add to cart" action. + * @param {HTMLElement} event.delegateTarget - The form element that was submitted. + * @throws {Error} Will throw an error if required data is missing or if an error occurs during the process. + * @returns {Promise} - A Promise that resolves once the "add to cart" process is complete. */ const addToCartHandler = async (event) => { event.preventDefault(); diff --git a/_dev/js/theme/core/cart/handler/cart/deleteFromCartHandler.js b/_dev/js/theme/core/cart/handler/cart/deleteFromCartHandler.js index e5a26a4c..02a1723a 100644 --- a/_dev/js/theme/core/cart/handler/cart/deleteFromCartHandler.js +++ b/_dev/js/theme/core/cart/handler/cart/deleteFromCartHandler.js @@ -2,9 +2,11 @@ import prestashop from 'prestashop'; import deleteFromCartRequest from '../../request/cart/deleteFromCartRequest'; /** - * Delete product from cart handler - * @param event {Event} - event object - * @returns {Promise} + * Handles the deletion of a product from the cart. + * @param {Event} event - The event object that triggered the product deletion. + * @param {HTMLElement} event.delegateTarget - The target element that was clicked. + * @throws {Error} Will throw an error if required data is missing or if an error occurs during the deletion process. + * @returns {Promise} - A Promise that resolves once the deletion process is complete. */ const deleteFromCartHandler = async (event) => { event.preventDefault(); diff --git a/_dev/js/theme/core/cart/handler/cart/quantityChangeHandler.js b/_dev/js/theme/core/cart/handler/cart/quantityChangeHandler.js index f2b797c9..80e781a7 100644 --- a/_dev/js/theme/core/cart/handler/cart/quantityChangeHandler.js +++ b/_dev/js/theme/core/cart/handler/cart/quantityChangeHandler.js @@ -5,10 +5,12 @@ import cartStateStore from '../../store/cartStateStore'; const { setIsUpdateOperation, setHasError, setErrorMsg } = cartStateStore(); /** - * @param {string} operation - increase|decrease - * @param {number} qtyDifference - quantity difference - * @param {HTMLElement} input - input element - * @returns {Promise} + * Handles the change in quantity for a product in the cart. + * @param {string} operation - The type of quantity change ('increase' or 'decrease'). + * @param {number} qtyDifference - The quantity difference. + * @param {HTMLElement} input - The input element triggering the quantity change. + * @throws {Error} Will throw an error if required data is missing or if an error occurs during the quantity change process. + * @returns {Promise} - A Promise that resolves once the quantity change process is complete. */ const quantityChangeHandler = async (operation, qtyDifference, input) => { const { dataset } = input; diff --git a/_dev/js/theme/core/cart/handler/cart/updateCartHandler.js b/_dev/js/theme/core/cart/handler/cart/updateCartHandler.js index 6fbb57b6..443a1418 100644 --- a/_dev/js/theme/core/cart/handler/cart/updateCartHandler.js +++ b/_dev/js/theme/core/cart/handler/cart/updateCartHandler.js @@ -3,9 +3,11 @@ import parseToHtml from '../../../../utils/parseToHtml'; import updateCartContentRequest from '../../request/cart/updateCartContentRequest'; /** - * Update cart handler - update cart content and emit updatedCart event - * @param {object} event - update cart event object - * @returns {Promise} + * Handles the update of the cart content and emits the 'updatedCart' event. + * @param {object} event - The update cart event object. + * @param {object} event.resp - The response object containing updated cart data. + * @throws {Error} Will throw an error if an error occurs during the cart update process. + * @returns {Promise} - A Promise that resolves once the cart update process is complete. */ const updateCartHandler = async (event) => { prestashop.cart = event.resp.cart; diff --git a/_dev/js/theme/core/cart/handler/cart/updatedCartHandler.js b/_dev/js/theme/core/cart/handler/cart/updatedCartHandler.js index 4f143b59..92d85096 100644 --- a/_dev/js/theme/core/cart/handler/cart/updatedCartHandler.js +++ b/_dev/js/theme/core/cart/handler/cart/updatedCartHandler.js @@ -1,5 +1,5 @@ /** - * Updated cart handler + * Handles the completion of the cart update process. */ const updatedCartHandler = () => { document.querySelector('body').classList.remove('cart-loading');