From 95b8e5e1679aa1fe8e7e71c4b4272813f2f725ce Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Wed, 27 Sep 2023 09:58:53 +0330 Subject: [PATCH 01/11] TF-102 fixed favicon in project --- public/icons/favicon.png | Bin 0 -> 5300 bytes src/pages/_document.jsx | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 public/icons/favicon.png diff --git a/public/icons/favicon.png b/public/icons/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..c82bf9ae9a460e07f08680dac85d1b898b36ed25 GIT binary patch literal 5300 zcmV;l6ie%gP)!S`@hvq9~f(u4ao_ z-g39p@>-@@YFEqrvTG_XkS3U*BAc3ui6U-@z_1R?%sb!nyfd$N9HFe>`~7ZTFTcY( zGw(U)eg4n$oM$^nhCk^g`;+3rU%>v`B>VqLVs(MF{x?a@83ccqev|GJAm@8+I34G6 z9?$*%&zR#(hy+YdL~!HpOpM@kcP7x08PYfjIQMmK4K93VU`&*Pn$q6*y9CTapG|g< z3{;YUBQtm`H%F$J?PGYnBSU^kUs0#4L)}4m}2kVy@%*K6UU&c z?RWkzy^!Z%AUsZL3U6<3b@%SweY3N(^R8XHX0*@23~^+Hqv}giD~2^dS38#7P3JA#$^O5YZP zB{5J^TZsmVcuD1Js4q9x6sb7^{6*EXWW%&9Y(c5wVMz8ILUNs}fIwP?{ICOsoPjHIk5DWSwrvb(6TXsNxwpi-$6-MV#a zV=$C;s4$rW47UnAn)rITXkA_9g$1`NJRA8G%H;A~H@!ad$dM!G>C>kZi;Ig3=slJ8CarUpth5~N0au&E+^Cm# zWMpJqVnRaPfddE7zC#COq-ElTDbdI{nN}Sd68dFEX6FA`tyWdDX3ZipGBQTCYu8q@ zWWh2F88H~8Wu+K8WC+e*$T=L?GBEYj>C;bH%;pwt+qahu4DTe-cl1X+4@f~yNyBLX%p zF)=YNVSfT#0<_S}UEpT&M%>?~VdJLHL2D_sq^L-L2oAaKN6f)#@K-j%!mf)D z)g}hVla9m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iLy|tYup?$lEO2Kn2FbRiN=bz zo+3HOPWu9BsVS$ZuE^y#E|}I?esi2pvXG9FbM^4>@NUzlP3*^oMce+bU@{C+T4GN%FB;e*HrtG^+da%_INZf5WbE4pirq`tggYWfk|J`2$L8_xx!7ro zIU1!(0#%bgSh0#X@v|>ox-^D5^9CUAkx5%gzX;43oOl$88Uy6$#HD4cR_(mKyt>`K zeY-=sp|r*A!V+JqSL!%2p^!W+}sL$e0*{UR2FTo(qV(lTxMGT{{2Hzj-@O% zRvHBb6?SaF3B{u9*`2hJzp^6`I4c+ZC;u1ZZG+mTXJuuLrpMBLG$-Hp)b49n0o!XN z>D@VNMZfX-3`Rpp>aiYPG_w)$0qlZQGVb z52O - + {emotionStyleTags} From 481c2c02bfc807043948aabd4149e36b39caf63b Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Wed, 27 Sep 2023 09:59:09 +0330 Subject: [PATCH 02/11] TF-102 fixed manifest in project --- public/manifest.json | 57 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 public/manifest.json diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..32bacd5 --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,57 @@ +{ + "short_name": "Loan Facilities Dashboard", + "name": "Loan Facilities User Dashboard", + "description": "Loan Facilities", + "version": "1.0.0", + "version_name": "1.0.0 beta", + "start_url": "/dashboard", + "orientation": "portrait", + "display": "standalone", + "theme_color": "#084070", + "background_color": "#084070", + "icons": [ + { + "src": "/icons/maskable_icon.png", + "sizes": "any", + "type": "image/png" + }, + { + "src": "/icons/maskable_icon_x48.png", + "sizes": "48x48", + "type": "image/png" + }, + { + "src": "/icons/maskable_icon_x72.png", + "sizes": "72x72", + "type": "image/png" + }, + { + "src": "/icons/maskable_icon_x96.png", + "sizes": "96x96", + "type": "image/png" + }, + { + "src": "/icons/maskable_icon_x128.png", + "sizes": "128x128", + "type": "image/png" + }, + { + "src": "/icons/maskable_icon_x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/icons/maskable_icon_x384.png", + "sizes": "384x384", + "type": "image/png" + }, + { + "src": "/icons/maskable_icon_x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "categories": [ + "government" + ] +} From f07c5c1b1574949a2cbedf90c7e5d0c1772f5d3f Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Wed, 27 Sep 2023 10:04:35 +0330 Subject: [PATCH 03/11] TF-102 fixed bug notifications style --- .../components/notifications/ErrorNotification.jsx | 4 ++-- .../components/notifications/PendingNotification.jsx | 3 ++- .../components/notifications/SuccessNotification.jsx | 2 +- .../components/notifications/WarningNotification.jsx | 12 ++++++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/core/components/notifications/ErrorNotification.jsx b/src/core/components/notifications/ErrorNotification.jsx index 4c2e857..05e2fb9 100644 --- a/src/core/components/notifications/ErrorNotification.jsx +++ b/src/core/components/notifications/ErrorNotification.jsx @@ -4,7 +4,7 @@ import {toast} from "react-toastify"; const ErrorNotification = (t, status, message) => { toast( - ({closeToast}) => ( + () => ( <> { ); }; -export default ErrorNotification; +export default ErrorNotification; \ No newline at end of file diff --git a/src/core/components/notifications/PendingNotification.jsx b/src/core/components/notifications/PendingNotification.jsx index f3a0af4..6183f6b 100644 --- a/src/core/components/notifications/PendingNotification.jsx +++ b/src/core/components/notifications/PendingNotification.jsx @@ -3,9 +3,10 @@ import {toast} from "react-toastify"; const PendingNotification = (t) => { toast(t("notifications.pending"), { autoClose: false, + closeButton: false, closeOnClick: false, draggable: false, }); }; -export default PendingNotification; +export default PendingNotification; \ No newline at end of file diff --git a/src/core/components/notifications/SuccessNotification.jsx b/src/core/components/notifications/SuccessNotification.jsx index 998deaa..3507cef 100644 --- a/src/core/components/notifications/SuccessNotification.jsx +++ b/src/core/components/notifications/SuccessNotification.jsx @@ -39,4 +39,4 @@ const SuccessNotification = (t, status) => { ); }; -export default SuccessNotification; +export default SuccessNotification; \ No newline at end of file diff --git a/src/core/components/notifications/WarningNotification.jsx b/src/core/components/notifications/WarningNotification.jsx index 5e931f0..19d6a2f 100644 --- a/src/core/components/notifications/WarningNotification.jsx +++ b/src/core/components/notifications/WarningNotification.jsx @@ -1,10 +1,10 @@ import ReportIcon from "@mui/icons-material/Report"; -import {Box, Divider, Typography} from "@mui/material"; +import {Box, Typography} from "@mui/material"; import {toast} from "react-toastify"; const WarningNotification = (t, status) => { toast( - ({closeToast}) => ( + () => ( <> { - {t("warning")} ({t("code")}: {status}) + {t("notifications.warning")} ({t("notifications.code")}:{" "} + {status}) - {t("warning_static_text")} + {t("notifications.warning_static_text")} - ), { @@ -37,4 +37,4 @@ const WarningNotification = (t, status) => { ); }; -export default WarningNotification; +export default WarningNotification; \ No newline at end of file From 67e1801bb57b4d6fce696734b92a2b3aa0edb09c Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Wed, 27 Sep 2023 10:15:01 +0330 Subject: [PATCH 04/11] TF-102 Add network config --- public/locales/fa/app.json | 2 + src/core/components/GlobalHead.jsx | 58 ++++++++++++++++++ src/core/components/NetworkComponent.jsx | 34 +++++++++++ src/layouts/AppLayout.jsx | 75 ++++-------------------- src/lib/app/hooks/useNetwork.jsx | 58 ++++++++++++++++++ src/lib/app/hooks/useRequest.js | 26 ++++---- 6 files changed, 176 insertions(+), 77 deletions(-) create mode 100644 src/core/components/GlobalHead.jsx create mode 100644 src/core/components/NetworkComponent.jsx create mode 100644 src/lib/app/hooks/useNetwork.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 435a0c7..c91dc84 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -15,6 +15,8 @@ "Resend_code_in": "ارسال مجدد کد در", "seconds_later": "ثانیه دیگر", "upload_file_text": "بارگذاری فایل", + "online_message": "شما به اینترنت وصل هستید", + "offline_message": "اتصال شما به اینترنت قطع شده است", "header": { "open_profile": "پروفایل", "edit_profile": "ویرایش پروفایل", diff --git a/src/core/components/GlobalHead.jsx b/src/core/components/GlobalHead.jsx new file mode 100644 index 0000000..5d6186d --- /dev/null +++ b/src/core/components/GlobalHead.jsx @@ -0,0 +1,58 @@ +import Head from "next/head"; + +const GlobalHead = () => { + return ( + + + + + + + + + + + + + + + + + + + + + ) +} + +export default GlobalHead \ No newline at end of file diff --git a/src/core/components/NetworkComponent.jsx b/src/core/components/NetworkComponent.jsx new file mode 100644 index 0000000..8ebbb68 --- /dev/null +++ b/src/core/components/NetworkComponent.jsx @@ -0,0 +1,34 @@ +import useNetwork from "@/lib/app/hooks/useNetwork"; +import {useEffect, useRef} from "react"; +import {toast} from "react-toastify"; +import WifiIcon from '@mui/icons-material/Wifi'; +import WifiOffIcon from '@mui/icons-material/WifiOff'; +import {useTranslations} from "next-intl"; + +const NetworkComponent = () => { + const toastId = useRef(null); + const network = useNetwork() + const t = useTranslations() + + useEffect(() => { + if (network.online) { + toast.update(toastId.current, { + type: toast.TYPE.SUCCESS, + render: t('online_message'), + autoClose: 2000, + closeButton: true, + closeOnClick: true, + icon: + }); + return + } + toast.dismiss() + toastId.current = toast.warn(t('offline_message'), { + autoClose: false, closeButton: false, closeOnClick: false, icon: + }) + }, [network.online]); + + return '' +} + +export default NetworkComponent \ No newline at end of file diff --git a/src/layouts/AppLayout.jsx b/src/layouts/AppLayout.jsx index 611e707..2b4593b 100644 --- a/src/layouts/AppLayout.jsx +++ b/src/layouts/AppLayout.jsx @@ -2,12 +2,13 @@ import theme from "@/core/utils/theme"; import useLanguage from "@/lib/app/hooks/useLanguage"; import useLoading from "@/lib/app/hooks/useLoading"; import useUser from "@/lib/app/hooks/useUser"; -import Head from "next/head"; import NextNProgress from "nextjs-progressbar"; import {useEffect} from "react"; import {ToastContainer} from "react-toastify"; import useDirection from "@/lib/app/hooks/useDirection"; import "react-toastify/dist/ReactToastify.css"; +import NetworkComponent from "@/core/components/NetworkComponent"; +import GlobalHead from "@/core/components/GlobalHead"; function AppLayout({children, isBot}) { const {languageIsReady} = useLanguage(); @@ -40,66 +41,16 @@ function AppLayout({children, isBot}) { if (!languageIsReady) return; } - return ( - <> - - - - - - - - - - - - - - - - - - - - - - - {children} - - ); + return (<> + + + + + {children} + ); } -export default AppLayout; +export default AppLayout; \ No newline at end of file diff --git a/src/lib/app/hooks/useNetwork.jsx b/src/lib/app/hooks/useNetwork.jsx new file mode 100644 index 0000000..4fff7fe --- /dev/null +++ b/src/lib/app/hooks/useNetwork.jsx @@ -0,0 +1,58 @@ +import {useEffect, useState} from "react"; + +function getNetworkConnection() { + return ( + navigator.connection || + navigator.mozConnection || + navigator.webkitConnection || + null + ); +} + +function getNetworkConnectionInfo() { + const connection = getNetworkConnection(); + if (!connection) { + return {}; + } + return { + rtt: connection.rtt, + type: connection.type, + saveData: connection.saveData, + downLink: connection.downLink, + downLinkMax: connection.downLinkMax, + effectiveType: connection.effectiveType, + }; +} + +function useNetwork() { + const [state, setState] = useState(() => { + return { + online: navigator.onLine, + }; + }); + useEffect(() => { + const handleOnline = () => { + setState((prevState) => ({ + ...prevState, + online: true, + })); + }; + const handleOffline = () => { + setState((prevState) => ({ + ...prevState, + online: false, + })); + }; + + window.addEventListener("online", handleOnline); + window.addEventListener("offline", handleOffline); + return () => { + window.removeEventListener("online", handleOnline); + window.removeEventListener("offline", handleOffline); + }; + }, []); + + return state; +} + +export default useNetwork; \ No newline at end of file diff --git a/src/lib/app/hooks/useRequest.js b/src/lib/app/hooks/useRequest.js index 5c567ca..d361e08 100644 --- a/src/lib/app/hooks/useRequest.js +++ b/src/lib/app/hooks/useRequest.js @@ -4,27 +4,23 @@ import PendingNotification from "@/core/components/notifications/PendingNotifica import {useTranslations} from "next-intl"; import useUser from "@/lib/app/hooks/useUser"; import {errorRequest, errorResponse, errorSetting} from "@/core/utils/errorHandler"; +import useNetwork from "@/lib/app/hooks/useNetwork"; const defaultOptions = { - auth: false, - data: {}, - requestOptions: { + auth: false, data: {}, requestOptions: { headers: {} - }, - notification: true, - pending: true, - success: { + }, notification: true, pending: true, success: { notification: { show: true, }, - }, - failed: { + }, failed: { notification: { show: true, }, }, } const useRequest = (initOptions) => { + const network = useNetwork() const t = useTranslations() const {token, clearToken} = useUser() let _options = {...defaultOptions, ...initOptions} @@ -32,20 +28,20 @@ const useRequest = (initOptions) => { function requestServer(url = '', method = 'get', options) { _options = {..._options, ...options} if (_options.auth) _options = { - ..._options, - requestOptions: { + ..._options, requestOptions: { ..._options.requestOptions, headers: {..._options.requestOptions.headers, authorization: `Bearer ${token}`} } } return new Promise((resolve, reject) => { + if (!network.online) { + reject() + return + } if (_options.notification && _options.failed.notification.show && _options.pending) PendingNotification(t) axios({ - url: url, - method: method, - data: _options.data, - ..._options.requestOptions + url: url, method: method, data: _options.data, ..._options.requestOptions }) .then(response => { successRequest(response, t, _options) From 650c02e09ea7c83d7f4fd969ac651751a9fa4d3e Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Wed, 27 Sep 2023 10:34:32 +0330 Subject: [PATCH 05/11] TF-102 fixed error handler when response is logic error --- src/core/utils/errorHandler.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/utils/errorHandler.js b/src/core/utils/errorHandler.js index ec5858a..8dbd364 100644 --- a/src/core/utils/errorHandler.js +++ b/src/core/utils/errorHandler.js @@ -3,11 +3,11 @@ import WarningNotification from "@/core/components/notifications/WarningNotifica import {toast} from "react-toastify"; export const errorSetting = (t, notification) => { - //todo + if (notification) toast.dismiss(); } export const errorRequest = (t, notification) => { - //todo + if (notification) toast.dismiss(); } export const errorResponse = (response, clearToken, t, notification) => { @@ -48,7 +48,7 @@ const isServerError = status => status >= 500 && status <= 599; const isClientError = status => status >= 400 && status <= 499; const errorLogic = (response, t, notification) => { - if (notification) ErrorNotification(t, response.status) + if (notification) ErrorNotification(t, response.status, response.data.message) } const errorValidation = (response, t, notification) => { if (notification) { @@ -59,4 +59,4 @@ const errorValidation = (response, t, notification) => { ErrorNotification(t, response.status, errorsArray[item][0]); }) } -} +} \ No newline at end of file From cff36d5b0412aa3e409725bcd082509f18a295f4 Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Wed, 27 Sep 2023 10:55:36 +0330 Subject: [PATCH 06/11] TF-102 fixed follow-up page when no request found --- public/locales/fa/app.json | 3 +- .../dashboard/refahi/followUp-loan/index.jsx | 46 ++++++++----------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index c91dc84..7289568 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -113,7 +113,8 @@ "loan_follow_up_page": "پیگیری درخواست", "loan_request_correction": "اصلاح درخواست", "loan_request_detail": "مشاهده جزئیات", - "request_number": "درخواست شماره" + "request_number": "درخواست شماره", + "no_request_found": "درخواستی یافت نشد" }, "LoanRequest": { "loan_request_page": "ثبت درخواست وام", diff --git a/src/components/dashboard/refahi/followUp-loan/index.jsx b/src/components/dashboard/refahi/followUp-loan/index.jsx index 331bab0..32b121d 100644 --- a/src/components/dashboard/refahi/followUp-loan/index.jsx +++ b/src/components/dashboard/refahi/followUp-loan/index.jsx @@ -1,19 +1,18 @@ import DashboardLayouts from "@/layouts/dashboardLayouts"; -import { - Grid, - Stack, -} from "@mui/material"; +import {Grid, Stack, Typography,} from "@mui/material"; import {useEffect, useState} from "react"; import {SHOW_LOAN_REQUEST_WELFARE} from "@/core/data/apiRoutes"; import useLoading from "@/lib/app/hooks/useLoading"; import useRequest from "@/lib/app/hooks/useRequest"; import moment from "jalali-moment"; import RequestCard from "@/components/dashboard/refahi/followUp-loan/RequestCard"; +import {useTranslations} from "next-intl"; const LoanFollowUpComponent = () => { + const t = useTranslations() const requestServer = useRequest(); const {setLoadingPage} = useLoading(); - const [requestsList, setRequestsList] = useState([]); + const [requestsList, setRequestsList] = useState(null); // get form data useEffect(() => { setLoadingPage(true) @@ -33,28 +32,23 @@ const LoanFollowUpComponent = () => { }) }, []); - return ( - - + + {requestsList == null ? '' : requestsList.length ? ( - - {requestsList.map((item, index) => ( - - ))} - - - - ); + {requestsList.map((item, index) => ())} + ) : ({t('LoanFollowUp.no_request_found')})} + + ); }; export default LoanFollowUpComponent; From 6652615c94e40700abc0f2bb3e590342085b1ecc Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Wed, 27 Sep 2023 12:04:30 +0330 Subject: [PATCH 07/11] TF-102 fixed form in add-request-refahi --- public/locales/fa/app.json | 2 + .../refahi/add-request-loan/forms/AddForm.jsx | 96 +++++++++++-------- src/lib/app/hooks/useProvince.jsx | 29 ++++++ 3 files changed, 85 insertions(+), 42 deletions(-) create mode 100644 src/lib/app/hooks/useProvince.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 7289568..6031f3e 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -135,6 +135,8 @@ "text_field_vehicle_type": "نام وسیله نقلیه", "text_field_enter_your_vehicle_type": "نام وسیله نقلیه خود را وارد کنید", "text_field_province": "استان", + "text_field_loading_provinces_list": "درحال دریافت استان ها", + "text_field_error_fetching_provinces": "خطا در دریافت استان ها", "text_field_enter_your_province": "استان خود را وارد کنید", "text_field_navgan_id": "شماره ناوگان", "text_field_enter_your_navgan_id": "شماره ناوگان خود را وارد کنید", diff --git a/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx b/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx index 06a40fc..4c67ee3 100644 --- a/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx +++ b/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx @@ -1,39 +1,30 @@ import StyledForm from "@/core/components/StyledForm"; import UploadSystem from "@/core/components/UploadSystem"; -import {GET_PROVINCE_LIST, SEND_LOAN_REQUEST_WELFARE} from "@/core/data/apiRoutes"; -import useDirection from "@/lib/app/hooks/useDirection"; -import useUser from "@/lib/app/hooks/useUser"; +import {SEND_LOAN_REQUEST_WELFARE} from "@/core/data/apiRoutes"; import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; -import {Box, Button, Chip, Divider, Stack, TextField} from "@mui/material"; +import { + Box, + Button, + Chip, + Divider, + FormControl, + FormHelperText, + InputLabel, + MenuItem, + Select, + Stack, + TextField +} from "@mui/material"; import {Field, Formik} from "formik"; import {useTranslations} from "next-intl"; -import {useEffect, useState} from "react"; import * as Yup from "yup"; -import SelectBox from "@/core/components/SelectBox"; import useRequest from "@/lib/app/hooks/useRequest"; +import useProvince from "@/lib/app/hooks/useProvince"; const AddFormComponent = () => { const t = useTranslations(); - const {directionApp} = useDirection(); - const {token} = useUser(); const requestServer = useRequest() - - const [provinceList, setProvinceList] = useState([]); - - // get province list - useEffect(() => { - requestServer(GET_PROVINCE_LIST, "get", {auth: true, notification: false}) - .then(function ({data}) { - const formattedData = data.map((province, index) => ({ - id: index, - name: province.name, - value: province.id, - })); - setProvinceList(formattedData); - }).catch(() => { - }) - }, []); - // end get province list + const {provinceList, isLoadingProvinceList, errorProvinceList} = useProvince() // initial values, validation and request action of form const initialValues = { @@ -183,27 +174,48 @@ const AddFormComponent = () => { - + > + {t("LoanRequest.text_field_province")} + + + {props.touched.province && props.errors.province ? props.errors.province : ""} + + { + const requestServer = useRequest({auth: true, notification: false}) + + //swr config + const fetcher = (...args) => { + return requestServer(args, 'get').then(({data}) => { + return data; + }).catch(() => { + }) + }; + + const {data, isLoading} = useSWR(GET_PROVINCE_LIST, fetcher, { + revalidateIfStale: false, + revalidateOnFocus: false, + revalidateOnReconnect: false + }); + + return { + provinceList: data, + isLoadingProvinceList: isLoading, + errorProvinceList: !data + } +}; + +export default useProvince; \ No newline at end of file From dbd3b032b4aad7ed99334b569a3bbdac3f2c955e Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Wed, 27 Sep 2023 16:03:58 +0330 Subject: [PATCH 08/11] TF-103 debug make all places province and national code text and other actions same as together --- public/locales/fa/app.json | 12 +++--- .../refahi/add-request-loan/forms/AddForm.jsx | 40 +++++++++---------- .../edit-request-loan/forms/EditForm.jsx | 20 +++++----- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 6031f3e..263693a 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -125,8 +125,8 @@ "error_message_vehicle_type": "لطفا نوع وسیله نقلیه خود را وارد کنید!", "error_message_plate_number": "لطفا شماره پلاک خود را وارد کنید!", "error_message_navgan_id": "لطفا کد ناوگان خود را وارد کنید!", - "error_message_province": "لطفا استان خود را وارد کنید!", - "error_message_national_code": "لطفا کد ملی خود را وارد کنید!", + "error_message_province_id": "لطفا استان خود را وارد کنید!", + "error_message_national_id": "لطفا کد ملی خود را وارد کنید!", "error_message_shenasname_id": "لطفا شماره شناسنامه خود را وارد کنید!", "text_field_phone_number": "شماره تلفن", "text_field_enter_your_phone_number": "شماره تلفن خود را وارد کنید", @@ -134,14 +134,14 @@ "text_field_enter_your_name": "نام خود را وارد کنید", "text_field_vehicle_type": "نام وسیله نقلیه", "text_field_enter_your_vehicle_type": "نام وسیله نقلیه خود را وارد کنید", - "text_field_province": "استان", + "text_field_province_id": "استان", "text_field_loading_provinces_list": "درحال دریافت استان ها", "text_field_error_fetching_provinces": "خطا در دریافت استان ها", - "text_field_enter_your_province": "استان خود را وارد کنید", + "text_field_enter_your_province_id": "استان خود را وارد کنید", "text_field_navgan_id": "شماره ناوگان", "text_field_enter_your_navgan_id": "شماره ناوگان خود را وارد کنید", - "text_field_national_code": "کد ملی", - "text_field_enter_your_national_code": "کد ملی خود را وارد کنید", + "text_field_national_id": "کد ملی", + "text_field_enter_your_national_id": "کد ملی خود را وارد کنید", "text_field_shenasname_id": "شماره شناسنامه", "text_field_enter_your_shenasname_id": "شماره شناسنامه خود را وارد کنید", "text_field_plate_number": "شماره پلاک", diff --git a/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx b/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx index 4c67ee3..76bdb1a 100644 --- a/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx +++ b/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx @@ -30,8 +30,8 @@ const AddFormComponent = () => { const initialValues = { name: "", phone_number: "", - province: "", - national_code: "", + province_id: "", + national_id: "", shenasname_id: "", sherkat_naft_doc: null, estate_doc: null, @@ -46,9 +46,9 @@ const AddFormComponent = () => { phone_number: Yup.string().required( t("LoanRequest.error_message_phone_number") ), - province: Yup.string().required(t("LoanRequest.error_message_province")), - national_code: Yup.string().required( - t("LoanRequest.error_message_national_code") + province_id: Yup.string().required(t("LoanRequest.error_message_province_id")), + national_id: Yup.string().required( + t("LoanRequest.error_message_national_id") ), shenasname_id: Yup.string().required( t("LoanRequest.error_message_shenasname_id") @@ -64,8 +64,8 @@ const AddFormComponent = () => { const formData = new FormData(); formData.append("name", values.name); formData.append("phone_number", values.phone_number); - formData.append("province_id", values.province); - formData.append("national_id", values.national_code); + formData.append("province_id", values.province_id); + formData.append("national_id", values.national_id); formData.append("shenasname_id", values.shenasname_id); if (values.sherkat_naft_doc != null) formData.append("sherkat_naft_doc", values.sherkat_naft_doc); @@ -179,18 +179,18 @@ const AddFormComponent = () => { }} > - {t("LoanRequest.text_field_province")} + {t("LoanRequest.text_field_province_id")} - {props.touched.province && props.errors.province ? props.errors.province : ""} + {props.touched.province_id && props.errors.province_id ? props.errors.province_id : ""} @@ -237,21 +237,21 @@ const AddFormComponent = () => { diff --git a/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx b/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx index 9ea22c2..dba81c6 100644 --- a/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx +++ b/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx @@ -74,8 +74,8 @@ const EditFormComponent = () => { phone_number: Yup.string().required( t("LoanRequest.error_message_phone_number") ), - province_id: Yup.string().required(t("LoanRequest.error_message_province")), - national_id: Yup.string().required(t("LoanRequest.error_message_national_code")), + province_id: Yup.string().required(t("LoanRequest.error_message_province_id")), + national_id: Yup.string().required(t("LoanRequest.error_message_national_id")), shenasname_id: Yup.string().required(t("LoanRequest.error_message_shenasname_id")), sherkat_naft_doc: Yup.mixed().required(t("LoanRequest.error_message_sherkat_naft_doc")), estate_doc: Yup.mixed().required(t("LoanRequest.error_message_estate_doc")), @@ -205,7 +205,7 @@ const EditFormComponent = () => { > { name="national_id" variant="outlined" size="small" - label={t("LoanRequest.text_field_national_code")} + label={t("LoanRequest.text_field_national_id")} placeholder={t( - "LoanRequest.text_field_enter_your_national_code" + "LoanRequest.text_field_enter_your_national_id" )} type={"text"} error={ @@ -307,7 +307,7 @@ const EditFormComponent = () => { setFieldValue={props.setFieldValue} default_image={initialValues.sherkat_naft_doc} fieldName="sherkat_naft_doc" - imageAlt={t("app_name")} + imageAlt={t("LoanRequest.file_field_sherkat_naft_doc")} label={t("LoanRequest.file_field_sherkat_naft_doc")} enableDelete={false} error={ @@ -326,7 +326,7 @@ const EditFormComponent = () => { setFieldValue={props.setFieldValue} default_image={initialValues.estate_doc} fieldName="estate_doc" - imageAlt={t("app_name")} + imageAlt={t("LoanRequest.file_field_estate_doc")} label={t("LoanRequest.file_field_estate_doc")} enableDelete={false} error={ @@ -345,7 +345,7 @@ const EditFormComponent = () => { setFieldValue={props.setFieldValue} default_image={initialValues.agreement_doc} fieldName="agreement_doc" - imageAlt={t("app_name")} + imageAlt={t("LoanRequest.file_field_agreement_doc")} label={t("LoanRequest.file_field_agreement_doc")} enableDelete={false} error={ @@ -364,7 +364,7 @@ const EditFormComponent = () => { setFieldValue={props.setFieldValue} default_image={initialValues.shenasname_image} fieldName="shenasname_image" - imageAlt={t("app_name")} + imageAlt={t("LoanRequest.file_field_shenasname_image")} label={t("LoanRequest.file_field_shenasname_image")} enableDelete={false} error={ @@ -383,7 +383,7 @@ const EditFormComponent = () => { setFieldValue={props.setFieldValue} default_image={initialValues.payan_khedmat_image} fieldName="payan_khedmat_image" - imageAlt={t("app_name")} + imageAlt={t("LoanRequest.file_field_payan_khedmat_image")} label={t("LoanRequest.file_field_payan_khedmat_image")} enableDelete={false} error={ From 3fa08e0df3d785f72c0d0d45b1314e803d2a28d0 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Thu, 28 Sep 2023 13:13:48 +0330 Subject: [PATCH 09/11] TF-103 ban user to see edit page by changing router staticaly --- .../edit-request-loan/forms/EditForm.jsx | 51 +------------- .../refahi/edit-request-loan/index.jsx | 70 +++++++++++++++++-- 2 files changed, 67 insertions(+), 54 deletions(-) diff --git a/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx b/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx index dba81c6..71d9660 100644 --- a/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx +++ b/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx @@ -1,21 +1,19 @@ import StyledForm from "@/core/components/StyledForm"; import UploadSystem from "@/core/components/UploadSystem"; -import {GET_PROVINCE_LIST, UPDATE_LOAN_REQUEST_WELFARE, DETAILS_LOAN_REQUEST_WELFARE} from "@/core/data/apiRoutes"; +import {UPDATE_LOAN_REQUEST_WELFARE} from "@/core/data/apiRoutes"; import useDirection from "@/lib/app/hooks/useDirection"; import useUser from "@/lib/app/hooks/useUser"; import DataSaverOnIcon from "@mui/icons-material/DataSaverOn"; import {Box, Button, Chip, Divider, Stack, TextField} from "@mui/material"; -import axios from "axios"; import {Field, Formik} from "formik"; import {useTranslations} from "next-intl"; -import {useEffect, useMemo, useState} from "react"; import * as Yup from "yup"; import SelectBox from "@/core/components/SelectBox"; import useRequest from "@/lib/app/hooks/useRequest"; import {useRouter} from "next/router"; import useLoading from "@/lib/app/hooks/useLoading"; -const EditFormComponent = () => { +const EditFormComponent = ({provinceList, initialValues}) => { const t = useTranslations(); const {directionApp} = useDirection(); const {token} = useUser(); @@ -23,51 +21,6 @@ const EditFormComponent = () => { const router = useRouter(); const {setLoadingPage} = useLoading(); - const [provinceList, setProvinceList] = useState(null); - const [initialValues, setInitialValues] = useState(null); - - // get province list - useEffect(() => { - setLoadingPage(true) - requestServer(GET_PROVINCE_LIST, "get", {auth: true, notification: false}) - .then(function ({data}) { - const formattedData = data.map((province, index) => ({ - id: index, - name: province.name, - value: province.id, - })); - setProvinceList(formattedData); - }).catch(() => { - }); - }, []); - - - // get form data - useEffect(() => { - if (!provinceList) return; - requestServer(DETAILS_LOAN_REQUEST_WELFARE + router.query.id, "get", {auth: true, notification: false}) - .then(function ({data}) { - const item = data.data; - const formattedData = { - name: item.name, - phone_number: item.phone_number, - province_id: item.province_id, - national_id: item.national_id, - shenasname_id: item.shenasname_id, - sherkat_naft_doc: item.sherkat_naft_doc, - estate_doc: item.estate_doc, - agreement_doc: item.agreement_doc, - national_card_image: item.national_card_image, - shenasname_image: item.shenasname_image, - payan_khedmat_image: item.payan_khedmat_image, - } - setInitialValues(formattedData); - setLoadingPage(false) - }) - .catch(() => { - }) - }, [provinceList]); - // validation and request action of form const validationSchema = Yup.object().shape({ name: Yup.string().required(t("LoanRequest.error_message_name")), diff --git a/src/components/dashboard/refahi/edit-request-loan/index.jsx b/src/components/dashboard/refahi/edit-request-loan/index.jsx index 4be62ff..f2ab1e1 100644 --- a/src/components/dashboard/refahi/edit-request-loan/index.jsx +++ b/src/components/dashboard/refahi/edit-request-loan/index.jsx @@ -1,15 +1,75 @@ import DashboardLayouts from "@/layouts/dashboardLayouts"; -import useUser from "@/lib/app/hooks/useUser"; -import {useTranslations} from "next-intl"; import EditFormComponent from "@/components/dashboard/refahi/edit-request-loan/forms/EditForm"; +import {useEffect, useState} from "react"; +import {DETAILS_LOAN_REQUEST_WELFARE, GET_PROVINCE_LIST} from "@/core/data/apiRoutes"; +import useLoading from "@/lib/app/hooks/useLoading"; +import useRequest from "@/lib/app/hooks/useRequest"; +import {useRouter} from "next/router"; const LoanRequestComponent = () => { - const t = useTranslations(); - const {user} = useUser(); + const requestServer = useRequest(); + const {setLoadingPage} = useLoading(); + const router = useRouter(); + + const [provinceList, setProvinceList] = useState(null); + const [initialValues, setInitialValues] = useState(null); + + // get province list + useEffect(() => { + setLoadingPage(true); + requestServer(GET_PROVINCE_LIST, "get", {auth: true, notification: false}) + .then(function ({data}) { + const formattedData = data.map((province, index) => ({ + id: index, + name: province.name, + value: province.id, + })); + setProvinceList(formattedData); + }).catch(() => { + setLoadingPage(false); + }); + }, []); + + // get form data + useEffect(() => { + if (!provinceList) return; + setLoadingPage(true); + requestServer(DETAILS_LOAN_REQUEST_WELFARE + router.query.id, "get", {auth: true, notification: false}) + .then(function ({data}) { + const item = data.data; + const formattedData = { + name: item.name, + phone_number: item.phone_number, + province_id: item.province_id, + national_id: item.national_id, + shenasname_id: item.shenasname_id, + sherkat_naft_doc: item.sherkat_naft_doc, + estate_doc: item.estate_doc, + agreement_doc: item.agreement_doc, + national_card_image: item.national_card_image, + shenasname_image: item.shenasname_image, + payan_khedmat_image: item.payan_khedmat_image, + state_id: item.state_id + }; + setInitialValues(formattedData); + }) + .catch(() => { + setLoadingPage(false); + }); + }, [provinceList, router]); + + // Redirect to /dashboard/refahi/followUp-loan if state_id is not 7 + useEffect(() => { + if (initialValues && initialValues.state_id !== 7) { + router.push('/dashboard/refahi/followUp-loan'); + } + }, [initialValues, router]); return ( - + {initialValues && initialValues.state_id === 7 && ( + + )} ); }; From 87f26f90e0e3650a13612b7e747bca7ffd5e66ef Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sat, 30 Sep 2023 11:49:08 +0330 Subject: [PATCH 10/11] TF-103 debug add page accessibility and edit form redirecting follow up problem --- public/locales/fa/app.json | 3 +- .../add-request-loan/accessibility/index.jsx | 32 +++++++++++++++++++ .../refahi/add-request-loan/forms/AddForm.jsx | 5 ++- .../refahi/add-request-loan/index.jsx | 5 ++- .../edit-request-loan/forms/EditForm.jsx | 4 +-- .../refahi/edit-request-loan/index.jsx | 18 +++++++---- 6 files changed, 52 insertions(+), 15 deletions(-) create mode 100644 src/components/dashboard/refahi/add-request-loan/accessibility/index.jsx diff --git a/public/locales/fa/app.json b/public/locales/fa/app.json index 263693a..0c9d741 100644 --- a/public/locales/fa/app.json +++ b/public/locales/fa/app.json @@ -158,7 +158,8 @@ "file_field_payan_khedmat_image": "تصویر کارت پایان خدمت", "error_message_national_card_image": "تصویر کارت ملی خود را وارد کنید", "error_message_shenasname_image": "تصویر شناسنامه خود را وارد کنید", - "error_message_payan_khedmat_image": "تصویر کارت پایان خدمت خود را وارد کنید" + "error_message_payan_khedmat_image": "تصویر کارت پایان خدمت خود را وارد کنید", + "add_loan_request_permission": "اکنون امکان ثبت درخواست جدید برای شما مقدور نیست" }, "EditLoanRequest": { "edit_loan_request_page": "ویرایش درخواست وام" diff --git a/src/components/dashboard/refahi/add-request-loan/accessibility/index.jsx b/src/components/dashboard/refahi/add-request-loan/accessibility/index.jsx new file mode 100644 index 0000000..3618d0b --- /dev/null +++ b/src/components/dashboard/refahi/add-request-loan/accessibility/index.jsx @@ -0,0 +1,32 @@ +import {Button, Typography} from "@mui/material"; +import {useTranslations} from "next-intl"; +import CenterLayout from "@/layouts/CenterLayout"; +import {useRouter} from "next/router"; +import {NextLinkComposed} from "@/core/components/LinkRouting"; + +const AccessibilityComponent = () => { + const t = useTranslations(); + const router = useRouter(); + + return ( + + + {t("LoanRequest.add_loan_request_permission")} + + + + ); +}; + +export default AccessibilityComponent; diff --git a/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx b/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx index 76bdb1a..4051854 100644 --- a/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx +++ b/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx @@ -20,11 +20,13 @@ import {useTranslations} from "next-intl"; import * as Yup from "yup"; import useRequest from "@/lib/app/hooks/useRequest"; import useProvince from "@/lib/app/hooks/useProvince"; +import {useRouter} from "next/router"; const AddFormComponent = () => { const t = useTranslations(); const requestServer = useRequest() - const {provinceList, isLoadingProvinceList, errorProvinceList} = useProvince() + const {provinceList, isLoadingProvinceList, errorProvinceList} = useProvince(); + const router = useRouter(); // initial values, validation and request action of form const initialValues = { @@ -81,6 +83,7 @@ const AddFormComponent = () => { formData.append("payan_khedmat_image", values.payan_khedmat_image); requestServer(SEND_LOAN_REQUEST_WELFARE, "post", {auth: true, data: formData}) .then(function (response) { + router.replace('/dashboard/refahi/followUp-loan'); }) .catch(function (error) { }) diff --git a/src/components/dashboard/refahi/add-request-loan/index.jsx b/src/components/dashboard/refahi/add-request-loan/index.jsx index feb8df0..bc82ac7 100644 --- a/src/components/dashboard/refahi/add-request-loan/index.jsx +++ b/src/components/dashboard/refahi/add-request-loan/index.jsx @@ -1,16 +1,15 @@ import DashboardLayouts from "@/layouts/dashboardLayouts"; import useUser from "@/lib/app/hooks/useUser"; -import {Box, Chip, Divider} from "@mui/material"; import {useTranslations} from "next-intl"; import AddFormComponent from "@/components/dashboard/refahi/add-request-loan/forms/AddForm"; +import AccessibilityComponent from "@/components/dashboard/refahi/add-request-loan/accessibility"; const LoanRequestComponent = () => { const t = useTranslations(); const {user} = useUser(); - return ( - + {user.can_request_a_new_loan ? : } ); }; diff --git a/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx b/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx index 71d9660..36f5aa0 100644 --- a/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx +++ b/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx @@ -15,11 +15,9 @@ import useLoading from "@/lib/app/hooks/useLoading"; const EditFormComponent = ({provinceList, initialValues}) => { const t = useTranslations(); - const {directionApp} = useDirection(); - const {token} = useUser(); const requestServer = useRequest(); const router = useRouter(); - const {setLoadingPage} = useLoading(); + // validation and request action of form const validationSchema = Yup.object().shape({ diff --git a/src/components/dashboard/refahi/edit-request-loan/index.jsx b/src/components/dashboard/refahi/edit-request-loan/index.jsx index f2ab1e1..89de937 100644 --- a/src/components/dashboard/refahi/edit-request-loan/index.jsx +++ b/src/components/dashboard/refahi/edit-request-loan/index.jsx @@ -5,6 +5,7 @@ import {DETAILS_LOAN_REQUEST_WELFARE, GET_PROVINCE_LIST} from "@/core/data/apiRo import useLoading from "@/lib/app/hooks/useLoading"; import useRequest from "@/lib/app/hooks/useRequest"; import {useRouter} from "next/router"; +import {log} from "next/dist/server/typescript/utils"; const LoanRequestComponent = () => { const requestServer = useRequest(); @@ -60,17 +61,20 @@ const LoanRequestComponent = () => { // Redirect to /dashboard/refahi/followUp-loan if state_id is not 7 useEffect(() => { - if (initialValues && initialValues.state_id !== 7) { - router.push('/dashboard/refahi/followUp-loan'); - } - }, [initialValues, router]); + if (!initialValues) return + if (initialValues.state_id === 7) return + + router.replace('/dashboard/refahi/followUp-loan'); + }, [initialValues]); return ( - + <> {initialValues && initialValues.state_id === 7 && ( - + + + )} - + ); }; From c30423ba55f59ede06ea37f96c82657c0b5faeac Mon Sep 17 00:00:00 2001 From: AmirHossein Mahmoodi Date: Sat, 30 Sep 2023 12:03:13 +0330 Subject: [PATCH 11/11] change version --- example.env.local | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example.env.local b/example.env.local index b8f7ab4..0883de5 100644 --- a/example.env.local +++ b/example.env.local @@ -1,11 +1,11 @@ NEXT_PUBLIC_API_NAME = "Loan Facilities Dashboard" -NEXT_PUBLIC_API_VERSION = "1.0.0" +NEXT_PUBLIC_API_VERSION = "1.7.3" NEXT_PUBLIC_DEFAULT_LANGUAGE = "fa" NEXT_PUBLIC_DEFAULT_DIRECTION = "rtl" NEXT_PUBLIC_PRIMARY_MAIN = "#084070" NEXT_PUBLIC_SECONDARY_MAIN = "#FF4E00" -NEXT_PUBLIC_BASE_URL = "deploy api" +NEXT_PUBLIC_BASE_URL = "https://loan.witel.ir" NODE_ENV = "development" \ No newline at end of file