WIP backup before merge
This commit is contained in:
@@ -12,8 +12,8 @@ type Task = {
|
||||
description: string;
|
||||
isCompleted: boolean;
|
||||
lastChanged: string;
|
||||
deadline: string;
|
||||
uId: string;
|
||||
aId: string;
|
||||
}
|
||||
|
||||
export default function Tasks() {
|
||||
@@ -34,6 +34,17 @@ export default function Tasks() {
|
||||
},
|
||||
[])
|
||||
|
||||
const GetTasks = async () => {
|
||||
const { data, error } = await supabase.from("tasks").select("*");
|
||||
|
||||
if (error) {
|
||||
Alert.alert("Tasks could not be fetched, please try again");
|
||||
return;
|
||||
}
|
||||
|
||||
SetTasks(data ?? []);
|
||||
}
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
if (session) {
|
||||
@@ -42,17 +53,6 @@ export default function Tasks() {
|
||||
}, [session])
|
||||
);
|
||||
|
||||
const GetTasks = async () => {
|
||||
const { data, error } = await supabase.from("tasks").select("tId, title, description, isCompleted,lastChanged, deadline, uId").order("deadline", { ascending: false });
|
||||
|
||||
if (error) {
|
||||
Alert.alert("Task could not be fetched, please try again");
|
||||
return;
|
||||
}
|
||||
|
||||
SetTasks(data ?? []);
|
||||
}
|
||||
|
||||
const DeleteTask = async (tId: string) => {
|
||||
Alert.alert(
|
||||
"Delete Task",
|
||||
@@ -101,7 +101,7 @@ export default function Tasks() {
|
||||
/>
|
||||
|
||||
<View style={defaultStyles.buttonContainer}>
|
||||
<Button title="Create Task" onPress={() => router.push("/createTask")} />
|
||||
<Button title="Create Task" onPress={() => router.push("/task/createTask")} />
|
||||
</View>
|
||||
|
||||
<SectionList
|
||||
@@ -113,12 +113,16 @@ export default function Tasks() {
|
||||
|
||||
return (
|
||||
<View style={defaultStyles.container}>
|
||||
<Text style={defaultStyles.boldBody}>{item.title}</Text>
|
||||
<Text style={defaultStyles.body}>{item.deadline}</Text>
|
||||
<Pressable style={defaultStyles.container} onPress={() => router.push({pathname: "/task/viewDetailsTask", params: { tId: item.tId }})}>
|
||||
<Text style={defaultStyles.boldBody}>{item.title}</Text>
|
||||
<View style={defaultStyles.checkbox}>
|
||||
{item.isCompleted && <Text style={defaultStyles.checkboxMark}>✓</Text>}
|
||||
</View>
|
||||
</Pressable>
|
||||
|
||||
{isOwner && (
|
||||
<View style={defaultStyles.buttonContainer}>
|
||||
<Button title="Edit" onPress={() => router.push({pathname: "/editTask", params: { tId: item.tId }})} />
|
||||
<Button title="Edit" onPress={() => router.push({pathname: "/task/editTask", params: { tId: item.tId }})} />
|
||||
<Button title="Delete" onPress={() => DeleteTask(item.tId)} />
|
||||
</View>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user