getters.ts 438 Bytes
import { QueryForPaginationParams, Sort } from '@/types/global';

export function getSort(state: any): Sort {
  return state.sort;
}

export function getQuery(state: any): QueryForPaginationParams {
  const { current, pageSize } = state.pagination;
  const { column, type } = state.sort;

  return {
    ...state.filter,
    page: current,
    pageSize,
    sortBy: column,
    sortType: type.replace('end', '') as 'desc' | 'asc',
  };
}