add duration
This commit is contained in:
@@ -43,8 +43,13 @@ const ToDoFinish: FC<ToDoFinishProps> = ({reload}) => {
|
||||
</button>
|
||||
|
||||
{errorLabel()}
|
||||
{showTodos && <ul className="list-disc ml-5">
|
||||
{toDos.map(toDo => <li key={toDo.id}>{toDo.checked ? (new Date(toDo.checked)).toSmallFrDate() : ''} {toDo.name}</li>)}
|
||||
{showTodos && <ul className="list-disc m-2">
|
||||
{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>
|
||||
<span>{toDo.duration.durationify()}</span>
|
||||
|
||||
</li>)}
|
||||
</ul>}
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ import {Link} from "react-router-dom";
|
||||
import useTracker from "../../hooks/TraskerHook";
|
||||
import {Simulate} from "react-dom/test-utils";
|
||||
import load = Simulate.load;
|
||||
import {DraggableSVG, PlaySVG} from "../SVG";
|
||||
import {DraggableSVG, PauseSVG, PlaySVG} from "../SVG";
|
||||
|
||||
const ToDoIndex: FC<ToDoIndexProps> = ({reload, setReload}) => {
|
||||
|
||||
const {loading, setLoading, errorCatch, errorLabel, axiosGet, axiosPut} = useAxiosTools(true)
|
||||
const [toDos, setToDos] = useState<toDo[]>([])
|
||||
const {startTrackToDo} = useTracker()
|
||||
const {currentTimeTracker, startTrackToDo, stopCurrentTimeTrack} = useTracker()
|
||||
|
||||
useEffect(() => {
|
||||
fetchToDos()
|
||||
@@ -59,13 +59,21 @@ const ToDoIndex: FC<ToDoIndexProps> = ({reload, setReload}) => {
|
||||
<Link to={"/todos/" + toDo.id}
|
||||
className={`${toDo.checked ? 'line-through' : ''} flex-1 flex justify-between`}>
|
||||
<span>{toDo.name}</span>
|
||||
<span className="text-gray-400 text-md mr-2">{toDo.duration} s</span>
|
||||
<span className="text-gray-400 text-md mr-2">{toDo.duration.durationify()}</span>
|
||||
</Link>
|
||||
{!toDo.checked && <span className="cursor-pointer flex items-center"
|
||||
title="Commencer"
|
||||
onClick={() => startTrackToDo(toDo)}>
|
||||
<PlaySVG className="w-4" />
|
||||
</span>}
|
||||
{toDo.id === currentTimeTracker?.to_do?.id
|
||||
? <button className="cursor-pointer w-7 justify-center flex items-center"
|
||||
type="button"
|
||||
title="Commencer"
|
||||
onClick={stopCurrentTimeTrack}>
|
||||
<PauseSVG className="w-7"/>
|
||||
</button>
|
||||
: <button className="cursor-pointer w-7 justify-center flex items-center"
|
||||
type="button"
|
||||
title="Commencer"
|
||||
onClick={() => startTrackToDo(toDo)}>
|
||||
<PlaySVG className="w-4"/>
|
||||
</button>}
|
||||
</li>)}
|
||||
</ul>
|
||||
</>
|
||||
@@ -74,6 +82,6 @@ const ToDoIndex: FC<ToDoIndexProps> = ({reload, setReload}) => {
|
||||
export default ToDoIndex
|
||||
|
||||
interface ToDoIndexProps {
|
||||
reload: Date|null,
|
||||
reload: Date | null,
|
||||
setReload: (date: Date) => void,
|
||||
}
|
||||
|
||||
@@ -68,10 +68,11 @@ const ToDoTimeTrackers: FC<ToDoTimeTrackers> = ({toDo: toDo}) => {
|
||||
})
|
||||
|
||||
timer = Math.floor(timer / 1000)
|
||||
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 (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>
|
||||
|
||||
Reference in New Issue
Block a user