mirror of
https://github.com/FranP-code/Pomodoro-Timer-with-Clockify-integration.git
synced 2025-10-12 23:52:30 +00:00
console.logs deleted
This commit is contained in:
@@ -48,8 +48,6 @@ function App() {
|
|||||||
root.style.display = 'flex'
|
root.style.display = 'flex'
|
||||||
root.style.flexDirection ='column'
|
root.style.flexDirection ='column'
|
||||||
|
|
||||||
} else {
|
|
||||||
console.log(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -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 ?
|
||||||
|
<h1>Loading</h1>
|
||||||
|
:
|
||||||
|
<div>
|
||||||
|
<select>
|
||||||
|
{
|
||||||
|
workspacesArray.map(workspace => (
|
||||||
|
|
||||||
|
<option> {workspace.name} </option>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withRouter(ClockifyTasksHoursCounter)
|
||||||
@@ -13,7 +13,6 @@ const makeRequest = async (apiKey) => {
|
|||||||
return await data
|
return await data
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,13 +13,8 @@ const getAndFormatCurrentTime = (KonamiCodeON) => {
|
|||||||
seconds: data.getSeconds()
|
seconds: data.getSeconds()
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(KonamiCodeON)
|
|
||||||
|
|
||||||
if (KonamiCodeON) {
|
if (KonamiCodeON) {
|
||||||
hour.hours = hour.hours + 3
|
hour.hours = hour.hours + 3
|
||||||
|
|
||||||
console.log(hour.hours)
|
|
||||||
console.log('KONAMI ON')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hour.hours === 24) {
|
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`
|
const structuredData = `${date.year}-${date.month}-${date.day}T${hour.hours}:${hour.minutes}:${hour.seconds}Z`
|
||||||
|
|
||||||
console.log(structuredData)
|
|
||||||
return structuredData
|
return structuredData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,10 +28,7 @@ const uploadToClockifyTimer = async (workspaceID, projectID, start, end, apiKey,
|
|||||||
const result = await fetch(url, request)
|
const result = await fetch(url, request)
|
||||||
const data = await result.json()
|
const data = await result.json()
|
||||||
|
|
||||||
console.log(data)
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ const DarkMode = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const darkModeCache = localStorage.getItem('dark-mode')
|
const darkModeCache = localStorage.getItem('dark-mode')
|
||||||
console.log(darkModeCache)
|
|
||||||
|
|
||||||
if (darkModeCache === 'true') {
|
if (darkModeCache === 'true') {
|
||||||
props.setDarkmode(true)
|
props.setDarkmode(true)
|
||||||
|
|||||||
@@ -76,13 +76,11 @@ const MainPomodoroTimer = (props) => {
|
|||||||
if (document.visibilityState === 'hidden') {
|
if (document.visibilityState === 'hidden') {
|
||||||
|
|
||||||
setVelocity(2)
|
setVelocity(2)
|
||||||
console.log(document.visibilityState)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document.visibilityState === 'visible') {
|
if (document.visibilityState === 'visible') {
|
||||||
|
|
||||||
setVelocity(1)
|
setVelocity(1)
|
||||||
console.log(document.visibilityState)
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ const detectKeys = (setKonamiCodeActive) => {
|
|||||||
let secuencie = []
|
let secuencie = []
|
||||||
|
|
||||||
window.addEventListener('keydown', (event) => {
|
window.addEventListener('keydown', (event) => {
|
||||||
|
|
||||||
console.log(event.key)
|
|
||||||
|
|
||||||
|
|
||||||
let k = event.key
|
let k = event.key
|
||||||
|
|
||||||
@@ -25,7 +22,6 @@ const detectKeys = (setKonamiCodeActive) => {
|
|||||||
secuencie[10] === 'Enter'
|
secuencie[10] === 'Enter'
|
||||||
) {
|
) {
|
||||||
|
|
||||||
console.log('TODO BIEN')
|
|
||||||
secuencie = []
|
secuencie = []
|
||||||
|
|
||||||
setKonamiCodeActive(true)
|
setKonamiCodeActive(true)
|
||||||
@@ -70,10 +66,7 @@ const detectKeys = (setKonamiCodeActive) => {
|
|||||||
|
|
||||||
secuencie = []
|
secuencie = []
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(secuencie)
|
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user