Complete 'All Versions' search functionality - search across all Bible translations and default to 'all' on version selector page
This commit is contained in:
@@ -22,8 +22,9 @@ const SearchComponent: React.FC<SearchComponentProps> = ({
|
||||
onClose,
|
||||
isModal = false
|
||||
}) => {
|
||||
// Default to ESV if no version is selected, otherwise use the current version
|
||||
const defaultVersion = initialVersion || 'esv';
|
||||
// Default to "all" if no version is selected (on version selector page),
|
||||
// otherwise use the current version
|
||||
const defaultVersion = initialVersion || 'all';
|
||||
const [query, setQuery] = useState('');
|
||||
const [results, setResults] = useState<SearchResult[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -85,9 +86,12 @@ const SearchComponent: React.FC<SearchComponentProps> = ({
|
||||
// Handle result click
|
||||
const handleResultClick = (result: SearchResult) => {
|
||||
const urlBookName = getBookUrlName(formatBookName(result.book));
|
||||
// For "all versions" search, use the specific version from the result
|
||||
// For single version search, use the selected version
|
||||
const resultVersion = (result as any).searchVersion || selectedVersion;
|
||||
// Navigate to chapter with verse hash to scroll directly to the verse
|
||||
// Include the version in the URL to ensure we navigate to the correct translation
|
||||
const url = `/version/${selectedVersion}/book/${urlBookName}/chapter/${result.chapter}#verse-${result.verse}`;
|
||||
const url = `/version/${resultVersion}/book/${urlBookName}/chapter/${result.chapter}#verse-${result.verse}`;
|
||||
navigate(url);
|
||||
if (onClose) onClose();
|
||||
};
|
||||
@@ -169,6 +173,7 @@ const SearchComponent: React.FC<SearchComponentProps> = ({
|
||||
bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100
|
||||
focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
||||
>
|
||||
<option value="all">All Versions</option>
|
||||
<option value="esv">ESV - English Standard Version</option>
|
||||
<option value="nkjv">NKJV - New King James Version</option>
|
||||
<option value="nlt">NLT - New Living Translation</option>
|
||||
|
||||
Reference in New Issue
Block a user