mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 00:24:53 +00:00
merge resolve
This commit is contained in:
@ -1,17 +1,17 @@
|
||||
import {Text, View} from "react-native";
|
||||
import React, {useEffect, useRef} from "react";
|
||||
import {TextField, TextFieldRef} from "react-native-ui-lib";
|
||||
import {GroceryCategory, IGrocery, useGroceryContext,} from "@/contexts/GroceryContext";
|
||||
import {GroceryCategory, useGroceryContext,} from "@/contexts/GroceryContext";
|
||||
|
||||
interface IEditGrocery {
|
||||
id?: number;
|
||||
id?: string;
|
||||
title: string;
|
||||
category: GroceryCategory;
|
||||
setTitle: (value: string) => void;
|
||||
setCategory?: (category: GroceryCategory) => void;
|
||||
category: GroceryCategory;
|
||||
setSubmit?: (value: boolean) => void;
|
||||
updateCategory?: (id: number, changes: Partial<IGrocery>) => void;
|
||||
closeEdit?: (value: boolean) => void;
|
||||
handleEditSubmit?: Function
|
||||
}
|
||||
|
||||
const EditGroceryItem = ({editGrocery}: { editGrocery: IEditGrocery }) => {
|
||||
@ -49,12 +49,18 @@ const EditGroceryItem = ({editGrocery}: { editGrocery: IEditGrocery }) => {
|
||||
editGrocery.setTitle(value);
|
||||
}}
|
||||
onSubmitEditing={() => {
|
||||
if (editGrocery.setSubmit) editGrocery.setSubmit(true);
|
||||
if (editGrocery.closeEdit) editGrocery.closeEdit(false);
|
||||
if (editGrocery.updateCategory && editGrocery.id)
|
||||
editGrocery.updateCategory(editGrocery.id, {
|
||||
category: fuzzyMatchGroceryCategory(editGrocery.title), title: editGrocery.title
|
||||
});
|
||||
if (editGrocery.setSubmit) {
|
||||
editGrocery.setSubmit(true);
|
||||
}
|
||||
if (editGrocery.setCategory) {
|
||||
editGrocery.setCategory(fuzzyMatchGroceryCategory(editGrocery.title));
|
||||
}
|
||||
if (editGrocery.handleEditSubmit) {
|
||||
editGrocery.handleEditSubmit({id: editGrocery.id, title: editGrocery.title, category: editGrocery.category});
|
||||
}
|
||||
if (editGrocery.closeEdit) {
|
||||
editGrocery.closeEdit(false);
|
||||
}
|
||||
}}
|
||||
maxLength={25}
|
||||
/>
|
||||
|
||||
@ -84,11 +84,11 @@ const GroceryItem = ({
|
||||
editGrocery={{
|
||||
id: item.id,
|
||||
title: newTitle,
|
||||
setTitle: setNewTitle,
|
||||
category: category,
|
||||
updateCategory: updateGroceryItem,
|
||||
closeEdit: setIsEditingTitle,
|
||||
setTitle: setNewTitle,
|
||||
setCategory: setCategory,
|
||||
closeEdit: setIsEditingTitle,
|
||||
handleEditSubmit: updateGroceryItem
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
@ -1,34 +1,14 @@
|
||||
import { StyleSheet } from "react-native";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
ButtonSize,
|
||||
View,
|
||||
Text,
|
||||
ActionSheet,
|
||||
TextField,
|
||||
Dialog,
|
||||
Slider,
|
||||
NumberInput,
|
||||
NumberInputData,
|
||||
DateTimePicker,
|
||||
Switch,
|
||||
Picker,
|
||||
} from "react-native-ui-lib";
|
||||
import { AntDesign, Feather, Ionicons } from "@expo/vector-icons";
|
||||
import React, { useState } from "react";
|
||||
import { Button, ButtonSize, Text, View } from "react-native-ui-lib";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import LinearGradient from "react-native-linear-gradient";
|
||||
import { PanningDirectionsEnum } from "react-native-ui-lib/src/components/panningViews/panningProvider";
|
||||
import { repeatOptions, useToDosContext } from "@/contexts/ToDosContext";
|
||||
import { setDate } from "date-fns";
|
||||
import PointsSlider from "@/components/shared/PointsSlider";
|
||||
import AddChoreDialog from "./AddChoreDialog";
|
||||
|
||||
const AddChore = () => {
|
||||
|
||||
const [isVisible, setIsVisible] = useState<boolean>(false);
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<LinearGradient
|
||||
colors={["transparent", "#f9f8f7"]}
|
||||
|
||||
@ -13,26 +13,31 @@ import {
|
||||
import { PanningDirectionsEnum } from "react-native-ui-lib/src/incubator/panView";
|
||||
import { StyleSheet } from "react-native";
|
||||
import DropModalIcon from "@/assets/svgs/DropModalIcon";
|
||||
import { IToDo } from "@/hooks/firebase/types/todoData";
|
||||
|
||||
interface IAddChoreDialog {
|
||||
isVisible: boolean;
|
||||
setIsVisible: (value: boolean) => void;
|
||||
selectedTodo?: IToDo
|
||||
}
|
||||
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
const { addToDo, toDos } = useToDosContext();
|
||||
|
||||
const [newTitle, setNewTitle] = useState<string>("");
|
||||
const [points, setPoints] = useState<number>(10);
|
||||
const [choreDate, setChoreDate] = useState<Date | null>(new Date());
|
||||
const [rotate, setRotate] = useState<boolean>(false);
|
||||
const [repeatType, setRepeatType] = useState<string>("Every week");
|
||||
const defaultTodo = {
|
||||
id: "",
|
||||
title: "",
|
||||
points: 10,
|
||||
date: new Date(),
|
||||
rotate: false,
|
||||
repeatType: "Every week"
|
||||
};
|
||||
|
||||
const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
const { addToDo, updateToDo } = useToDosContext();
|
||||
const [todo, setTodo] = useState<IToDo>(addChoreDialogProps.selectedTodo ?? defaultTodo)
|
||||
|
||||
const [points, setPoints] = useState<number>(todo.points);
|
||||
|
||||
const handleClose = () => {
|
||||
setNewTitle("");
|
||||
setPoints(10);
|
||||
setChoreDate(new Date());
|
||||
setRotate(false);
|
||||
setRepeatType("every week");
|
||||
setTodo(defaultTodo);
|
||||
addChoreDialogProps.setIsVisible(false);
|
||||
};
|
||||
|
||||
@ -45,6 +50,7 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
setPoints(0);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
bottom={true}
|
||||
@ -84,15 +90,15 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
label="Save"
|
||||
onPress={() => {
|
||||
try {
|
||||
if (addChoreDialogProps.selectedTodo) {
|
||||
updateToDo({...todo, points: points})
|
||||
} else {
|
||||
addToDo({
|
||||
id: "",
|
||||
title: newTitle,
|
||||
...todo,
|
||||
done: false,
|
||||
date: choreDate,
|
||||
points: points,
|
||||
rotate: rotate,
|
||||
repeatType: repeatType,
|
||||
});
|
||||
}
|
||||
handleClose();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@ -102,9 +108,9 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
</View>
|
||||
<TextField
|
||||
placeholder="Add a To Do"
|
||||
value={newTitle}
|
||||
value={todo?.title}
|
||||
onChangeText={(text) => {
|
||||
setNewTitle(text);
|
||||
setTodo((oldValue: IToDo) => ({...oldValue, title: text}));
|
||||
}}
|
||||
placeholderTextColor="#2d2d30"
|
||||
text60R
|
||||
@ -114,15 +120,15 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
<View style={styles.divider} marginT-8 />
|
||||
<View marginL-30 centerV>
|
||||
<View row marginB-10>
|
||||
{choreDate && (
|
||||
{todo?.date && (
|
||||
<View row centerV>
|
||||
<Feather name="calendar" size={25} color="#919191" />
|
||||
<DateTimePicker
|
||||
value={choreDate}
|
||||
value={todo.date}
|
||||
text70
|
||||
marginL-8
|
||||
onChange={(date) => {
|
||||
setChoreDate(date);
|
||||
setTodo((oldValue: IToDo) => ({...oldValue, date: date}));
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
@ -133,15 +139,13 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
<Picker
|
||||
marginL-8
|
||||
placeholder="Select Repeat Type"
|
||||
value={repeatType}
|
||||
value={todo?.repeatType}
|
||||
onChange={(value) => {
|
||||
if (value) {
|
||||
if (value.toString() == "None") {
|
||||
setChoreDate(null);
|
||||
setRepeatType("None");
|
||||
setTodo((oldValue) => ({...oldValue, date: null, repeatType: "None"}));
|
||||
} else {
|
||||
setRepeatType(value.toString());
|
||||
setChoreDate(new Date());
|
||||
setTodo((oldValue) => ({...oldValue, date: new Date(), repeatType: value.toString()}))
|
||||
}
|
||||
}
|
||||
}}
|
||||
@ -206,9 +210,9 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
|
||||
<Text text80>Take Turns</Text>
|
||||
<Switch
|
||||
onColor={"#ea156c"}
|
||||
value={rotate}
|
||||
value={todo.rotate}
|
||||
marginL-10
|
||||
onValueChange={(value) => setRotate(value)}
|
||||
onValueChange={(value) => setTodo((oldValue) => ({...oldValue, rotate: value}))}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.divider} />
|
||||
|
||||
@ -2,19 +2,18 @@ import {
|
||||
View,
|
||||
Text,
|
||||
Checkbox,
|
||||
TextField,
|
||||
TouchableOpacity,
|
||||
Modal,
|
||||
Dialog,
|
||||
Button,
|
||||
ButtonSize,
|
||||
} from "react-native-ui-lib";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, { useState } from "react";
|
||||
import { useToDosContext } from "@/contexts/ToDosContext";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import PointsSlider from "@/components/shared/PointsSlider";
|
||||
import { IToDo } from "@/hooks/firebase/types/todoData";
|
||||
import { ImageBackground } from "react-native";
|
||||
import AddChoreDialog from "@/components/pages/todos/AddChoreDialog";
|
||||
|
||||
const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
||||
const { updateToDo } = useToDosContext();
|
||||
@ -43,8 +42,8 @@ const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
||||
opacity: props.item.done ? 0.3 : 1,
|
||||
}}
|
||||
>
|
||||
<AddChoreDialog isVisible={editing} setIsVisible={setEditing} selectedTodo={props.item}/>
|
||||
<View paddingB-8 row spread>
|
||||
{!editing ? (
|
||||
<Text
|
||||
text70
|
||||
style={{
|
||||
@ -53,28 +52,11 @@ const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => {
|
||||
fontSize: 15,
|
||||
}}
|
||||
onPress={() => {
|
||||
if (props.isSettings) {
|
||||
setEditing(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{props.item.title}
|
||||
</Text>
|
||||
) : (
|
||||
<TextField
|
||||
value={props.item.title}
|
||||
text70R
|
||||
onChangeText={(text) => {
|
||||
updateToDo({ id: props.item.id, title: text });
|
||||
}}
|
||||
onSubmitEditing={() => {
|
||||
setEditing(false);
|
||||
}}
|
||||
onBlur={() => {
|
||||
setEditing(false);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<Checkbox
|
||||
value={props.item.done}
|
||||
containerStyle={{borderWidth: 0.7, borderRadius: 50, borderColor: 'gray', height: 24.64, width: 24.64}}
|
||||
|
||||
@ -7,7 +7,8 @@ import { AntDesign } from "@expo/vector-icons";
|
||||
import {IToDo} from "@/hooks/firebase/types/todoData";
|
||||
|
||||
const groupToDosByDate = (toDos: IToDo[]) => {
|
||||
return toDos.reduce((groups, toDo) => {
|
||||
let sortedTodos = toDos.sort((a, b) => a.date - b.date);
|
||||
return sortedTodos.reduce((groups, toDo) => {
|
||||
let dateKey;
|
||||
|
||||
if (toDo.date === null) {
|
||||
|
||||
@ -3,7 +3,7 @@ export interface IToDo {
|
||||
title: string;
|
||||
done: boolean;
|
||||
date: Date | null;
|
||||
points?: number;
|
||||
points: number;
|
||||
rotate: boolean;
|
||||
repeatType: string;
|
||||
creatorId?: string,
|
||||
|
||||
Reference in New Issue
Block a user