From e28e53eab6d4e5558a790274e03e49fcf4f8da92 Mon Sep 17 00:00:00 2001 From: Conrad Christian Date: Tue, 19 Nov 2024 01:04:44 -0800 Subject: [PATCH] Improve challenge navigation, query optimization, and fix delete goal --- app/(tabs)/challenges.tsx | 14 ++++++----- app/challenges/[id]/index.tsx | 5 +--- app/challenges/create/index.tsx | 32 +++++++++++++----------- app/goals/[goalId]/[goalLogId]/index.tsx | 2 +- convex/challengeGoals.ts | 16 ++++++++++++ 5 files changed, 43 insertions(+), 26 deletions(-) diff --git a/app/(tabs)/challenges.tsx b/app/(tabs)/challenges.tsx index ad3c2458..d53846b5 100644 --- a/app/(tabs)/challenges.tsx +++ b/app/(tabs)/challenges.tsx @@ -12,7 +12,7 @@ import { isBefore, isAfter, } from "date-fns"; -import { Link } from "expo-router"; +import { Link, router } from "expo-router"; const getChallengeStatus = (startDate: Date, endDate: Date) => { const currentDate = new Date(); @@ -52,11 +52,13 @@ export default function ChallengesScreen() { {/* TODO: Allow only admin to create challenges */} - - - + goal.challengeId === id - ); + const filteredChallengeGoals = useQuery(api.challengeGoals.listChallengeGoalsById, { goalId: id }); const createGoalLogsFromGoal = useMutation( api.goalLogs.createGoalLogsFromGoal ); diff --git a/app/challenges/create/index.tsx b/app/challenges/create/index.tsx index 4e484d41..03a26ef3 100644 --- a/app/challenges/create/index.tsx +++ b/app/challenges/create/index.tsx @@ -93,23 +93,25 @@ function CreateChallengeForm() {