Skip to content

Commit

Permalink
Replace fetcher in pagesPublished grid config
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Jul 26, 2024
1 parent f3bbfe4 commit 7d0a276
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions client/src/components/Grid/configs/pagesPublished.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import { faEye, faPlus } from "@fortawesome/free-solid-svg-icons";
import { useEventBus } from "@vueuse/core";

import { fetcher } from "@/api/schema";
import { client } from "@/api";
import Filtering, { contains, type ValidFilter } from "@/utils/filtering";
import { rethrowSimple } from "@/utils/simple-error";

import { type ActionArray, type FieldArray, type GridConfig } from "./types";

const { emit } = useEventBus<string>("grid-router-push");

/**
* Api endpoint handlers
*/
const getPages = fetcher.path("/api/pages").method("get").create();

/**
* Local types
*/
Expand All @@ -23,17 +19,26 @@ type PageEntry = Record<string, unknown>;
* Request and return data from server
*/
async function getData(offset: number, limit: number, search: string, sort_by: string, sort_desc: boolean) {
const { data, headers } = await getPages({
limit,
offset,
search,
sort_by: sort_by as SortKeyLiteral,
sort_desc,
show_own: false,
show_published: true,
show_shared: true,
const { response, data, error } = await client.GET("/api/pages", {
params: {
query: {
limit,
offset,
search,
sort_by: sort_by as SortKeyLiteral,
sort_desc,
show_own: false,
show_published: true,
show_shared: true,
},
},
});
const totalMatches = parseInt(headers.get("total_matches") ?? "0");

if (error) {
rethrowSimple(error);
}

const totalMatches = parseInt(response.headers.get("total_matches") ?? "0");
return [data, totalMatches];
}

Expand Down

0 comments on commit 7d0a276

Please sign in to comment.