From 59e652c182b7b76f8f2912c976f3bd552c82ac65 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Wed, 30 Aug 2023 15:34:44 +0330 Subject: [PATCH 1/2] TF-94 Number FontFamily Added To Project/Jalali Moment Added To Project/ Permission Format Appended To Sidebar Menu --- next.config.js | 3 ++ .../edit-request-loan/forms/EditForm.jsx | 5 ++- src/core/components/UploadSystem.jsx | 18 ++++----- src/core/data/sidebarMenu.jsx | 5 +++ .../dashboardLayouts/sidebar/SidebarList.jsx | 39 ++++++++++++------- 5 files changed, 43 insertions(+), 27 deletions(-) diff --git a/next.config.js b/next.config.js index 409876a..db2124f 100644 --- a/next.config.js +++ b/next.config.js @@ -2,6 +2,9 @@ const nextConfig = { reactStrictMode: true, + images: { + domains: ['loan.witel.ir', /* other domains */], + }, i18n: { defaultLocale: 'fa', locales: ['fa'], 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 31cc170..501c47f 100644 --- a/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx +++ b/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx @@ -63,8 +63,9 @@ const EditFormComponent = () => { } setInitialValues(formattedData); setLoadingPage(false) - }).catch(() => { - }) + }) + .catch(() => { + }) }, [provinceList]); // validation and request action of form diff --git a/src/core/components/UploadSystem.jsx b/src/core/components/UploadSystem.jsx index 8c5e058..54dd49d 100644 --- a/src/core/components/UploadSystem.jsx +++ b/src/core/components/UploadSystem.jsx @@ -16,7 +16,6 @@ const UploadSystem = ({ }) => { const t = useTranslations(); const fileInputRef = useRef(null); - const [selectedImage, setSelectedImage] = useState(default_image || "/images/upload-image.svg"); const [fileType, setFileType] = useState(null); const [fileName, setFileName] = useState(""); @@ -39,16 +38,12 @@ const UploadSystem = ({ border: "1px dashed #d32f2f", borderRadius: "5px", padding: "5px", - width: '200px', - height: '200px' } : { cursor: "pointer", objectFit: "contain", border: "1px dashed #e1e1e1", borderRadius: "5px", padding: "5px", - width: '200px', - height: '200px' } const handleClick = () => { @@ -72,13 +67,16 @@ const UploadSystem = ({ > {label} - {selectedImage === "/images/upload-image.svg" ? ( + + + + {selectedImage === "/images/upload-image.svg" || selectedImage === default_image ? ( {imageAlt} @@ -87,8 +85,8 @@ const UploadSystem = ({ src={selectedImage} priority alt={imageAlt} - width={0} - height={0} + width={200} + height={200} onClick={handleClick} style={uploadBoxStyle} /> diff --git a/src/core/data/sidebarMenu.jsx b/src/core/data/sidebarMenu.jsx index 0eeedc7..a78ed6c 100644 --- a/src/core/data/sidebarMenu.jsx +++ b/src/core/data/sidebarMenu.jsx @@ -11,6 +11,7 @@ const sidebarMenu = [ icon: , userType: 0, selected: false, + permission_name: "all" }, { key: "sidebar.add-request-loan", @@ -19,6 +20,7 @@ const sidebarMenu = [ icon: , userType: 1, selected: false, + permission_name: "can_request_a_new_loan" }, { key: "sidebar.followUp-loan", @@ -27,6 +29,7 @@ const sidebarMenu = [ icon: , userType: 1, selected: false, + permission_name: "all" }, { key: "sidebar.add-request-loan", @@ -35,6 +38,7 @@ const sidebarMenu = [ icon: , userType: 2, selected: false, + permission_name: "can_request_a_new_loan" }, { key: "sidebar.followUp-loan", @@ -43,6 +47,7 @@ const sidebarMenu = [ icon: , userType: 2, selected: false, + permission_name: "all" }, ], ]; diff --git a/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx b/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx index f417286..6cd6847 100644 --- a/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx +++ b/src/layouts/dashboardLayouts/sidebar/SidebarList.jsx @@ -41,20 +41,29 @@ export default function SidebarList({handleDrawerToggle}) { return ( {itemMenu.map((itemArr, index) => ( - - {itemArr.map((item) => - (item.userType === user.type_id || item.userType === 0) ? ( - - ) : null - )} - - - ))} + + {itemArr.map((item) => { + if ( + (item.userType === user.type_id || item.userType === 0) && + (user[item.permission_name] || item.permission_name === "all") + ) { + return ( + + ); + } else { + return null; + } + })} + + + ) + )} - ); + ) + ; } From 38b22c6dadd4e59465724b1cf1b0189c114f7111 Mon Sep 17 00:00:00 2001 From: Mohammad Jalali Date: Sun, 3 Sep 2023 16:23:03 +0330 Subject: [PATCH 2/2] TF-94 Implementation of File Uploader Component --- .../dashboard/navgan/followUp-loan/index.jsx | 121 +++++------------- .../refahi/add-request-loan/forms/AddForm.jsx | 2 +- .../edit-request-loan/forms/EditForm.jsx | 2 +- src/components/login/SendToken.jsx | 3 +- src/components/login/SendUserData.jsx | 4 +- src/components/register/RequestOtp.jsx | 2 +- src/components/register/navy/UserRegister.jsx | 2 +- .../welfare-services/UserRegister.jsx | 3 +- src/core/components/ResendToken.jsx | 26 ++-- src/core/data/apiRoutes.js | 1 + 10 files changed, 52 insertions(+), 114 deletions(-) diff --git a/src/components/dashboard/navgan/followUp-loan/index.jsx b/src/components/dashboard/navgan/followUp-loan/index.jsx index cda243c..de3176c 100644 --- a/src/components/dashboard/navgan/followUp-loan/index.jsx +++ b/src/components/dashboard/navgan/followUp-loan/index.jsx @@ -1,66 +1,37 @@ import DashboardLayouts from "@/layouts/dashboardLayouts"; -import useUser from "@/lib/app/hooks/useUser"; -import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; import { - Avatar, - Card, - CardActions, - CardContent, - CardHeader, - Collapse, Grid, - IconButton, Stack, - Typography } from "@mui/material"; -import {styled} from "@mui/material/styles"; -import {useTranslations} from "next-intl"; -import {useState} from "react"; - -const ExpandMore = styled((props) => { - const {expand, ...other} = props; - return ; -})(({theme, expand}) => ({ - transform: !expand ? "rotate(0deg)" : "rotate(180deg)", - marginLeft: "auto", - transition: theme.transitions.create("transform", { - duration: theme.transitions.duration.shortest, - }), -})); - -const data = [ - { - name: "جان دو", - date: "۱۳۹۹/۰۴/۲۵", - description: - "لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است.", - }, - { - name: "جین اسمیت", - date: "۱۳۹۹/۰۴/۲۶", - description: "نُلا ویته الیت لیبرو آ، آ فارِترا آوگوه.", - }, - { - name: "مایک جانسون", - date: "۱۳۹۹/۰۴/۲۷", - description: - "دوئیس مولیس، است نُن کُمُدو لُکتوس، نیسی ارات پورتیتور لیگولا.", - }, -]; +import {useEffect, useState} from "react"; +import {SHOW_LOAN_REQUEST_NAVGAN} 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/navgan/followUp-loan/RequestCard"; const LoanFollowUpComponent = () => { - const t = useTranslations(); - const {token} = useUser(); - - const [expanded, setExpanded] = useState([]); - - const handleExpandClick = (index) => { - setExpanded((prevExpanded) => { - const newExpanded = [...prevExpanded]; - newExpanded[index] = !newExpanded[index]; - return newExpanded; - }); - }; + const requestServer = useRequest(); + const {setLoadingPage} = useLoading(); + const [requestsList, setRequestsList] = useState([]); + // get form data + useEffect(() => { + setLoadingPage(true) + requestServer(SHOW_LOAN_REQUEST_NAVGAN, "get", {auth: true, notification: false}) + .then(function ({data}) { + const items = data.data; + const formattedData = items.map((item, index) => ({ + id: item.id, + latest_history_created_at: moment(item.latest_history_created_at).locale("fa").format("HH:mm | YYYY/MM/DD"), + state_id: item.state_id, + loan_state: item.loan_state, + })); + setRequestsList(formattedData); + setLoadingPage(false) + }) + .catch(function (error) { + }) + }, []); return ( @@ -77,42 +48,8 @@ const LoanFollowUpComponent = () => { rowSpacing={2} sx={{alignItems: "start", justifyContent: "center"}} > - {data.map((item, index) => ( - - - - } - title={item.name} - subheader={item.date} - /> - - - متن تست - - - - handleExpandClick(index)} - aria-expanded={expanded[index]} - aria-label="show more" - > - - - - - - اطلاعات تکمیلی: - {item.description} - - - - + {requestsList.map((item, index) => ( + ))} 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 773cbe8..06a40fc 100644 --- a/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx +++ b/src/components/dashboard/refahi/add-request-loan/forms/AddForm.jsx @@ -69,7 +69,7 @@ const AddFormComponent = () => { shenasname_image: Yup.mixed().required(t("LoanRequest.error_message_shenasname_image")), payan_khedmat_image: Yup.mixed().required(t("LoanRequest.error_message_payan_khedmat_image")), }); - const handleSubmit = async (values, props) => { + const handleSubmit = (values, props) => { const formData = new FormData(); formData.append("name", values.name); formData.append("phone_number", values.phone_number); 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 501c47f..9ea22c2 100644 --- a/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx +++ b/src/components/dashboard/refahi/edit-request-loan/forms/EditForm.jsx @@ -85,7 +85,7 @@ const EditFormComponent = () => { payan_khedmat_image: Yup.mixed().required(t("LoanRequest.error_message_payan_khedmat_image")), }); - const handleSubmit = async (values, props) => { + const handleSubmit = (values, props) => { const formData = new FormData(); formData.append("name", values.name); formData.append("phone_number", values.phone_number); diff --git a/src/components/login/SendToken.jsx b/src/components/login/SendToken.jsx index c3e30be..517a5db 100644 --- a/src/components/login/SendToken.jsx +++ b/src/components/login/SendToken.jsx @@ -34,7 +34,7 @@ const SendTokenComponent = ({ ), }); - const handleSubmit = async (values, props) => { + const handleSubmit = (values, props) => { requestServer(LOGIN, "post", { auth: false, data: { phone_number: values.phone_number, @@ -130,6 +130,7 @@ const SendTokenComponent = ({ timer={timer} setTimer={setTimer} PhoneNumber={PhoneNumber} + disabled={props.isSubmitting} /> diff --git a/src/components/login/SendUserData.jsx b/src/components/login/SendUserData.jsx index 1e8adee..6743799 100644 --- a/src/components/login/SendUserData.jsx +++ b/src/components/login/SendUserData.jsx @@ -33,7 +33,7 @@ const SendUserDataComponent = ({ phone_number: Yup.string().required(t("LoginPage.error_message_phone_number")), }); - const handleSubmit = async (values, props) => { + const handleSubmit = (values, props) => { requestServer(SEND_OTP_TOKEN, "post", { auth: false, data: { phone_number: values.phone_number, @@ -101,7 +101,7 @@ const SendUserDataComponent = ({