diff --git a/app/(auth)/_layout.tsx b/app/(auth)/_layout.tsx index 4845457..aa94045 100644 --- a/app/(auth)/_layout.tsx +++ b/app/(auth)/_layout.tsx @@ -111,18 +111,21 @@ export default function TabLayout() { const showViewSwitch = ["calendar", "todos", "index"].includes( route.name ); + const isCalendarPage = ["calendar", "index"].includes(route.name); if (Device.deviceType !== DeviceType.TABLET || !showViewSwitch) { - return ( + return isCalendarPage ? ( - ); + ) : null; } return ( - - + + {isCalendarPage && ( + + )} ); diff --git a/components/pages/(tablet_pages)/chores/SingleUserChoreList.tsx b/components/pages/(tablet_pages)/chores/SingleUserChoreList.tsx index f8340f1..8bdb044 100644 --- a/components/pages/(tablet_pages)/chores/SingleUserChoreList.tsx +++ b/components/pages/(tablet_pages)/chores/SingleUserChoreList.tsx @@ -15,7 +15,12 @@ import { UserProfile } from "@/hooks/firebase/types/profileTypes"; import { ScrollView } from "react-native-gesture-handler"; const groupToDosByDate = (toDos: IToDo[]) => { - let sortedTodos = toDos.sort((a, b) => a.date - b.date); + let sortedTodos = toDos.sort((a, b) => { + const dateA = a.date === null ? new Date() : a.date; + const dateB = b.date === null ? new Date() : b.date; + return dateA - dateB; + }); + return sortedTodos.reduce( (groups, toDo) => { let dateKey; @@ -34,9 +39,7 @@ const groupToDosByDate = (toDos: IToDo[]) => { }); }; - if (toDo.date === null) { - dateKey = "No Date"; - } else if (isToday(toDo.date)) { + if (toDo.date === null || isToday(toDo.date)) { dateKey = "Today"; } else if (isTomorrow(toDo.date)) { dateKey = "Tomorrow"; @@ -228,42 +231,47 @@ const SingleUserChoreList = ({ user }: { user: UserProfile }) => { return ( - - {noDateToDos.length > 0 && ( - - - - Unscheduled - - { - setExpandNoDate(!expandNoDate); - }} - /> + + + {noDateToDos.length > 0 && ( + + + + Unscheduled + + { + setExpandNoDate(!expandNoDate); + }} + /> + + {expandNoDate && + noDateToDos + .sort((a, b) => Number(a.done) - Number(b.done)) + .map((item) => )} - {expandNoDate && - noDateToDos - .sort((a, b) => Number(a.done) - Number(b.done)) - .map((item) => )} - - )} + )} - {datedToDos.map(renderTodoGroup)} + {datedToDos.map(renderTodoGroup)} + ); diff --git a/components/pages/(tablet_pages)/chores/TabletChoresPage.tsx b/components/pages/(tablet_pages)/chores/TabletChoresPage.tsx index d85b2f1..160f79a 100644 --- a/components/pages/(tablet_pages)/chores/TabletChoresPage.tsx +++ b/components/pages/(tablet_pages)/chores/TabletChoresPage.tsx @@ -8,6 +8,7 @@ import { ImageBackground, StyleSheet } from "react-native"; import { colorMap } from "@/constants/colorMap"; import { ScrollView } from "react-native-gesture-handler"; import { ProfileType, useAuthContext } from "@/contexts/AuthContext"; +import AddChore from "../../todos/AddChore"; const TabletChoresPage = () => { const {data: users} = useGetFamilyMembers(); @@ -98,6 +99,9 @@ const TabletChoresPage = () => { ))} + + + ); }; @@ -113,6 +117,11 @@ const styles = StyleSheet.create({ fontSize: 22.43, color: "#2c2c2c", }, + addBtn: { + position: 'absolute', + bottom: 50, + right: 220 + } }); export default TabletChoresPage; diff --git a/components/pages/grocery/GroceryItem.tsx b/components/pages/grocery/GroceryItem.tsx index e076216..354dd44 100644 --- a/components/pages/grocery/GroceryItem.tsx +++ b/components/pages/grocery/GroceryItem.tsx @@ -25,6 +25,7 @@ const GroceryItem = ({ const { profileData } = useAuthContext(); const { data: creator } = useGetUserById(item.creatorId); const isParent = profileData?.userType === ProfileType.PARENT; + const isCaregiver = profileData?.userType === ProfileType.CAREGIVER; const [openFreqEdit, setOpenFreqEdit] = useState(false); const [isEditingTitle, setIsEditingTitle] = useState(false); @@ -36,7 +37,7 @@ const GroceryItem = ({ const closeEdit = () => setIsEditingTitle(false); const getInitials = (firstName: string, lastName: string) => { - return `${firstName.charAt(0)}${lastName.charAt(0)}`; + return `${firstName.charAt(0).toUpperCase()}${lastName.charAt(0).toUpperCase()}`; }; return ( @@ -81,7 +82,7 @@ const GroceryItem = ({ /> ) : ( - {isParent ? ( + {(isParent || isCaregiver) && !item.bought ? ( setIsEditingTitle(true)}> {item.title} @@ -108,7 +109,7 @@ const GroceryItem = ({ {!item.approved ? ( - {isParent && ( + {isParent || isCaregiver && ( <> ) : ( !isEditingTitle && - isParent && ( + (isParent || isCaregiver) && ( void}) => { id: "", title: title, category: category, - approved: profileData?.userType === ProfileType.PARENT, + approved: profileData?.userType === ProfileType.PARENT || profileData?.userType === ProfileType.CAREGIVER, recurring: false, frequency: GroceryFrequency.Never, bought: false, diff --git a/components/pages/todos/AddChoreDialog.tsx b/components/pages/todos/AddChoreDialog.tsx index e5149f9..d87dfd2 100644 --- a/components/pages/todos/AddChoreDialog.tsx +++ b/components/pages/todos/AddChoreDialog.tsx @@ -138,6 +138,7 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => { padding: 0, paddingTop: 4, margin: 0, + maxWidth: 600 }} visible={addChoreDialogProps.isVisible} > diff --git a/components/pages/todos/ToDosList.tsx b/components/pages/todos/ToDosList.tsx index 45bc481..b4ecd09 100644 --- a/components/pages/todos/ToDosList.tsx +++ b/components/pages/todos/ToDosList.tsx @@ -17,7 +17,12 @@ const FILTER_OPTIONS = { }; const groupToDosByDate = (toDos: IToDo[]) => { - let sortedTodos = toDos.sort((a, b) => a.date - b.date); + let sortedTodos = toDos.sort((a, b) => { + const dateA = a.date === null ? new Date() : a.date; + const dateB = b.date === null ? new Date() : b.date; + return dateA - dateB; + }); + return sortedTodos.reduce( (groups, toDo) => { let dateKey; @@ -36,9 +41,15 @@ const groupToDosByDate = (toDos: IToDo[]) => { }); }; - if (toDo.date === null) { - dateKey = "No Date"; - } else if (isToday(toDo.date)) { + const isOverdue = (date: Date) => { + const today = new Date(); + today.setHours(0, 0, 0, 0); + return date < today; + }; + + if (isOverdue(toDo.date) && !toDo.done) { + dateKey = "Overdue"; + } else if (toDo.date === null || isToday(toDo.date)) { dateKey = "Today"; } else if (isTomorrow(toDo.date)) { dateKey = "Tomorrow"; @@ -48,7 +59,8 @@ const groupToDosByDate = (toDos: IToDo[]) => { dateKey = "Next 30 Days"; subDateKey = format(toDo.date, "MMM d"); } else { - return groups; + dateKey = "Later"; + subDateKey = format(toDo.date, "MMM d, yyyy"); } if (!groups[dateKey]) { @@ -58,7 +70,7 @@ const groupToDosByDate = (toDos: IToDo[]) => { }; } - if (dateKey === "Next 30 Days" && subDateKey) { + if ((dateKey === "Next 30 Days" || dateKey === "Later") && subDateKey) { if (!groups[dateKey].subgroups[subDateKey]) { groups[dateKey].subgroups[subDateKey] = []; } @@ -138,14 +150,17 @@ const ToDosList = ({ isSettings }: { isSettings?: boolean }) => { }; const noDateToDos = groupedToDos["No Date"]?.items || []; - const datedToDos = Object.keys(groupedToDos).filter( - (key) => key !== "No Date" - ); + const datedToDos = Object.keys(groupedToDos) + .filter((key) => key !== "No Date") + .sort((a, b) => { + const order = ["Overdue", "Today", "Tomorrow", "Next 7 Days", "Next 30 Days", "Later"]; + return order.indexOf(a) - order.indexOf(b); + }); const renderTodoGroup = (dateKey: string) => { const isExpanded = expandedGroups[dateKey] || false; - if (dateKey === "Next 30 Days") { + if (dateKey === "Next 30 Days" || dateKey === "Later") { const subgroups = Object.entries(groupedToDos[dateKey].subgroups).sort( ([dateA], [dateB]) => { const dateAObj = new Date(dateA);