diff --git a/app/src/components/GoalDetails.js b/app/src/components/GoalDetails.js index bd831d3..0c756d3 100644 --- a/app/src/components/GoalDetails.js +++ b/app/src/components/GoalDetails.js @@ -93,6 +93,18 @@ function GoalDetails() { ); } + const getProgressValue = () => { + if (!goalDetails.goal_practice_times) { + return 0; + } + + if (goalDetails.goal_practice_times >= goalDetails.goal_times) { + return 100; + } + + return (goalDetails.goal_practice_times * 100) / goalDetails.goal_times; + }; + return ( <>
@@ -119,7 +131,7 @@ function GoalDetails() { Progress: {goalDetails.goal_practice_times < goalDetails.goal_times && ( @@ -134,7 +146,7 @@ function GoalDetails() { )} {goalDetails.goal_practice_times >= goalDetails.goal_times && ( - Congrats! You've completed this goal already. + Congrats! You've completed this goal :) )} diff --git a/app/src/components/Homepage.js b/app/src/components/Homepage.js index a0d1f2c..6d62b9f 100644 --- a/app/src/components/Homepage.js +++ b/app/src/components/Homepage.js @@ -101,6 +101,18 @@ function Homepage() { setIsAuthed(isAuthenticated()); }; + const getProgressValue = (goalDetails) => { + if (!goalDetails.goal_practice_times) { + return 0; + } + + if (goalDetails.goal_practice_times >= goalDetails.goal_times) { + return 100; + } + + return (goalDetails.goal_practice_times * 100) / goalDetails.goal_times; + }; + const getExistingGoalsTable = () => { if (!existingGoals.length) { return ( @@ -152,7 +164,7 @@ function Homepage() { {moment(row.goal_end_date).format('MMM D, YYYY')}