diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 6c32048..53699b0 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -655,6 +655,7 @@ "provinces": "استان های", "province": "استان", "all_provinces": "تمامی استان ها", + "excel_export_reports": "خروجی به اکسل گزارش عملکرد", "year": "سال", "years": "سال های", "text_field_loading_provinces_list": "درحال دریافت استان ها", diff --git a/src/components/dashboard/reports/ExcelExport/index.jsx b/src/components/dashboard/reports/ExcelExport/index.jsx new file mode 100644 index 0000000..a17e2af --- /dev/null +++ b/src/components/dashboard/reports/ExcelExport/index.jsx @@ -0,0 +1,63 @@ +import {Accordion, AccordionSummary, Box, Button, CircularProgress, Stack, Typography} from "@mui/material"; +import AssignmentIcon from '@mui/icons-material/Assignment'; +import BackupIcon from '@mui/icons-material/Backup'; +import {useTranslations} from "next-intl"; +import {GET_EXCEL_EXPORT} from "@/core/data/apiRoutes"; +import moment from "jalali-moment"; +import FileSaver from 'file-saver'; +import useRequest from "@/lib/app/hooks/useRequest"; +import {useState} from "react"; + +const ExcelExport = () => { + const t = useTranslations(); + const requestServer = useRequest(); + const [loading, setLoading] = useState(false); + + const clickHandler = () => { + setLoading(true) + requestServer(GET_EXCEL_EXPORT, 'get', { + auth: true, + requestOptions: {responseType: 'blob'} + }).then((response) => { + const filename = `گزارش عملکرد_${moment().format('jYYYY_jMM_jDD')}.xlsx`; + FileSaver.saveAs(response.data, filename); + }).catch(() => { + }).finally(() => { + setLoading(false) + }) + } + + return ( + + + + + + + + {t("filters.excel_export_reports")} + + + + + + + + ) +}; + +export default ExcelExport; \ No newline at end of file diff --git a/src/components/dashboard/reports/LoanDetails/FunctionalityCharts.jsx b/src/components/dashboard/reports/LoanDetails/FunctionalityCharts.jsx index 937fc34..b161a42 100644 --- a/src/components/dashboard/reports/LoanDetails/FunctionalityCharts.jsx +++ b/src/components/dashboard/reports/LoanDetails/FunctionalityCharts.jsx @@ -14,7 +14,7 @@ const FunctionalityCharts = ({reportList}) => { { Object.entries(reportList).map(([entryKey, innerObject]) => { - let percentage = innerObject.total !== 0 ? (innerObject.total - innerObject.pending) / innerObject.total * 100 : 0; + let percentage = innerObject.total !== 0 && innerObject.pending !== 64 ? (innerObject.total - innerObject.pending) / innerObject.total * 100 : 0; const ItemName = DataItemsName.find(item => item.id === entryKey).name; return ( { return ( <> + ) diff --git a/src/core/data/apiRoutes.js b/src/core/data/apiRoutes.js index e8e4df5..94c0982 100644 --- a/src/core/data/apiRoutes.js +++ b/src/core/data/apiRoutes.js @@ -225,6 +225,7 @@ export const GET_PERMISSIONS_LIST = // reports export const GET_EXPORT = BASE_URL + "/dashboard/exports/navgan" +export const GET_EXCEL_EXPORT = BASE_URL + "/dashboard/exports/navgan/expert_progress" export const GET_PROVINCE_PROGRESS = BASE_URL + "/dashboard/reports/navgan/province_progress" export const GET_LOAN_DISTRIBUTION = BASE_URL + "/dashboard/reports/navgan/loan_distribution" export const GET_LOAN_EXPERTPROGRESS = BASE_URL + "/dashboard/reports/navgan/expert_progress" diff --git a/src/lib/app/hooks/useProvince.jsx b/src/lib/app/hooks/useProvince.jsx index 3443a6e..2bc8c6b 100644 --- a/src/lib/app/hooks/useProvince.jsx +++ b/src/lib/app/hooks/useProvince.jsx @@ -8,7 +8,7 @@ const useProvince = () => { //swr config const fetcher = (...args) => { return requestServer(args, 'get').then(({data}) => { - return data; + return data.data; }).catch(() => { }) };