From 5f30928c6452faa540fb33e51764cf26b8729c85 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sun, 8 Mar 2026 21:12:08 +0000 Subject: [PATCH] Fix navigation --- .../src/components/account/AccountPage.tsx | 60 ++++++++----------- frontend/src/components/learn/LearnPage.tsx | 39 ++++-------- frontend/src/components/ui/SubNav.tsx | 27 +++++++++ 3 files changed, 65 insertions(+), 61 deletions(-) create mode 100644 frontend/src/components/ui/SubNav.tsx diff --git a/frontend/src/components/account/AccountPage.tsx b/frontend/src/components/account/AccountPage.tsx index 3bf1f90..d9e3bbd 100644 --- a/frontend/src/components/account/AccountPage.tsx +++ b/frontend/src/components/account/AccountPage.tsx @@ -11,10 +11,15 @@ import { ClipboardIcon } from '../ui/icons/ClipboardIcon'; import { BookmarkIcon } from '../ui/icons/BookmarkIcon'; import { TrashIcon } from '../ui/icons/TrashIcon'; import { CloseIcon } from '../ui/icons/CloseIcon'; -import { TabButton } from '../ui/TabButton'; +import { SubNav } from '../ui/SubNav'; type AccountTab = 'saved' | 'settings'; +const ACCOUNT_TABS = [ + { key: 'saved', label: 'Saved Searches' }, + { key: 'settings', label: 'Settings' }, +]; + const SUBSCRIPTION_OPTIONS = ['free', 'licensed'] as const; const SUBSCRIPTION_LABELS: Record = { @@ -493,7 +498,8 @@ export default function AccountPage({ return () => window.removeEventListener('hashchange', handleHashChange); }, []); - const switchTab = (tab: AccountTab) => { + const switchTab = (key: string) => { + const tab = key as AccountTab; setActiveTab(tab); window.history.replaceState( window.history.state, @@ -503,39 +509,25 @@ export default function AccountPage({ }; return ( -
-
-

Account

- - {/* Tabs */} -
- switchTab('saved')} - /> - switchTab('settings')} - /> +
+ +
+
+ {activeTab === 'saved' ? ( + + ) : ( + + )}
- - {/* Tab content */} - {activeTab === 'saved' ? ( - - ) : ( - - )}
); diff --git a/frontend/src/components/learn/LearnPage.tsx b/frontend/src/components/learn/LearnPage.tsx index a98eba9..5b76e10 100644 --- a/frontend/src/components/learn/LearnPage.tsx +++ b/frontend/src/components/learn/LearnPage.tsx @@ -1,8 +1,15 @@ import { useEffect, useState, useRef } from 'react'; import { ChevronIcon } from '../ui/icons/ChevronIcon'; +import { SubNav } from '../ui/SubNav'; type LearnTab = 'data-sources' | 'faq' | 'support'; +const LEARN_TABS = [ + { key: 'faq', label: 'FAQ' }, + { key: 'data-sources', label: 'Data Sources' }, + { key: 'support', label: 'Support' }, +]; + const DATA_SOURCES = [ { id: 'price-paid', @@ -288,36 +295,20 @@ export default function LearnPage() { scrollContainerRef.current?.scrollTo(0, 0); }, [tab]); - const tabClass = (t: LearnTab) => - `px-4 py-2 text-sm font-medium rounded-t border-b-2 ${tab === t - ? 'border-teal-500 text-teal-700 dark:text-teal-400' - : 'border-transparent text-warm-500 dark:text-warm-400 hover:text-warm-700 dark:hover:text-warm-300' - }`; + const switchTab = (key: string) => { + setTab(key as LearnTab); + setHighlightedId(null); + }; return (
-
-
- - - -
-
+
{tab === 'data-sources' ? ( <>
-

- Data Sources -

This application combines {DATA_SOURCES.length} open datasets covering property prices, energy performance, transport, demographics, crime, environment, and more. @@ -423,9 +414,6 @@ export default function LearnPage() { ) : tab === 'faq' ? (

-

- Frequently Asked Questions -

Common questions about how Perfect Postcode works, where the data comes from, and how to use the map. @@ -438,9 +426,6 @@ export default function LearnPage() {

) : (
-

- Support -

Have a question? Check our FAQ or reach out to us directly.

diff --git a/frontend/src/components/ui/SubNav.tsx b/frontend/src/components/ui/SubNav.tsx new file mode 100644 index 0000000..21b4a1a --- /dev/null +++ b/frontend/src/components/ui/SubNav.tsx @@ -0,0 +1,27 @@ +interface SubNavProps { + tabs: { key: string; label: string }[]; + activeTab: string; + onTabChange: (key: string) => void; +} + +export function SubNav({ tabs, activeTab, onTabChange }: SubNavProps) { + return ( +
+
+ {tabs.map((tab) => ( + + ))} +
+
+ ); +}