/** * Main Help Screen component for mobile apps */ import React, { useState, useMemo } from 'react'; import { View, Text, ScrollView, SafeAreaView } from 'react-native'; import type { HelpScreenProps, HelpSection } from '../types'; import { HelpSearchBar } from '../components/HelpSearchBar'; import { CategoryTabs } from '../components/CategoryTabs'; import { FAQList } from '../components/FAQList'; import { FeaturesList } from '../components/FeaturesList'; import { ContactCard } from '../components/ContactCard'; import { useHelpSearch } from '../hooks/useHelpContent'; import type { SearchResult } from '@manacore/shared-help-types'; export function HelpScreen({ content, appName, appId: _appId, translations, onBack: _onBack, defaultSection = 'faq', }: HelpScreenProps) { const [activeSection, setActiveSection] = useState(defaultSection); const [searchQuery, setSearchQuery] = useState(''); const [searchResults, setSearchResults] = useState([]); const { search } = useHelpSearch(content); // Define available sections const sections = useMemo( () => [ { id: 'faq' as HelpSection, label: translations.sections.faq, show: content.faq.length > 0 }, { id: 'features' as HelpSection, label: translations.sections.features, show: content.features.length > 0, }, { id: 'shortcuts' as HelpSection, label: translations.sections.shortcuts, show: content.shortcuts.length > 0, }, { id: 'getting-started' as HelpSection, label: translations.sections.gettingStarted, show: content.gettingStarted.length > 0, }, { id: 'changelog' as HelpSection, label: translations.sections.changelog, show: content.changelog.length > 0, }, { id: 'contact' as HelpSection, label: translations.sections.contact, show: !!content.contact, }, ], [content, translations] ); function handleSearch(query: string) { setSearchQuery(query); if (query.trim().length >= 2) { const results = search(query, 10); setSearchResults(results); } else { setSearchResults([]); } } function handleClearSearch() { setSearchQuery(''); setSearchResults([]); } function handleResultPress(result: SearchResult) { // Navigate to appropriate section switch (result.type) { case 'faq': setActiveSection('faq'); break; case 'feature': setActiveSection('features'); break; case 'guide': setActiveSection('getting-started'); break; case 'changelog': setActiveSection('changelog'); break; } handleClearSearch(); } // Use handleResultPress in search results (currently just viewing results) void handleResultPress; function renderContent() { // Show search results if searching if (searchQuery.length >= 2) { if (searchResults.length === 0) { return ( {translations.search.noResults.replace('{query}', searchQuery)} ); } return ( {translations.search.resultsCount.replace('{count}', String(searchResults.length))} {searchResults.map((result) => ( {result.title} {result.excerpt} ))} ); } // Show section content switch (activeSection) { case 'faq': return ; case 'features': return ; case 'contact': return ; case 'shortcuts': return ( {translations.shortcuts.noItems} ); case 'getting-started': return ( {translations.gettingStarted.noItems} ); case 'changelog': return ( {translations.changelog.noItems} ); default: return null; } } return ( {/* Header */} {translations.title} {translations.subtitle && ( {translations.subtitle} - {appName} )} {/* Search */} {/* Category Tabs */} {searchQuery.length < 2 && ( )} {/* Content */} {renderContent()} ); }