mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 08:24:55 +00:00
- Restricted editing of grocery and todo item for children
This commit is contained in:
@ -83,11 +83,15 @@ const GroceryItem = ({
|
||||
/>
|
||||
{!isEditingTitle ? (
|
||||
<View>
|
||||
<TouchableOpacity onPress={() => setIsEditingTitle(true)}>
|
||||
{ isParent ? <TouchableOpacity onPress={() => setIsEditingTitle(true)}>
|
||||
<Text text70T black style={styles.title}>
|
||||
{item.title}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</TouchableOpacity> :
|
||||
<Text text70T black style={styles.title}>
|
||||
{item.title}
|
||||
</Text>
|
||||
}
|
||||
</View>
|
||||
) : (
|
||||
<EditGroceryItem
|
||||
|
||||
@ -16,10 +16,14 @@ import { ImageBackground } from "react-native";
|
||||
import AddChoreDialog from "@/components/pages/todos/AddChoreDialog";
|
||||
import { useGetFamilyMembers } from "@/hooks/firebase/useGetFamilyMembers";
|
||||
import RepeatIcon from "@/assets/svgs/RepeatIcon";
|
||||
import {ProfileType, useAuthContext} from "@/contexts/AuthContext";
|
||||
|
||||
const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
||||
const { updateToDo } = useToDosContext();
|
||||
const { data: members } = useGetFamilyMembers();
|
||||
const { profileData } = useAuthContext();
|
||||
const isParent = profileData?.userType === ProfileType.PARENT;
|
||||
|
||||
const [visible, setVisible] = useState<boolean>(false);
|
||||
const [points, setPoints] = useState(props.item.points);
|
||||
const [pointsModalVisible, setPointsModalVisible] = useState<boolean>(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 (
|
||||
<View
|
||||
centerV
|
||||
@ -69,7 +81,7 @@ const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
||||
fontSize: 15,
|
||||
}}
|
||||
onPress={() => {
|
||||
setVisible(true);
|
||||
isTodoEditable ? setVisible(true) : null
|
||||
}}
|
||||
>
|
||||
{props.item.title}
|
||||
|
||||
Reference in New Issue
Block a user