add linter
This commit is contained in:
@@ -1,20 +1,17 @@
|
||||
import React, {FC, FormEvent, ReactEventHandler, useState} from "react"
|
||||
import Field from "../Field";
|
||||
import {timeTracker} from "../../utilities/types";
|
||||
import React, {FC, FormEvent, useState} from "react"
|
||||
import Field from "../Field"
|
||||
import {timeTracker} from "../../utilities/types"
|
||||
|
||||
const TimeTrackerEdit: FC<TimeTrackerEditProps> = ({timeTracker}) => {
|
||||
|
||||
const [trackerForm, setTrackerForm] = useState<timeTracker>(timeTracker)
|
||||
|
||||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
console.log(trackerForm, event.target.value)
|
||||
setTrackerForm({...trackerForm, [event.target.name]: event.target.value.replace('T', ' ')})
|
||||
}
|
||||
|
||||
const onSubmit = (event: FormEvent) => {
|
||||
event.preventDefault()
|
||||
|
||||
console.log(trackerForm)
|
||||
console.log('submit', trackerForm, event)
|
||||
}
|
||||
|
||||
return <form onSubmit={onSubmit}>
|
||||
@@ -27,7 +24,7 @@ const TimeTrackerEdit: FC<TimeTrackerEditProps> = ({timeTracker}) => {
|
||||
value={trackerForm.end_at}
|
||||
onChange={handleChange}/>
|
||||
|
||||
<button type="submit">Valider</button>
|
||||
<button type="submit" onClick={onSubmit}>Valider</button>
|
||||
</form>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, {useEffect, useState} from "react"
|
||||
import useTracker from "../../hooks/TraskerHook"
|
||||
import {Link} from "react-router-dom";
|
||||
import {StopSVG} from "../SVG";
|
||||
import {Link} from "react-router-dom"
|
||||
import {StopSVG} from "../SVG"
|
||||
|
||||
const Tracker = () => {
|
||||
|
||||
@@ -14,14 +14,14 @@ const Tracker = () => {
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(() => setTimer(formatTimer(currentTimeTracker?.start_at)), 1000)
|
||||
}, [timer]);
|
||||
}, [timer])
|
||||
|
||||
const formatTimer = (startAt: string|null|undefined) => {
|
||||
if (!startAt) {
|
||||
return '--:--'
|
||||
}
|
||||
let timer = Math.floor(((new Date()).getTime() - (new Date(startAt)).getTime()) / 1000)
|
||||
return timer.durationify()
|
||||
const timer = Math.floor(((new Date()).getTime() - (new Date(startAt)).getTime()) / 1000)
|
||||
return Number(timer).durationify()
|
||||
// let hours = Math.floor(timer / 3600)
|
||||
// let minutes = Math.floor((timer - hours * 3600) / 60)
|
||||
// let secondes = timer - hours * 3600 - minutes * 60
|
||||
|
||||
Reference in New Issue
Block a user