-
{option.title}
-
- {option.description}
-
+
+
{option.title}
+
+ {option.description}
diff --git a/src/components/ui/data-table.tsx b/src/components/ui/data-table.tsx
index ae94b12e..fde1f12b 100644
--- a/src/components/ui/data-table.tsx
+++ b/src/components/ui/data-table.tsx
@@ -20,7 +20,7 @@ import {
TableRow
} from "@/components/ui/table";
import { Button } from "@app/components/ui/button";
-import { useEffect, useMemo, useState } from "react";
+import { useState } from "react";
import { Input } from "@app/components/ui/input";
import { DataTablePagination } from "@app/components/DataTablePagination";
import { Plus, Search, RefreshCw } from "lucide-react";
@@ -32,42 +32,7 @@ import {
} from "@app/components/ui/card";
import { Tabs, TabsList, TabsTrigger } from "@app/components/ui/tabs";
import { useTranslations } from "next-intl";
-
-const STORAGE_KEYS = {
- PAGE_SIZE: 'datatable-page-size',
- getTablePageSize: (tableId?: string) =>
- tableId ? `${tableId}-size` : STORAGE_KEYS.PAGE_SIZE
-};
-
-const getStoredPageSize = (tableId?: string, defaultSize = 20): number => {
- if (typeof window === 'undefined') return defaultSize;
-
- try {
- const key = STORAGE_KEYS.getTablePageSize(tableId);
- const stored = localStorage.getItem(key);
- if (stored) {
- const parsed = parseInt(stored, 10);
- // Validate that it's a reasonable page size
- if (parsed > 0 && parsed <= 1000) {
- return parsed;
- }
- }
- } catch (error) {
- console.warn('Failed to read page size from localStorage:', error);
- }
- return defaultSize;
-};
-
-const setStoredPageSize = (pageSize: number, tableId?: string): void => {
- if (typeof window === 'undefined') return;
-
- try {
- const key = STORAGE_KEYS.getTablePageSize(tableId);
- localStorage.setItem(key, pageSize.toString());
- } catch (error) {
- console.warn('Failed to save page size to localStorage:', error);
- }
-};
+import { useMemo } from "react";
type TabFilter = {
id: string;
@@ -91,8 +56,6 @@ type DataTableProps
= {
};
tabs?: TabFilter[];
defaultTab?: string;
- persistPageSize?: boolean | string;
- defaultPageSize?: number;
};
export function DataTable({
@@ -107,23 +70,8 @@ export function DataTable({
searchColumn = "name",
defaultSort,
tabs,
- defaultTab,
- persistPageSize = false,
- defaultPageSize = 20
+ defaultTab
}: DataTableProps) {
- const t = useTranslations();
-
- // Determine table identifier for storage
- const tableId = typeof persistPageSize === 'string' ? persistPageSize : undefined;
-
- // Initialize page size from storage or default
- const [pageSize, setPageSize] = useState(() => {
- if (persistPageSize) {
- return getStoredPageSize(tableId, defaultPageSize);
- }
- return defaultPageSize;
- });
-
const [sorting, setSorting] = useState(
defaultSort ? [defaultSort] : []
);
@@ -132,6 +80,7 @@ export function DataTable({
const [activeTab, setActiveTab] = useState(
defaultTab || tabs?.[0]?.id || ""
);
+ const t = useTranslations();
// Apply tab filter to data
const filteredData = useMemo(() => {
@@ -159,7 +108,7 @@ export function DataTable({
onGlobalFilterChange: setGlobalFilter,
initialState: {
pagination: {
- pageSize: pageSize,
+ pageSize: 20,
pageIndex: 0
}
},
@@ -170,35 +119,12 @@ export function DataTable({
}
});
- useEffect(() => {
- const currentPageSize = table.getState().pagination.pageSize;
- if (currentPageSize !== pageSize) {
- table.setPageSize(pageSize);
-
- // Persist to localStorage if enabled
- if (persistPageSize) {
- setStoredPageSize(pageSize, tableId);
- }
- }
- }, [pageSize, table, persistPageSize, tableId]);
-
const handleTabChange = (value: string) => {
setActiveTab(value);
// Reset to first page when changing tabs
table.setPageIndex(0);
};
- // Enhanced pagination component that updates our local state
- const handlePageSizeChange = (newPageSize: number) => {
- setPageSize(newPageSize);
- table.setPageSize(newPageSize);
-
- // Persist immediately when changed
- if (persistPageSize) {
- setStoredPageSize(newPageSize, tableId);
- }
- };
-
return (
@@ -309,10 +235,7 @@ export function DataTable({
-
+
diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts
index 5cef9f0e..edb281b7 100644
--- a/src/lib/api/index.ts
+++ b/src/lib/api/index.ts
@@ -22,7 +22,7 @@ export function createApiClient({ env }: { env: Env }): AxiosInstance {
axios.defaults.withCredentials = true;
} else {
// user is accessing through a proxy
- baseURL = `${env.app.dashboardUrl}/${suffix}`;
+ baseURL = window.location.origin + `/${suffix}`;
}
if (!baseURL) {
diff --git a/src/lib/parseHostTarget.ts b/src/lib/parseHostTarget.ts
index b860f410..c79c7aa3 100644
--- a/src/lib/parseHostTarget.ts
+++ b/src/lib/parseHostTarget.ts
@@ -1,29 +1,15 @@
-
export function parseHostTarget(input: string) {
try {
- const normalized = input.match(/^(https?|h2c):\/\//) ? input : `http://${input}`;
+ const normalized = input.match(/^https?:\/\//) ? input : `http://${input}`;
const url = new URL(normalized);
- const protocol = url.protocol.replace(":", ""); // http | https | h2c
+ const protocol = url.protocol.replace(":", ""); // http | https
const host = url.hostname;
-
- let defaultPort: number;
- switch (protocol) {
- case "https":
- defaultPort = 443;
- break;
- case "h2c":
- defaultPort = 80;
- break;
- default: // http
- defaultPort = 80;
- break;
- }
-
- const port = url.port ? parseInt(url.port, 10) : defaultPort;
+ const port = url.port ? parseInt(url.port, 10) : protocol === "https" ? 443 : 80;
return { protocol, host, port };
} catch {
return null;
}
}
+