used useRequest
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user