mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 08:24:55 +00:00
- Added the assignees to the todo item
This commit is contained in:
@ -5,7 +5,7 @@ import {
|
|||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
Dialog,
|
Dialog,
|
||||||
Button,
|
Button,
|
||||||
ButtonSize,
|
ButtonSize
|
||||||
} from "react-native-ui-lib";
|
} from "react-native-ui-lib";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useToDosContext } from "@/contexts/ToDosContext";
|
import { useToDosContext } from "@/contexts/ToDosContext";
|
||||||
@ -14,9 +14,11 @@ import PointsSlider from "@/components/shared/PointsSlider";
|
|||||||
import { IToDo } from "@/hooks/firebase/types/todoData";
|
import { IToDo } from "@/hooks/firebase/types/todoData";
|
||||||
import { ImageBackground } from "react-native";
|
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";
|
||||||
|
|
||||||
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 [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);
|
||||||
@ -30,6 +32,12 @@ const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
|||||||
setPoints(0);
|
setPoints(0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getInitials = (firstName: string, lastName: string) => {
|
||||||
|
return `${firstName.charAt(0)}${lastName.charAt(0)}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const selectedMembers = members?.filter((x) => props?.item?.assignees?.includes(x?.uid!));
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
centerV
|
centerV
|
||||||
@ -96,6 +104,9 @@ const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
|||||||
) : (
|
) : (
|
||||||
<View />
|
<View />
|
||||||
)}
|
)}
|
||||||
|
<View row style={{ gap: 3 }}>
|
||||||
|
{selectedMembers?.map((member) => {
|
||||||
|
return member?.pfp ? (
|
||||||
<ImageBackground
|
<ImageBackground
|
||||||
source={require("../../../assets/images/child-picture.png")}
|
source={require("../../../assets/images/child-picture.png")}
|
||||||
style={{
|
style={{
|
||||||
@ -105,6 +116,32 @@ const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
|||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
<View style={{
|
||||||
|
position: 'relative',
|
||||||
|
width: 24.64,
|
||||||
|
aspectRatio: 1
|
||||||
|
}}>
|
||||||
|
<View style={{
|
||||||
|
backgroundColor: '#ccc',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
borderRadius: 100, // Circular shape
|
||||||
|
width: '100%',
|
||||||
|
height: '100%'
|
||||||
|
}}>
|
||||||
|
<Text style={{
|
||||||
|
color: '#fff',
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: 'bold'
|
||||||
|
}}>
|
||||||
|
{getInitials(member.firstName, member.lastName ?? "")}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<Dialog
|
<Dialog
|
||||||
visible={pointsModalVisible}
|
visible={pointsModalVisible}
|
||||||
|
|||||||
Reference in New Issue
Block a user