From 2f991e680bea37d1f97ea77df2343200f3899817 Mon Sep 17 00:00:00 2001 From: Anurag Date: Wed, 28 Feb 2024 21:13:25 +0530 Subject: feat: initialise a new totals tab with basic UI (#94) * feat: initialise a new totals tab with basic UI * fix: update group tabs and add stats page * fix: styling within the new elements * Prettier * Display active user expenses only if active user is set --------- Co-authored-by: Sebastien Castiel --- src/lib/hooks.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/lib/hooks.ts') diff --git a/src/lib/hooks.ts b/src/lib/hooks.ts index 4d3ad08..490eccf 100644 --- a/src/lib/hooks.ts +++ b/src/lib/hooks.ts @@ -48,3 +48,17 @@ export function useBaseUrl() { }, []) return baseUrl } + +/** + * @returns The active user, or `null` until it is fetched from local storage + */ +export function useActiveUser(groupId: string) { + const [activeUser, setActiveUser] = useState(null) + + useEffect(() => { + const activeUser = localStorage.getItem(`${groupId}-activeUser`) + if (activeUser) setActiveUser(activeUser) + }, [groupId]) + + return activeUser +} -- cgit v1.3