add linter
This commit is contained in:
@@ -6,8 +6,8 @@ import React, {
|
||||
useContext,
|
||||
useEffect,
|
||||
useState
|
||||
} from "react";
|
||||
import axios from "axios";
|
||||
} from "react"
|
||||
import axios from "axios"
|
||||
|
||||
const AuthUserContext = createContext<AuthUserProps|undefined>(undefined)
|
||||
|
||||
@@ -44,7 +44,7 @@ export const AuthUserProvider = ({children}: PropsWithChildren) => {
|
||||
const logout = async () => {
|
||||
try {
|
||||
setLoadingAuthUser(false)
|
||||
const res = await axios.delete('/api/logout')
|
||||
await axios.delete('/api/logout')
|
||||
setAuthUser(null)
|
||||
window.location.replace('/')
|
||||
} catch (e) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {useState} from "react";
|
||||
import axios from "axios";
|
||||
import React from "react";
|
||||
import {cleanErrorsForm, displayFormErrors} from "../utilities/form";
|
||||
import React, {useState} from "react"
|
||||
import axios from "axios"
|
||||
import {cleanErrorsForm, displayFormErrors} from "../utilities/form"
|
||||
|
||||
const useAxiosTools = (isLoading = false) => {
|
||||
|
||||
@@ -23,7 +22,7 @@ const useAxiosTools = (isLoading = false) => {
|
||||
|
||||
const errorLabel = () => {
|
||||
|
||||
return error ? <div className="bg-red-600 rounded m-2 text-center text-white px-2 py-1 mx-auto">{error}</div>: null
|
||||
return error ? <div className="m-2 mx-auto rounded bg-red-600 px-2 py-1 text-center text-white">{error}</div>: null
|
||||
}
|
||||
|
||||
const cleanErrors = () => {
|
||||
|
||||
@@ -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