Skip to content

Commit

Permalink
jsdocs for product handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Oksydan committed Oct 1, 2023
1 parent c55cdfc commit 7591d7d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import productStateStore from '../../store/productStateStore';

const { setFormChanged } = productStateStore();

/**
* Sets the form changed state
* Side effect: emits 'updateProduct' event
* @param event {Event}
*/
const productFormChangeHandler = (event) => {
setFormChanged(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ const { setOnPopState, isFormChanged } = productStateStore();

const { get } = productFormDataPersister();

/**
* Handle popstate event for product page
* Side effect: emits 'updateProduct' event, sets popState in productStateStore
* @param {Event} event
*/
const productPopStateHandler = (event) => {
setOnPopState(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import useAlertToast from '../../../../components/useAlertToast';

const { danger } = useAlertToast();

/**
* Handle product update error
* @param event
*/
const productUpdateErrorHandler = (event) => {
if (event?.errorMessage) {
danger(event.errorMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import productStateStore from '../../store/productStateStore';

const { isOnPopState, setOnPopState } = productStateStore();

/**
* Handle updated product on 'updatedProduct' event
* Side effect: changes the url and title, sets popState in productStateStore
* @param event - event object with response data
* @param formData - form data
*/
const updatedProductHandler = ({
product_url: responseProductUrl = null,
id_product_attribute: responseIdProductAttribute = null,
Expand Down
5 changes: 5 additions & 0 deletions _dev/js/theme/core/product/productController.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import productFormChangeHandler from './handler/product/productFormChangeHandler
const { on } = useEvent();
const { persist } = productFormDataPersister();

/**
* Persists form data on init
* Side effect: set formData in productFormDataPersister
* @return {void}
*/
const persistFormDataOnInit = () => {
const form = document.querySelector(`${prestashop.selectors.product.actions} form`);

Expand Down

0 comments on commit 7591d7d

Please sign in to comment.