diff --git a/src/App.js b/src/App.js index 16ff13d..51d72b6 100644 --- a/src/App.js +++ b/src/App.js @@ -48,8 +48,6 @@ function App() { root.style.display = 'flex' root.style.flexDirection ='column' - } else { - console.log(false) } return ( diff --git a/src/components/Clockify Tasks Hours Counter/ClockifyTasksHoursCounter.jsx b/src/components/Clockify Tasks Hours Counter/ClockifyTasksHoursCounter.jsx new file mode 100644 index 0000000..33af9fc --- /dev/null +++ b/src/components/Clockify Tasks Hours Counter/ClockifyTasksHoursCounter.jsx @@ -0,0 +1,125 @@ +import React, {useState} from 'react' +import { makeRequest } from '../Clockify/clockify' + +import { getFirestore, doc, getDoc } from 'firebase/firestore' +import { onAuthStateChanged, getAuth } from 'firebase/auth' + +import { firebase } from '../Firebase/firebase' +import { withRouter } from 'react-router-dom' + +const ClockifyTasksHoursCounter = (props) => { + + const auth = getAuth() + + const [userUID, setUserUID] = useState('') + + const [workspacesArray, setWorkspacesArray] = useState([]) + + const [loading, setLoading] = useState(true) + + const getApiKey = async () => { + + try { + + const db = await getFirestore(firebase) + + const reference = await doc(db, 'users', userUID) + + const dataSnap = await getDoc(reference) + const result = await dataSnap.data() + + return result.keyClockify + + + } catch (error) { + + } + } + + const makeRequestWorkspaces = async (apiClockify) => { + + try { + const request = { + method: "GET", + headers: { + 'X-Api-Key': apiClockify, + "content-type": "application/json" + } + } + const response = await fetch(`https://api.clockify.me/api/v1/workspaces/`, request) + const data = await response.json() + + return await data + + } catch (error) { + + } + } + + const bringData = async () => { + + await makeRequest(props.apiKey) + } + + React.useEffect( () => { + + if (props.signIn) { + + onAuthStateChanged(auth, async (user) => { + + if (user) { + + setUserUID(await user.uid) + + if (userUID) { + + const keyClockify = await getApiKey() + + const workspaces = await makeRequestWorkspaces(keyClockify) + + workspaces.forEach(workspace => { + + let copyWorkspacesArray = workspacesArray + copyWorkspacesArray.push(workspace) + + setWorkspacesArray(copyWorkspacesArray) + }) + + setLoading(false) + } + } else { + + return (<>) + } + + }) + } else { + + props.history.push('/') + } + + }, [props, onAuthStateChanged, setUserUID, userUID]) + + + return ( + <> + { + loading ? +

Loading

+ : +
+ +
+ } + + ) +} + +export default withRouter(ClockifyTasksHoursCounter) diff --git a/src/components/Clockify/clockify.js b/src/components/Clockify/clockify.js index e1b273f..c4bebdc 100644 --- a/src/components/Clockify/clockify.js +++ b/src/components/Clockify/clockify.js @@ -13,7 +13,6 @@ const makeRequest = async (apiKey) => { return await data } catch (error) { - console.log(error) } } diff --git a/src/components/Clockify/getAndFormatCurrentTime.js b/src/components/Clockify/getAndFormatCurrentTime.js index 628f7df..e748927 100644 --- a/src/components/Clockify/getAndFormatCurrentTime.js +++ b/src/components/Clockify/getAndFormatCurrentTime.js @@ -13,13 +13,8 @@ const getAndFormatCurrentTime = (KonamiCodeON) => { seconds: data.getSeconds() } - console.log(KonamiCodeON) - if (KonamiCodeON) { hour.hours = hour.hours + 3 - - console.log(hour.hours) - console.log('KONAMI ON') } if (hour.hours === 24) { @@ -51,7 +46,6 @@ const getAndFormatCurrentTime = (KonamiCodeON) => { const structuredData = `${date.year}-${date.month}-${date.day}T${hour.hours}:${hour.minutes}:${hour.seconds}Z` - console.log(structuredData) return structuredData } diff --git a/src/components/Clockify/uploadToClockifyTimer.js b/src/components/Clockify/uploadToClockifyTimer.js index 3636a57..d3db160 100644 --- a/src/components/Clockify/uploadToClockifyTimer.js +++ b/src/components/Clockify/uploadToClockifyTimer.js @@ -28,10 +28,7 @@ const uploadToClockifyTimer = async (workspaceID, projectID, start, end, apiKey, const result = await fetch(url, request) const data = await result.json() - console.log(data) - } catch (error) { - console.log(error) } } diff --git a/src/components/Header Childrens/DarkMode.jsx b/src/components/Header Childrens/DarkMode.jsx index 5a004b3..cc6e5fc 100644 --- a/src/components/Header Childrens/DarkMode.jsx +++ b/src/components/Header Childrens/DarkMode.jsx @@ -13,7 +13,6 @@ const DarkMode = (props) => { } const darkModeCache = localStorage.getItem('dark-mode') - console.log(darkModeCache) if (darkModeCache === 'true') { props.setDarkmode(true) diff --git a/src/components/Main Pomodoro Childrens/MainPomodoroTimer.jsx b/src/components/Main Pomodoro Childrens/MainPomodoroTimer.jsx index 6b15c7c..6b5e444 100644 --- a/src/components/Main Pomodoro Childrens/MainPomodoroTimer.jsx +++ b/src/components/Main Pomodoro Childrens/MainPomodoroTimer.jsx @@ -76,13 +76,11 @@ const MainPomodoroTimer = (props) => { if (document.visibilityState === 'hidden') { setVelocity(2) - console.log(document.visibilityState) } if (document.visibilityState === 'visible') { setVelocity(1) - console.log(document.visibilityState) } }); diff --git a/src/components/Misc/detectKeys.js b/src/components/Misc/detectKeys.js index 71d737d..8b48e24 100644 --- a/src/components/Misc/detectKeys.js +++ b/src/components/Misc/detectKeys.js @@ -3,9 +3,6 @@ const detectKeys = (setKonamiCodeActive) => { let secuencie = [] window.addEventListener('keydown', (event) => { - - console.log(event.key) - let k = event.key @@ -25,7 +22,6 @@ const detectKeys = (setKonamiCodeActive) => { secuencie[10] === 'Enter' ) { - console.log('TODO BIEN') secuencie = [] setKonamiCodeActive(true) @@ -70,10 +66,7 @@ const detectKeys = (setKonamiCodeActive) => { secuencie = [] break; - } - - console.log(secuencie) - + } }) }