From b2b1e5d1e45a5150248db853ab73d87e2bc743af Mon Sep 17 00:00:00 2001 From: Dejan Date: Sat, 26 Oct 2024 15:36:01 +0200 Subject: [PATCH] - Restricted editing of grocery and todo item for children --- components/pages/grocery/GroceryItem.tsx | 8 ++++++-- components/pages/todos/ToDoItem.tsx | 14 +++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/components/pages/grocery/GroceryItem.tsx b/components/pages/grocery/GroceryItem.tsx index 32c79ad..72f19cd 100644 --- a/components/pages/grocery/GroceryItem.tsx +++ b/components/pages/grocery/GroceryItem.tsx @@ -83,11 +83,15 @@ const GroceryItem = ({ /> {!isEditingTitle ? ( - setIsEditingTitle(true)}> + { isParent ? setIsEditingTitle(true)}> {item.title} - + : + + {item.title} + + } ) : ( { const { updateToDo } = useToDosContext(); const { data: members } = useGetFamilyMembers(); + const { profileData } = useAuthContext(); + const isParent = profileData?.userType === ProfileType.PARENT; + const [visible, setVisible] = useState(false); const [points, setPoints] = useState(props.item.points); const [pointsModalVisible, setPointsModalVisible] = useState(false); @@ -41,6 +45,14 @@ const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => { const selectedMembers = members?.filter((x) => props?.item?.assignees?.includes(x?.uid!) ); + + let isTodoEditable; + if (isParent) { + isTodoEditable = true + } else { + isTodoEditable = props.item.creatorId === profileData?.uid; + } + return ( { fontSize: 15, }} onPress={() => { - setVisible(true); + isTodoEditable ? setVisible(true) : null }} > {props.item.title}