Skip to content

Commit

Permalink
Replace fetcher in visualizations grid config
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Jul 26, 2024
1 parent e2a1c11 commit 741bb62
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions client/src/components/Grid/configs/visualizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { faCopy, faEdit, faEye, faPlus, faShareAlt, faTrash, faTrashRestore } fr
import { useEventBus } from "@vueuse/core";
import axios from "axios";

import { fetcher } from "@/api/schema";
import { client } from "@/api";
import { updateTags } from "@/api/tags";
import Filtering, { contains, equals, expandNameTag, toBool, type ValidFilter } from "@/utils/filtering";
import { withPrefix } from "@/utils/redirect";
Expand All @@ -12,11 +12,6 @@ import { type ActionArray, type FieldArray, type GridConfig } from "./types";

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

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

/**
* Local types
*/
Expand All @@ -27,17 +22,26 @@ type VisualizationEntry = 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 getVisualizations({
limit,
offset,
search,
sort_by: sort_by as SortKeyLiteral,
sort_desc,
show_published: false,
show_own: true,
show_shared: false,
const { response, data, error } = await client.GET("/api/visualizations", {
params: {
query: {
limit,
offset,
search,
sort_by: sort_by as SortKeyLiteral,
sort_desc,
show_published: false,
show_own: true,
show_shared: false,
},
},
});
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 741bb62

Please sign in to comment.