diff --git a/.gitignore b/.gitignore index 1b02c6d..6a9332f 100644 --- a/.gitignore +++ b/.gitignore @@ -195,4 +195,7 @@ cython_debug/ .DS_Store node_modules -package-lock.json \ No newline at end of file +dist +.vscode +package-lock.json + diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 6ec5549..c92eaaf 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -22,6 +22,7 @@ "@radix-ui/react-tabs": "^1.1.12", "@radix-ui/react-tooltip": "^1.2.7", "@tailwindcss/vite": "^4.1.10", + "@tanstack/react-query": "^5.81.5", "@tanstack/react-table": "^8.21.3", "@types/react-router-dom": "^5.3.3", "class-variance-authority": "^0.7.1", @@ -2585,6 +2586,32 @@ "vite": "^5.2.0 || ^6" } }, + "node_modules/@tanstack/query-core": { + "version": "5.81.5", + "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.81.5.tgz", + "integrity": "sha512-ZJOgCy/z2qpZXWaj/oxvodDx07XcQa9BF92c0oINjHkoqUPsmm3uG08HpTaviviZ/N9eP1f9CM7mKSEkIo7O1Q==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/react-query": { + "version": "5.81.5", + "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.81.5.tgz", + "integrity": "sha512-lOf2KqRRiYWpQT86eeeftAGnjuTR35myTP8MXyvHa81VlomoAWNEd8x5vkcAfQefu0qtYCvyqLropFZqgI2EQw==", + "license": "MIT", + "dependencies": { + "@tanstack/query-core": "5.81.5" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^18 || ^19" + } + }, "node_modules/@tanstack/react-table": { "version": "8.21.3", "resolved": "https://registry.npmjs.org/@tanstack/react-table/-/react-table-8.21.3.tgz", diff --git a/frontend/package.json b/frontend/package.json index 07f6c96..d32224f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -24,6 +24,7 @@ "@radix-ui/react-tabs": "^1.1.12", "@radix-ui/react-tooltip": "^1.2.7", "@tailwindcss/vite": "^4.1.10", + "@tanstack/react-query": "^5.81.5", "@tanstack/react-table": "^8.21.3", "@types/react-router-dom": "^5.3.3", "class-variance-authority": "^0.7.1", diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 2763661..06960d2 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -9,17 +9,22 @@ import About from './modules/about/About'; import Layout from "./components/Layout"; import Dashboard from './modules/dashboard/Dashboard'; import Search from './modules/search/Search'; +import { Upload } from './modules/upload/Upload'; + function App() { return ( + // + // -
+
} /> } /> } /> } /> + } />
diff --git a/frontend/src/components/app-sidebar.tsx b/frontend/src/components/app-sidebar.tsx index d6c1a8c..ee7436f 100644 --- a/frontend/src/components/app-sidebar.tsx +++ b/frontend/src/components/app-sidebar.tsx @@ -27,30 +27,30 @@ import { // This is sample data. const data = { user: { - name: "shadcn", - email: "m@example.com", + name: "Andra Police", + email: "designed by Cyberark", avatar: "/avatars/shadcn.jpg", }, teams: [ { - name: "Acme Inc", + name: "News Analyzer", logo: GalleryVerticalEnd, plan: "Enterprise", }, { - name: "Acme Corp.", + name: "News AI", logo: AudioWaveform, plan: "Startup", }, - { - name: "Evil Corp.", - logo: Command, - plan: "Free", - }, + // { + // name: "Evil Corp.", + // logo: Command, + // plan: "Free", + // }, ], navMain: [ { - title: "Playground", + title: "Available Links", url: "#", icon: SquareTerminal, isActive: true, @@ -71,90 +71,94 @@ const data = { title: "About", url: "/about", }, - ], - }, - { - title: "Models", - url: "#", - icon: Bot, - items: [ - { - title: "Genesis", - url: "#", - }, - { - title: "Explorer", - url: "#", - }, - { - title: "Quantum", - url: "#", - }, - ], - }, - { - title: "Documentation", - url: "#", - icon: BookOpen, - items: [ - { - title: "Introduction", - url: "#", - }, - { - title: "Get Started", - url: "#", - }, - { - title: "Tutorials", - url: "#", - }, { - title: "Changelog", - url: "#", - }, - ], - }, - { - title: "Settings", - url: "#", - icon: Settings2, - items: [ - { - title: "General", - url: "#", - }, - { - title: "Team", - url: "#", - }, - { - title: "Billing", - url: "#", - }, - { - title: "Limits", - url: "#", + title: "Uploads", + url: "/upload", }, ], }, + // { + // title: "Models", + // url: "#", + // icon: Bot, + // items: [ + // { + // title: "Genesis", + // url: "#", + // }, + // { + // title: "Explorer", + // url: "#", + // }, + // { + // title: "Quantum", + // url: "#", + // }, + // ], + // }, + // { + // title: "Documentation", + // url: "#", + // icon: BookOpen, + // items: [ + // { + // title: "Introduction", + // url: "#", + // }, + // { + // title: "Get Started", + // url: "#", + // }, + // { + // title: "Tutorials", + // url: "#", + // }, + // { + // title: "Changelog", + // url: "#", + // }, + // ], + // }, + // { + // title: "Settings", + // url: "#", + // icon: Settings2, + // items: [ + // { + // title: "General", + // url: "#", + // }, + // { + // title: "Team", + // url: "#", + // }, + // { + // title: "Billing", + // url: "#", + // }, + // { + // title: "Limits", + // url: "#", + // }, + // ], + // }, ], projects: [ - { - name: "Design Engineering", - url: "#", - icon: Frame, - }, - { - name: "Sales & Marketing", - url: "#", - icon: PieChart, - }, - { - name: "Travel", - url: "#", - icon: Map, - }, + // { + // name: "Design Engineering", + // url: "#", + // icon: Frame, + // }, + // { + // name: "Sales & Marketing", + // url: "#", + // icon: PieChart, + // }, + // { + // name: "Travel", + // url: "#", + // icon: Map, + // }, ], } diff --git a/frontend/src/modules/search/Search.tsx b/frontend/src/modules/search/Search.tsx index 3300f4b..9cb279e 100644 --- a/frontend/src/modules/search/Search.tsx +++ b/frontend/src/modules/search/Search.tsx @@ -2,14 +2,12 @@ import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/textarea"; import { DataTable } from "./table/data-table"; -import { columns, type GroupedCategory } from "./table/columns"; +import { columns, type Article } from "./table/columns"; import { useEffect, useRef, useState } from "react"; -import { GetArticles } from "./GetArticles"; import { Pagination, PaginationContent, PaginationItem, PaginationPrevious, PaginationLink, PaginationNext } from "@/components/ui/pagination"; import { Skeleton } from "@/components/ui/skeleton"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { useReactToPrint } from "react-to-print"; -import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; function renderSkeletonTable() { return ( @@ -41,27 +39,59 @@ function renderSkeletonTable() { } export default function Search() { - const [data, setData] = useState([]); + const [dataState, setDataState] = useState([]); const [loading, setLoading] = useState(false); const [page, setPage] = useState(1); const [pageSize, setPageSize] = useState(10); const [total, setTotal] = useState(0); - const [rowSelection, setRowSelection] = useState>({}); + const [, setRowSelection] = useState>({}); + const API_BASE_URL = import.meta.env.VITE_API_UPLOAD_URL || ""; let componentRef = useRef(null); const handlePrint = useReactToPrint({ contentRef: componentRef, - documentTitle: `${'test'}-Print`, + documentTitle: `${new Date()}-Search Results`, onPrintError: () => alert("there is an error when printing"), }); - const fetchData = async (pageNum = page, size = pageSize) => { + const fetchFeedList = async () => { + const response = await fetch(`http://localhost:3001/GetFeed`); + // const response = await fetch(`${API_BASE_URL}/getfeed`); + const data = await response.json(); + console.log(data); + return data as Article[]; + } + + // const { isFetching, isError, data, error } = useQuery({ + // queryKey: ['feed'], + // queryFn: fetchFeedList, + // refetchOnWindowFocus: false, + // refetchOnReconnect: false, + // refetchOnMount: false, // or 'always'/'false' as needed + // staleTime: 1000 * 60 * 5, // 5 minutes, adjust as needed + // }) + + + const fetchData = async (page: any, pageSize: any) => { + // setLoading(true); + // const result = await GetArticles({ page: pageNum, pageSize: size }); + // setDataState(result.data); + // setTotal(result.total); + // setLoading(false); setLoading(true); - const result = await GetArticles({ page: pageNum, pageSize: size }); - setData(result.data); - setTotal(result.total); + const data = await fetchFeedList(); + const start = (page - 1) * pageSize; + const end = start + pageSize; + const result = data?.slice(start, end) ?? []; + setLoading(false); + setDataState(result); + setTotal(data?.length ?? 0); + return { + data: result, + total: data?.length ?? 0 + }; }; useEffect(() => { @@ -73,16 +103,11 @@ export default function Search() { return (
-
-