import * as types from '../constants/actionTypes';

const actions: ActionType = (dispatch) => ({
  setTotalPage: (page) =>
    dispatch({ type: types.SET_TOTAL_PAGE, payload: page }),
  setCurrentPage: (page) =>
    dispatch({ type: types.SET_CURRENT_PAGE, payload: page }),
  setPdf: (pdf) => dispatch({ type: types.SET_PDF, payload: pdf }),
  setProgress: (progress) =>
    dispatch({ type: types.SET_PROGRESS, payload: progress }),
  setViewport: (viewport) =>
    dispatch({ type: types.SET_VIEWPORT, payload: viewport }),
  changeScale: (scale) =>
    dispatch({ type: types.CHANGE_SCALE, payload: scale }),
  changeRotate: (rotation) =>
    dispatch({ type: types.CHANGE_ROTATE, payload: rotation }),
  addAnnots: (annotations, init = true) =>
    dispatch({ type: types.ADD_ANNOTS, payload: { annotations, init } }),
  updateAnnots: (annotations) =>
    dispatch({ type: types.UPDATE_ANNOTS, payload: annotations }),
  updateWatermark: (watermark) =>
    dispatch({ type: types.UPDATE_WATERMARK, payload: watermark }),
});

export default actions;
