mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 08:24:55 +00:00
- Fixed an issue with the Tod dialog
- Implementation of update todo and adding new days in the rule for a repeatable todo
This commit is contained in:
@ -31,7 +31,7 @@ const AddChore = () => {
|
||||
</Text>
|
||||
</Button>
|
||||
</View>
|
||||
<AddChoreDialog isVisible={isVisible} setIsVisible={setIsVisible} />
|
||||
{isVisible && <AddChoreDialog isVisible={isVisible} setIsVisible={setIsVisible} />}
|
||||
</LinearGradient>
|
||||
);
|
||||
};
|
||||
|
||||
@ -36,6 +36,7 @@ const defaultTodo = {
|
||||
rotate: false,
|
||||
repeatType: "Every week",
|
||||
assignees: [],
|
||||
repeatDays: []
|
||||
};
|
||||
|
||||
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
@ -48,14 +49,12 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
);
|
||||
const { width, height } = Dimensions.get("screen");
|
||||
const [points, setPoints] = useState<number>(todo.points);
|
||||
const [selectedDays, setSelectedDays] = useState([]);
|
||||
|
||||
const { data: members } = useGetFamilyMembers();
|
||||
|
||||
const handleClose = () => {
|
||||
setTodo(defaultTodo);
|
||||
setSelectedAssignees([]);
|
||||
setSelectedDays([]);
|
||||
addChoreDialogProps.setIsVisible(false);
|
||||
};
|
||||
|
||||
@ -71,12 +70,20 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
|
||||
const handleRepeatDaysChange = (day: string, set: boolean) => {
|
||||
if (set) {
|
||||
setSelectedDays((prevState) => [...prevState, day]);
|
||||
const updatedTodo = {
|
||||
...todo,
|
||||
repeatDays: [...todo.repeatDays, day]
|
||||
}
|
||||
setTodo(updatedTodo);
|
||||
} else {
|
||||
const array = selectedDays;
|
||||
const array = todo.repeatDays ?? [];
|
||||
let index = array.indexOf(day);
|
||||
array.splice(index, 1);
|
||||
setSelectedDays(array);
|
||||
const updatedTodo = {
|
||||
...todo,
|
||||
repeatDays: array
|
||||
}
|
||||
setTodo(updatedTodo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,8 +130,7 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
updateToDo({
|
||||
...todo,
|
||||
points: points,
|
||||
assignees: selectedAssignees,
|
||||
repeatDays: selectedDays,
|
||||
assignees: selectedAssignees
|
||||
});
|
||||
} else {
|
||||
addToDo({
|
||||
@ -132,7 +138,7 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
done: false,
|
||||
points: points,
|
||||
assignees: selectedAssignees,
|
||||
repeatDays: selectedDays
|
||||
repeatDays: todo.repeatDays ?? []
|
||||
});
|
||||
}
|
||||
handleClose();
|
||||
|
||||
@ -26,11 +26,14 @@ export default RepeatFreq;
|
||||
const RepeatOption = ({ value, handleRepeatDaysChange, repeatDays }: { value: string, handleRepeatDaysChange: Function, repeatDays: string[] }) => {
|
||||
const [isSet, setisSet] = useState(repeatDays.includes(value));
|
||||
|
||||
useEffect(() => {
|
||||
handleRepeatDaysChange(value, isSet);
|
||||
}, [isSet])
|
||||
|
||||
const handleDayChange = () => {
|
||||
handleRepeatDaysChange(value, !isSet)
|
||||
setisSet(!isSet);
|
||||
}
|
||||
|
||||
return (
|
||||
<TouchableOpacity onPress={() => setisSet(!isSet)}>
|
||||
<TouchableOpacity onPress={handleDayChange}>
|
||||
<View
|
||||
center
|
||||
marginT-8
|
||||
|
||||
Reference in New Issue
Block a user