saleStatisticsActions.js 1.12 KB
/**
 * # guideActions.js
 *
 * App user guide
 *
 */
'use strict';

import {Actions} from 'react-native-router-flux';
import CONFIG from '../../constants/config';
import HomeService from '../../services/HomeService';

const {

	SALE_STATS_REQUEST,
	SALE_STATS_SUCCESS,
	SALE_STATS_FAILURE,
	SALE_STATS_CLEAN,

} = require('../../constants/actionTypes').default;

export function saleStatsRequest(params) {
    return {
        type: SALE_STATS_REQUEST,
        payload: params
    };
}

export function saleStatsSuccess(json) {
    return {
        type: SALE_STATS_SUCCESS,
        payload: json
    };
}

export function saleStatsFailure(error) {
    return {
        type: SALE_STATS_FAILURE,
        payload: error
    };
}

export function saleStats(params) {

	return dispatch => {
		dispatch(saleStatsRequest(params));
        return new HomeService().saleStats(params)
            .then(json => {
                dispatch(saleStatsSuccess(json));
            })
            .catch(error => {
                dispatch(saleStatsFailure(error));
            });
	};

}

export function saleStatsClean() {
	return {
		type: SALE_STATS_CLEAN,
	}
}