diff --git a/web/src/actions/walletActions.js b/web/src/actions/walletActions.js index 5698ae3708..f98bb89721 100644 --- a/web/src/actions/walletActions.js +++ b/web/src/actions/walletActions.js @@ -7,6 +7,9 @@ export const ACTION_KEYS = { USER_TRADES_PENDING: 'USER_TRADES_PENDING', USER_TRADES_FULFILLED: 'USER_TRADES_FULFILLED', USER_TRADES_REJECTED: 'USER_TRADES_REJECTED', + ORDER_HISTORY_PENDING: 'ORDER_HISTORY_PENDING', + ORDER_HISTORY_FULFILLED: 'ORDER_HISTORY_FULFILLED', + ORDER_HISTORY_REJECTED: 'ORDER_HISTORY_REJECTED', USER_DEPOSITS_PENDING: 'USER_DEPOSITS_PENDING', USER_DEPOSITS_FULFILLED: 'USER_DEPOSITS_FULFILLED', USER_DEPOSITS_REJECTED: 'USER_DEPOSITS_REJECTED', @@ -178,6 +181,59 @@ export const getUserOrders = ({ }; }; +export const getOrdersHistory = ({ + symbol, + limit = 50, + page = 1, + start_date, + end_date, + open, + ...rest +}) => { + let dataParams = { page, limit }; + if (symbol) { + dataParams.symbol = symbol; + } + + if (start_date) { + dataParams.start_date = start_date; + } + + if (end_date) { + dataParams.end_date = end_date; + } + + if (open !== undefined) { + dataParams.open = open; + } + const query = querystring.stringify(dataParams); + + return (dispatch) => { + dispatch({ type: ACTION_KEYS.ORDER_HISTORY_PENDING, payload: { page } }); + axios + .get(`${ENDPOINTS.TRADES}?${query}`) + .then((body) => { + dispatch({ + type: ACTION_KEYS.ORDER_HISTORY_FULFILLED, + payload: { + ...body.data, + page, + isRemaining: body.data.count > page * limit, + }, + }); + // if (body.data.count > page * limit) { + // dispatch(getUserTrades({ symbol, limit, page: page + 1 })); + // } + }) + .catch((err) => { + dispatch({ + type: ACTION_KEYS.ORDER_HISTORY_REJECTED, + payload: err.response, + }); + }); + }; +}; + export const downloadUserTrades = (key) => { const query = querystring.stringify({ format: 'csv', diff --git a/web/src/components/Form/TradeFormFields/Clear.js b/web/src/components/Form/TradeFormFields/Clear.js index cbc233317f..5fea333416 100644 --- a/web/src/components/Form/TradeFormFields/Clear.js +++ b/web/src/components/Form/TradeFormFields/Clear.js @@ -5,7 +5,7 @@ const Clear = (props) => { const { onClick } = props; return ( -