merge thr left sidebar fucntionaliity of this import React, { useState, useEffect } from…
- User
merge thr left sidebar fucntionaliity of this import React, { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import ResultCard from '../components/Resultcard'; // Ensure the path is correct import './Home.css';
const Home = () => { const [searchTerm, setSearchTerm] = useState(''); const [excludeWords, setExcludeWords] = useState(''); const [searchResults, setSearchResults] = useState([]); const [error, setError] = useState(null); const [isLoading, setIsLoading] = useState(false); const [filteredFilenames, setFilteredFilenames] = useState([]); const [fileInput, setFileInput] = useState(''); const [searchType, setSearchType] = useState('issues'); const navigate = useNavigate();
const filenames = [ //all file names here ];
const issuefiles = [ //all issues names here ];
useEffect(() => { setFilteredFilenames(searchType === 'issues' ? issueFiles : filenames); }, [searchType]);
const handleSearchTypeChange = (event) => { const value = event.target.value; setSearchType(value); setFileInput(''); setFilteredFilenames(value === 'issues' ? issueFiles : filenames); };
const handleFileInputChange = (event) => { const value = event.target.value; setFileInput(value); if (value) { setFilteredFilenames( (searchType === 'issues' ? issueFiles : filenames).filter((file) => file.name.toLowerCase().includes(value.toLowerCase()) ) ); } else { setFilteredFilenames(searchType === 'issues' ? issueFiles : filenames); } };
const handleSubmit = async (event) => { event.preventDefault(); if (!searchTerm.trim()) { setError('Please enter a search term.'); return; }
codesetIsLoading(true); setError(null); try { const response = await fetch( `http://192.168.2.5:3006/search?keyword=${encodeURIComponent(searchTerm)}&exclude=${encodeURIComponent( excludeWords || '' )}&type=${encodeURIComponent(searchType)}` ); if (!response.ok) throw new Error('Failed to fetch search results'); const data = await response.json(); setSearchResults(data); } catch (error) { console.error(error); setError('Error fetching search results.'); } finally { setIsLoading(false); }};
return ( S&A Law Offices <input type="text" placeholder={searchType === 'issues' ? 'Type an issue to search...' : 'Type a filename to search...'} value={fileInput} onChange={handleFileInputChange} className="sidebar-input" /> <input type="radio" value="issues" checked={searchType === 'issues'} onChange={handleSearchTypeChange} /> Issues <input type="radio" value="judgments" checked={searchType === 'judgments'} onChange={handleSearchTypeChange} /> Judgments {fileInput && ( {filteredFilenames.length > 0 ? ( filteredFilenames.map((file, index) => ( {file.name} )) ) : ( No matches found )} )}
- Assistant
- User
no right sode is noy showing pdf results as they are in th esecond code
- Assistant
- User
- Assistant
- User
- Assistant
- User
- Assistant
The error you are seeing indicates that somewhere in your code, there is an attempt to call the
toLowerCase()method onundefined. This usually happens when you are trying to access a property of an object that does not exist or when the property is not defined.