import React from "react"; import axios from "axios"; import {toast} from "react-toastify"; import {BsArchive} from "react-icons/bs"; export const useAssignmentArchive = (assignmentId: string, reload?: Function) => { const [loading, setLoading] = React.useState(false); const archive = () => { // archive assignment setLoading(true); axios .post(`/api/assignments/${assignmentId}/archive`) .then((res) => { toast.success("Assignment archived!"); if (reload) reload(); setLoading(false); }) .catch((err) => { toast.error("Failed to archive the assignment!"); setLoading(false); }); }; const renderIcon = (downloadClasses: string, loadingClasses: string) => { if (loading) { return ; } return (