diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json
index 9b1e9f4..5088829 100644
--- a/public/locales/fa/app.json
+++ b/public/locales/fa/app.json
@@ -58,7 +58,7 @@
"user-management": "مدیریت کاربر",
"role-management": "مدیریت نقش ها",
"edit-profile": "ویرایش پروفایل",
- "loan-history": "تاریخچه وام ها"
+ "loan-history": "کارتابل نظارت"
},
"secondary": {
"passenger-office": "توزیع درخواست",
@@ -117,7 +117,7 @@
"edit_profile": "ویرایش پروفایل",
"expert_management": "مدیریت کارشناسان",
"user_management_page": "مدیریت کاربر",
- "loan_history": "تاریخچهِ وام ها"
+ "loan_history": "کارتابل نظارت"
},
"MuiDatePicker": {
"date_picker_birthday": "تاریخ"
@@ -537,6 +537,14 @@
"update_again": "بروزرسانی مجدد"
},
"LoanHistory": {
- "history": "تاریخچه"
+ "history": "تاریخچه",
+ "Table_history_error": "خطا در دریافت اطلاعات",
+ "history_report": "فایل ضمیمه",
+ "Table_head_name": "نام",
+ "Table_head_date": "تاریخ",
+ "Table_head_position": "سمت",
+ "Table_head_action": "عملیات",
+ "Table_head_file": "فایل پیوست",
+ "empty_history_detail": "سابقه ای برای این وام وجود ندارد"
}
}
diff --git a/src/components/dashboard/loan-history/Form/HistoryForm/HistoryContent.jsx b/src/components/dashboard/loan-history/Form/HistoryForm/HistoryContent.jsx
index 040aef8..d4d214c 100644
--- a/src/components/dashboard/loan-history/Form/HistoryForm/HistoryContent.jsx
+++ b/src/components/dashboard/loan-history/Form/HistoryForm/HistoryContent.jsx
@@ -11,7 +11,7 @@ const HistoryContent = ({mutate, setOpenConfirmDialog, rowId}) => {
return (
<>
-
+
+ )
+}
+
+export default PrintHistory
\ No newline at end of file
diff --git a/src/components/dashboard/loan-history/Form/HistoryForm/TableContent.jsx b/src/components/dashboard/loan-history/Form/HistoryForm/TableContent.jsx
index 3a6603d..cd0569b 100644
--- a/src/components/dashboard/loan-history/Form/HistoryForm/TableContent.jsx
+++ b/src/components/dashboard/loan-history/Form/HistoryForm/TableContent.jsx
@@ -1,210 +1,88 @@
import {
- Button,
- CircularProgress,
+ Box,
+ LinearProgress,
Paper,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
- TableRow
+ TableRow,
+ Typography
} from "@mui/material";
-import DescriptionIcon from "@mui/icons-material/Description";
-import {useState} from "react";
import {useTranslations} from "next-intl";
+import useHistory from "@/lib/app/hooks/useHistory";
+import {GET_HISTORY_DETAIL} from "@/core/data/apiRoutes";
+import moment from "jalali-moment";
+import PrintHistory from "@/components/dashboard/loan-history/Form/HistoryForm/PrintHistory";
-const fakeData = [
- {
- date: "1401/08/28",
- name: "امین قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "امیر قاسم پور",
- place: "اداره راه و شهرسازی مشهد",
- toDo: "ارجاع به معاونت حمل و نقل"
- },
- {
- date: "1401/08/28",
- name: "محمد جلالی",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "احمد قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "اکبر قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "اصغر قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "نیما قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
- {
- date: "1401/08/28",
- name: "مهدی قاسم پور",
- place: "اداره راه و شهرسازی تهران",
- toDo: "ارجاع به کارشناس"
- },
-]
-const TableContent = () => {
+const TableContent = ({rowId}) => {
const t = useTranslations();
- const [loading, setLoading] = useState(false)
-
- const clickHandler = () => {
- }
+ const {history_details, isLoading, error} = useHistory(`${GET_HISTORY_DETAIL}/${rowId}`)
return (
-
+ {error ? ({t("LoanHistory.Table_history_error")}) :
+ (isLoading ? () : (
+ history_details.latest_histories.length === 0 ? (
+ {t("LoanHistory.empty_history_detail")}
+ ) : (
+
+
+
+
+
+ {t("LoanHistory.Table_head_name")}
+ {t("LoanHistory.Table_head_date")}
+ {t("LoanHistory.Table_head_position")}
+ {t("LoanHistory.Table_head_action")}
+ {t("LoanHistory.Table_head_file")}
+
+
+
+ {
+ history_details.latest_histories.map((latest_history, index) => {
+ return (
+
+
+ {latest_history.expert.name}
+
+ {moment(latest_history.created_at).locale("fa").format("HH:mm | yyyy/MM/DD")}
+ {latest_history.expert.position}
+ {latest_history.previous_state_name}
+
+ {latest_history.attachment ? (
+
+ ) : null}
+
+
+ )
+ })
+ }
+
+
+
+
+ )
+ ))
}
- }}>
-
-
-
-
- نام
- تاریخ
- سمت
- عملیات
- فایل پیوست
-
-
-
- {fakeData.map((singleData, index) => {
- return (
-
-
- {singleData.name}
-
- {singleData.date}
- {singleData.place}
- {singleData.toDo}
-
- :
- }
- onClick={clickHandler}
- >
- {t("MachinaryOffice.excel_report")}
-
-
-
- )
- })}
-
-
-
-
+
+
)
}
export default TableContent
\ No newline at end of file
diff --git a/src/components/dashboard/loan-history/index.jsx b/src/components/dashboard/loan-history/index.jsx
index 0f0a261..c2bb293 100644
--- a/src/components/dashboard/loan-history/index.jsx
+++ b/src/components/dashboard/loan-history/index.jsx
@@ -1,6 +1,6 @@
import {Box, Typography} from "@mui/material";
import {useMemo} from "react";
-import {GET_MACHINARY_OFFICE} from "@/core/data/apiRoutes";
+import {GET_LOAN_HISTORY} from "@/core/data/apiRoutes";
import {useTranslations} from "next-intl";
import TableRowActions from "./TableRowActions";
import moment from "jalali-moment";
@@ -154,14 +154,10 @@ function DashboardLoanHistoryComponent() {
],
[]
);
- const data = [{
- id: 1
- }]
return (
{
+
+ const requestServer = useRequest({auth: true, notification: false})
+
+ //swr config
+ const fetcher = (...args) => {
+ return requestServer(args, 'get').then((response) => {
+ return response.data.data;
+ }).catch(() => {
+ })
+ };
+
+ const {data, isLoading, error} = useSWR(url, fetcher)
+ const history_details = data
+ //swr config
+
+ // render data
+ return {history_details, isLoading, error}
+}
+export default useHistory
\ No newline at end of file