From ab9d7f8096ddce51e05142c26938c3403cf62d30 Mon Sep 17 00:00:00 2001 From: rift <117926989+Riftriot@users.noreply.github.com> Date: Fri, 29 Dec 2023 14:09:52 -0600 Subject: [PATCH] autofill --- src/pages/Home.tsx | 51 ++++++++++++++++++++++++++++++++++++++++++---- src/routes.tsx | 1 + 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 1284cdf..9456799 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -3,11 +3,27 @@ import { useTranslation } from "react-i18next"; import { HeaderRoute } from "../components/HeaderRoute"; import { enc } from "../aes"; import CloakedHead from "../util/CloakedHead"; + export function Home() { const [isFocused, setIsFocused] = useState(false); + const [showSuggestions, setShowSuggestions] = useState(false); const [inputValue, setInputValue] = useState(""); + const [suggestions, setSuggestions] = useState([]); const { t } = useTranslation(); + const handleInputChange = async (event) => { + setInputValue((event.target as HTMLInputElement).value); + const newQuery = event.target.value; + setInputValue(newQuery); + + const response = await fetch(`/search=${newQuery}`).then((res) => + res.json() + ); + + const newSuggestions = response?.map((item) => item.phrase) || []; + setSuggestions(newSuggestions); + }; + const handleSubmit = (event) => { event.preventDefault(); window.location.href = @@ -38,25 +54,52 @@ export function Home() {
diff --git a/src/routes.tsx b/src/routes.tsx index 68afe0b..869231b 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -6,6 +6,7 @@ import { ProxyFrame } from "./pages/ProxyFrame.js"; import { Radon } from "./pages/Radon"; import { Settings } from "./pages/Settings/"; import { AboutBlank } from "./AboutBlank"; +import AutocompleteInput from "./Autocomplete"; import "./style.css"; import "./themes/main.css"; import "./i18n";