Skip to content

Commit

Permalink
minor jsdocs changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Oksydan committed Oct 22, 2023
1 parent 2fd8850 commit 8fed5f9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
8 changes: 5 additions & 3 deletions _dev/js/theme/core/cart/handler/cart/addToCartHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>}
* 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<void>} - A Promise that resolves once the "add to cart" process is complete.
*/
const addToCartHandler = async (event) => {
event.preventDefault();
Expand Down
8 changes: 5 additions & 3 deletions _dev/js/theme/core/cart/handler/cart/deleteFromCartHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>}
* 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<void>} - A Promise that resolves once the deletion process is complete.
*/
const deleteFromCartHandler = async (event) => {
event.preventDefault();
Expand Down
10 changes: 6 additions & 4 deletions _dev/js/theme/core/cart/handler/cart/quantityChangeHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>}
* 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<void>} - A Promise that resolves once the quantity change process is complete.
*/
const quantityChangeHandler = async (operation, qtyDifference, input) => {
const { dataset } = input;
Expand Down
8 changes: 5 additions & 3 deletions _dev/js/theme/core/cart/handler/cart/updateCartHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>}
* 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<void>} - A Promise that resolves once the cart update process is complete.
*/
const updateCartHandler = async (event) => {
prestashop.cart = event.resp.cart;
Expand Down
2 changes: 1 addition & 1 deletion _dev/js/theme/core/cart/handler/cart/updatedCartHandler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Updated cart handler
* Handles the completion of the cart update process.
*/
const updatedCartHandler = () => {
document.querySelector('body').classList.remove('cart-loading');
Expand Down

0 comments on commit 8fed5f9

Please sign in to comment.