add linter
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, {FC, useEffect, useState} from "react"
|
||||
import useAxiosTools from "../../hooks/AxiosTools";
|
||||
import {toDo} from "../../utilities/types";
|
||||
import {PlaySVG} from "../SVG";
|
||||
import useAxiosTools from "../../hooks/AxiosTools"
|
||||
import {toDo} from "../../utilities/types"
|
||||
import {PlaySVG} from "../SVG"
|
||||
|
||||
const ToDoFinish: FC<ToDoFinishProps> = ({reload}) => {
|
||||
|
||||
@@ -36,14 +36,14 @@ const ToDoFinish: FC<ToDoFinishProps> = ({reload}) => {
|
||||
}
|
||||
|
||||
return <div>
|
||||
<button className="flex justify-between items-center w-full bg-blue-700 px-2 py-1 rounded cursor-pointer"
|
||||
<button className="flex w-full cursor-pointer items-center justify-between rounded bg-blue-700 px-2 py-1"
|
||||
onClick={handleShow}>
|
||||
<h2 className="inline">Tâches terminées</h2>
|
||||
<span><PlaySVG className={`w-4 transition ${showTodos ? 'rotate-90' : 'rotate-180'}`} /></span>
|
||||
</button>
|
||||
|
||||
{errorLabel()}
|
||||
{showTodos && <ul className="list-disc m-2">
|
||||
{showTodos && <ul className="m-2 list-disc">
|
||||
{toDos.map(toDo => <li key={toDo.id} className="flex gap-2">
|
||||
<span>{toDo.checked ? (new Date(toDo.checked)).toSmallFrDate() : ''}</span>
|
||||
<span className="flex-1">{toDo.name}</span>
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import React, {FC, useEffect, useState} from "react";
|
||||
import useAxiosTools from "../../hooks/AxiosTools";
|
||||
import {toDo} from "../../utilities/types";
|
||||
import {Link} from "react-router-dom";
|
||||
import useTracker from "../../hooks/TraskerHook";
|
||||
import {Simulate} from "react-dom/test-utils";
|
||||
import load = Simulate.load;
|
||||
import {DraggableSVG, PauseSVG, PlaySVG} from "../SVG";
|
||||
import React, {FC, useEffect, useState} from "react"
|
||||
import useAxiosTools from "../../hooks/AxiosTools"
|
||||
import {toDo} from "../../utilities/types"
|
||||
import {Link} from "react-router-dom"
|
||||
import useTracker from "../../hooks/TraskerHook"
|
||||
import {DraggableSVG, PauseSVG, PlaySVG} from "../SVG"
|
||||
|
||||
const ToDoIndex: FC<ToDoIndexProps> = ({reload, setReload}) => {
|
||||
|
||||
@@ -21,7 +19,7 @@ const ToDoIndex: FC<ToDoIndexProps> = ({reload, setReload}) => {
|
||||
if (reload && !loading) {
|
||||
fetchToDos()
|
||||
}
|
||||
}, [reload]);
|
||||
}, [reload])
|
||||
|
||||
const fetchToDos = async () => {
|
||||
try {
|
||||
@@ -57,18 +55,18 @@ const ToDoIndex: FC<ToDoIndexProps> = ({reload, setReload}) => {
|
||||
onChange={() =>toggleCheck(toDo)}
|
||||
className=""/>
|
||||
<Link to={"/todos/" + toDo.id}
|
||||
className={`${toDo.checked ? 'line-through' : ''} flex-1 flex justify-between`}>
|
||||
className={`${toDo.checked ? 'line-through' : ''} flex flex-1 justify-between`}>
|
||||
<span>{toDo.name}</span>
|
||||
<span className="text-gray-400 text-md mr-2">{toDo.duration.durationify()}</span>
|
||||
<span className="mr-2 text-sm text-gray-400">{toDo.duration.durationify()}</span>
|
||||
</Link>
|
||||
{toDo.id === currentTimeTracker?.to_do?.id
|
||||
? <button className="cursor-pointer w-7 justify-center flex items-center"
|
||||
? <button className="flex w-7 cursor-pointer items-center justify-center"
|
||||
type="button"
|
||||
title="Commencer"
|
||||
onClick={stopCurrentTimeTrack}>
|
||||
<PauseSVG className="w-7"/>
|
||||
</button>
|
||||
: <button className="cursor-pointer w-7 justify-center flex items-center"
|
||||
: <button className="flex w-7 cursor-pointer items-center justify-center"
|
||||
type="button"
|
||||
title="Commencer"
|
||||
onClick={() => startTrackToDo(toDo)}>
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
import React, {FC, HTMLInputTypeAttribute, ReactElement, useEffect, useState} from "react"
|
||||
import {useParams} from "react-router-dom";
|
||||
import useAxiosTools from "../../hooks/AxiosTools";
|
||||
import {timeTracker, toDo} from "../../utilities/types";
|
||||
|
||||
const ToDoShow = () => {
|
||||
|
||||
const {id} = useParams()
|
||||
console.log(id)
|
||||
const {setLoading, errorCatch, errorLabel, axiosGet, axiosPut} = useAxiosTools(true)
|
||||
const [toDo, setToDo] = useState<toDo|null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
fetchToDo()
|
||||
}, [])
|
||||
|
||||
const fetchToDo = async () => {
|
||||
try {
|
||||
const res = await axiosGet('/api/todos/' + id)
|
||||
setToDo(res.data)
|
||||
} catch (error) {
|
||||
errorCatch(error)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return <div>
|
||||
<h1>{toDo?.name}</h1>
|
||||
<h1>{toDo?.description}</h1>
|
||||
|
||||
{toDo && <ToDoTimeTrackers toDo={toDo} />}
|
||||
</div>
|
||||
}
|
||||
|
||||
export default ToDoShow
|
||||
|
||||
const ToDoTimeTrackers: FC<ToDoTimeTrackers> = ({toDo: toDo}) => {
|
||||
|
||||
const {setLoading, errorCatch, errorLabel, axiosGet, axiosPut} = useAxiosTools(true)
|
||||
const [timeTrackers, setTimeTrackers] = useState<timeTracker[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
fetchTimeTrackers()
|
||||
}, [])
|
||||
|
||||
const fetchTimeTrackers = async () => {
|
||||
try {
|
||||
const res = await axiosGet(`/api/todos/${toDo.id}/time-trackers`)
|
||||
setTimeTrackers(res.data)
|
||||
} catch (error) {
|
||||
errorCatch(error)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const timeSpend = () => {
|
||||
let timer = 0
|
||||
let more = false
|
||||
timeTrackers.forEach(timeTracker => {
|
||||
if (! timeTracker.end_at) {
|
||||
more = true
|
||||
} else {
|
||||
timer += ((new Date(timeTracker.end_at)).getTime()) - (new Date(timeTracker.start_at)).getTime()
|
||||
}
|
||||
})
|
||||
|
||||
timer = Math.floor(timer / 1000)
|
||||
return (more ? '+' : '') + timer.durationify()
|
||||
// let hours = Math.floor(timer / 3600)
|
||||
// let minutes = Math.floor((timer - hours * 3600) / 60)
|
||||
// let secondes = timer - hours * 3600 - minutes * 60
|
||||
// return `${more ? '+' : ''} ${hours}:${String(minutes).padStart(2, '0')}:${String(secondes).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
return <div>
|
||||
<div>Temps passé : {timeSpend()}</div>
|
||||
<table className="mx-auto">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Début</th>
|
||||
<th>Fin</th>
|
||||
<th>Différence</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{timeTrackers.map(timeTracker => <tr key={timeTracker.id} className="text-center">
|
||||
<td>{timeTracker.start_at ? (new Date(timeTracker.start_at)).toSmallFrDate() : ''}</td>
|
||||
<td>{timeTracker.end_at ? (new Date(timeTracker.end_at)).toSmallFrDate() : ''}</td>
|
||||
<td className="text-right">{timeTracker.start_at && timeTracker.end_at ? (new Date(timeTracker.end_at)).difference(new Date(timeTracker.start_at)) : ''}</td>
|
||||
</tr>)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
interface ToDoTimeTrackers {
|
||||
toDo: toDo,
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, {FC, FormEvent, useState} from "react"
|
||||
import Field from "../Field";
|
||||
import useAxiosTools from "../../hooks/AxiosTools";
|
||||
import Field from "../Field"
|
||||
import useAxiosTools from "../../hooks/AxiosTools"
|
||||
|
||||
const ToDoStore: FC<ToDoStoreProps> = ({setReload}) => {
|
||||
|
||||
@@ -24,10 +24,10 @@ const ToDoStore: FC<ToDoStoreProps> = ({setReload}) => {
|
||||
<Field name="todo"
|
||||
value={toDo}
|
||||
classNameForm="flex-1"
|
||||
className="h-10 !mt-0 rounded-r-none px-2"
|
||||
className="!mt-0 h-10 rounded-r-none px-2"
|
||||
onChange={event => setToDo(event.target.value)} />
|
||||
<button type="submit"
|
||||
className="bg-blue-900 h-10 rounded-r px-5">
|
||||
className="h-10 rounded-r bg-blue-900 px-5">
|
||||
Ajouter
|
||||
</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user