add some test
This commit is contained in:
@@ -64,3 +64,9 @@ export const StopSVG: FC<ComponentProps<any>> = (props) => SVGSkeleton({
|
||||
paths: <path d="M8 16h8V8H8zm4 6q-2.075 0-3.9-.788t-3.175-2.137q-1.35-1.35-2.137-3.175T2 12q0-2.075.788-3.9t2.137-3.175q1.35-1.35 3.175-2.137T12 2q2.075 0 3.9.788t3.175 2.137q1.35 1.35 2.138 3.175T22 12q0 2.075-.788 3.9t-2.137 3.175q-1.35 1.35-3.175 2.138T12 22"/>,
|
||||
...props
|
||||
})
|
||||
|
||||
export const TrashSVG: FC<ComponentProps<any>> = (props) => SVGSkeleton({
|
||||
viewBox: "0 0 448 512",
|
||||
paths: <path d="M32 464a48 48 0 0 0 48 48h288a48 48 0 0 0 48-48V128H32zm272-256a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zM432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16z" />,
|
||||
...props
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, {FC, useEffect, useState} from "react"
|
||||
import {useParams} from "react-router-dom"
|
||||
import useAxiosTools from "../../hooks/AxiosTools"
|
||||
import {timeTracker, toDo} from "../../utilities/types"
|
||||
import {EditSVG} from "../../components/SVG"
|
||||
import {EditSVG, TrashSVG} from "../../components/SVG"
|
||||
import Field, {TextArea} from "../../components/Field"
|
||||
import TimeTrackerEdit from "../../components/TimeTrackers/TimeTrackerEdit"
|
||||
import {Modal} from "../../components/Modals"
|
||||
@@ -70,7 +70,7 @@ export default ToDoShow
|
||||
|
||||
const ToDoTimeTrackers: FC<{toDo: toDo}> = ({toDo: toDo}) => {
|
||||
|
||||
const {setLoading, errorCatch, errorLabel, axiosGet} = useAxiosTools(true)
|
||||
const {setLoading, errorCatch, errorLabel, axiosGet, axiosDelete} = useAxiosTools(true)
|
||||
const [timeTrackers, setTimeTrackers] = useState<timeTracker[]>([])
|
||||
const [showTrackers, setShowTrackers] = useState<timeTracker|null>(null)
|
||||
const [reload, setReload] = useState<timeTracker|null>(null)
|
||||
@@ -112,6 +112,17 @@ const ToDoTimeTrackers: FC<{toDo: toDo}> = ({toDo: toDo}) => {
|
||||
return (more ? '+' : '') + timer.durationify()
|
||||
}
|
||||
|
||||
const destroyTimeTracker = async (timeTracker: timeTracker) => {
|
||||
try {
|
||||
await axiosDelete('/api/time-trackers/' + timeTracker.id)
|
||||
await fetchTimeTrackers()
|
||||
} catch (error) {
|
||||
errorCatch(error)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
return <div className="p-5">
|
||||
<div className="text-center">Temps passé : {timeSpend()}</div>
|
||||
{errorLabel()}
|
||||
@@ -134,6 +145,11 @@ const ToDoTimeTrackers: FC<{toDo: toDo}> = ({toDo: toDo}) => {
|
||||
<EditSVG className="w-5"/>
|
||||
</button>
|
||||
</td>
|
||||
<td className="px-1 text-right">
|
||||
<button onClick={() => destroyTimeTracker(timeTracker)}>
|
||||
<TrashSVG className="w-5"/>
|
||||
</button>
|
||||
</td>
|
||||
</tr>)}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user