diff --git a/global.d.ts b/global.d.ts index 4b4d817c..47c7a8bd 100644 --- a/global.d.ts +++ b/global.d.ts @@ -13,6 +13,7 @@ declare module "little-state-machine" { register: RegisterType; profile: ProfileType; profileView: ProfileDisplayState; + profileActiveTab: string; } } diff --git a/src/components/AppFooter.tsx b/src/components/AppFooter.tsx index 8e7dcce7..1d15674e 100644 --- a/src/components/AppFooter.tsx +++ b/src/components/AppFooter.tsx @@ -3,6 +3,8 @@ import Link from "next/link"; import { Icons } from "./Icons"; import { cn } from "@/lib/client/utils"; import { usePathname } from "next/navigation"; +import { useStateMachine } from "little-state-machine"; +import updateStateFromAction from "@/lib/shared/updateAction"; interface RouterItem { label: string; @@ -13,12 +15,22 @@ interface RouterItem { } const TabItem = ({ label, href, icon, isActive, iconSize }: RouterItem) => { + const { actions, getState } = useStateMachine({ updateStateFromAction }); const Icon: any = icon; const textColor = isActive ? "text-white" : "text-gray-10"; return ( - + { + actions.updateStateFromAction({ + ...getState(), + // on navigation, reset the active tab to the default + profileActiveTab: "activity-feed", + }); + }} + >
void; + fixed?: boolean; // if true, the header will be fixed } -const AppHeader = ({ isMenuOpen, setIsMenuOpen }: AppHeaderProps) => { +const AppHeader = ({ isMenuOpen, setIsMenuOpen, fixed }: AppHeaderProps) => { const handleSignout = async () => { await clearIndexedDB(); deleteAccountFromLocalStorage(); @@ -224,7 +226,11 @@ const AppHeader = ({ isMenuOpen, setIsMenuOpen }: AppHeaderProps) => { }; return ( -
+
{!isMenuOpen && (