LFFE-10 complete excel and working on loading
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {Accordion, AccordionDetails, AccordionSummary, Box, Button, Stack, Typography} from "@mui/material";
|
||||
import FileUploadIcon from '@mui/icons-material/FileUpload';
|
||||
import AssignmentIcon from '@mui/icons-material/Assignment';
|
||||
import BackupIcon from '@mui/icons-material/Backup';
|
||||
import {useTranslations} from "next-intl";
|
||||
import ProvinceFilter from "@/components/dashboard/reports/Filter/ProvinceFilter";
|
||||
import YearFilter from "@/components/dashboard/reports/Filter/YearFilter";
|
||||
@@ -10,6 +11,7 @@ import {GET_EXPORT} from "@/core/data/apiRoutes";
|
||||
import moment from "jalali-moment";
|
||||
import FileSaver from 'file-saver';
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import {periodOfYear} from "@/core/utils/yearPeriodFinder";
|
||||
|
||||
const ExcelExport = () => {
|
||||
const t = useTranslations();
|
||||
@@ -31,8 +33,8 @@ const ExcelExport = () => {
|
||||
...(filter_by_province && {
|
||||
province_id: filter_by_province.multiple ? [] : ""
|
||||
}),
|
||||
from_date: "",
|
||||
to_date: ""
|
||||
from_date: periodOfYear(moment().format('jYYYY')).from,
|
||||
to_date: periodOfYear(moment().format('jYYYY')).to
|
||||
}, onSubmit: (values, {setSubmitting}) => {
|
||||
const province = values.province_id;
|
||||
const fields = [
|
||||
@@ -50,6 +52,7 @@ const ExcelExport = () => {
|
||||
const queryString = fields.length !== 0
|
||||
? `?${fields.map((option) => `${option.key}=${option.value}`).join('&')}`
|
||||
: '';
|
||||
setSubmitting(true)
|
||||
requestServer(`${GET_EXPORT}${queryString}`, 'GET', {auth: true, requestOptions: {responseType: 'blob'}})
|
||||
.then((response) => {
|
||||
const filename = `گزارش درخواست های وام ناوگان تاریخ_${moment().format('jYYYY_jMM_jDD')}.xlsx`;
|
||||
@@ -97,6 +100,7 @@ const ExcelExport = () => {
|
||||
<Button onClick={formik.handleSubmit} variant="contained"
|
||||
disabled={formik.isSubmitting}
|
||||
sx={{backgroundColor: "success.main"}}
|
||||
startIcon={<BackupIcon/>}
|
||||
>
|
||||
{t("filters.export")}
|
||||
</Button>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import {Box, CircularProgress, Grid, Paper, Typography} from "@mui/material";
|
||||
import {Grid, Paper, Typography} from "@mui/material";
|
||||
import BarChart from "./BarChart";
|
||||
import Filter from "../Filter";
|
||||
import {useTranslations} from "next-intl";
|
||||
import useChart from "@/lib/app/hooks/useChart";
|
||||
import {GET_PROVINCE_PROGRESS} from "@/core/data/apiRoutes";
|
||||
import LoadingHardPage from "@/core/components/LoadingHardPage";
|
||||
|
||||
const LoanProgress = () => {
|
||||
const t = useTranslations();
|
||||
@@ -21,21 +22,12 @@ const LoanProgress = () => {
|
||||
<Grid container>
|
||||
<Grid item xs={12} sx={{aspectRatio: {xs: "1/1", sm: "1/1", md: "1/0.4", xl: "1/0.3"}}}>
|
||||
{isLoadingReportList ? (
|
||||
<Box sx={{
|
||||
height: "100%",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
justifyContent: "center"
|
||||
}}>
|
||||
<CircularProgress sx={{mb: 1, color: "#c2c2c2"}}/>
|
||||
<Typography variant="h6"
|
||||
sx={{color: "#c2c2c2", letterSpacing: "0.2rem"}}
|
||||
>
|
||||
{t("reports.loading_fetching_reports")}
|
||||
</Typography>
|
||||
</Box>
|
||||
) : errorReportList ? (
|
||||
// <LoadingHardPage icon={routingItem?.icon}
|
||||
// label={routingItem?.key ? `${t('routing_to')} ${t(routingItem?.key)}` : ''}
|
||||
// loading={routing} width={100} height={100}
|
||||
// sx={{position: "absolute", bgcolor: "#fffc"}}>
|
||||
|
||||
) : errorReportList ? (
|
||||
<Typography variant="caption">{t("reports.error_fetching_reports")}</Typography>
|
||||
) : (
|
||||
<BarChart data={reportList}/>
|
||||
|
||||
Reference in New Issue
Block a user