From e044cacccf8bb08e4507c5145d92387864560ca4 Mon Sep 17 00:00:00 2001 From: Francisco Pessano Date: Thu, 30 Sep 2021 19:30:49 -0300 Subject: [PATCH] The times passed in the pomodoro work cicle now are registered in Clockify (apparently) --- .../MainPomodoroTimer.jsx | 22 ++++++---- src/components/MainPomodoro.jsx | 40 ++++++++++++++++++- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/src/components/Main Pomodoro Childrens/MainPomodoroTimer.jsx b/src/components/Main Pomodoro Childrens/MainPomodoroTimer.jsx index 9184132..59b6092 100644 --- a/src/components/Main Pomodoro Childrens/MainPomodoroTimer.jsx +++ b/src/components/Main Pomodoro Childrens/MainPomodoroTimer.jsx @@ -20,8 +20,6 @@ const MainPomodoroTimer = (props) => { const [alreadyCountingStart, setAlreadyCountingStart] = useState(false) /* TOO MUCH FUCKING STATES https://pbs.twimg.com/media/EoM2rXuW8AMRxZh?format=png&name=large*/ const [alreadyCountingEnd, setAlreadyCountingEnd] = useState(false) - const [startTime, setStartTime] = useState('') - const setTimeStyle = () => { if (props.style === 'Can I play, Daddy?') { @@ -227,7 +225,8 @@ const MainPomodoroTimer = (props) => { if (!weAreInBreakTime) { if (!alreadyCountingStart) { - getAndFormatCurrentTime() + const time = getAndFormatCurrentTime() + props.setStartTime(time) setAlreadyCountingStart(true) } @@ -262,9 +261,12 @@ const MainPomodoroTimer = (props) => { } if (!alreadyCountingEnd) { - getAndFormatCurrentTime() - + const time = getAndFormatCurrentTime() + + props.setEndTime(time) setAlreadyCountingEnd(true) + + props.setLetsUpload(true) } } @@ -322,9 +324,12 @@ const MainPomodoroTimer = (props) => { setRestCounter((restCounter + 1)) if (!alreadyCountingEnd) { - getAndFormatCurrentTime() + const time = getAndFormatCurrentTime() + props.setEndTime(time) setAlreadyCountingEnd(true) + + props.setLetsUpload(true) } } } @@ -353,8 +358,11 @@ const MainPomodoroTimer = (props) => { setTimerActivity(false) setTimeStyle() } + + setAlreadyCountingStart(false) + setAlreadyCountingEnd(false) } - }, [props.timerOn, minutes, seconds, breakTime, setMinutes, setSeconds, getAndFormatCurrentTime, setAlreadyCountingEnd, setAlreadyCountingStart, alreadyCountingEnd, alreadyCountingStart] + }, [props.timerOn, minutes, seconds, breakTime, setMinutes, setSeconds, getAndFormatCurrentTime, setAlreadyCountingEnd, setAlreadyCountingStart, alreadyCountingEnd, alreadyCountingStart, props.setEndTime, props.endTime] ) const formatMinutes = () => { diff --git a/src/components/MainPomodoro.jsx b/src/components/MainPomodoro.jsx index 4086ade..fbdbf93 100644 --- a/src/components/MainPomodoro.jsx +++ b/src/components/MainPomodoro.jsx @@ -2,7 +2,8 @@ import React, {useState} from 'react' import MainPomodoroTimer from './Main Pomodoro Childrens/MainPomodoroTimer' import PomodoroCounter from './Main Pomodoro Childrens/PomodoroCounter' import StyleSelector from './Main Pomodoro Childrens/StyleSelector' - +import uploadToClockifyTimer from './Clockify/uploadToClockifyTimer' +import react from 'react' const MainPomodoro = (props) => { @@ -16,12 +17,35 @@ const MainPomodoro = (props) => { const [rests, setRests] = useState(0) const [longRests, setLongRests] = useState(0) + + + const [startTime, setStartTime] = useState('') + const [endTime, setEndTime] = useState('') + + const [letsUpload, setLetsUpload] = useState(false) + + const showStyles = () => { console.log('Styles Deployed') setDisplayHidden(!displayHidden) } + React.useEffect( () => { + if (letsUpload) { + + uploadToClockifyTimer( props.workspaceID, props.projectID, startTime, endTime, props.apiKey) + + setLetsUpload(false) + + setStartTime('') + setEndTime('') + } + }) + + + + return ( <>
@@ -50,6 +74,20 @@ const MainPomodoro = (props) => { setProjectID={props.setProjectID} apiKey={props.apiKey} + + /*alreadyCountingStart={alreadyCountingStart} + setAlreadyCountingStart={setAlreadyCountingStart} + + alreadyCountingEnd={alreadyCountingEnd} + setAlreadyCountingEnd={setAlreadyCountingEnd}*/ + + startTime={startTime} + setStartTime={setStartTime} + + endtime={endTime} + setEndTime={setEndTime} + + setLetsUpload={setLetsUpload} />