From 74c086504be94d95e15d2187e883f781b9fd942e Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Merino Date: Thu, 11 Jul 2024 11:04:21 +0200 Subject: Pages: Search: Add search page --- src/App.tsx | 4 +++ src/pages/Login.tsx | 4 +-- src/pages/Search.tsx | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 src/pages/Search.tsx (limited to 'src') diff --git a/src/App.tsx b/src/App.tsx index 739a64a..b77acbc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,6 +9,7 @@ import Logout from './pages/Logout'; import Recent from './pages/Recent'; import { useLocalStorage } from "@uidotdev/usehooks"; import { useState } from "react"; +import Search from "./pages/Search"; const supabase = createClient('https://slpoocycjgqsuoedhkbn.supabase.co', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNscG9vY3ljamdxc3VvZWRoa2JuIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTUyMDU0MjUsImV4cCI6MjAzMDc4MTQyNX0.xZYRTRN65rlms1Hb96IBAQvw3EGtMzUxlGPP5TVey34') @@ -32,6 +33,9 @@ function App() { } /> + + } /> } /> diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index aa3d284..bde52de 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -36,11 +36,11 @@ export default function Login(props: any) {

fs-tracer

-
+
Hello!
- Continue with + Continue with { + if (!props.session) { + navigate('/login') + } + }, [props.session]) + + const fetchFiles = useCallback(async () => { + console.log("FETCHIN FILES, pagination: ", paginationOffset, " search: ", search) + const { data, error } = await props.supabase + .from('file') + .select() + .ilike('absolute_path', `%${search}%`) + .range(paginationOffset, paginationOffset + numOfFilesToShow - 1) + if (error) { + console.error(error) + return + } + console.log("RAW FILES: ", data) + setFiles(data.map((file: any) => { + return file as File + })) + console.log("FETCHED FILES") + }, [props.supabase, paginationOffset, search]) + + useEffect(() => { + fetchFiles() + }, [paginationOffset]) + + return ( + <> +
+ +
+
+ + setSearch(e.target.value)} className="block bg-white w-1/2 rounded"> + +
+
+ +
+
+
+ {files.map((file: any) => ( +
console.log("clocked file")}> +

file: {file.absolute_path}

+
+ )) + } +
+
+
+ + +
+
+
+ + ) +} -- cgit 1.4.1