From 69fa008ea4e1a167e6076a69869388bf012d24b1 Mon Sep 17 00:00:00 2001 From: Sebastien Castiel Date: Mon, 11 Dec 2023 10:26:13 -0500 Subject: Tiny adjustments --- src/app/groups/recent-group-list.tsx | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'src/app/groups/recent-group-list.tsx') diff --git a/src/app/groups/recent-group-list.tsx b/src/app/groups/recent-group-list.tsx index 92bc743..60e3922 100644 --- a/src/app/groups/recent-group-list.tsx +++ b/src/app/groups/recent-group-list.tsx @@ -1,4 +1,5 @@ 'use client' +import { getGroupsAction } from '@/app/groups/actions' import { getRecentGroups } from '@/app/groups/recent-groups-helpers' import { Button } from '@/components/ui/button' import { getGroups } from '@/lib/api' @@ -28,7 +29,7 @@ type Props = { getGroupsAction: (groupIds: string[]) => ReturnType } -export function RecentGroupList({ getGroupsAction }: Props) { +export function RecentGroupList() { const [state, setState] = useState({ status: 'pending' }) useEffect(() => { @@ -37,15 +38,30 @@ export function RecentGroupList({ getGroupsAction }: Props) { getGroupsAction(groupsInStorage.map((g) => g.id)).then((groupsDetails) => { setState({ status: 'complete', groups: groupsInStorage, groupsDetails }) }) - }, [getGroupsAction]) + }, []) - if (state.status === 'pending') + if (state.status === 'pending') { return (

Loading recent groups…

) + } + + if (state.groups.length === 0) { + return ( +
+

You have not visited any group recently.

+

+ {' '} + or ask a friend to send you the link to an existing one. +

+
+ ) + } return (
    @@ -70,9 +86,12 @@ export function RecentGroupList({ getGroupsAction }: Props) {
    - {details.createdAt.toLocaleDateString('en-US', { - dateStyle: 'medium', - })} + {new Date(details.createdAt).toLocaleDateString( + 'en-US', + { + dateStyle: 'medium', + }, + )}
    -- cgit v1.3