add linter
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, {createContext, PropsWithChildren, useContext, useEffect, useState} from "react";
|
||||
import {timeTracker, toDo} from "../utilities/types";
|
||||
import useAxiosTools from "./AxiosTools";
|
||||
import React, {createContext, PropsWithChildren, useContext, useEffect, useState} from "react"
|
||||
import {timeTracker, toDo} from "../utilities/types"
|
||||
import useAxiosTools from "./AxiosTools"
|
||||
|
||||
|
||||
const TrackerContext = createContext<TrackerProps|undefined>(undefined)
|
||||
@@ -9,12 +9,10 @@ interface TrackerProps {
|
||||
currentTimeTracker: timeTracker|null,
|
||||
startTrackToDo: (toDo: toDo) => void,
|
||||
stopCurrentTimeTrack: () => void,
|
||||
isToDoTracked: (toDo: toDo) => boolean,
|
||||
}
|
||||
|
||||
export const TrackerProvider = ({children}: PropsWithChildren) => {
|
||||
const [currentTimeTracker, setCurrentTimeTracker] = useState<timeTracker|null>(null)
|
||||
const [toDoTracked, setToDoTracked] = useState<toDo|null>(null)
|
||||
const {axiosGet, axiosPost, axiosDelete} = useAxiosTools()
|
||||
|
||||
useEffect(() => {
|
||||
@@ -41,16 +39,14 @@ export const TrackerProvider = ({children}: PropsWithChildren) => {
|
||||
|
||||
const stopCurrentTimeTrack = async () => {
|
||||
try {
|
||||
const res = await axiosDelete(`/api/time-trackers/user`)
|
||||
await axiosDelete(`/api/time-trackers/user`)
|
||||
setCurrentTimeTracker(null)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
const isToDoTracked = (toDo: toDo) => toDo.id === toDoTracked?.id
|
||||
|
||||
return <TrackerContext.Provider value={{currentTimeTracker, startTrackToDo, stopCurrentTimeTrack, isToDoTracked}}>
|
||||
return <TrackerContext.Provider value={{currentTimeTracker, startTrackToDo, stopCurrentTimeTrack}}>
|
||||
{children}
|
||||
</TrackerContext.Provider>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user