Skip to content

Commit

Permalink
reorg: move new components to shared lib
Browse files Browse the repository at this point in the history
  • Loading branch information
SaraVieira authored and skeptrunedev committed Sep 13, 2024
1 parent 2a8b7f6 commit bdf2587
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
5 changes: 2 additions & 3 deletions frontends/analytics/src/components/charts/RagQueries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ import { getRAGQueries } from "../../api/analytics";
import { DatasetContext } from "../../layouts/TopBarLayout";
import { usePagination } from "../../hooks/usePagination";
import { ChartCard } from "./ChartCard";
import { Select } from "shared/ui";
import { Select, TanStackTable } from "shared/ui";
import { ALL_FAKE_RAG_OPTIONS } from "../../pages/RagAnalyticsPage";
import { FullScreenModal, JSONMetadata } from "shared/ui";
import { IoOpenOutline } from "solid-icons/io";
import { Table } from "../Table";

interface RagQueriesProps {
filter: RAGAnalyticsFilter;
Expand Down Expand Up @@ -189,7 +188,7 @@ export const RagQueries = (props: RagQueriesProps) => {
data={data()[current()].results}
/>
</FullScreenModal>
<Table
<TanStackTable
pages={pages}
perPage={10}
total={usage?.total_queries}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { usePagination } from "../hooks/usePagination";
import { Accessor } from "solid-js";
import { IoChevronBack, IoChevronForward } from "solid-icons/io";

interface PaginationProps {
pages: ReturnType<typeof usePagination>;
pages: {
page: Accessor<number>;
nextPage: () => void;
prevPage: () => void;
canGoNext: Accessor<boolean>;
};
total?: number;
perPage?: number;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { flexRender, type Table as TableType } from "@tanstack/solid-table";
import { Pagination } from "./Pagination";
import { For } from "solid-js";
import { Accessor, For } from "solid-js";
import { cn } from "shared/utils";
import { usePagination } from "../hooks/usePagination";
import { Pagination } from "shared/ui";

type TableProps = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
table: TableType<any>;
pages: ReturnType<typeof usePagination>;
pages: {
page: Accessor<number>;
nextPage: () => void;
prevPage: () => void;
canGoNext: Accessor<boolean>;
};
total?: number;
perPage?: number;
};

export const Table = (props: TableProps) => {
export const TanStackTable = (props: TableProps) => {
return (
<>
<table class="min-w-full border-separate border-spacing-0">
Expand All @@ -27,7 +31,7 @@ export const Table = (props: TableProps) => {
? null
: flexRender(
header.column.columnDef.header,
header.getContext(),
header.getContext()
)}
</th>
)}
Expand All @@ -47,12 +51,12 @@ export const Table = (props: TableProps) => {
idx() !== props.table.getRowModel().rows.length - 1
? "border-b border-neutral-200"
: "",
"whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-neutral-900 sm:pl-6 lg:pl-8",
"whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-neutral-900 sm:pl-6 lg:pl-8"
)}
>
{flexRender(
cell.column.columnDef.cell,
cell.getContext(),
cell.getContext()
)}
</td>
)}
Expand Down
2 changes: 2 additions & 0 deletions frontends/shared/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export * from "./Table";
export * from "./DateRangePicker";
export * from "./JsonInput";
export * from "./JSONMetadata";
export * from "./Pagination";
export * from "./TanStackTable";

0 comments on commit bdf2587

Please sign in to comment.