diff --git a/src/api/habits/mock-habits.tsx b/src/api/habits/mock-habits.tsx index f79988b..8096eac 100644 --- a/src/api/habits/mock-habits.tsx +++ b/src/api/habits/mock-habits.tsx @@ -88,6 +88,11 @@ export const mockHabits: { id: HabitIdT; data: DbHabitT }[] = [ displayName: 'John Doe', username: 'john_doe', lastActivity: new Date('2024-12-01T00:00:00'), + }, + ['6' as UserIdT]: { + displayName: 'Sarah Wilson', + username: 'sarah_wilson', + lastActivity: new Date('2024-12-15T00:00:00'), isOwner: true, }, }, @@ -161,6 +166,13 @@ export const mockHabitCompletions: Record = { '2024-12-06': { numberOfCompletions: 1 }, }, }, + ['6' as UserIdT]: { + entries: { + '2024-12-13': { numberOfCompletions: 1 }, + '2024-12-14': { numberOfCompletions: 1 }, + '2024-12-15': { numberOfCompletions: 1, note: 'Great book tonight!' }, + }, + }, }, }; export const setMockHabitCompletions = ( diff --git a/src/api/users/mock-users.tsx b/src/api/users/mock-users.tsx index 14d2262..8ca576c 100644 --- a/src/api/users/mock-users.tsx +++ b/src/api/users/mock-users.tsx @@ -31,6 +31,12 @@ export const mockUsers: UserT[] = [ username: 'lorem_ipsum', createdAt: new Date(), }, + { + id: '6' as UserIdT, + displayName: 'Sarah Wilson', + username: 'sarah_wilson', + createdAt: new Date(), + }, ]; export const mockPictures: Record = { @@ -39,6 +45,7 @@ export const mockPictures: Record = { ['3' as UserIdT]: 'https://randomuser.me/api/portraits/women/4.jpg', ['4' as UserIdT]: 'https://randomuser.me/api/portraits/men/5.jpg', ['5' as UserIdT]: 'https://randomuser.me/api/portraits/men/6.jpg', + ['6' as UserIdT]: 'https://randomuser.me/api/portraits/women/7.jpg', }; export const mockRelationships: Record< diff --git a/src/app/habits/view-habit.tsx b/src/app/habits/view-habit.tsx index 1cab512..daae27b 100644 --- a/src/app/habits/view-habit.tsx +++ b/src/app/habits/view-habit.tsx @@ -16,13 +16,14 @@ import { type HabitT, type ParticipantWithIdT, useAllUsersHabitCompletions, + type UserIdT, type UserT, } from '@/api'; import { ErrorMessage } from '@/components/error-message'; import { HabitIcon, type habitIcons } from '@/components/habit-icon'; import ModifyHabitEntry from '@/components/modify-habit-entry'; import { DayNavigation } from '@/components/modify-habit-entry/day-navigation'; -import { UserImageNameAndUsername } from '@/components/user-card'; +import UserCard, { UserImageNameAndUsername } from '@/components/user-card'; import { getTranslucentColor } from '@/core/get-translucent-color'; import { Button, @@ -180,6 +181,21 @@ interface HabitHeaderProps { const HabitHeader = ({ habit }: HabitHeaderProps) => { const { colorScheme } = useColorScheme(); const modal = useModal(); + const participants = Object.entries(habit.participants) + .filter( + (entry): entry is [string, NonNullable<(typeof entry)[1]>] => + entry[1] !== undefined, + ) + .map(([_, p]) => p); + const isOwner = habit.participants['1' as UserIdT]?.isOwner; + + const handleTransferOwnership = (userId: string) => { + alert('TODO: Transfer ownership to ' + userId); + }; + + const handleKickUser = (userId: string) => { + alert('TODO: Kick user ' + userId); + }; return ( <> @@ -214,15 +230,93 @@ const HabitHeader = ({ habit }: HabitHeaderProps) => { colorScheme === 'dark' ? colors.neutral[800] : colors.white, }} > - -
- + + + + + + {habit.title} + + {habit.description && ( + {habit.description} + )} + + {habit.settings.allowMultipleCompletions + ? 'Multiple completions allowed per day' + : 'One completion per day limit'} + + + Created{' '} + {new Date(habit.createdAt).toLocaleDateString(undefined, { + year: 'numeric', + month: 'long', + day: 'numeric', + })} + + +