Mod. git ignore

This commit is contained in:
2021-10-05 21:50:59 -03:00
parent 8a7b4ec1d2
commit ad4b9b7cd0
5 changed files with 118 additions and 2 deletions

2
.gitignore vendored
View File

@@ -24,4 +24,4 @@ yarn-error.log*
# firebase
src/components/Firebase
#/src/components/Firebase

View File

@@ -0,0 +1,20 @@
const makeRequest = async (apiKey) => {
try {
const request = {
method: "GET",
headers: {
'X-Api-Key': apiKey.trim(),
"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) {
console.log(error)
}
}
export {makeRequest}

View File

@@ -0,0 +1,58 @@
const getAndFormatCurrentTime = (KonamiCodeON) => {
const data = new Date()
const date = {
year: data.getFullYear(),
month: data.getMonth() + 1,
day: data.getDate()
}
const hour = {
hours: data.getHours(),
minutes: data.getMinutes(),
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) {
date.day = date.day + 1
hour.hours = 0
}
if (hour.hours > 24) {
hour.hours = hour.hours - 24
date.day = date.day + 1
}
const formatData = (data) => {
Object.keys(data).forEach(key => {
if (data[key] < 10) {
data[key] = `0${data[key]}`
}
});
//Credits to https://stackoverflow.com/a/62010113
}
formatData(date)
formatData(hour)
const structuredData = `${date.year}-${date.month}-${date.day}T${hour.hours}:${hour.minutes}:${hour.seconds}Z`
console.log(structuredData)
return structuredData
}
export default getAndFormatCurrentTime

View File

@@ -0,0 +1,38 @@
const uploadToClockifyTimer = async (workspaceID, projectID, start, end, apiKey, taskName) => {
if (!workspaceID && !projectID) {
return
}
try {
const url = `https://api.clockify.me/api/v1/workspaces/${workspaceID}/time-entries`
const body = {
start: start,
end: end,
projectId: projectID,
description: taskName
}
const headers = {
'X-Api-Key': apiKey,
'Content-type' : 'application/json; charset=UTF-8'
}
const request = {
method: 'POST',
body: JSON.stringify(body),
headers
}
const result = await fetch(url, request)
const data = await result.json()
console.log(data)
} catch (error) {
console.log(error)
}
}
export default uploadToClockifyTimer

View File

@@ -167,7 +167,7 @@ const MainPomodoroTimer = (props) => {
const startTimer = () => {
document.title = minutes + ':' + seconds
//document.title = minutes + ':' + seconds
document.addEventListener('visibilitychange', () => {