diff --git a/src/Layout/DefaultLayout.jsx b/src/Layout/DefaultLayout.jsx index 18b1cf2..82e3808 100644 --- a/src/Layout/DefaultLayout.jsx +++ b/src/Layout/DefaultLayout.jsx @@ -75,8 +75,10 @@ import CutomBreadcrumb from "../Components/CutomBreadcrumb"; import CustomBreadcrumb from "../Components/CutomBreadcrumb"; import { getCountdownTimer } from "../Constants/Constants"; import { useLogoutMutation } from "../Services/token.serivce"; - - +import CreateRequest from "../Pages/Fawateer/CreateRequest"; +import ApproveRequest from "../Pages/FawateerChecker/ApproveRequest/ApproveRequest"; +import ApproveHistoryMaker from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryMaker"; +import ApproveHistory from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryChecker"; const DashboardLayout = ({ isOnline }) => { const navigate = useNavigate(); @@ -96,14 +98,14 @@ const DashboardLayout = ({ isOnline }) => { const [openIndex, setOpenIndex] = useState(null); useEffect(() => { - if(!localStorage.getItem('accessToken') && !localStorage.getItem('refreshToken')){ - logOutHandler() - return navigate('/login') + if ( + !localStorage.getItem("accessToken") && + !localStorage.getItem("refreshToken") + ) { + logOutHandler(); + return navigate("/login"); } - - - }, []) - + }, []); useEffect(() => { const savedIndex = localStorage.getItem("openAccordionIndex"); @@ -122,7 +124,7 @@ const DashboardLayout = ({ isOnline }) => { // Set a timer to hide the splash screen after 3 seconds const timer = setTimeout(() => { setSplashVisible(false); - },1000); // 3000ms = 3 seconds + }, 1000); // 3000ms = 3 seconds // Cleanup the timer return () => clearTimeout(timer); @@ -132,20 +134,17 @@ const DashboardLayout = ({ isOnline }) => { setOpenDrawerClick(!openDrawerClick); }; - const [ logout ] = useLogoutMutation() - + const [logout] = useLogoutMutation(); const logOutHandler = async () => { // dispach(loginUser(false)); setIsAuthenticate(false); Cookies.remove("isAuthenticated"); try { - await logout() + await logout(); localStorage.clear(); navigate("/login"); - } catch (error) { - - } + } catch (error) {} }; // // Function to get the title based on the route @@ -209,9 +208,6 @@ const DashboardLayout = ({ isOnline }) => { ); - - - case path.startsWith("/deposit-request"): return ( @@ -227,11 +223,6 @@ const DashboardLayout = ({ isOnline }) => { ); - - - - - case path.startsWith("/withdraw-request"): return ( @@ -458,7 +449,7 @@ const DashboardLayout = ({ isOnline }) => { }} src={colorMode === "light" ? logo : logoDark} alt="Logo" - onClick={()=> navigate('/')} + onClick={() => navigate("/")} cursor={"pointer"} /> ) : ( @@ -468,7 +459,7 @@ const DashboardLayout = ({ isOnline }) => { }} src={colorMode === "light" ? logoMini : logoMiniDark} alt="Logo" - onClick={()=> navigate('/')} + onClick={() => navigate("/")} cursor={"pointer"} /> )} @@ -494,42 +485,52 @@ const DashboardLayout = ({ isOnline }) => { if (type === "accordion") { return ( - - - - {/* {Icon && title === "Admin" ? : } */} - {Icon && ( - - )} - - - {title} - - - - + {/* {Icon && title === "Admin" ? : } */} + {Icon && ( + + )} + + + {title} + + + + { { title: subMenuTitle, path: link, icon: SubIcon }, i ) => ( - - - - - - {SubIcon && ( - - )} - + + + - {subMenuTitle} - - - + {SubIcon && ( + + )} + + {subMenuTitle} + + + ) )} @@ -621,30 +632,36 @@ const DashboardLayout = ({ isOnline }) => { ); } else if (type === "single") { return ( - - - - {Icon && } - - {title} - - + {Icon && } + + {title} + + ); } else { @@ -676,16 +693,16 @@ const DashboardLayout = ({ isOnline }) => { )} {/* {getCountdownTimer(localStorage.getItem('accessTokenExp'))} */} - )}
{/*
@@ -698,244 +715,11 @@ const DashboardLayout = ({ isOnline }) => { icon title={getTitle()} /> - - {/* */} + + {/* */}
- - {/* =======[ Left ]============ */} - - {/* {slideFromRight ? ( - - ) : null} */} ); }; @@ -943,11 +727,37 @@ const DashboardLayout = ({ isOnline }) => { export default DashboardLayout; const AppContent = () => { + const userRole = localStorage.getItem("role"); return ( {RouteLink.map(({ path, Component }, index) => ( } /> ))} + + + ) : userRole === "Checker" ? ( + + ) : ( + + ) + } + /> + + ) : userRole === "Checker" ? ( + + ) : ( + + ) + } + /> } /> ); diff --git a/src/Pages/Fawateer/CreateRequest.jsx b/src/Pages/Fawateer/CreateRequest.jsx index 99f8e51..43a4c29 100644 --- a/src/Pages/Fawateer/CreateRequest.jsx +++ b/src/Pages/Fawateer/CreateRequest.jsx @@ -21,8 +21,17 @@ import { useNavigate } from "react-router-dom"; const validationSchema = Yup.object().shape({ investorName: Yup.string().required("Investor name is required"), clientId: Yup.string().required("Client ID is required"), - transaction_date: Yup.date().required("Date is required").max(new Date(), "Date cannot be in the future"), - transaction_amount: Yup.number().required("Amount is required").positive("Amount must be positive"), + transaction_date: Yup.date() + .required('Date is required') + .transform((value, originalValue) => { + return originalValue === "" ? null : value; // Convert empty strings to null + }) + .typeError('Please enter a valid date').max(new Date(), "Date cannot be in the future"), + transaction_amount: Yup.number() + .required("Transaction amount is required") + .transform((value, originalValue) => originalValue === "" ? null : value) // Convert empty strings to null + .typeError('Transaction amount must be a number') // Custom error message if it's not a number + .positive('Transaction amount must be greater than zero'), spportFile_path: Yup.mixed().required("Support file is required"), makerComment: Yup.string().required("Description is required"), }); @@ -52,10 +61,15 @@ const CreateRequest = () => { // Convert data to FormData const formData = new FormData(); - // Append each field from the data object to the FormData - Object.keys(data).forEach((key) => { - formData.append(key, data[key]); // Append other fields - }); + // Append each field from the data object to the FormData + Object.keys(data).forEach((key) => { + if (key === "spportFile_path" && data[key] instanceof FileList) { + // Append the first file from FileList (assuming single file input) + formData.append(key, fileType); // This extracts the first file + } else { + formData.append(key, data[key]); // Append other fields + } + }); try { // Make the API call with formData @@ -137,7 +151,7 @@ const CreateRequest = () => { onSubmit={handleSubmit(onSubmit)} > {/* Investor Name Field */} - + Investor name @@ -162,7 +176,7 @@ const CreateRequest = () => { {/* Client ID Field */} - + Client Id @@ -181,7 +195,7 @@ const CreateRequest = () => { {/* Date Field */} - + Date @@ -199,7 +213,7 @@ const CreateRequest = () => { {/* Amount Field */} - + Amount @@ -217,7 +231,7 @@ const CreateRequest = () => { {/* Support File Field with Preview */} - + Support file @@ -258,7 +272,7 @@ const CreateRequest = () => { {/* Description Field */} - + Description diff --git a/src/Pages/Fawateer/SelectInvestorModal.jsx b/src/Pages/Fawateer/SelectInvestorModal.jsx index f5e805f..7d1384c 100644 --- a/src/Pages/Fawateer/SelectInvestorModal.jsx +++ b/src/Pages/Fawateer/SelectInvestorModal.jsx @@ -215,7 +215,7 @@ console.log(investor); - + />} diff --git a/src/Pages/FawateerChecker/ApproveRequest/ApproveRequest.jsx b/src/Pages/FawateerChecker/ApproveRequest/ApproveRequest.jsx index 39f8897..5f3e37a 100644 --- a/src/Pages/FawateerChecker/ApproveRequest/ApproveRequest.jsx +++ b/src/Pages/FawateerChecker/ApproveRequest/ApproveRequest.jsx @@ -136,8 +136,8 @@ import RequestRejectModal from "./RequestRejectModal"; "Phone Number", "Transaction Date", "Transaction Amount", - "Status", - role === "Checker"&&"Action", + // "Status", + "Action", ]; diff --git a/src/Routes/Nav.js b/src/Routes/Nav.js index 1c57363..5345fec 100644 --- a/src/Routes/Nav.js +++ b/src/Routes/Nav.js @@ -119,7 +119,8 @@ export const nav = [ ], type: "accordion", Icon: HiOutlineBanknotes, - }, + } +, { title: "Bank Deposit", diff --git a/src/Routes/Routes.js b/src/Routes/Routes.js index 805cd1a..dd94426 100644 --- a/src/Routes/Routes.js +++ b/src/Routes/Routes.js @@ -119,9 +119,9 @@ export const RouteLink = [ - // ===============[ fawateer ]=============== - { path: "/fawateer", Component: localStorage.getItem("role") === "Maker"? CreateRequest:ApproveRequest }, - { path: "/fawateer-history", Component: localStorage.getItem("role") === "Maker"?ApproveHistoryMaker: ApproveHistory }, + // // ===============[ fawateer ]=============== + // { path: "/fawateer", Component: localStorage.getItem("role") === "Maker"? CreateRequest:ApproveRequest }, + // { path: "/fawateer-history", Component: localStorage.getItem("role") === "Maker"?ApproveHistoryMaker: ApproveHistory }, // { path: "/fawateer-approver", Component: ApproveRequest },