used useRequest

This commit is contained in:
Amirhossein Mahmoodi
2023-08-09 15:05:29 +03:30
parent 65753c52ca
commit 64e717990f
13 changed files with 147 additions and 238 deletions

View File

@@ -5,22 +5,19 @@ import moment from "moment-jalaali";
import useSWR from "swr";
import {Typography} from "@mui/material";
import MaterialReactTable from "material-react-table";
import axios from "axios";
import useUser from "@/lib/app/hooks/useUser";
import useRequest from "@/lib/app/hooks/useRequest";
function DataTable(props) {
const {token} = useUser();
const requestServer = useRequest({auth: true})
const fetcher = (...args) => {
return axios
.get(args, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
setRowCount(res.data.meta.totalRowCount);
return res.data.data;
});
return requestServer(args, 'get', {
pending: false,
success: {notification: {show: false}}
}).then((response) => {
setRowCount(response.data.meta.totalRowCount);
return response.data.data;
}).catch(() => {
})
};
const t = useTranslations();
const {languageApp, languageList} = useLanguage();