{"size": 1280, "ext": "js", "max_stars_repo_path": "samuilivanov23-internet_shop/frontend/src/Components/actions/CartActions.js", "max_stars_repo_name": "samuilivanov23/training-projects", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "samuilivanov23-internet_shop/frontend/src/Components/actions/CartActions.js", "max_issues_repo_name": "samuilivanov23/training-projects", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "samuilivanov23-internet_shop/frontend/src/Components/actions/CartActions.js", "max_forks_repo_name": "samuilivanov23/training-projects", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 35.5555555556, "max_line_length": 116, "alphanum_fraction": 0.60859375}
const AllCartProducts = (cart_products_data) => async (dispatch) => {
    console.log('AllCartProducts action');
    dispatch({type : 'ADD_ALL_PRODUCTS_TO_CART', data: cart_products_data});
}

const AddProductToCart = (id, name, description, price, selected_count, count, image) => async (dispatch) => {
    console.log('AddProductToCart action');
    
    selected_count = parseInt(selected_count);
    dispatch( { type : 'ADD_PRODUCT_TO_CART', 
                data: {
                    id, 
                    name, 
                    description, 
                    price, 
                    selected_count,
                    count,
                    image
                }
    });
}

const ChangeSelectedCount = (id, name, description, price, selected_count, count, image) => async(dispatch) => {
    console.log('ChangeSelectedCount action');

    selected_count = parseInt(selected_count);
    dispatch({type : 'CHANGE_SELECTED_COUNT', data : {id, name, description, price, selected_count, count, image}});
}

//Remove all items from cart on checkout
const EmptyCart = () => async (dispatch) => {
    console.log('EmptyCar action');
    dispatch({type : 'EMPTY_CAR', data : []});
}

export { AllCartProducts, AddProductToCart, ChangeSelectedCount, EmptyCart }