From 17e5633d2ae3ee544f9166ccce6ab33f91817860 Mon Sep 17 00:00:00 2001 From: Robert Ostermann Date: Thu, 2 Nov 2023 12:03:03 -0500 Subject: [PATCH] Allow duration to be entered manually --- .../components/pages/coaches/Entry/Entry.tsx | 48 ++++++------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/client/src/components/pages/coaches/Entry/Entry.tsx b/client/src/components/pages/coaches/Entry/Entry.tsx index b65f5d6..52d762b 100644 --- a/client/src/components/pages/coaches/Entry/Entry.tsx +++ b/client/src/components/pages/coaches/Entry/Entry.tsx @@ -24,7 +24,7 @@ export default function CoachEntry() { const [user, setUser] = useState(); const [isLoading, setIsLoading] = useState(false); const [activity, setActivity] = useState(ActivityTypes.game.id); - const [duration, setDuration] = useState(15); + const [duration, setDuration] = useState(15); const [date, setDate] = useState( new Date(new Date().setHours(0, 0, 0, 0)) ); @@ -50,7 +50,7 @@ export default function CoachEntry() { mutationFn: () => EntryRequests.createEntry(token, { authId: user?.authId, activityType: activity, - activityDuration: duration, + activityDuration: typeof duration === "number" ? duration : 0, activityDate: date, }), onSuccess: () => { @@ -105,32 +105,6 @@ export default function CoachEntry() { ); }; - const durationOptions = () => { - const options = []; - let currentDuration = 15; - const maxDuration = 180; - - let index = 0; - while (currentDuration <= maxDuration) { - currentDuration += 15; - const hours = Math.floor(currentDuration / 60); - const hoursString = - hours > 0 ? (hours === 1 ? `${hours} Hour ` : `${hours} Hours `) : ""; - const minutes = currentDuration % 60; - const minutesString = `${minutes} minutes`; - - options.push( - - ); - index++; - } - - return options; - }; - const submitButton = () => { return ( - Duration - setDuration(parseInt(event.target.value))} - > - {durationOptions()} - + Duration (minutes) + { + const number = parseInt(event.target.value); + if (isNaN(number)) setDuration(""); + else setDuration(parseInt(event.target.value)) + }} + /> {submitButton()}