refine-jsonapi
Version:
Data provider for refine with JSON:API specification. refine is a React-based framework for building internal tools, rapidly. JSON:API is a specification for building apis in JSON.
22 lines (17 loc) • 414 B
text/typescript
import { CrudSorting } from "@refinedev/core";
export const generateSort = (sorters?: CrudSorting) => {
if (sorters && sorters.length > 0) {
const _sort: string[] = [];
sorters.map((item) => {
if (item.order === "desc") {
_sort.push(`-${item.field}`);
} else {
_sort.push(item.field);
}
});
return {
_sort,
};
}
return;
};