From 651d94a28ddced7e65c005448dabce7075505625 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 21 Jun 2026 14:11:56 -0500 Subject: stub dashboard --- src/web/src/components/Dashboard/Dashboard.jsx | 12 +++ src/web/src/components/Dashboard/SearchBar.jsx | 102 +++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 src/web/src/components/Dashboard/Dashboard.jsx create mode 100644 src/web/src/components/Dashboard/SearchBar.jsx (limited to 'src/web') diff --git a/src/web/src/components/Dashboard/Dashboard.jsx b/src/web/src/components/Dashboard/Dashboard.jsx new file mode 100644 index 00000000..01dd1aa0 --- /dev/null +++ b/src/web/src/components/Dashboard/Dashboard.jsx @@ -0,0 +1,12 @@ +import SearchBar from './SearchBar'; +import React from 'react'; + +const Dashboard = ({ server } = {}) => { + return ( +
+ +
+ ); +}; + +export default Dashboard; diff --git a/src/web/src/components/Dashboard/SearchBar.jsx b/src/web/src/components/Dashboard/SearchBar.jsx new file mode 100644 index 00000000..e8c0b7e4 --- /dev/null +++ b/src/web/src/components/Dashboard/SearchBar.jsx @@ -0,0 +1,102 @@ +import '../Search/Search.css'; +import { urlBase } from '../../config'; +import * as library from '../../lib/searches'; +import React, { useRef, useState } from 'react'; +import { Link, useHistory } from 'react-router-dom'; +import { toast } from 'react-toastify'; +import { Button, Icon, Input, Segment } from 'semantic-ui-react'; +import { v4 as uuidv4 } from 'uuid'; + +const SearchBar = ({ server } = {}) => { + const [creating, setCreating] = useState(false); + + const inputRef = useRef(); + const history = useHistory(); + + const create = async ({ navigate = false } = {}) => { + const ref = inputRef?.current?.inputRef?.current; + const searchText = ref.value; + const id = uuidv4(); + + try { + setCreating(true); + await library.create({ id, searchText }); + + ref.value = ''; + ref.focus(); + + setCreating(false); + + if (navigate) { + history.push(`${urlBase}/searches/${id}`); + } else { + const label = + searchText.length > 30 ? `${searchText.slice(0, 15)}...` : searchText; + toast.info( + + Search for ‘{label}’ started.{' '} + View results + , + ); + } + } catch (createError) { + console.error(createError); + toast.error( + createError?.response?.data ?? createError?.message ?? createError, + ); + setCreating(false); + } + }; + + inputRef?.current?.inputRef?.current?.focus(); + + return ( + +
+ +
+ +