This commit is contained in:
YasinShaikh123
2024-10-11 16:01:53 +05:30
6 changed files with 217 additions and 392 deletions

View File

@@ -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 }) => {
</span>
);
case path.startsWith("/deposit-request"):
return (
<span className="d-flex align-items-end gap-2">
@@ -227,11 +223,6 @@ const DashboardLayout = ({ isOnline }) => {
</span>
);
case path.startsWith("/withdraw-request"):
return (
<span className="d-flex align-items-end gap-2">
@@ -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 (
<AccordionItem key={index} border={"none"}>
<Tooltip isDisabled={isDrawerOpen || openDrawerClick} hasArrow bg={"#fff"} fontSize={"xs"} label={title} placement="top-start" color={"blue.800"} >
<AccordionButton
style={{ height: "auto" }}
className={`${
isDrawerOpen || openDrawerClick
? "p-2 web-text-medium ps-3 justify-content-between"
: "p-2 ps-1 web-text-xlarge justify-content-center"
} rounded-1 link d-flex align-items-center gap-2 w-100 mb-1`}
<Tooltip
isDisabled={isDrawerOpen || openDrawerClick}
hasArrow
bg={"#fff"}
fontSize={"xs"}
label={title}
placement="top-start"
color={"blue.800"}
>
<Box
as="span"
display={"flex"}
gap={2}
alignItems={"center"}
<AccordionButton
style={{ height: "auto" }}
className={`${
isDrawerOpen || openDrawerClick
? "p-2 web-text-medium ps-3 justify-content-between"
: "p-2 ps-1 web-text-xlarge justify-content-center"
} rounded-1 link d-flex align-items-center gap-2 w-100 mb-1`}
>
{/* {Icon && title === "Admin" ? <Image w={15} src={shield} /> : <Icon className={`web-text-large`} />} */}
{Icon && (
<Icon
fontSize={title === "Admin" ? "18px" : "15px"}
/>
)}
<Text
as={"span"}
display={
isDrawerOpen || openDrawerClick ? "flex" : "none"
}
alignItems="center"
overflow="hidden"
textAlign={"left"}
<Box
as="span"
display={"flex"}
gap={2}
alignItems={"center"}
>
{title}
</Text>
</Box>
<AccordionIcon />
</AccordionButton>
{/* {Icon && title === "Admin" ? <Image w={15} src={shield} /> : <Icon className={`web-text-large`} />} */}
{Icon && (
<Icon
fontSize={title === "Admin" ? "18px" : "15px"}
/>
)}
<Text
as={"span"}
display={
isDrawerOpen || openDrawerClick
? "flex"
: "none"
}
alignItems="center"
overflow="hidden"
textAlign={"left"}
>
{title}
</Text>
</Box>
<AccordionIcon />
</AccordionButton>
</Tooltip>
<AccordionPanel
p={0}
@@ -543,66 +544,76 @@ const DashboardLayout = ({ isOnline }) => {
{ title: subMenuTitle, path: link, icon: SubIcon },
i
) => (
<Tooltip isDisabled={isDrawerOpen || openDrawerClick} hasArrow bg={"#fff"} fontSize={"xs"} label={subMenuTitle} placement="right" color={"blue.800"} >
<Box
key={i}
style={{ height: "auto", position: "relative" }}
className={`${
isDrawerOpen || openDrawerClick
? " web-text-medium ps-4"
: " web-text-xlarge justify-content-center"
} d-flex align-items-center p-0`}
<Tooltip
isDisabled={isDrawerOpen || openDrawerClick}
hasArrow
bg={"#fff"}
fontSize={"xs"}
label={subMenuTitle}
placement="right"
color={"blue.800"}
>
<Box
backgroundColor={"gray.300"}
style={{
position: "absolute",
top: 0,
width: 2,
left: 22,
height:
i === submenu?.length - 1 ? "55%" : "120%",
borderRadius: "0 0 10px 10px",
}}
/>
<Box
backgroundColor={"gray.300"}
style={{
position: "absolute",
width: 10,
left: 22,
height: 2,
}}
/>
<NavLink
key={i}
style={{ height: "auto", position: "relative" }}
className={`${
isDrawerOpen || openDrawerClick
? "p-2 ps-1 ms-2 web-text-medium "
: "p-2 ps-0 ms-0 zindex-3 ms-4 web-text-xlarge justify-content-center"
} rounded-1 link d-flex align-items-center gap-2 w-100 `}
to={link}
? " web-text-medium ps-4"
: " web-text-xlarge justify-content-center"
} d-flex align-items-center p-0`}
>
{SubIcon && (
<SubIcon
className="web-text-large ms-2"
style={{ zIndex: 111 }}
/>
)}
<Text
as={"span"}
display={
<Box
backgroundColor={"gray.300"}
style={{
position: "absolute",
top: 0,
width: 2,
left: 22,
height:
i === submenu?.length - 1
? "55%"
: "120%",
borderRadius: "0 0 10px 10px",
}}
/>
<Box
backgroundColor={"gray.300"}
style={{
position: "absolute",
width: 10,
left: 22,
height: 2,
}}
/>
<NavLink
className={`${
isDrawerOpen || openDrawerClick
? "flex"
: "none"
}
alignItems="center"
overflow="hidden"
? "p-2 ps-1 ms-2 web-text-medium "
: "p-2 ps-0 ms-0 zindex-3 ms-4 web-text-xlarge justify-content-center"
} rounded-1 link d-flex align-items-center gap-2 w-100 `}
to={link}
>
{subMenuTitle}
</Text>
</NavLink>
</Box>
{SubIcon && (
<SubIcon
className="web-text-large ms-2"
style={{ zIndex: 111 }}
/>
)}
<Text
as={"span"}
display={
isDrawerOpen || openDrawerClick
? "flex"
: "none"
}
alignItems="center"
overflow="hidden"
>
{subMenuTitle}
</Text>
</NavLink>
</Box>
</Tooltip>
)
)}
@@ -621,30 +632,36 @@ const DashboardLayout = ({ isOnline }) => {
);
} else if (type === "single") {
return (
<Tooltip hasArrow bg={"#fff"} fontSize={"xs"} label={title} placement="top-start" color={"blue.800"} >
<NavLink
key={index}
style={{ height: "auto", position: "relative" }}
className={`${
isDrawerOpen || openDrawerClick
? "p-2 web-text-medium"
: "p-2 ps-0 web-text-xlarge justify-content-start"
} rounded-1 link d-flex align-items-center gap-2 w-100`}
to={path}
<Tooltip
hasArrow
bg={"#fff"}
fontSize={"xs"}
label={title}
placement="top-start"
color={"blue.800"}
>
{Icon && <Icon className="web-text-large ms-2" />}
<Text
as={"span"}
display={
isDrawerOpen || openDrawerClick ? "flex" : "none"
}
alignItems="center"
overflow="hidden"
<NavLink
key={index}
style={{ height: "auto", position: "relative" }}
className={`${
isDrawerOpen || openDrawerClick
? "p-2 web-text-medium"
: "p-2 ps-0 web-text-xlarge justify-content-start"
} rounded-1 link d-flex align-items-center gap-2 w-100`}
to={path}
>
{title}
</Text>
</NavLink>
{Icon && <Icon className="web-text-large ms-2" />}
<Text
as={"span"}
display={
isDrawerOpen || openDrawerClick ? "flex" : "none"
}
alignItems="center"
overflow="hidden"
>
{title}
</Text>
</NavLink>
</Tooltip>
);
} else {
@@ -676,16 +693,16 @@ const DashboardLayout = ({ isOnline }) => {
)}
</Button>
{/* <Text textAlign={'center'} fontWeight={500} fontSize={'xs'} color={"gray.600"}>{getCountdownTimer(localStorage.getItem('accessTokenExp'))}</Text> */}
</aside>
)}
<main
className={`h-100 ${slideFromRight ? "pe-3" : "ps-3"} d-flex flex-column gap-0`}
className={`h-100 ${
slideFromRight ? "pe-3" : "ps-3"
} d-flex flex-column gap-0`}
style={{
width: `calc(100% - ${isDrawerOpen || openDrawerClick ? 230 : 74}px)`,
transition: "width 0.3s ease-in-out",
}}
>
{/* <header className="p-2 ps-0 pt-3 fw-400 border-bottom">
@@ -698,244 +715,11 @@ const DashboardLayout = ({ isOnline }) => {
icon
title={getTitle()}
/>
{/* <CustomBreadcrumb /> */}
{/* <CustomBreadcrumb /> */}
<AppContent />
</main>
{/* =======[ Left ]============ */}
{/* {slideFromRight ? (
<aside
className="h-100 position-relative sideBar pe-1 bg-black"
// onMouseOver={() => setIsDrawerOpen(true)}
// onMouseLeave={() => setIsDrawerOpen(false)}
style={{
width: isDrawerOpen || openDrawerClick ? 232 : 74,
transition: "width 0.3s ease-in-out", // Smooth transition for width change
// overflow: "hidden",
backgroundColor: "#0041180A",
position: "relative",
// backgroundColor: "#002F0F",
}}
>
<div
className={`d-flex ${
isDrawerOpen || openDrawerClick
? "justify-content-end"
: "justify-content-center"
} p-3 pt-3 pb-4 position-relative `}
height={"10%"}
>
{isDrawerOpen || openDrawerClick ? (
<img
style={{
width: 120,
}}
src={logo}
alt="Logo"
/>
) : (
<img
style={{
width: 30,
}}
src={logoMini}
alt="Logo"
/>
)}
</div>
<Box
className="ps-2 scroll-bar"
style={{ height: "80%", overflowY: "scroll", overflowX: "hidden" }}
>
<Accordion m={0} allowToggle>
{nav.map(({ title, type, Icon, submenu, path }, index) => {
if (type === "accordion") {
return (
<AccordionItem key={index} border={"none"}>
<AccordionButton
style={{ height: "auto" }}
className={`${
isDrawerOpen || openDrawerClick
? "p-2 web-text-medium ps-3 justify-content-between"
: "p-2 ps-1 web-text-xlarge justify-content-center"
} rounded-1 link d-flex align-items-center gap-2 w-100 mb-1`}
flexDirection={"row-reverse"}
>
<Box
as="span"
display={"flex"}
gap={2}
alignItems={"center"}
flexDirection={"row-reverse"}
>
{Icon && <Icon className="web-text-large" />}
<Text
as={"span"}
display={
isDrawerOpen || openDrawerClick ? "flex" : "none"
}
alignItems="center"
overflow="hidden"
>
{title}
</Text>
</Box>
<AccordionIcon />
</AccordionButton>
<AccordionPanel
p={0}
pb={1}
display={"flex"}
flexDirection={"column"}
gap={1}
>
{submenu?.map(
(
{ title: subMenuTitle, path: link, icon: SubIcon },
i
) => (
<Box
key={i}
style={{ height: "auto", position: "relative" }}
className={`${
isDrawerOpen || openDrawerClick
? " web-text-medium ps-0 pe-4"
: " web-text-xlarge justify-content-center"
} d-flex align-items-center p-0`}
>
<Box
backgroundColor={"gray.300"}
style={{
position: "absolute",
top: 0,
width: 2,
right: 20,
height:
i === submenu?.length - 1 ? "55%" : "120%",
borderRadius: "0 0 10px 10px",
}}
/>
<Box
backgroundColor={"gray.300"}
style={{
position: "absolute",
width: 8,
right: 20,
height: 2,
}}
/>
<NavLink
flexDirection={"row-reverse"}
className={`${
isDrawerOpen || openDrawerClick
? "p-2 ps-1 me-1 web-text-medium "
: "p-2 ps-0 ms-0 zindex-3 ms-4 web-text-xlarge justify-content-center"
} rounded-1 link d-flex align-items-center gap-2 w-100 flex-direction-row-reverse`}
to={link}
style={{ flexDirection: "row-reverse" }}
>
{SubIcon && (
<SubIcon
className="web-text-large ms-0"
style={{ zIndex: 111 }}
/>
)}
<Text
as={"span"}
display={
isDrawerOpen || openDrawerClick
? "flex"
: "none"
}
alignItems="center"
overflow="hidden"
>
{subMenuTitle}
</Text>
</NavLink>
</Box>
)
)}
</AccordionPanel>
</AccordionItem>
);
} else if (type === "title") {
return (
<Text
as={"span"}
key={index}
className="web-text-xxsmall fw-600 mt-1 text-secondary fw-bold me-2"
padding={0}
display={"flex"}
justifyContent={"end"}
>
{title}
</Text>
);
} else if (type === "single") {
return (
<NavLink
key={index}
style={{
height: "auto",
position: "relative",
flexDirection: "row-reverse",
}}
className={`${
isDrawerOpen || openDrawerClick
? "p-2 web-text-medium"
: "p-2 ps-0 web-text-xlarge justify-content-start"
} rounded-1 link d-flex align-items-center gap-2 w-100`}
to={path}
>
{Icon && <Icon className="web-text-large ms-2" />}
<Text
as={"span"}
display={
isDrawerOpen || openDrawerClick ? "flex" : "none"
}
alignItems="center"
overflow="hidden"
>
{title}
</Text>
</NavLink>
);
} else {
return null;
}
})}
</Accordion>
</Box>
<Button
colorScheme={"forestGreen"}
rounded={"lg"}
// onMouseOver={() => setIsDrawerOpen(true)}
// onMouseLeave={() => setIsDrawerOpen(false)}
onClick={openDrawerOnClick}
style={{
width: 18,
height: 26,
position: "absolute",
left: -18,
bottom: 28,
zIndex: 99,
}}
>
{isDrawerOpen || openDrawerClick ? (
<ArrowRightIcon className="web-text-small " />
) : (
<ArrowLeftIcon className="web-text-small" />
)}
</Button>
</aside>
) : null} */}
</Box>
);
};
@@ -943,11 +727,37 @@ const DashboardLayout = ({ isOnline }) => {
export default DashboardLayout;
const AppContent = () => {
const userRole = localStorage.getItem("role");
return (
<Routes>
{RouteLink.map(({ path, Component }, index) => (
<Route key={index} path={path} element={<Component />} />
))}
<Route
path="/fawateer"
element={
userRole === "Maker" ? (
<CreateRequest />
) : userRole === "Checker" ? (
<ApproveRequest />
) : (
<NotFound />
)
}
/>
<Route
path="/fawateer-history"
element={
userRole === "Maker" ? (
<ApproveHistoryMaker />
) : userRole === "Checker" ? (
<ApproveHistory />
) : (
<NotFound />
)
}
/>
<Route path="*" element={<NotFound />} />
</Routes>
);

View File

@@ -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 */}
<FormControl w={"49%"} mb={2} isInvalid={errors.investorName}>
<FormControl isRequired w={"49%"} mb={2} isInvalid={errors.investorName}>
<FormLabel textAlign={"left"} fontSize={"xs"} color={"gray.600"}>
Investor name
</FormLabel>
@@ -162,7 +176,7 @@ const CreateRequest = () => {
</FormControl>
{/* Client ID Field */}
<FormControl w={"49%"} mb={2} isInvalid={errors.clientId}>
<FormControl isRequired w={"49%"} mb={2} isInvalid={errors.clientId}>
<FormLabel textAlign={"left"} fontSize={"xs"} color={"gray.600"}>
Client Id
</FormLabel>
@@ -181,7 +195,7 @@ const CreateRequest = () => {
</FormControl>
{/* Date Field */}
<FormControl w={"49%"} mb={2} isInvalid={errors.date}>
<FormControl isRequired w={"49%"} mb={2} isInvalid={errors.date}>
<FormLabel textAlign={"left"} fontSize={"xs"} color={"gray.600"}>
Date
</FormLabel>
@@ -199,7 +213,7 @@ const CreateRequest = () => {
</FormControl>
{/* Amount Field */}
<FormControl w={"49%"} mb={2} isInvalid={errors.amount}>
<FormControl isRequired w={"49%"} mb={2} isInvalid={errors.amount}>
<FormLabel textAlign={"left"} fontSize={"xs"} color={"gray.600"}>
Amount
</FormLabel>
@@ -217,7 +231,7 @@ const CreateRequest = () => {
</FormControl>
{/* Support File Field with Preview */}
<FormControl w={"49%"} mb={2} isInvalid={errors.spportFile_path}>
<FormControl w={"49%"} mb={2} isInvalid={errors.spportFile_path}>
<FormLabel textAlign={"left"} fontSize={"xs"} color={"gray.600"}>
Support file
</FormLabel>
@@ -258,7 +272,7 @@ const CreateRequest = () => {
</FormControl>
{/* Description Field */}
<FormControl w={"100%"} mb={2} isInvalid={errors.makerComment}>
<FormControl isRequired w={"100%"} mb={2} isInvalid={errors.makerComment}>
<FormLabel textAlign={"left"} fontSize={"xs"} color={"gray.600"}>
Description
</FormLabel>

View File

@@ -215,7 +215,7 @@ console.log(investor);
</HStack>
<NormalTable
{investorDetailsLoading?"Loaading":<NormalTable
// centered={true}
emptyMessage={`We don't have any Sponers `}
tableHeadRow={tableHeadRow}
@@ -229,7 +229,7 @@ console.log(investor);
selectedRadio={selectedRadio}
showRadioButton={true}
radio={true}
/>
/>}
</ModalBody>
</ModalContent>

View File

@@ -136,8 +136,8 @@ import RequestRejectModal from "./RequestRejectModal";
"Phone Number",
"Transaction Date",
"Transaction Amount",
"Status",
role === "Checker"&&"Action",
// "Status",
"Action",
];

View File

@@ -119,7 +119,8 @@ export const nav = [
],
type: "accordion",
Icon: HiOutlineBanknotes,
},
}
,
{
title: "Bank Deposit",

View File

@@ -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 },