From 406f541163851897d5d13fbd12e6a81ffe503673 Mon Sep 17 00:00:00 2001 From: ivic00 <102467664+ivic00@users.noreply.github.com> Date: Tue, 24 Dec 2024 20:44:30 +0100 Subject: [PATCH 1/3] ui changes --- components/pages/brain_dump/BrainDumpPage.tsx | 7 +++++-- components/pages/brain_dump/DumpItem.tsx | 2 +- components/pages/calendar/ManuallyAddEventModal.tsx | 9 +++++---- components/pages/todos/ToDosList.tsx | 13 +++++++++---- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/components/pages/brain_dump/BrainDumpPage.tsx b/components/pages/brain_dump/BrainDumpPage.tsx index 7f0e0c2..d4b5ff8 100644 --- a/components/pages/brain_dump/BrainDumpPage.tsx +++ b/components/pages/brain_dump/BrainDumpPage.tsx @@ -3,12 +3,13 @@ import React, {useState} from "react"; import {Button, Text, TextField, View} from "react-native-ui-lib"; import DumpList from "./DumpList"; import HeaderTemplate from "@/components/shared/HeaderTemplate"; -import {Feather, MaterialIcons} from "@expo/vector-icons"; +import {Feather} from "@expo/vector-icons"; import AddBrainDump from "./AddBrainDump"; import LinearGradient from "react-native-linear-gradient"; import PlusIcon from "@/assets/svgs/PlusIcon"; import * as Device from 'expo-device' import {DeviceType} from 'expo-device' + const BrainDumpPage = () => { const [searchText, setSearchText] = useState(""); const [isAddVisible, setIsAddVisible] = useState(false); @@ -21,7 +22,7 @@ const BrainDumpPage = () => { showsVerticalScrollIndicator={false} showsHorizontalScrollIndicator={false} > - + { marginV-5 paddingH-13 paddingV-10 - style={{ borderRadius: 15, elevation: 2 }} + style={{ borderRadius: 15, elevation: 0 }} > { is24Hour={profileData?.userType === ProfileType.PARENT ? false : true} onChange={(time) => { if (endDate.getDate() === startDate.getDate() && - time.getHours() >= endTime.getHours()) + time.getHours() >= endTime.getHours() && time.getMinutes() >= endTime.getHours()) { const newEndDate = new Date(endDate); @@ -435,7 +435,7 @@ export const ManuallyAddEventModal = () => { }} minuteInterval={5} mode="time" - timeFormat={profileData?.userType === ProfileType.PARENT ? "hh:mm" : "HH:mm"} + timeFormat={profileData?.userType === ProfileType.PARENT ? "hh:mm A" : "HH:mm A"} style={[styles.timePicker]} /> @@ -461,7 +461,8 @@ export const ManuallyAddEventModal = () => { setEndTime(time); if ( endDate.getDate() === startDate.getDate() && - time.getHours() < startTime.getHours() + time.getHours() <= startTime.getHours() && + time.getMinutes() <= startTime.getMinutes() ) { const newEndDate = new Date(endDate); newEndDate.setDate(newEndDate.getDate() + 1); @@ -470,7 +471,7 @@ export const ManuallyAddEventModal = () => { }} minuteInterval={5} mode="time" - timeFormat={profileData?.userType === ProfileType.PARENT ? "hh:mm" : "HH:mm"} + timeFormat={profileData?.userType === ProfileType.PARENT ? "hh:mm A" : "HH:mm A"} style={[styles.timePicker]} /> diff --git a/components/pages/todos/ToDosList.tsx b/components/pages/todos/ToDosList.tsx index faea2f9..c91e9ec 100644 --- a/components/pages/todos/ToDosList.tsx +++ b/components/pages/todos/ToDosList.tsx @@ -327,11 +327,16 @@ const ToDosList = ({ isSettings, members }: { isSettings?: boolean, members?: Ar style={{ marginRight: 8 }} /> )} - renderItem={(item) => { + renderItem={(item, selected) => { return ( - - {item.label} - + + + {item.label} + + ); }} onChange={(item) => { From c14910447e59d858f4ab95e5fa96a3556ce6fc7f Mon Sep 17 00:00:00 2001 From: Dejan Date: Wed, 25 Dec 2024 22:41:53 +0100 Subject: [PATCH 2/3] - Implemented saving of points per week per day for user - Implemented saving of the number of completed todos per user - Changed "To do's" labels to "To Do" --- app/(auth)/_layout.tsx | 6 ++-- .../pages/(tablet_pages)/ViewSwitch.tsx | 2 +- components/pages/brain_dump/MoveBrainDump.tsx | 2 +- components/pages/todos/ToDosPage.tsx | 2 +- .../family-chores/FamilyChoresProgress.tsx | 4 +-- hooks/firebase/types/profileTypes.ts | 2 ++ hooks/firebase/useUpdateTodo.ts | 29 ++++++++++++++++++- 7 files changed, 38 insertions(+), 9 deletions(-) diff --git a/app/(auth)/_layout.tsx b/app/(auth)/_layout.tsx index 89585e4..feaef0a 100644 --- a/app/(auth)/_layout.tsx +++ b/app/(auth)/_layout.tsx @@ -255,7 +255,7 @@ export default function TabLayout() { />*/} { props.navigation.navigate("todos"); @@ -400,8 +400,8 @@ export default function TabLayout() { drawerLabel: "To-Do", title: Device.deviceType === DeviceType.TABLET - ? "Family To Do's" - : "To Do's", + ? "Family To Dos" + : "To Dos", }} /> Move to - my to do's + my to dos diff --git a/components/pages/todos/ToDosPage.tsx b/components/pages/todos/ToDosPage.tsx index 53269c0..fc42bb2 100644 --- a/components/pages/todos/ToDosPage.tsx +++ b/components/pages/todos/ToDosPage.tsx @@ -41,7 +41,7 @@ const ToDosPage = () => { - Return to To Do's + Return to To Dos @@ -123,7 +123,7 @@ const FamilyChoresProgress = ({ - x/y chores completed + {`${child?.weeklyCompletedTodos ?? 0}/y chores completed`} diff --git a/hooks/firebase/types/profileTypes.ts b/hooks/firebase/types/profileTypes.ts index 5af414f..4d5e478 100644 --- a/hooks/firebase/types/profileTypes.ts +++ b/hooks/firebase/types/profileTypes.ts @@ -44,5 +44,7 @@ export interface UserProfile { microsoftAccounts?: { [email: string]: MicrosoftAccount }; appleAccounts?: { [email: string]: AppleAccount }; weeklyPoints?: number; + weeklyDayPoints?: Object; allTimePoints?: number; + weeklyCompletedTodos?: number; } \ No newline at end of file diff --git a/hooks/firebase/useUpdateTodo.ts b/hooks/firebase/useUpdateTodo.ts index 01356bf..71ecff0 100644 --- a/hooks/firebase/useUpdateTodo.ts +++ b/hooks/firebase/useUpdateTodo.ts @@ -130,16 +130,37 @@ export const useUpdateTodo = () => { ? userWeeklyPoints + todoUpdate.points : userWeeklyPoints - todoUpdate.points; + let pointsPerDay = userData.weeklyDayPoints || { + Monday: 0, + Tuesday: 0, + Wednesday: 0, + Thursday: 0, + Friday: 0, + Saturday: 0, + Sunday: 0, + }; + const currentDay = getCurrentDay(); + const updatedPointsPerDay = todoData.done + ? pointsPerDay[currentDay] + todoUpdate.points + : pointsPerDay[currentDay] - todoUpdate.points; + pointsPerDay[currentDay] = Math.max(0, updatedPointsPerDay); + let userAllTimePoints = userData.allTimePoints ?? 0; const allTimePoints = todoData.done ? userAllTimePoints + todoUpdate.points : userAllTimePoints - todoUpdate.points; + const weeklyCompletedTodos = todoData.done + ? (userData.weeklyCompletedTodos || 0) + 1 + : (userData.weeklyCompletedTodos || 0) - 1; + // Update the user's points in Firestore userData = { ...userData, weeklyPoints: weeklyPoints >= 0 ? weeklyPoints : 0, - allTimePoints: allTimePoints >= 0 ? allTimePoints : 0 + weeklyDayPoints: updatedPointsPerDay, + allTimePoints: allTimePoints >= 0 ? allTimePoints : 0, + weeklyCompletedTodos: weeklyCompletedTodos >= 0 ? weeklyCompletedTodos : 0 } userBatch.update(userRef, userData); }); @@ -161,4 +182,10 @@ export const useUpdateTodo = () => { queryClients.invalidateQueries({queryKey: ["todos"]}) } }) +}; + +const getCurrentDay = () => { + const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; + const now = new Date(); + return days[now.getDay()]; }; \ No newline at end of file From f1869f02f2990d0e00d2beb6243ca8f3a247e43f Mon Sep 17 00:00:00 2001 From: Dejan Date: Wed, 25 Dec 2024 22:49:07 +0100 Subject: [PATCH 3/3] - Filtered out todos of deleted users when the Everyone option is selected in the filter --- components/pages/todos/ToDosList.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/pages/todos/ToDosList.tsx b/components/pages/todos/ToDosList.tsx index c91e9ec..bd04273 100644 --- a/components/pages/todos/ToDosList.tsx +++ b/components/pages/todos/ToDosList.tsx @@ -139,7 +139,13 @@ const ToDosList = ({ isSettings, members }: { isSettings?: boolean, members?: Ar if (localTodos && selectedFilter) { let resolvedGroupedTodos; if (selectedFilter?.value === FILTER_OPTIONS.EVERYONE) { - resolvedGroupedTodos = groupToDosByDate(toDos ?? []); + let filtered = localTodos?.filter((todo) => + todo.assignees?.some(assigneeId => + members.some(member => member.uid === assigneeId) + ) + ); + + resolvedGroupedTodos = groupToDosByDate(filtered ?? []); } else { let filtered = localTodos?.filter((todo) => todo.assignees?.includes(selectedFilter.value)) || [];