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 ? (
|
{!isEditingTitle ? (
|
||||||
<View>
|
<View>
|
||||||
<TouchableOpacity onPress={() => setIsEditingTitle(true)}>
|
{ isParent ? <TouchableOpacity onPress={() => setIsEditingTitle(true)}>
|
||||||
<Text text70T black style={styles.title}>
|
<Text text70T black style={styles.title}>
|
||||||
{item.title}
|
{item.title}
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity> :
|
||||||
|
<Text text70T black style={styles.title}>
|
||||||
|
{item.title}
|
||||||
|
</Text>
|
||||||
|
}
|
||||||
</View>
|
</View>
|
||||||
) : (
|
) : (
|
||||||
<EditGroceryItem
|
<EditGroceryItem
|
||||||
|
|||||||
@ -16,10 +16,14 @@ import { ImageBackground } from "react-native";
|
|||||||
import AddChoreDialog from "@/components/pages/todos/AddChoreDialog";
|
import AddChoreDialog from "@/components/pages/todos/AddChoreDialog";
|
||||||
import { useGetFamilyMembers } from "@/hooks/firebase/useGetFamilyMembers";
|
import { useGetFamilyMembers } from "@/hooks/firebase/useGetFamilyMembers";
|
||||||
import RepeatIcon from "@/assets/svgs/RepeatIcon";
|
import RepeatIcon from "@/assets/svgs/RepeatIcon";
|
||||||
|
import {ProfileType, useAuthContext} from "@/contexts/AuthContext";
|
||||||
|
|
||||||
const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
||||||
const { updateToDo } = useToDosContext();
|
const { updateToDo } = useToDosContext();
|
||||||
const { data: members } = useGetFamilyMembers();
|
const { data: members } = useGetFamilyMembers();
|
||||||
|
const { profileData } = useAuthContext();
|
||||||
|
const isParent = profileData?.userType === ProfileType.PARENT;
|
||||||
|
|
||||||
const [visible, setVisible] = useState<boolean>(false);
|
const [visible, setVisible] = useState<boolean>(false);
|
||||||
const [points, setPoints] = useState(props.item.points);
|
const [points, setPoints] = useState(props.item.points);
|
||||||
const [pointsModalVisible, setPointsModalVisible] = useState<boolean>(false);
|
const [pointsModalVisible, setPointsModalVisible] = useState<boolean>(false);
|
||||||
@ -41,6 +45,14 @@ const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
|||||||
const selectedMembers = members?.filter((x) =>
|
const selectedMembers = members?.filter((x) =>
|
||||||
props?.item?.assignees?.includes(x?.uid!)
|
props?.item?.assignees?.includes(x?.uid!)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let isTodoEditable;
|
||||||
|
if (isParent) {
|
||||||
|
isTodoEditable = true
|
||||||
|
} else {
|
||||||
|
isTodoEditable = props.item.creatorId === profileData?.uid;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
centerV
|
centerV
|
||||||
@ -69,7 +81,7 @@ const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
|||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
}}
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setVisible(true);
|
isTodoEditable ? setVisible(true) : null
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{props.item.title}
|
{props.item.title}
|
||||||
|
|||||||
Reference in New Issue
Block a user