diff --git a/gui/app/(dashboard)/actions.ts b/gui/app/(dashboard)/actions.ts
index 0d9a88da68..5fd3c3281f 100644
--- a/gui/app/(dashboard)/actions.ts
+++ b/gui/app/(dashboard)/actions.ts
@@ -8,6 +8,8 @@ import {
ITableSegment
} from '@/lib/databse-interface';
import { drop, get, post } from '@/lib/request';
+import { isResponseListExist } from '@/lib/utils';
+import { unstable_rethrow } from 'next/navigation';
export const listDatabase = async () => {
try {
@@ -15,7 +17,8 @@ export const listDatabase = async () => {
console.log('🚀 ~ x:', x);
return x;
} catch (error) {
- console.log('🚀 ~ error:', error);
+ unstable_rethrow(error);
+ return { databases: [] };
}
};
@@ -142,6 +145,8 @@ export const showConfigs = async () => {
return x;
} catch (error) {
console.log('🚀 ~ error:', error);
+ unstable_rethrow(error);
+ return {};
}
};
@@ -150,16 +155,9 @@ export const showVariables = async () => {
const x = await get(`${ApiUrl.variables}/global`);
return x;
} catch (error) {
+ unstable_rethrow(error);
console.log('🚀 ~ error:', error);
- }
-};
-
-export const showCurrentNode = async () => {
- try {
- const x = await get(`${ApiUrl.variables}/global`);
- return x;
- } catch (error) {
- console.log('🚀 ~ error:', error);
+ return {};
}
};
@@ -174,11 +172,12 @@ export const showTableColumns = async ({
const x = await get(
`${ApiUrl.databases}/${database_name}/${ApiUrl.tables}/${table_name}/${ApiUrl.columns}`
);
- if (x.error_code === 0) {
+ if (isResponseListExist(x, 'columns')) {
return x.columns;
}
return [];
- } catch (error) {
+ } catch (error: unknown) {
+ console.log('🚀 ~ error:', error);
return [];
}
};
@@ -194,11 +193,12 @@ export const showTableIndexes = async ({
const x = await get(
`${ApiUrl.databases}/${database_name}/${ApiUrl.tables}/${table_name}/${ApiUrl.indexes}`
);
- if (x.error_code === 0) {
+ if (isResponseListExist(x, 'indexes')) {
return x.indexes;
}
return [];
- } catch (error) {
+ } catch (error: unknown) {
+ console.log('🚀 ~ error:', error);
return [];
}
};
@@ -214,11 +214,12 @@ export const showTableSegments = async ({
const x = await get(
`${ApiUrl.databases}/${database_name}/${ApiUrl.tables}/${table_name}/${ApiUrl.segments}`
);
- if (x.error_code === 0) {
+ if (isResponseListExist(x, 'segments')) {
return x?.segments ?? [];
}
return [];
- } catch (error) {
+ } catch (error: unknown) {
+ console.log('🚀 ~ error:', error);
return [];
}
};
diff --git a/gui/app/(dashboard)/database/[databaseId]/table/[tableId]/columns.tsx b/gui/app/(dashboard)/database/[databaseId]/table/[tableId]/columns.tsx
deleted file mode 100644
index 592a8cf9da..0000000000
--- a/gui/app/(dashboard)/database/[databaseId]/table/[tableId]/columns.tsx
+++ /dev/null
@@ -1,91 +0,0 @@
-import {
- Table,
- TableBody,
- TableCaption,
- TableCell,
- TableFooter,
- TableHead,
- TableHeader,
- TableRow
-} from '@/components/ui/table';
-import { DatabaseRouteParams } from 'app/(dashboard)/database/interface';
-
-const invoices = [
- {
- invoice: 'INV001',
- paymentStatus: 'Paid',
- totalAmount: '$250.00',
- paymentMethod: 'Credit Card'
- },
- {
- invoice: 'INV002',
- paymentStatus: 'Pending',
- totalAmount: '$150.00',
- paymentMethod: 'PayPal'
- },
- {
- invoice: 'INV003',
- paymentStatus: 'Unpaid',
- totalAmount: '$350.00',
- paymentMethod: 'Bank Transfer'
- },
- {
- invoice: 'INV004',
- paymentStatus: 'Paid',
- totalAmount: '$450.00',
- paymentMethod: 'Credit Card'
- },
- {
- invoice: 'INV005',
- paymentStatus: 'Paid',
- totalAmount: '$550.00',
- paymentMethod: 'PayPal'
- },
- {
- invoice: 'INV006',
- paymentStatus: 'Pending',
- totalAmount: '$200.00',
- paymentMethod: 'Bank Transfer'
- },
- {
- invoice: 'INV007',
- paymentStatus: 'Unpaid',
- totalAmount: '$300.00',
- paymentMethod: 'Credit Card'
- }
-];
-
-export function TableColumns({
- tableId,
- databaseId
-}: DatabaseRouteParams['params']) {
- return (
-
- TableColumns
-
-
- Invoice
- Status
- Method
- Amount
-
-
-
- {invoices.map((invoice) => (
-
- {invoice.invoice}
- {invoice.paymentStatus}
- {invoice.paymentMethod}
- {invoice.totalAmount}
-
- ))}
-
-
-
- Total
- $2,500.00
-
-
-
- );
-}
diff --git a/gui/app/(dashboard)/database/[databaseId]/table/[tableId]/page.tsx b/gui/app/(dashboard)/database/[databaseId]/table/[tableId]/page.tsx
index acf0a7dccf..f8a0ee0043 100644
--- a/gui/app/(dashboard)/database/[databaseId]/table/[tableId]/page.tsx
+++ b/gui/app/(dashboard)/database/[databaseId]/table/[tableId]/page.tsx
@@ -12,12 +12,16 @@ const TableMap = {
[Leaf.Segments]: TableSegments
};
+const Empty = () => {
+ return empty
;
+};
+
export default async function DatabasePage({
searchParams: { tab },
params: { tableId, databaseId }
}: DatabaseRouteParams) {
const DatabaseTable: React.FunctionComponent =
- TableMap[tab];
+ TableMap[tab] ?? Empty;
return (
diff --git a/gui/app/(dashboard)/database/hooks.ts b/gui/app/(dashboard)/database/hooks.ts
index b57ee89a83..80a9f56b46 100644
--- a/gui/app/(dashboard)/database/hooks.ts
+++ b/gui/app/(dashboard)/database/hooks.ts
@@ -39,7 +39,7 @@ export const useHandleClickTreeName = () => {
}
}
},
- []
+ [router]
);
return { handleClickTreeName };
@@ -55,7 +55,7 @@ export const useBuildTreeData = () => {
try {
setLoading(true);
const ret = await listDatabase();
- if (ret.databases.length > 0) {
+ if (ret.databases?.length > 0) {
setData(
updateTreeData(
[
@@ -125,7 +125,7 @@ export const useBuildTreeData = () => {
}, [fetchDatabases]);
const onLoadData = async ({ element }: { element: INode }) => {
- if (element.children.length > 0) {
+ if (element?.children?.length > 0) {
return;
}
@@ -157,7 +157,7 @@ export const useBuildTreeData = () => {
};
const wrappedOnLoadData = async (props: ITreeViewOnLoadDataProps) => {
- const nodeHasNoChildData = props.element.children.length === 0;
+ const nodeHasNoChildData = props.element.children?.length === 0;
const nodeHasAlreadyBeenLoaded = nodesAlreadyLoaded.find(
(e) => e.id === props.element.id
);
@@ -196,7 +196,7 @@ export const useFetchTableColumns = ({
});
setTableColumns(data);
- }, []);
+ }, [databaseId, tableId]);
useEffect(() => {
fetchTableColumns();
@@ -218,7 +218,7 @@ export const useFetchTableIndexes = ({
});
setTableIndexes(data);
- }, []);
+ }, [databaseId, tableId]);
useEffect(() => {
fetchTableIndexes();
@@ -240,7 +240,7 @@ export const useFetchTableSegments = ({
});
setTableSegments(data);
- }, []);
+ }, [databaseId, tableId]);
useEffect(() => {
fetchTableSegments();
diff --git a/gui/app/(dashboard)/database/layout.tsx b/gui/app/(dashboard)/database/layout.tsx
index d851c97548..e000712df5 100644
--- a/gui/app/(dashboard)/database/layout.tsx
+++ b/gui/app/(dashboard)/database/layout.tsx
@@ -9,7 +9,7 @@ export default async function DatabaseLayout({
children: React.ReactNode;
}) {
return (
-
+
diff --git a/gui/app/(dashboard)/database/tree.tsx b/gui/app/(dashboard)/database/tree.tsx
index a7cea43447..e2bf9b77a6 100644
--- a/gui/app/(dashboard)/database/tree.tsx
+++ b/gui/app/(dashboard)/database/tree.tsx
@@ -59,7 +59,7 @@ function AsyncTree() {
const branchNode = (isExpanded: boolean, element: INode) => {
return isExpanded &&
!element.metadata?.isEmpty &&
- element.children.length === 0 ? (
+ element.children?.length === 0 ? (
<>
{isBranch && branchNode(isExpanded, element)}
-
+
{renderIcon(level, element.name)}
{element.name}
diff --git a/gui/app/(dashboard)/databases/page.tsx b/gui/app/(dashboard)/databases/page.tsx
index 6d7c355fc6..ca7e4ab375 100644
--- a/gui/app/(dashboard)/databases/page.tsx
+++ b/gui/app/(dashboard)/databases/page.tsx
@@ -1,51 +1,18 @@
import { Card, CardHeader, CardTitle } from '@/components/ui/card';
import AddIcon from '/public/add.svg';
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue
-} from '@radix-ui/react-select';
import { listDatabase } from '../actions';
import { DatabaseCard } from '../database-card';
import { DatabaseCreatingDialog } from '../database-creating-dialog';
-interface IDatabaseSelectProps {
- placeholder?: string;
- options: Array<{ label: string; value: string }>;
-}
-
-export function DatabaseSelect({ placeholder, options }: IDatabaseSelectProps) {
- return (
-
- );
-}
-
-export default async function HomePage({
- searchParams
-}: {
+export default async function HomePage({}: {
searchParams: { q: string; offset: string };
}) {
const ret = await listDatabase();
- const search = searchParams.q ?? '';
- const offset = searchParams.offset ?? 0;
return (
- {ret.databases.map((x: string, idx: number) => (
+ {ret?.databases?.map((x: string, idx: number) => (
))}
diff --git a/gui/app/(dashboard)/error.tsx b/gui/app/(dashboard)/error.tsx
index 66bcfca317..cd279cf9c4 100644
--- a/gui/app/(dashboard)/error.tsx
+++ b/gui/app/(dashboard)/error.tsx
@@ -3,8 +3,7 @@
import { useEffect } from 'react';
export default function Error({
- error,
- reset
+ error
}: {
error: Error & { digest?: string };
reset: () => void;
@@ -15,12 +14,12 @@ export default function Error({
}, [error]);
return (
-
+
-
- Please complete setup
+
+ Connection failed
-
+ {/*
Inside the Vercel Postgres dashboard, create a table based on the
schema defined in this repository.
@@ -39,7 +38,7 @@ export default function Error({
{`INSERT INTO users (id, email, name, username) VALUES (1, 'me@site.com', 'Me', 'username');`}
-
+ */}
);
diff --git a/gui/app/(dashboard)/page.tsx b/gui/app/(dashboard)/page.tsx
index bed4ec14de..3c06fec619 100644
--- a/gui/app/(dashboard)/page.tsx
+++ b/gui/app/(dashboard)/page.tsx
@@ -8,27 +8,9 @@ import {
import { showConfigs, showVariables } from './actions';
// import { getProducts } from '@/lib/db';
-export default async function ProductsPage({
- searchParams
-}: {
- searchParams: { q: string; offset: string };
-}) {
- const search = searchParams.q ?? '';
- const offset = searchParams.offset ?? 0;
+export default async function ProductsPage() {
const configs = await showConfigs();
const variables = await showVariables();
- // const { products, newOffset, totalProducts } = await getProducts(
- // search,
- // Number(offset)
- // );
- console.log(variables);
- // const products = await request('http://localhost:3000/products');
-
- const { newOffset, totalProducts, products } = {
- newOffset: 0,
- totalProducts: 0,
- products: []
- };
return (
diff --git a/gui/app/(dashboard)/search.tsx b/gui/app/(dashboard)/search.tsx
index 8d106bbd09..70ba2d60dd 100644
--- a/gui/app/(dashboard)/search.tsx
+++ b/gui/app/(dashboard)/search.tsx
@@ -1,18 +1,18 @@
'use client';
-import { useTransition } from 'react';
-import { useRouter } from 'next/navigation';
-import { Input } from '@/components/ui/input';
import { Spinner } from '@/components/icons';
+import { Input } from '@/components/ui/input';
import { Search } from 'lucide-react';
+import { useRouter } from 'next/navigation';
+import { useTransition } from 'react';
export function SearchInput() {
const router = useRouter();
const [isPending, startTransition] = useTransition();
function searchAction(formData: FormData) {
- let value = formData.get('q') as string;
- let params = new URLSearchParams({ q: value });
+ const value = formData.get('q') as string;
+ const params = new URLSearchParams({ q: value });
startTransition(() => {
router.replace(`/?${params.toString()}`);
});
diff --git a/gui/app/(dashboard)/system/page.tsx b/gui/app/(dashboard)/system/page.tsx
index 2e497d8787..4639761731 100644
--- a/gui/app/(dashboard)/system/page.tsx
+++ b/gui/app/(dashboard)/system/page.tsx
@@ -8,27 +8,12 @@ import {
import { showConfigs, showVariables } from '../actions';
// import { getProducts } from '@/lib/db';
-export default async function ProductsPage({
- searchParams
-}: {
+export default async function ProductsPage({}: {
searchParams: { q: string; offset: string };
}) {
- const search = searchParams.q ?? '';
- const offset = searchParams.offset ?? 0;
const configs = await showConfigs();
const variables = await showVariables();
- // const { products, newOffset, totalProducts } = await getProducts(
- // search,
- // Number(offset)
- // );
console.log(variables);
- // const products = await request('http://localhost:3000/products');
-
- const { newOffset, totalProducts, products } = {
- newOffset: 0,
- totalProducts: 0,
- products: []
- };
return (
diff --git a/gui/app/(dashboard)/system/product.tsx b/gui/app/(dashboard)/system/product.tsx
deleted file mode 100644
index a4981c4782..0000000000
--- a/gui/app/(dashboard)/system/product.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import { Badge } from '@/components/ui/badge';
-import { Button } from '@/components/ui/button';
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuTrigger
-} from '@/components/ui/dropdown-menu';
-import { TableCell, TableRow } from '@/components/ui/table';
-import { MoreHorizontal } from 'lucide-react';
-// import { SelectProduct } from '@/lib/db';
-
-export function Product({ product }: { product: any }) {
- return (
-
- {product.name}
-
-
- {product.status}
-
-
- {`$${product.price}`}
- {product.stock}
-
- {product.availableAt}
-
-
-
-
-
-
-
- Actions
- Edit
-
-
-
-
-
-
-
- );
-}
diff --git a/gui/app/(dashboard)/system/products-table.tsx b/gui/app/(dashboard)/system/products-table.tsx
deleted file mode 100644
index c152c97c8e..0000000000
--- a/gui/app/(dashboard)/system/products-table.tsx
+++ /dev/null
@@ -1,113 +0,0 @@
-'use client';
-
-import {
- Card,
- CardContent,
- CardDescription,
- CardFooter,
- CardHeader,
- CardTitle
-} from '@/components/ui/card';
-import {
- Table,
- TableBody,
- TableHead,
- TableHeader,
- TableRow
-} from '@/components/ui/table';
-import { Product } from './product';
-// import { SelectProduct } from '@/lib/db';
-import { Button } from '@/components/ui/button';
-import { ChevronLeft, ChevronRight } from 'lucide-react';
-import { useRouter } from 'next/navigation';
-
-export function ProductsTable({
- products,
- offset,
- totalProducts
-}: {
- products: any[];
- offset: number;
- totalProducts: number;
-}) {
- let router = useRouter();
- let productsPerPage = 5;
-
- function prevPage() {
- router.back();
- }
-
- function nextPage() {
- router.push(`/?offset=${offset}`, { scroll: false });
- }
-
- return (
-
-
- Products
-
- Manage your products and view their sales performance.
-
-
-
-
-
-
-
- Image
-
- Name
- Status
- Price
-
- Total Sales
-
- Created at
-
- Actions
-
-
-
-
- {products.map((product) => (
-
- ))}
-
-
-
-
-
-
-
- );
-}
diff --git a/gui/app/(dashboard)/tables/context-menu.tsx b/gui/app/(dashboard)/tables/context-menu.tsx
index 95c5b40c02..b198fc6662 100644
--- a/gui/app/(dashboard)/tables/context-menu.tsx
+++ b/gui/app/(dashboard)/tables/context-menu.tsx
@@ -8,11 +8,7 @@ import { useSeDialogState } from '@/lib/hooks';
import { TableCreatingDialog } from './table-creating-dialog';
import AddIcon from '/public/add.svg';
-export function InfinityContextMenuContent({
- databaseName
-}: {
- databaseName: string;
-}) {
+export function InfinityContextMenuContent({}: { databaseName: string }) {
const { showDialog, visible, hideDialog, switchVisible } = useSeDialogState();
return (
<>
diff --git a/gui/app/(dashboard)/tables/page.tsx b/gui/app/(dashboard)/tables/page.tsx
index 374113d54d..8ca62edc8a 100644
--- a/gui/app/(dashboard)/tables/page.tsx
+++ b/gui/app/(dashboard)/tables/page.tsx
@@ -30,14 +30,9 @@ async function InfinityTable() {
);
}
-export default async function DatabasePage({
- searchParams
-}: {
+export default async function DatabasePage({}: {
searchParams: { q: string; offset: string };
}) {
- const search = searchParams.q ?? '';
- const offset = searchParams.offset ?? 0;
-
const items: MenuItem[] = [
{
key: 'sub1',
@@ -56,14 +51,14 @@ export default async function DatabasePage({
];
const ret = await listDatabase();
- if (ret.databases.length > 1) {
- const latestDatabase = ret.databases.at(-1);
+ if (ret.databases?.length > 1) {
+ const latestDatabase = ret.databases?.at(-1);
const tables = await listTable(latestDatabase);
console.log('🚀 ~ ret:', tables);
items.push({
key: latestDatabase,
label: latestDatabase,
- children: tables.tables
+ children: tables?.tables ?? []
});
}
diff --git a/gui/app/(dashboard)/tables/table-creating-dialog.tsx b/gui/app/(dashboard)/tables/table-creating-dialog.tsx
index f99be95179..9d5b695873 100644
--- a/gui/app/(dashboard)/tables/table-creating-dialog.tsx
+++ b/gui/app/(dashboard)/tables/table-creating-dialog.tsx
@@ -18,7 +18,7 @@ export function TableCreatingDialog({
visible,
switchVisible,
hideDialog
-}: React.PropsWithChildren
>) {
+}: React.PropsWithChildren>) {
return (