23 lines
677 B
TypeScript
23 lines
677 B
TypeScript
import {Grading} from "@/interfaces";
|
|
import {Code, Group, User} from "@/interfaces/user";
|
|
import axios from "axios";
|
|
import {useEffect, useState} from "react";
|
|
|
|
export default function useGradingSystem() {
|
|
const [gradingSystem, setGradingSystem] = useState<Grading>();
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
const [isError, setIsError] = useState(false);
|
|
|
|
const getData = () => {
|
|
setIsLoading(true);
|
|
axios
|
|
.get<Grading>(`/api/grading`)
|
|
.then((response) => setGradingSystem(response.data))
|
|
.finally(() => setIsLoading(false));
|
|
};
|
|
|
|
useEffect(getData, []);
|
|
|
|
return {gradingSystem, isLoading, isError, reload: getData, mutate: setGradingSystem};
|
|
}
|