Handle Update

PHOTO EMBED

Wed Feb 28 2024 09:29:22 GMT+0000 (Coordinated Universal Time)

Saved by @2018331055

const handleUpdate=()=>{
  toast.promise(
                axiosInstance
                    .patch(
                        `api/business/${businessId}/department/${department.id}`,
                        values,
                        {
                            headers: {
                                "Content-Type": "application/json",
                            },
                        }
                    )
                    .then((res) => {
                        setDepartments(res.data.departments);
                    })
                    .finally(() => {
                        setIsLoading(false);
                    }),
                {
                    loading: "updating the department",
                    success: "Department is updated",
                    error: (err) =>
                        err?.response?.data?.message
                            ? err?.response.data?.message
                            : err?.response?.data,
                }
            );
  
}
content_copyCOPY