Compare commits
118 Commits
Sprint7.1.
...
Sprint-10.
| Author | SHA1 | Date | |
|---|---|---|---|
| 35d3e07224 | |||
|
|
651c775c2a | ||
|
|
18035047d4 | ||
|
|
a51585089c | ||
|
|
ebcb06bf5e | ||
|
|
84dc47b447 | ||
|
|
a07d011c85 | ||
|
|
0ed01bf94f | ||
|
|
45f69fe2b7 | ||
|
|
974d1501b2 | ||
|
|
c33e358e8e | ||
|
|
1434088c1b | ||
|
|
3c6f083432 | ||
|
|
f81b210b0a | ||
|
|
5743cadf5e | ||
|
|
4579573f23 | ||
|
|
625f721325 | ||
|
|
01aece9bf6 | ||
|
|
d9692c3890 | ||
|
|
6e42bc0adb | ||
|
|
c9e5223989 | ||
|
|
69f76bbdce | ||
|
|
25df0d6160 | ||
|
|
51727d4de1 | ||
|
|
1539493641 | ||
|
|
d63ac2eb2b | ||
|
|
9eca3ae9fc | ||
| 6c2a38becb | |||
|
|
212f5d4d37 | ||
|
|
b620cd410d | ||
|
|
84298ff453 | ||
| bddf7381a6 | |||
|
|
8eae4222f4 | ||
| 52a987b616 | |||
|
|
2a3c211b56 | ||
| 4d6a8bb472 | |||
|
|
41a60c0892 | ||
|
|
5c05a68bb0 | ||
| f02f9c8b7d | |||
|
|
137912aa11 | ||
| e3fe5a1618 | |||
|
|
edcb4cd7b9 | ||
| c72f3ece4e | |||
|
|
85be7c891e | ||
|
|
e41d6b17b9 | ||
| 3217605a0f | |||
| b4d28387fa | |||
|
|
5411d4cd18 | ||
|
|
6a0aa17e2d | ||
|
|
471e4f32ab | ||
|
|
5d2c28f6ca | ||
|
|
49f39e1c2c | ||
|
|
f9c7bf9d5d | ||
|
|
49beb9539a | ||
|
|
ed27ed6939 | ||
|
|
d84b3a0e35 | ||
|
|
20c0c7840f | ||
|
|
bbfd617b27 | ||
|
|
87e0716383 | ||
|
|
c7d6a0fe36 | ||
|
|
c83aaa411a | ||
|
|
a2fe1435cb | ||
| 6a9e0f9908 | |||
|
|
9c0b231e62 | ||
|
|
4ca28fd910 | ||
|
|
fed5125660 | ||
|
|
8a297d02ef | ||
|
|
2c8965c16a | ||
| 9d4d5301e5 | |||
| 88dc9d14fe | |||
|
|
d567acfec8 | ||
|
|
463325e603 | ||
| 84f869d9bd | |||
| 606ac68d85 | |||
|
|
537304f0fb | ||
|
|
3b83b625c3 | ||
|
|
694dde0f14 | ||
|
|
4f8916036e | ||
|
|
0c21e99732 | ||
|
|
5900f637be | ||
|
|
2453b24d91 | ||
|
|
3db9488444 | ||
| bb30a71a60 | |||
|
|
526d2aecca | ||
| e742f6c18d | |||
|
|
d4c9a5521f | ||
| 7a04ee0abb | |||
|
|
a12b2c9a2c | ||
| 0b2e48200a | |||
|
|
bf7b3e1596 | ||
| 059b711bc1 | |||
| b0c01f3a0c | |||
| 272e94caf0 | |||
| cd95aa35a7 | |||
| 973ec656d0 | |||
|
|
29a49150b7 | ||
| 7a908a3284 | |||
|
|
23c3997d06 | ||
| 6779fdd672 | |||
|
|
0ab898a3da | ||
|
|
f3a8a80f4d | ||
| d1cbeee294 | |||
|
|
1c4f975781 | ||
| 17ffb864a3 | |||
|
|
6ffcff58a2 | ||
| 82612fa7f2 | |||
|
|
470ba49c00 | ||
| b29478a939 | |||
|
|
7ba524d2e4 | ||
| cc58cdc9b7 | |||
|
|
9f54bfbc65 | ||
| 992cb13e1e | |||
|
|
85e3c34120 | ||
| 46672a34e2 | |||
|
|
61e49393fe | ||
|
|
5fc16b58ea | ||
| 95c629533e | |||
|
|
06548abf1e |
28
.env.example
Normal file
28
.env.example
Normal file
@@ -0,0 +1,28 @@
|
||||
# Default Value Maker
|
||||
VITE_MAKER="Maker"
|
||||
|
||||
# Default Value Checker
|
||||
VITE_CHECKER="Checker"
|
||||
|
||||
# Role Encryption key
|
||||
VITE_ROLE_ENCRYPTION_KEY="export"
|
||||
|
||||
# Super Admin
|
||||
VITE_SUPER_ADMIN_ID=1
|
||||
|
||||
# BaseURL
|
||||
VITE_BAS_URL="your_base_url"
|
||||
|
||||
# BaseURL for Images
|
||||
VITE_IMAGE_URL="your_base_url"
|
||||
|
||||
# Max try re-genrate token
|
||||
VITE_MAX_TRY_REGENRATE_TOKEN=3
|
||||
|
||||
VITE_STATUS_DRAFT="Draft"
|
||||
VITE_STATUS_PROCESSING="Processing"
|
||||
VITE_STATUS_OPEN="Open"
|
||||
VITE_STATUS_CLOSED="Closed"
|
||||
VITE_STATUS_EXITED="Exited"
|
||||
VITE_STATUS_CANCELLED="Cancelled"
|
||||
VITE_STATUS_DEACTIVATE="DeActivate"
|
||||
117
README.md
117
README.md
@@ -1,10 +1,113 @@
|
||||
# React + Vite
|
||||
# **Tanami Capital**
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
**Tanami** is a cutting-edge fintech platform designed to streamline investment opportunities for users in the Gulf region. It features two main components:
|
||||
|
||||
Currently, two official plugins are available:
|
||||
- **Admin Panel:** A web-based dashboard for managing users, monitoring transactions, and overseeing investments efficiently.
|
||||
- **Mobile Application:** A user-friendly app that empowers individuals to invest in diverse asset classes, including real estate, private equity, and other financial instruments located in Gulf countries.
|
||||
|
||||
---
|
||||
|
||||
## **Key Features**
|
||||
- **Regional Focus:** Exclusively operational in Gulf countries, offering investment opportunities tailored to the region.
|
||||
- **Diverse Investment Options:** Enables users to invest in financial instruments like real estate and private equity with ease and transparency.
|
||||
- **Comprehensive Admin Tools:** The admin panel offers robust tools for tracking and managing platform activity.
|
||||
|
||||
---
|
||||
|
||||
## **Current Status**
|
||||
The project is **live and operational**, catering specifically to the investment needs of users in the Gulf region.
|
||||
|
||||
---
|
||||
|
||||
## **Table of Contents**
|
||||
- [Installation](#installation)
|
||||
- [Usage](#usage)
|
||||
- [Environment Variables](#environment-variables)
|
||||
- [Scripts](#scripts)
|
||||
- [License](#license)
|
||||
|
||||
---
|
||||
|
||||
## **Installation**
|
||||
|
||||
### **Prerequisites**
|
||||
- [Node.js](https://nodejs.org/) (version 14 or higher recommended)
|
||||
- [npm](https://www.npmjs.com/) (bundled with Node.js)
|
||||
|
||||
### **Steps**
|
||||
1. Clone the repository:
|
||||
```bash
|
||||
git clone http://git.wdipl.com/Siddhesh.More/tanami-admin-panel.git
|
||||
```
|
||||
2. Navigate to the project directory:
|
||||
```bash
|
||||
cd tanami-admin-panel
|
||||
```
|
||||
3. Install dependencies:
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Usage**
|
||||
|
||||
### **Development Mode**
|
||||
1. Start the development server:
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
2. Open your browser and navigate to:
|
||||
```
|
||||
http://localhost:5173/
|
||||
```
|
||||
|
||||
### **Production Mode**
|
||||
1. Install [PM2](https://pm2.keymetrics.io/) globally for process management:
|
||||
```bash
|
||||
npm install pm2 -g
|
||||
```
|
||||
|
||||
2. Build the application (if applicable):
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
3. Serve the application using PM2:
|
||||
```bash
|
||||
pm2 serve ./dist <port_number> --spa --name=<application_name>
|
||||
```
|
||||
Replace:
|
||||
- `./dist` with your build directory.
|
||||
- `<port_number>` with the desired port (e.g., `3000`).
|
||||
- `<application_name>` with the name of your application.
|
||||
|
||||
4. Save the PM2 process list and enable startup on system reboot:
|
||||
```bash
|
||||
pm2 save
|
||||
pm2 startup
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Environment Variables**
|
||||
|
||||
Create a `.env` file in the root directory based on the structure of [`.env.example`](.env.example).
|
||||
|
||||
---
|
||||
|
||||
## **Scripts**
|
||||
|
||||
| Script | Description |
|
||||
|---------------------|-------------------------------------------------------------|
|
||||
| `npm run dev` | Starts the app in development mode with `Vite` server. |
|
||||
| `npm run build` | Builds the app for production. |
|
||||
| `npm run lint` | Runs ESLint to check for code quality issues. |
|
||||
| `npm run preview` | Previews the production build locally. |
|
||||
|
||||
---
|
||||
|
||||
## **License**
|
||||
|
||||
This project is licensed under the [MIT License](LICENSE).
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||
# rubix-admin-panel
|
||||
# tanami-admin-panel
|
||||
|
||||
@@ -63,8 +63,8 @@ const App = () => {
|
||||
path="/*"
|
||||
element={
|
||||
// isOnline ? (
|
||||
// isAuthenticate || isAuthenticatedInCookie === "true" ? (
|
||||
localStorage.getItem('accessToken') && localStorage.getItem('refreshToken') ? (
|
||||
isAuthenticate || isAuthenticatedInCookie === "true" ? (
|
||||
// localStorage.getItem('accessToken') && localStorage.getItem('refreshToken') ? (
|
||||
// true ? (
|
||||
<DefaultLayout isOnline={isOnline} />
|
||||
) : (
|
||||
|
||||
@@ -31,6 +31,7 @@ import Header from "../Header";
|
||||
import ToastBox from "../ToastBox";
|
||||
import BannerMainCard from "./BannerMainCard";
|
||||
|
||||
|
||||
const AddBanner = ({ createApi, navigateLink, title, center }) => {
|
||||
const toast = useToast();
|
||||
const navigate = useNavigate();
|
||||
|
||||
@@ -520,7 +520,7 @@ const FormField = ({
|
||||
ps={1}
|
||||
{...field}
|
||||
{...props} size='md' colorScheme='forestGreen'>
|
||||
<Text as={"span"} fontSize={"sm"}>Is This Sharia Compliant</Text>
|
||||
<Text as={"span"} fontSize={"sm"}>Is This Shariah Compliant</Text>
|
||||
</Checkbox>
|
||||
</HStack>
|
||||
);} else{
|
||||
|
||||
@@ -13,8 +13,9 @@ import {
|
||||
Portal,
|
||||
Text,
|
||||
useColorMode,
|
||||
useDisclosure,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext } from "react";
|
||||
import React, { useContext, useRef } from "react";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
import { IoMdDownload } from "react-icons/io";
|
||||
import * as XLSX from "xlsx";
|
||||
@@ -23,6 +24,7 @@ import GlobalStateContext from "../Contexts/GlobalStateContext";
|
||||
import { MdOutlineDarkMode, MdOutlineLightMode } from "react-icons/md";
|
||||
import logoMini from "../assets/propic.png";
|
||||
import { BsBack } from "react-icons/bs";
|
||||
import ChangePassword from "../Pages/ChangePassword";
|
||||
|
||||
const HeaderMain = ({
|
||||
link,
|
||||
@@ -35,6 +37,8 @@ const HeaderMain = ({
|
||||
}) => {
|
||||
const navigate = useNavigate();
|
||||
const { colorMode, toggleColorMode } = useContext(GlobalStateContext);
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const firstField = useRef();
|
||||
|
||||
return (
|
||||
<Box
|
||||
@@ -66,11 +70,11 @@ const HeaderMain = ({
|
||||
<PopoverBody onClick={()=> navigate('/profile')} className="web-text-medium pointer link">
|
||||
Profile
|
||||
</PopoverBody>
|
||||
<Link to={"/help-and-support"}>
|
||||
<Box onClick={onOpen}>
|
||||
<PopoverBody className="web-text-medium pointer ">
|
||||
Help & Support
|
||||
Change Password
|
||||
</PopoverBody>
|
||||
</Link>
|
||||
</Box>
|
||||
<PopoverFooter
|
||||
onClick={logOutHandler}
|
||||
className="web-text-medium pointer link"
|
||||
@@ -112,6 +116,11 @@ const HeaderMain = ({
|
||||
{/* <Box onClick={() => toggleColorMode()} as="span" p={2} rounded={'lg'} className="link pointer">
|
||||
{colorMode === "light"? <MdOutlineDarkMode /> :<MdOutlineLightMode />}
|
||||
</Box> */}
|
||||
<ChangePassword
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
firstField={firstField}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import { Box, Spinner, Text } from "@chakra-ui/react";
|
||||
import React from "react";
|
||||
import './FullscreenLoaders.css'
|
||||
import "./FullscreenLoaders.css";
|
||||
|
||||
const FullscreenLoaders = ({height}) => {
|
||||
const FullscreenLoaders = ({ height }) => {
|
||||
return (
|
||||
<Box
|
||||
display={"flex"}
|
||||
justifyContent={"center"}
|
||||
flexDirection={'column'}
|
||||
flexDirection={"column"}
|
||||
alignItems={"center"}
|
||||
w={"100%"}
|
||||
h={height ? height: "100vh"}
|
||||
h={height ? height : "100vh"}
|
||||
gap={4}
|
||||
><div className="dot-spinner">
|
||||
>
|
||||
{/* <div className="dot-spinner">
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
@@ -21,8 +22,17 @@ const FullscreenLoaders = ({height}) => {
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
</div>
|
||||
{/* <Text color='#004717' fontSize={'md'} fontWeight={500}>Loading...</Text> */}
|
||||
</div> */}
|
||||
{/* <Text color='#004717' fontSize={'md'} fontWeight={500}>Loading...</Text> */}
|
||||
{/* <div className="spinner-grow" style={{backgroundColor:"#004118"}} role="status" /> */}
|
||||
|
||||
<Spinner
|
||||
thickness="4px"
|
||||
speed="0.65s"
|
||||
emptyColor="#fff"
|
||||
color="#004118"
|
||||
size="lg"
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,19 +1,31 @@
|
||||
import React from "react";
|
||||
import './FullscreenLoaders.css'
|
||||
import { Spinner } from "@chakra-ui/react";
|
||||
|
||||
const Loader01 = () => {
|
||||
return (
|
||||
// <div className="dot-spinner">
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// </div>
|
||||
|
||||
<div className="dot-spinner">
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
</div>
|
||||
// <div className="dot-spinner">
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// <div className="dot-spinner__dot"></div>
|
||||
// </div>
|
||||
<Spinner color='green.900' />
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ChevronLeftIcon, ChevronRightIcon } from "@chakra-ui/icons";
|
||||
const Pagination = ({
|
||||
pageSize,
|
||||
setPageSize,
|
||||
totalItems,
|
||||
totalItems = 1,
|
||||
isLoading,
|
||||
setCurrentPage,
|
||||
currentPage,
|
||||
@@ -49,7 +49,7 @@ const Pagination = ({
|
||||
value={pageSize}
|
||||
onChange={handlePageSizeChange}
|
||||
>
|
||||
{[15, 20, 30]?.map((size) => (
|
||||
{[15, 20, 30, 500]?.map((size) => (
|
||||
<option key={size} value={size}>
|
||||
{size}
|
||||
</option>
|
||||
@@ -84,7 +84,7 @@ const Pagination = ({
|
||||
onClick={paginationNext}
|
||||
className="link pointer"
|
||||
isDisabled={currentPage === totalPages}
|
||||
aria-label="Next Page"
|
||||
aria-label="Next Page"
|
||||
/>
|
||||
</HStack>
|
||||
</HStack>
|
||||
|
||||
65
src/Components/RoleSwitchButton.jsx
Normal file
65
src/Components/RoleSwitchButton.jsx
Normal file
@@ -0,0 +1,65 @@
|
||||
import { Box, Text } from "@chakra-ui/react";
|
||||
import React from "react";
|
||||
|
||||
const RoleSwitchButton = ({ isSwitchOn, setIsSwitchOn }) => {
|
||||
|
||||
// const [isSwitchOn, setIsSwitchOn] = useState(false);
|
||||
|
||||
// const audio = useRef();
|
||||
|
||||
const switchOnChangeHandle = () => {
|
||||
setIsSwitchOn(!isSwitchOn);
|
||||
// if (audio.current) {
|
||||
// audio.current.play();
|
||||
// }
|
||||
};
|
||||
|
||||
return (
|
||||
<Box display="flex" alignItems="center">
|
||||
<Box
|
||||
as="button"
|
||||
display="flex"
|
||||
justifyContent="normal"
|
||||
alignItems="center"
|
||||
// justifyContent={isSwitchOn ? "flex-end" : "flex-start"}
|
||||
width="85px"
|
||||
height="24px"
|
||||
borderRadius="20px"
|
||||
backgroundColor={isSwitchOn ? "#00ffcc" : "#b3ff99"}
|
||||
onClick={switchOnChangeHandle}
|
||||
position="relative"
|
||||
fontSize="12px"
|
||||
fontWeight="100"
|
||||
transition="background-color 0.2s"
|
||||
_before={{
|
||||
content: '""',
|
||||
position: "absolute",
|
||||
width: "20px",
|
||||
height: "20px",
|
||||
borderRadius: "50%",
|
||||
backgroundColor: "#fff",
|
||||
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.2)",
|
||||
transform: isSwitchOn ? "translateX(61px)" : "translateX(0)",
|
||||
transition: "transform 0.2s",
|
||||
left:'2px',
|
||||
top:'2px'
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
fontWeight="500"
|
||||
zIndex={1}
|
||||
position="absolute"
|
||||
mb={0}
|
||||
color={isSwitchOn ? "#000" : "#000"}
|
||||
left={isSwitchOn ? "10px" : "auto"}
|
||||
right={isSwitchOn ? "auto" : "10px"}
|
||||
>
|
||||
{isSwitchOn ? "Maker" : "Checker"}
|
||||
</Text>
|
||||
</Box>
|
||||
{/* <audio ref={audio} src={audioClick} /> */}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default RoleSwitchButton;
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
import dns from "node:dns"
|
||||
import * as XLSX from 'xlsx';
|
||||
import CryptoJS from "crypto-js";
|
||||
|
||||
|
||||
export const generateSerialNumber = (index, currentPage, pageSize) => {
|
||||
export const generateSerialNumber = (index, currentPage = 1, pageSize = 1) => {
|
||||
return (currentPage - 1) * pageSize + (index + 1);
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ export function getTomorrowDate() {
|
||||
const today = new Date();
|
||||
const tomorrow = new Date(today);
|
||||
tomorrow.setDate(today.getDate() + 1);
|
||||
|
||||
|
||||
// Format the date as YYYY-MM-DD (ISO 8601)
|
||||
return tomorrow.toISOString().split('T')[0];
|
||||
}
|
||||
@@ -33,7 +33,7 @@ export function removeTrailingZeros(value) {
|
||||
}
|
||||
|
||||
|
||||
export function getCountdownTimer(utcDateString) {
|
||||
export function getCountdownTimer(utcDateString) {
|
||||
// Parse the UTC datetime string into a Date object
|
||||
const targetDate = new Date(utcDateString);
|
||||
const now = new Date();
|
||||
@@ -56,7 +56,7 @@ export function removeTrailingZeros(value) {
|
||||
const remainingMinutes = minutes % 60;
|
||||
const remainingSeconds = seconds % 60;
|
||||
|
||||
return `${remainingDays === 0 ? "": remainingDays+"d"} ${remainingHours === 0 ? "": remainingHours+"h"} ${remainingMinutes}m ${remainingSeconds}s `;
|
||||
return `${remainingDays === 0 ? "" : remainingDays + "d"} ${remainingHours === 0 ? "" : remainingHours + "h"} ${remainingMinutes}m ${remainingSeconds}s `;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,30 +94,33 @@ export function debounce(func, delay) {
|
||||
|
||||
|
||||
|
||||
async function resolveMx(domain, recordType) {
|
||||
async function resolveMx(domain) {
|
||||
return new Promise((resolve, reject) => {
|
||||
dns.resolveMx(domain, (err, mxRecords) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
const addresses = mxRecords.map((mxRecord) => mxRecord.exchange);
|
||||
resolve(addresses);
|
||||
});
|
||||
dns.resolveMx(domain, (err, mxRecords) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
const addresses = mxRecords.map((mxRecord) => mxRecord.exchange);
|
||||
resolve(addresses);
|
||||
});
|
||||
});
|
||||
}
|
||||
// Async function to check email address validity
|
||||
export async function checkEmailValidity(email) {
|
||||
try {
|
||||
const domain = email?.split("@")[1];
|
||||
const addresses = await resolveMx(domain, "MX");
|
||||
const domain = email?.split('@')[1];
|
||||
const addresses = await resolveMx(domain, 'MX');
|
||||
console.log(addresses);
|
||||
|
||||
if (addresses && addresses?.length > 0) {
|
||||
return true;
|
||||
}
|
||||
return false; // No MX record exists
|
||||
if (addresses && addresses?.length > 0) {
|
||||
return true;
|
||||
}
|
||||
return false; // No MX record exists
|
||||
} catch (err) {
|
||||
return false; // Error occurred
|
||||
console.log(err);
|
||||
|
||||
return false; // Error occurred
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,15 +128,15 @@ export async function checkEmailValidity(email) {
|
||||
// Function to convert timestamp to readable date format in Gulf timezone
|
||||
export function formatTimestampInGulfTimezone(timestamp) {
|
||||
const date = new Date(timestamp);
|
||||
const options = {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
timeZone: 'Asia/Dubai', // Gulf Standard Time (GST) timezone
|
||||
timeZoneName: 'short'
|
||||
const options = {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
timeZone: 'Asia/Dubai', // Gulf Standard Time (GST) timezone
|
||||
timeZoneName: 'short'
|
||||
};
|
||||
return date.toLocaleDateString('en-GB', options);
|
||||
}
|
||||
@@ -163,7 +166,7 @@ const getNestedValue = (obj, key) => {
|
||||
export const exportToExcel = (data, headers) => {
|
||||
const flattenedData = data.map((item) => {
|
||||
const newItem = {};
|
||||
|
||||
|
||||
// Loop through customHeaders and get the correct values
|
||||
headers.forEach((header) => {
|
||||
newItem[header.label] = getNestedValue(item, header.key); // Use the helper function
|
||||
@@ -174,7 +177,7 @@ export const exportToExcel = (data, headers) => {
|
||||
|
||||
// Now pass flattenedData to your Excel library to generate the file
|
||||
// Assuming you're using a library like `xlsx` for this part:
|
||||
|
||||
|
||||
const worksheet = XLSX.utils.json_to_sheet(flattenedData);
|
||||
const workbook = XLSX.utils.book_new();
|
||||
XLSX.utils.book_append_sheet(workbook, worksheet, "Sheet1");
|
||||
@@ -218,4 +221,25 @@ export function formatDateToYYYYMMDD(dateString) {
|
||||
|
||||
// Combine the formatted parts
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Encrypt a string
|
||||
export const encryptString = (text) => {
|
||||
const ciphertext = CryptoJS.AES.encrypt(text, import.meta.env.VITE_ROLE_ENCRYPTION_KEY).toString();
|
||||
return ciphertext;
|
||||
};
|
||||
|
||||
// Decrypt a string
|
||||
export const decryptString = (ciphertext) => {
|
||||
const bytes = CryptoJS.AES.decrypt(ciphertext, import.meta.env.VITE_ROLE_ENCRYPTION_KEY);
|
||||
const originalText = bytes.toString(CryptoJS.enc.Utf8);
|
||||
return originalText;
|
||||
};
|
||||
|
||||
export const SUPER_ADMIN_ID = Number(import.meta.env.VITE_SUPER_ADMIN_ID) || 1
|
||||
export const MAKER_ID = import.meta.env.VITE_MAKER_ID || 1
|
||||
export const CHECKER_ID = import.meta.env.VITE_CHECKER_ID || 2
|
||||
|
||||
export const isMaker = (role = decryptString(localStorage?.getItem("role"))) => role === import.meta.env.VITE_MAKER;
|
||||
export const isChecker = (role = decryptString(localStorage?.getItem("role"))) => role === import.meta.env.VITE_CHECKER;
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export const TABLE_PAGINATION = { page: 1, size:20 }
|
||||
export const IMAGE_URI = import.meta.env.VITE_API_IMAGE_URL
|
||||
export const TABLE_PAGINATION = { page: 1, size: 20 }
|
||||
export const IMAGE_URI = import.meta.env.VITE_API_IMAGE_URL
|
||||
export const INVESTOR_TABLE_PAGINATION = { page: 1, size: 500 }
|
||||
@@ -1557,6 +1557,123 @@ const GlobalStateProvider = ({ children }) => {
|
||||
},
|
||||
]);
|
||||
|
||||
const [approved, setApproved] = useState([
|
||||
{
|
||||
id: 1,
|
||||
transactionDate: "02-Jan-24",
|
||||
particulars: "Cash Reserve- Initated",
|
||||
amount: "50,000.00",
|
||||
Comments: "",
|
||||
user: "Faisal",
|
||||
entryDate: "02-Jan-24",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
transactionDate: "12-Feb-24",
|
||||
particulars: "Fees & Expense",
|
||||
amount: "-22,000.00",
|
||||
Comments: "",
|
||||
user: "Faisal",
|
||||
entryDate: "13-Feb-24",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
transactionDate: "12-Feb-24",
|
||||
particulars: "Distribution Received From Sponsor",
|
||||
amount: "50,000.00",
|
||||
Comments: "",
|
||||
user: "Nawab",
|
||||
entryDate: "24-Mar-24",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
transactionDate: "28-Mar-24",
|
||||
particulars: "Distribution Paid To Investors",
|
||||
amount: "-40,000.00",
|
||||
Comments: "",
|
||||
user: "Faisal",
|
||||
entryDate: "28-Mar-24",
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
transactionDate: "26-Jun-24",
|
||||
particulars: "Distribution Received From Sponsor",
|
||||
amount: "70,000.00",
|
||||
Comments: "",
|
||||
user: "Faisal",
|
||||
entryDate: "27-Jun-24",
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
transactionDate: "28-Jun-24",
|
||||
particulars: "Distribution Paid To Investors",
|
||||
amount: "-60,000.00",
|
||||
Comments: "",
|
||||
user: "Nawab",
|
||||
entryDate: "28-Jun-24",
|
||||
},
|
||||
]);
|
||||
|
||||
const [iONAVDetail, setIONAVDetail] = useState([
|
||||
{
|
||||
id: 1,
|
||||
valuationDate: "01-Jul-24",
|
||||
nav: "1,229,750.00 ",
|
||||
lastUpdate: "12.56",
|
||||
investmentClose: "29.45",
|
||||
updatedBy: "Nawab",
|
||||
updatedOn: "01-Jul-24",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
valuationDate: "25-Apr-24",
|
||||
nav: "1,092,500.00",
|
||||
lastUpdate: "15.00",
|
||||
investmentClose: "15.00",
|
||||
updatedBy: "Faisal",
|
||||
updatedOn: "25-Apr-24",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
valuationDate: "02-Jan-24",
|
||||
nav: "950,000.00",
|
||||
lastUpdate: "",
|
||||
investmentClose: "",
|
||||
updatedBy: "Faisal",
|
||||
updatedOn: "02-Jan-24",
|
||||
},
|
||||
]);
|
||||
|
||||
const [iOTransaction, setIOTransaction] = useState([
|
||||
{
|
||||
id: 1,
|
||||
transactionName: "Amount Invested",
|
||||
amount: "995,000",
|
||||
createdBy: "Faisal",
|
||||
createdOn: "27-Oct-24",
|
||||
approvedBy: "Nawab",
|
||||
approvedOn: "28-Oct-24",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
transactionName: "Distribution To Sponser",
|
||||
amount: "40,000",
|
||||
createdBy: "Faisal",
|
||||
createdOn: "30-Oct-24",
|
||||
approvedBy: "Nawab",
|
||||
approvedOn: "31-Oct-24",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
transactionName: "Amount Invested",
|
||||
amount: "995,000",
|
||||
createdBy: "Faisal",
|
||||
createdOn: "27-Oct-24",
|
||||
approvedBy: "Nawab",
|
||||
approvedOn: "28-Oct-24",
|
||||
},
|
||||
]);
|
||||
|
||||
const [InvestorWallet, setInvestorWallet] = useState(null);
|
||||
|
||||
// ==============[ prod state ]===============================
|
||||
@@ -1643,7 +1760,13 @@ const GlobalStateProvider = ({ children }) => {
|
||||
fawateerRequest,
|
||||
setFawateerRequest,
|
||||
approveHistory,
|
||||
setApproveHistory
|
||||
setApproveHistory,
|
||||
approved,
|
||||
setApproved,
|
||||
iONAVDetail,
|
||||
setIONAVDetail,
|
||||
iOTransaction,
|
||||
setIOTransaction,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -1,21 +1,48 @@
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import logo from "../assets/logo2.png";
|
||||
import logoDark from "../assets/logo.png";
|
||||
import logoMini from "../assets/logo-min.png";
|
||||
import logoMiniDark from "../assets/favicon.png";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { loginUser } from "../Redux/Slice/auth";
|
||||
import Button02 from "../Components/Buttons/Button02";
|
||||
import { CgProfile } from "react-icons/cg";
|
||||
import { useDispatch } from "react-redux";
|
||||
import logoMiniDark from "../assets/favicon.png";
|
||||
import logoMini from "../assets/logo-min.png";
|
||||
import logoDark from "../assets/logo.png";
|
||||
import logo from "../assets/logo2.png";
|
||||
|
||||
import {
|
||||
TbArrowBadgeLeftFilled,
|
||||
ArrowBackIcon,
|
||||
ArrowLeftIcon,
|
||||
ArrowRightIcon,
|
||||
AtSignIcon,
|
||||
} from "@chakra-ui/icons";
|
||||
import {
|
||||
Accordion,
|
||||
AccordionButton,
|
||||
AccordionIcon,
|
||||
AccordionItem,
|
||||
AccordionPanel,
|
||||
Alert,
|
||||
AlertIcon,
|
||||
Box,
|
||||
Button,
|
||||
Image,
|
||||
Text,
|
||||
Tooltip
|
||||
} from "@chakra-ui/react";
|
||||
import Cookies from "js-cookie"; // Import the Cookies library
|
||||
import { GrManual } from "react-icons/gr";
|
||||
import { HiOutlineChartSquareBar } from "react-icons/hi";
|
||||
import { LuContact } from "react-icons/lu";
|
||||
import { MdNotificationsNone, MdOutlineAddChart } from "react-icons/md";
|
||||
import {
|
||||
RiBankLine,
|
||||
RiExchangeBoxLine,
|
||||
RiFileUserLine,
|
||||
RiMoneyDollarBoxLine,
|
||||
} from "react-icons/ri";
|
||||
import {
|
||||
TbListDetails,
|
||||
TbReportMoney,
|
||||
TbTransactionDollar,
|
||||
TbTransactionDollar
|
||||
} from "react-icons/tb";
|
||||
import { TbArrowBadgeRightFilled } from "react-icons/tb";
|
||||
import { ArrowBackIcon, ArrowLeftIcon, ArrowRightIcon, AtSignIcon } from "@chakra-ui/icons";
|
||||
import { VscSymbolClass } from "react-icons/vsc";
|
||||
import {
|
||||
Link,
|
||||
NavLink,
|
||||
@@ -24,70 +51,21 @@ import {
|
||||
useLocation,
|
||||
useNavigate,
|
||||
} from "react-router-dom";
|
||||
import { RouteLink } from "../Routes/Routes";
|
||||
import NotFound from "../Pages/NotFound";
|
||||
import { nav } from "../Routes/Nav";
|
||||
import {
|
||||
Avatar,
|
||||
Box,
|
||||
Button,
|
||||
PopoverArrow,
|
||||
PopoverBody,
|
||||
PopoverCloseButton,
|
||||
PopoverContent,
|
||||
PopoverFooter,
|
||||
PopoverHeader,
|
||||
PopoverTrigger,
|
||||
Portal,
|
||||
Text,
|
||||
WrapItem,
|
||||
Popover,
|
||||
Tag,
|
||||
Accordion,
|
||||
AccordionItem,
|
||||
AccordionButton,
|
||||
AccordionIcon,
|
||||
AccordionPanel,
|
||||
Image,
|
||||
Alert,
|
||||
AlertIcon,
|
||||
Breadcrumb,
|
||||
Divider,
|
||||
Tooltip,
|
||||
useRadio,
|
||||
} from "@chakra-ui/react";
|
||||
import GlobalStateContext from "../Contexts/GlobalStateContext";
|
||||
import Cookies from "js-cookie"; // Import the Cookies library
|
||||
import Header from "../Components/Header";
|
||||
import HeaderMain from "../Components/HeaderMain";
|
||||
import { IoMdSwap } from "react-icons/io";
|
||||
import {
|
||||
RiBankLine,
|
||||
RiExchangeBoxLine,
|
||||
RiFileUserLine,
|
||||
RiMoneyDollarBoxLine,
|
||||
} from "react-icons/ri";
|
||||
import { VscSymbolClass } from "react-icons/vsc";
|
||||
import { MdNotificationsNone, MdOutlineAddChart } from "react-icons/md";
|
||||
import { HiOutlineChartSquareBar } from "react-icons/hi";
|
||||
import { GrManual } from "react-icons/gr";
|
||||
import { LuContact } from "react-icons/lu";
|
||||
import shield from "../assets/shield.png";
|
||||
import SplashScreen from "../Pages/SplashScreen";
|
||||
import CutomBreadcrumb from "../Components/CutomBreadcrumb";
|
||||
import CustomBreadcrumb from "../Components/CutomBreadcrumb";
|
||||
import { getCountdownTimer } from "../Constants/Constants";
|
||||
import { useLogoutMutation } from "../Services/token.serivce";
|
||||
import GlobalStateContext from "../Contexts/GlobalStateContext";
|
||||
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";
|
||||
import ApproveHistoryMaker from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryMaker";
|
||||
import ApproveRequest from "../Pages/FawateerChecker/ApproveRequest/ApproveRequest";
|
||||
import NotFound from "../Pages/NotFound";
|
||||
import SplashScreen from "../Pages/SplashScreen";
|
||||
import { nav } from "../Routes/Nav";
|
||||
import { RouteLink } from "../Routes/Routes";
|
||||
import { useProfileQuery } from "../Services/io.service";
|
||||
import { useLogoutMutation } from "../Services/token.serivce";
|
||||
|
||||
const DashboardLayout = ({ isOnline }) => {
|
||||
const userRole = localStorage.getItem("role");
|
||||
const navigate = useNavigate();
|
||||
const dispach = useDispatch();
|
||||
const location = useLocation();
|
||||
const path = location.pathname;
|
||||
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
||||
@@ -104,15 +82,15 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
|
||||
const { data, refetch } = useProfileQuery();
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
!localStorage.getItem("accessToken") &&
|
||||
!localStorage.getItem("refreshToken")
|
||||
) {
|
||||
logOutHandler();
|
||||
return navigate("/login");
|
||||
}
|
||||
}, []);
|
||||
// useEffect(() => {
|
||||
// if (
|
||||
// !localStorage.getItem("accessToken") &&
|
||||
// !localStorage.getItem("refreshToken")
|
||||
// ) {
|
||||
// logOutHandler();
|
||||
// return navigate("/login");
|
||||
// }
|
||||
// }, []);
|
||||
|
||||
useEffect(() => {
|
||||
const savedIndex = localStorage.getItem("openAccordionIndex");
|
||||
@@ -151,7 +129,9 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
await logout();
|
||||
localStorage.clear();
|
||||
navigate("/login");
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
// // Function to get the title based on the route
|
||||
@@ -165,29 +145,29 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
<RiMoneyDollarBoxLine className="h4 m-0" /> Sponsor
|
||||
</span>
|
||||
);
|
||||
case path.startsWith("/email"):
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
<AtSignIcon className="h4 m-0" /> Email Notifiation
|
||||
</span>
|
||||
);
|
||||
case path.startsWith("/email"):
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
<AtSignIcon className="h4 m-0" /> Email Notification
|
||||
</span>
|
||||
);
|
||||
case path.startsWith("/investment-type"):
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
<VscSymbolClass className="h4 m-0" /> Investment Type
|
||||
</span>
|
||||
);
|
||||
case path.startsWith("/profile"):
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
<CgProfile className="h4 m-0" /> Profile
|
||||
</span>
|
||||
);
|
||||
case path.startsWith("/profile"):
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
<CgProfile className="h4 m-0" /> Profile
|
||||
</span>
|
||||
);
|
||||
case path.startsWith("/exchange-rate"):
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
<RiExchangeBoxLine className="h4 m-0 fw-normal" />
|
||||
Echange rate
|
||||
Exchange rate
|
||||
</span>
|
||||
);
|
||||
case path.startsWith("/create-io"):
|
||||
@@ -231,17 +211,17 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
<RiMoneyDollarBoxLine className="h4 m-0 fw-normal" />
|
||||
Deposit pending request
|
||||
Deposit Pending Request
|
||||
</span>
|
||||
);
|
||||
case path.startsWith("/deposit-history"):
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
<RiExchangeBoxLine className="h4 m-0 fw-normal" />
|
||||
Deposite request
|
||||
Deposite Request
|
||||
</span>
|
||||
);
|
||||
|
||||
|
||||
case path.startsWith("/fawateer"):
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
@@ -249,13 +229,13 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
Fawateer Deposit
|
||||
</span>
|
||||
);
|
||||
case path.startsWith("/fawateer-history"):
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
<RiMoneyDollarBoxLine className="h4 m-0 fw-normal" />
|
||||
Fawateer Deposit
|
||||
</span>
|
||||
);
|
||||
case path.startsWith("/fawateer-history"):
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
<RiMoneyDollarBoxLine className="h4 m-0 fw-normal" />
|
||||
Fawateer Deposit
|
||||
</span>
|
||||
);
|
||||
|
||||
case path.startsWith("/withdraw-request"):
|
||||
return (
|
||||
@@ -317,7 +297,7 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
<MdNotificationsNone className="h4 m-0 fw-normal" />
|
||||
Notification
|
||||
Push Notification
|
||||
</span>
|
||||
);
|
||||
case path.startsWith("/contact"):
|
||||
@@ -369,6 +349,13 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
Deletion request
|
||||
</span>
|
||||
);
|
||||
case path.startsWith("/subadmin"):
|
||||
return (
|
||||
<span className="d-flex align-items-end gap-2">
|
||||
<RiMoneyDollarBoxLine className="h4 m-0 fw-normal" />
|
||||
Manage SubAdmin
|
||||
</span>
|
||||
);
|
||||
|
||||
default:
|
||||
if (path.startsWith("/community/view/")) {
|
||||
@@ -398,6 +385,19 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
return <SplashScreen />;
|
||||
}
|
||||
|
||||
const filteredNav = nav.map((item) => {
|
||||
if (item.submenu) {
|
||||
return {
|
||||
...item,
|
||||
submenu: item.submenu.filter(
|
||||
(submenuItem) =>
|
||||
!(!data?.data?.superAdmin && submenuItem.title === "Sub Admin")
|
||||
),
|
||||
};
|
||||
}
|
||||
return item;
|
||||
});
|
||||
|
||||
return (
|
||||
<Box
|
||||
style={{
|
||||
@@ -515,7 +515,7 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
index={openIndex}
|
||||
onChange={handleAccordionChange}
|
||||
>
|
||||
{nav.map(({ title, type, Icon, submenu, path }, index) => {
|
||||
{filteredNav.map(({ title, type, Icon, submenu, path }, index) => {
|
||||
if (type === "accordion") {
|
||||
return (
|
||||
<AccordionItem key={index} border={"none"}>
|
||||
@@ -788,6 +788,7 @@ const AppContent = ({ data }) => {
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Routes>
|
||||
);
|
||||
|
||||
@@ -49,7 +49,7 @@ const InvestorComment = ({ isOpen, onClose }) => {
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="md"
|
||||
placeholder={"Enter your comments...."}
|
||||
placeholder={"Enter your comment...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
/>
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
HStack,
|
||||
Input,
|
||||
Select,
|
||||
Switch,
|
||||
Text,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useState, useRef } from "react";
|
||||
import { Link, Link as RouterLink, useNavigate } from "react-router-dom";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import { debounce } from "../../../Master/Sponser/AddSponser";
|
||||
import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
|
||||
import NormalTable from "../../../../Components/DataTable/NormalTable";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import Pagination from "../../../../Components/Pagination";
|
||||
import NormalTable from "../../../../Components/DataTable/NormalTable";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import ReasonBanModal from "./ReasonBanModal";
|
||||
import { useGetbanInvestorQuery } from "../../../../Services/ban.investor.service";
|
||||
import { TABLE_PAGINATION } from "../../../../Constants/Paginations";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
|
||||
import { useGetbanInvestorQuery } from "../../../../Services/ban.investor.service";
|
||||
import { debounce } from "../../../Master/Sponser/AddSponser";
|
||||
import ReasonBanModal from "./ReasonBanModal";
|
||||
import Pagination from "../../../../Components/Pagination";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter
|
||||
|
||||
@@ -233,8 +231,6 @@ const BankInvestor = () => {
|
||||
),
|
||||
}));
|
||||
|
||||
console.log(extractedArray);
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedInvestorDetails = InvestorDetails.filter(
|
||||
(sponsor) => sponsor.id !== actionId
|
||||
@@ -278,6 +274,14 @@ const BankInvestor = () => {
|
||||
/>
|
||||
|
||||
<HStack display={"flex"} alignItems={"center"}>
|
||||
<Pagination
|
||||
isLoading={unbanLoading}
|
||||
pageSize={pageSize}
|
||||
setPageSize={setPageSize}
|
||||
currentPage={currentPage}
|
||||
setCurrentPage={setCurrentPage}
|
||||
totalItems={data?.data?.totalItems}
|
||||
/>
|
||||
{/* <Select
|
||||
focusBorderColor="green.500"
|
||||
size={"sm"}
|
||||
|
||||
@@ -1,31 +1,26 @@
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
HStack,
|
||||
Input,
|
||||
Select,
|
||||
Switch,
|
||||
Text,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useState, useRef } from "react";
|
||||
import { Link, Link as RouterLink, useNavigate } from "react-router-dom";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import { debounce } from "../../../Master/Sponser/AddSponser";
|
||||
import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
|
||||
import DataTable from "../../../../Components/DataTable/NormalTable";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import Pagination from "../../../../Components/Pagination";
|
||||
import DataTable from "../../../../Components/DataTable/NormalTable";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import ReasonBanModal from "./ReasonBanModal";
|
||||
import {
|
||||
useGetInvestorQuery,
|
||||
useGetUnbanInvestorQuery,
|
||||
} from "../../../../Services/ban.investor.service";
|
||||
import { generateSerialNumber } from "../../../../Constants/Constants";
|
||||
import { TABLE_PAGINATION } from "../../../../Constants/Paginations";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
|
||||
import { useGetUnbanInvestorQuery } from "../../../../Services/ban.investor.service";
|
||||
import { debounce } from "../../../Master/Sponser/AddSponser";
|
||||
import ReasonBanModal from "./ReasonBanModal";
|
||||
import Pagination from "../../../../Components/Pagination";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter
|
||||
|
||||
@@ -270,6 +265,14 @@ const UnbanInvestor = () => {
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
<HStack display={"flex"} alignItems={"center"}>
|
||||
<Pagination
|
||||
isLoading={unbanLoading}
|
||||
pageSize={pageSize}
|
||||
setPageSize={setPageSize}
|
||||
currentPage={currentPage}
|
||||
setCurrentPage={setCurrentPage}
|
||||
totalItems={data?.data?.totalItems}
|
||||
/>
|
||||
{/* <Select
|
||||
focusBorderColor="green.500"
|
||||
size={"sm"}
|
||||
|
||||
@@ -3,11 +3,14 @@ import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
Select,
|
||||
Text,
|
||||
Tooltip,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import { useForm} from "react-hook-form";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import * as yup from "yup";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
@@ -23,15 +26,13 @@ import ToastBox from "../../Components/ToastBox";
|
||||
import NormalTable from "../../Components/DataTable/NormalTable";
|
||||
import GlobalStateContext from "../../Contexts/GlobalStateContext";
|
||||
import { useGetInvestorsQuery } from "../../Services/investor.details.service";
|
||||
import { TABLE_PAGINATION } from "../../Constants/Paginations";
|
||||
import { INVESTOR_TABLE_PAGINATION, TABLE_PAGINATION } from "../../Constants/Paginations";
|
||||
import { formatDate, generateSerialNumber } from "../../Constants/Constants";
|
||||
import { ViewIcon } from "@chakra-ui/icons";
|
||||
import { useGetUnbanInvestorQuery } from "../../Services/ban.investor.service";
|
||||
|
||||
export const notification = yup.object().shape({
|
||||
title: yup
|
||||
.string()
|
||||
.required("Investment Name is required"),
|
||||
title: yup.string().required("Notification Header is required"),
|
||||
ManualDate: yup
|
||||
.date()
|
||||
.required("Manual Date is required")
|
||||
@@ -43,33 +44,26 @@ export const notification = yup.object().shape({
|
||||
/^([01]\d|2[0-3]):?([0-5]\d)$/,
|
||||
"Invalid time format, must be in HH:mm"
|
||||
),
|
||||
expectedReturn: yup
|
||||
.string()
|
||||
.required("Expected Return is required"),
|
||||
expectedReturn: yup.string().required("Expected Return is required"),
|
||||
});
|
||||
|
||||
export const notificationNew = yup.object().shape({
|
||||
title: yup
|
||||
.string()
|
||||
.required("Investment Name is required"),
|
||||
message: yup
|
||||
.string()
|
||||
.required("Message is required"),
|
||||
|
||||
title: yup.string().required("Notification Header is required"),
|
||||
message: yup.string().required("Message is required"),
|
||||
});
|
||||
|
||||
|
||||
|
||||
const Notification = () => {
|
||||
const toast = useToast();
|
||||
const navigate = useNavigate();
|
||||
const [form, setForm] = useState({});
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [ selectedRadio, setSelectedRadio] = useState([])
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
const [selectedRadio, setSelectedRadio] = useState([]);
|
||||
const [pageSize, setPageSize] = useState(INVESTOR_TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(INVESTOR_TABLE_PAGINATION?.page);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
|
||||
const [country, setCountry] = useState("");
|
||||
const [kyc, setKyc] = useState("");
|
||||
|
||||
const {
|
||||
control,
|
||||
@@ -80,21 +74,20 @@ const Notification = () => {
|
||||
} = useForm({
|
||||
resolver: yupResolver(notificationNew),
|
||||
|
||||
defaultValues: {
|
||||
title: '',
|
||||
message: '',
|
||||
},
|
||||
defaultValues: {
|
||||
title: "",
|
||||
message: "",
|
||||
},
|
||||
});
|
||||
|
||||
console.log(errors);
|
||||
|
||||
|
||||
const {
|
||||
data: contact,
|
||||
isLoading: contactLoading,
|
||||
error,
|
||||
} = useGetContactQuery();
|
||||
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
@@ -109,28 +102,42 @@ const Notification = () => {
|
||||
// // error,
|
||||
// } = useGetInvestorsQuery({ page: currentPage, size: pageSize });
|
||||
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => {
|
||||
setDebouncedSearchTerm(searchTerm.trim()); // Trim to remove leading/trailing spaces
|
||||
}, 300);
|
||||
return () => clearTimeout(handler);
|
||||
}, [searchTerm]);
|
||||
|
||||
|
||||
const {
|
||||
data : investorDetails,
|
||||
isLoading: investorDetailsLoading,
|
||||
refetch,
|
||||
} = useGetUnbanInvestorQuery({
|
||||
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
|
||||
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
|
||||
search: debouncedSearchTerm,
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
});;
|
||||
const { data: investorDetails, isLoading: investorDetailsLoading, refetch } =
|
||||
useGetUnbanInvestorQuery(
|
||||
{
|
||||
page: 1, // Omit pagination for search
|
||||
size: 10000, // Omit pagination for search
|
||||
// page: debouncedSearchTerm ? undefined : currentPage, // Disable pagination for search
|
||||
// size: debouncedSearchTerm ? undefined : 10000 || pageSize || 500, // Disable pagination for search
|
||||
search: debouncedSearchTerm, // Pass search term
|
||||
country_xid: country,
|
||||
KYCStatus: kyc,
|
||||
},
|
||||
{
|
||||
skip: searchTerm !== "" && debouncedSearchTerm === "", // Skip if search not debounced yet
|
||||
}
|
||||
);
|
||||
|
||||
// useEffect(() => {
|
||||
// console.log("Search Term:", searchTerm);
|
||||
// console.log("Debounced Search Term:", debouncedSearchTerm);
|
||||
// console.log("Investor Details:", investorDetails);
|
||||
// }, [searchTerm, debouncedSearchTerm, investorDetails]);
|
||||
|
||||
|
||||
|
||||
console.log(investorDetails);
|
||||
|
||||
|
||||
const [sendNotification] = useSendNotificationMutation();
|
||||
|
||||
|
||||
if (contactLoading) {
|
||||
return <FullscreenLoaders />;
|
||||
}
|
||||
@@ -141,9 +148,11 @@ const Notification = () => {
|
||||
placeHolder: " ",
|
||||
name: "title",
|
||||
type: "text",
|
||||
width:"100%",
|
||||
maxLength:100,
|
||||
helperText:`Maximum length should be 100 characters. You have entered ${watch()?.title?.length || 0} characters.`,
|
||||
width: "100%",
|
||||
maxLength: 100,
|
||||
helperText: `Maximum length should be 100 characters. You have entered ${
|
||||
watch()?.title?.length || 0
|
||||
} characters.`,
|
||||
isRequired: true,
|
||||
section: "Send Custom Push Notification",
|
||||
// value: contact?.phoneNumber || "",
|
||||
@@ -152,15 +161,16 @@ const Notification = () => {
|
||||
label: "Notification Message",
|
||||
placeHolder: " ",
|
||||
name: "message",
|
||||
width:"100%",
|
||||
width: "100%",
|
||||
type: "textarea",
|
||||
isRequired: true,
|
||||
maxLength:200,
|
||||
helperText:`Maximum length should be 200 characters. You have entered ${watch()?.message?.length || 0} characters.`,
|
||||
maxLength: 200,
|
||||
helperText: `Maximum length should be 200 characters. You have entered ${
|
||||
watch()?.message?.length || 0
|
||||
} characters.`,
|
||||
section: "Send Custom Push Notification",
|
||||
// value: contact?.phoneNumber || "",
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
const groupedFields = formFields.reduce((groups, field) => {
|
||||
@@ -173,55 +183,47 @@ const Notification = () => {
|
||||
}, {});
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
|
||||
const dataToPass = {
|
||||
...data,
|
||||
principal_xid:selectedRadio
|
||||
}
|
||||
principal_xid: selectedRadio,
|
||||
};
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const res = await sendNotification(dataToPass);
|
||||
console.log(res);
|
||||
|
||||
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false)
|
||||
}else if(res?.data){
|
||||
setIsLoading(false);
|
||||
} else if (res?.data) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
setIsLoading(false)
|
||||
setSelectedRadio([])
|
||||
setIsLoading(false);
|
||||
setSelectedRadio([]);
|
||||
reset({
|
||||
title: '', // Resetting specific fields
|
||||
message: '',
|
||||
title: "", // Resetting specific fields
|
||||
message: "",
|
||||
}); // Clears the form fields
|
||||
}else{
|
||||
} else {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
<ToastBox status={"error"} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false)
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// ====================================================[Table Setup]================================================================
|
||||
const tableHeadRow = [
|
||||
"Sr N/O",
|
||||
@@ -235,7 +237,6 @@ const Notification = () => {
|
||||
"KYC Status",
|
||||
];
|
||||
|
||||
|
||||
const extractedArray = investorDetails?.data?.rows?.map((item, idx) => ({
|
||||
id: item?.principal_xid,
|
||||
"Sr N/O": (
|
||||
@@ -245,7 +246,7 @@ const Notification = () => {
|
||||
color={"gray.600"}
|
||||
className="d-flex align-items-center fw-bold web-text-small"
|
||||
>
|
||||
{generateSerialNumber(idx,currentPage, pageSize )}
|
||||
{generateSerialNumber(idx, currentPage, pageSize)}
|
||||
</Text>
|
||||
),
|
||||
Date: (
|
||||
@@ -305,13 +306,14 @@ const Notification = () => {
|
||||
color={item?.KYCStatus === false ? "red" : "blue"}
|
||||
px={2}
|
||||
py={0.5}
|
||||
variant={'ghost'}
|
||||
variant={"ghost"}
|
||||
>
|
||||
{item?.KYCStatus === true ? "Completed" : "Incompleted"}
|
||||
{item?.KYCStatus === true ? "Completed" : "Not Completed"}
|
||||
</Badge>
|
||||
</Box>
|
||||
),
|
||||
}));
|
||||
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={14}>
|
||||
@@ -322,18 +324,77 @@ const Notification = () => {
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
btnLoading={isLoading}
|
||||
>
|
||||
<Box overflow={'scroll'} h={'58vh'}>
|
||||
<NormalTable
|
||||
centered={true}
|
||||
emptyMessage={`We don't have any Sponers `}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
// isLoading={isLoading}
|
||||
setSelectedRadio={setSelectedRadio}
|
||||
selectedRadio={selectedRadio}
|
||||
showRadioButton={true}
|
||||
/>
|
||||
</Box>
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
ps={1}
|
||||
pe={1}
|
||||
pb={4}
|
||||
pt={4}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
mt={1}
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
<HStack className="col" justifyContent={"end"}>
|
||||
<Select
|
||||
w={250}
|
||||
focusBorderColor="green.500"
|
||||
size={"sm"}
|
||||
fontSize={"xs"}
|
||||
cursor={"pointer"}
|
||||
onChange={(e) => setCountry(e.target.value)}
|
||||
value={country}
|
||||
>
|
||||
<option value="" defaultValue={""} disabled hidden>
|
||||
Country
|
||||
</option>
|
||||
<option value="">All</option>
|
||||
<option value="1">Bahrain</option>
|
||||
<option value="2">Kuwait</option>
|
||||
<option value="3">Oman</option>
|
||||
<option value="4">Qatar</option>
|
||||
<option value="5">Saudi arabia</option>
|
||||
<option value="6">United arab emirates</option>
|
||||
</Select>
|
||||
<Select
|
||||
w={250}
|
||||
focusBorderColor="green.500"
|
||||
size={"sm"}
|
||||
fontSize={"xs"}
|
||||
cursor={"pointer"}
|
||||
onChange={(e) => setKyc(e.target.value)}
|
||||
value={kyc}
|
||||
>
|
||||
<option value="" defaultValue={""} disabled hidden>
|
||||
KYC Status
|
||||
</option>
|
||||
<option value="">KYC Status</option>
|
||||
<option value="0">Not Completed</option>
|
||||
<option value="1">Completed</option>
|
||||
</Select>
|
||||
</HStack>
|
||||
</HStack>
|
||||
<Box overflow={"scroll"} h={"58vh"}>
|
||||
<NormalTable
|
||||
centered={true}
|
||||
emptyMessage={`We don't have any Sponers `}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={investorDetailsLoading}
|
||||
setSelectedRadio={setSelectedRadio}
|
||||
selectedRadio={selectedRadio}
|
||||
showRadioButton={true}
|
||||
/>
|
||||
</Box>
|
||||
</FormInputMain>
|
||||
</Box>
|
||||
);
|
||||
|
||||
245
src/Pages/ChangePassword.jsx
Normal file
245
src/Pages/ChangePassword.jsx
Normal file
@@ -0,0 +1,245 @@
|
||||
import {
|
||||
Button,
|
||||
DrawerFooter,
|
||||
FormControl,
|
||||
FormErrorMessage,
|
||||
FormLabel,
|
||||
Input,
|
||||
InputGroup,
|
||||
InputRightElement,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Stack,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import React, { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import * as yup from "yup";
|
||||
import CustomAlertDialog from "../Components/CustomAlertDialog";
|
||||
import ToastBox from "../Components/ToastBox";
|
||||
import { useUpdatePasswordMutation } from "../Services/change.password.service";
|
||||
|
||||
// Validation schema
|
||||
const passwordSchema = yup.object().shape({
|
||||
oldPassword: yup.string().required("Current Password is required"),
|
||||
newPassword: yup
|
||||
.string()
|
||||
.required("New Password is required")
|
||||
.min(8, "Password must be at least 8 characters long")
|
||||
.max(16, "Password must be at most 50 characters long")
|
||||
.matches(/[A-Z]/, "Password must contain at least one uppercase letter")
|
||||
.matches(/[a-z]/, "Password must contain at least one lowercase letter")
|
||||
.matches(/[0-9]/, "Password must contain at least one number")
|
||||
.matches(
|
||||
/[@$!%*?&#]/,
|
||||
"Password must contain at least one special character"
|
||||
),
|
||||
confirmNewPassword: yup
|
||||
.string()
|
||||
.required("Confirm New Password is required")
|
||||
.oneOf([yup.ref("newPassword")], "Password do not match"),
|
||||
});
|
||||
|
||||
const ChangePassword = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
firstField,
|
||||
actionId,
|
||||
setActionId,
|
||||
}) => {
|
||||
const initialValue = {
|
||||
oldPassword: "",
|
||||
newPassword: "",
|
||||
confirmNewPassword: "",
|
||||
};
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [alert, setAlert] = useState(false);
|
||||
const [showCurrentPassword, setShowCurrentPassword] = useState(false);
|
||||
const [showNewPassword, setShowNewPassword] = useState(false);
|
||||
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||
const toast = useToast();
|
||||
const [input, setInput] = useState(initialValue);
|
||||
|
||||
const [updatePassword] = useUpdatePasswordMutation();
|
||||
|
||||
// Form handling
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
reset,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(passwordSchema),
|
||||
mode: "all",
|
||||
});
|
||||
|
||||
// Form submit handler
|
||||
const onSubmit = async () => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const res = await updatePassword(input); // Assuming API request works as expected
|
||||
if (res?.data?.statusCode === 200) {
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
handleClose();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
),
|
||||
});
|
||||
setAlert(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmitFrom = (data) => {
|
||||
setAlert(true);
|
||||
setInput(data);
|
||||
};
|
||||
|
||||
// Handle modal close
|
||||
const handleClose = () => {
|
||||
setAlert(false);
|
||||
onClose();
|
||||
reset();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal isOpen={isOpen} onClose={handleClose} initialFocusRef={firstField}>
|
||||
<ModalOverlay />
|
||||
<ModalContent>
|
||||
<ModalHeader fontSize="md">Change Password</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
<ModalBody pb={6}>
|
||||
<Stack spacing={4}>
|
||||
{/* Current Password */}
|
||||
<FormControl isInvalid={errors.oldPassword} isRequired>
|
||||
<FormLabel fontSize="sm" mb={1} fontWeight={500}>
|
||||
Current Password
|
||||
</FormLabel>
|
||||
<InputGroup size="sm">
|
||||
<Input
|
||||
{...register("oldPassword")}
|
||||
fontSize="sm"
|
||||
type={showCurrentPassword ? "text" : "password"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
/>
|
||||
<InputRightElement width="4.5rem">
|
||||
<Button
|
||||
h="1.5rem"
|
||||
size="xs"
|
||||
onClick={() => setShowCurrentPassword((prev) => !prev)}
|
||||
>
|
||||
{showCurrentPassword ? "Hide" : "Show"}
|
||||
</Button>
|
||||
</InputRightElement>
|
||||
</InputGroup>
|
||||
<FormErrorMessage>
|
||||
{errors.oldPassword?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
{/* New Password */}
|
||||
<FormControl isInvalid={errors.newPassword} isRequired>
|
||||
<FormLabel fontSize="sm" mb={1}>
|
||||
New Password
|
||||
</FormLabel>
|
||||
<InputGroup size="sm">
|
||||
<Input
|
||||
{...register("newPassword")}
|
||||
fontSize="sm"
|
||||
type={showNewPassword ? "text" : "password"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
/>
|
||||
<InputRightElement width="4.5rem">
|
||||
<Button
|
||||
h="1.5rem"
|
||||
size="xs"
|
||||
onClick={() => setShowNewPassword((prev) => !prev)}
|
||||
>
|
||||
{showNewPassword ? "Hide" : "Show"}
|
||||
</Button>
|
||||
</InputRightElement>
|
||||
</InputGroup>
|
||||
<FormErrorMessage>
|
||||
{errors.newPassword?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
{/* Confirm Password */}
|
||||
<FormControl isInvalid={errors.confirmNewPassword} isRequired>
|
||||
<FormLabel fontSize="sm" mb={1}>
|
||||
Confirm New Password
|
||||
</FormLabel>
|
||||
<InputGroup size="sm">
|
||||
<Input
|
||||
{...register("confirmNewPassword")}
|
||||
fontSize="sm"
|
||||
type={showConfirmPassword ? "text" : "password"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
/>
|
||||
<InputRightElement width="4.5rem">
|
||||
<Button
|
||||
h="1.5rem"
|
||||
size="xs"
|
||||
onClick={() => setShowConfirmPassword((prev) => !prev)}
|
||||
>
|
||||
{showConfirmPassword ? "Hide" : "Show"}
|
||||
</Button>
|
||||
</InputRightElement>
|
||||
</InputGroup>
|
||||
<FormErrorMessage>
|
||||
{errors.confirmNewPassword?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
</Stack>
|
||||
</ModalBody>
|
||||
|
||||
<DrawerFooter mb={5}>
|
||||
<Button
|
||||
onClick={handleClose}
|
||||
bg="#e0ebeb"
|
||||
size="sm"
|
||||
mr={3}
|
||||
rounded={"sm"}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
rounded={"sm"}
|
||||
colorScheme="forestGreen"
|
||||
size="sm"
|
||||
// onClick={() => setAlert(true)}
|
||||
onClick={handleSubmit(handleSubmitFrom)}
|
||||
isLoading={isLoading}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
</DrawerFooter>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
|
||||
<CustomAlertDialog
|
||||
isOpen={alert}
|
||||
onClose={() => setAlert(false)}
|
||||
alertHandler={onSubmit}
|
||||
message={"Are you sure you want to change the password?"}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ChangePassword;
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
Button,
|
||||
FormControl,
|
||||
FormErrorMessage,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
@@ -35,7 +36,7 @@ const FILE_TYPES = ["image/jpeg", "image/png", "image/gif"];
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
investorAmount: yup.string().required("Investor amount is required"),
|
||||
comment: yup.string().notRequired(),
|
||||
comment: yup.string().notRequired() .max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
supporting_FileName: yup.mixed().required("File is required"),
|
||||
// .test("fileType", "Unsupported File Format", (value) => {
|
||||
// return value && FILE_TYPES.includes(value.type);
|
||||
@@ -192,7 +193,7 @@ const DepositRequestApprove = ({
|
||||
)}
|
||||
</FormControl>
|
||||
<FormControl mb={4}>
|
||||
<FormLabel fontSize="sm">Comments</FormLabel>
|
||||
<FormLabel fontSize="sm">Comment</FormLabel>
|
||||
<Textarea
|
||||
rows={5}
|
||||
focusBorderColor="green.400"
|
||||
@@ -201,14 +202,19 @@ const DepositRequestApprove = ({
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="sm"
|
||||
placeholder={"Enter your comments...."}
|
||||
placeholder={"Enter your comment...."}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comment && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comment.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered </Box>
|
||||
{watch("comment")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
@@ -24,7 +25,8 @@ import { useDepositRejectMutation } from "../../../Services/deposit.request.serv
|
||||
import ToastBox from "../../../Components/ToastBox";
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
comments: yup.string().required("Comment is required"),
|
||||
comments: yup.string().required("Comment is required")
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const DepositRequestReject = ({ isOpen, onClose, firstField ,id}) => {
|
||||
@@ -35,6 +37,7 @@ const DepositRequestReject = ({ isOpen, onClose, firstField ,id}) => {
|
||||
const {
|
||||
register,
|
||||
reset,
|
||||
watch,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
@@ -121,15 +124,20 @@ const DepositRequestReject = ({ isOpen, onClose, firstField ,id}) => {
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="md"
|
||||
placeholder={"Enter your comments...."}
|
||||
placeholder={"Enter your comment...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comments && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comments.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered </Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
|
||||
@@ -7,10 +7,11 @@ import {
|
||||
FormLabel,
|
||||
HStack,
|
||||
Input,
|
||||
Select,
|
||||
Text,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { OPACITY_ON_LOAD } from "../../Layout/animations";
|
||||
import NormalTable from "../../Components/DataTable/NormalTable";
|
||||
import { useGetUnbanInvestorQuery } from "../../Services/ban.investor.service";
|
||||
@@ -28,8 +29,11 @@ const EmailNotification = () => {
|
||||
const [subject, setSubject] = useState("");
|
||||
const [value, setValue] = useState(""); // Quill content (body)
|
||||
const toast = useToast();
|
||||
|
||||
const [sendCustomNotification] = useSendCustomEmailMutation();
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
|
||||
const [country, setCountry] = useState("");
|
||||
const [kyc, setKyc] = useState("");
|
||||
|
||||
// ===========================[Table Setup]==============================
|
||||
const tableHeadRow = [
|
||||
@@ -47,14 +51,40 @@ const EmailNotification = () => {
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
|
||||
// const {
|
||||
// data: investorDetails,
|
||||
// isLoading: investorDetailsLoading,
|
||||
// refetch,
|
||||
// } = useGetUnbanInvestorQuery({
|
||||
// page: currentPage, // Omit pagination for search
|
||||
// size: 10000, // Omit pagination for search
|
||||
// });
|
||||
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => {
|
||||
setDebouncedSearchTerm(searchTerm.trim()); // Trim to remove leading/trailing spaces
|
||||
}, 300);
|
||||
return () => clearTimeout(handler);
|
||||
}, [searchTerm]);
|
||||
|
||||
const {
|
||||
data: investorDetails,
|
||||
isLoading: investorDetailsLoading,
|
||||
refetch,
|
||||
} = useGetUnbanInvestorQuery({
|
||||
page: currentPage, // Omit pagination for search
|
||||
size: 10000, // Omit pagination for search
|
||||
});
|
||||
} = useGetUnbanInvestorQuery(
|
||||
{
|
||||
page: 1, // Omit pagination for search
|
||||
size: 10000, // Omit pagination for search
|
||||
// page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
|
||||
// size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
|
||||
search: debouncedSearchTerm,
|
||||
country_xid: country,
|
||||
KYCStatus: kyc,
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
}
|
||||
);
|
||||
|
||||
const extractedArray = investorDetails?.data?.rows?.map((item, idx) => ({
|
||||
id: item?.principal_xid,
|
||||
@@ -127,7 +157,7 @@ const EmailNotification = () => {
|
||||
py={0.5}
|
||||
variant={"ghost"}
|
||||
>
|
||||
{item?.KYCStatus === true ? "Completed" : "Incompleted"}
|
||||
{item?.KYCStatus === true ? "Completed" : "Not Completed"}
|
||||
</Badge>
|
||||
</Box>
|
||||
),
|
||||
@@ -135,9 +165,9 @@ const EmailNotification = () => {
|
||||
|
||||
const modules = {
|
||||
toolbar: [
|
||||
// [{ header: "1" }, { header: "2" },
|
||||
// // { font: [] }
|
||||
// ],
|
||||
// [{ header: "1" }, { header: "2" },
|
||||
// // { font: [] }
|
||||
// ],
|
||||
// [{ size: [] }],
|
||||
["bold", "italic", "underline", "strike", "blockquote"],
|
||||
[{ list: "ordered" }, { list: "bullet" }],
|
||||
@@ -147,12 +177,15 @@ const EmailNotification = () => {
|
||||
|
||||
// Main submission logic
|
||||
const handleSend = async (e) => {
|
||||
e.preventDefault(); // Prevent default form submission
|
||||
e.preventDefault(); // Prevent default form submission
|
||||
|
||||
if (!subject || !value) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={"Subject or email body cannot be empty"} />
|
||||
<ToastBox
|
||||
status={"error"}
|
||||
message={"Subject or email body cannot be empty"}
|
||||
/>
|
||||
),
|
||||
});
|
||||
return;
|
||||
@@ -161,7 +194,10 @@ const EmailNotification = () => {
|
||||
if (selectedRadio.length === 0) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={"Please select at least one recipient"} />
|
||||
<ToastBox
|
||||
status={"error"}
|
||||
message={"Please select at least one recipient"}
|
||||
/>
|
||||
),
|
||||
});
|
||||
return;
|
||||
@@ -172,44 +208,36 @@ const EmailNotification = () => {
|
||||
const emailPayload = {
|
||||
subject,
|
||||
body: value,
|
||||
principal_xid: selectedRadio,
|
||||
principal_xid: selectedRadio,
|
||||
};
|
||||
|
||||
|
||||
try {
|
||||
const res = await sendCustomNotification(emailPayload)
|
||||
console.log(res);
|
||||
const res = await sendCustomNotification(emailPayload);
|
||||
console.log(res);
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false)
|
||||
}else if(res?.data){
|
||||
setIsLoading(false);
|
||||
} else if (res?.data) {
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
setIsLoading(false);
|
||||
setSubject("");
|
||||
setValue("");
|
||||
setSelectedRadio([]);
|
||||
} else {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
<ToastBox status={"error"} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false)
|
||||
setSubject("")
|
||||
setValue("")
|
||||
setSelectedRadio([])
|
||||
|
||||
}else{
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false)
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -247,40 +275,92 @@ const EmailNotification = () => {
|
||||
{/* <FormHelperText>Entered subject will be reflected on emails subject body.</FormHelperText> */}
|
||||
</FormControl>
|
||||
|
||||
|
||||
<FormControl minH={400} isRequired mb={3} p={1}>
|
||||
<FormLabel fontSize={"sm"}>Create Custom body</FormLabel>
|
||||
<ReactQuill
|
||||
theme="snow"
|
||||
style={{
|
||||
height:300
|
||||
}}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
modules={modules}
|
||||
placeholder="Start typing here..."
|
||||
|
||||
/>
|
||||
<ReactQuill
|
||||
theme="snow"
|
||||
style={{
|
||||
height: 300,
|
||||
}}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
modules={modules}
|
||||
placeholder="Start typing here..."
|
||||
/>
|
||||
</FormControl>
|
||||
{/* <FormHelperText fontSize={"xs"}>
|
||||
We'll never share your email.
|
||||
</FormHelperText> */}
|
||||
|
||||
|
||||
|
||||
|
||||
</FormControl>
|
||||
|
||||
<Box overflow={'scroll'} h={'58vh'}>
|
||||
<NormalTable
|
||||
centered={true}
|
||||
emptyMessage={`We don't have any Sponsors`}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
setSelectedRadio={setSelectedRadio}
|
||||
selectedRadio={selectedRadio}
|
||||
showRadioButton={true}
|
||||
/>
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
ps={1}
|
||||
pe={1}
|
||||
pb={4}
|
||||
pt={4}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
mt={1}
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
<HStack className="col" justifyContent={"end"}>
|
||||
<Select
|
||||
w={250}
|
||||
focusBorderColor="green.500"
|
||||
size={"sm"}
|
||||
fontSize={"xs"}
|
||||
cursor={"pointer"}
|
||||
onChange={(e) => setCountry(e.target.value)}
|
||||
value={country}
|
||||
>
|
||||
<option value="" defaultValue={""} disabled hidden>
|
||||
Country
|
||||
</option>
|
||||
<option value="">All</option>
|
||||
<option value="1">Bahrain</option>
|
||||
<option value="2">Kuwait</option>
|
||||
<option value="3">Oman</option>
|
||||
<option value="4">Qatar</option>
|
||||
<option value="5">Saudi arabia</option>
|
||||
<option value="6">United arab emirates</option>
|
||||
</Select>
|
||||
<Select
|
||||
w={250}
|
||||
focusBorderColor="green.500"
|
||||
size={"sm"}
|
||||
fontSize={"xs"}
|
||||
cursor={"pointer"}
|
||||
onChange={(e) => setKyc(e.target.value)}
|
||||
value={kyc}
|
||||
>
|
||||
<option value="" defaultValue={""} disabled hidden>
|
||||
KYC Status
|
||||
</option>
|
||||
<option value="">KYC Status</option>
|
||||
<option value="0">Not Completed</option>
|
||||
<option value="1">Completed</option>
|
||||
</Select>
|
||||
</HStack>
|
||||
</HStack>
|
||||
<Box overflow={"scroll"} h={"58vh"}>
|
||||
<NormalTable
|
||||
centered={true}
|
||||
emptyMessage={`We don't have any Sponsors`}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
setSelectedRadio={setSelectedRadio}
|
||||
selectedRadio={selectedRadio}
|
||||
showRadioButton={true}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<HStack justifyContent={"flex-end"} px={2}>
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
import React, { useState } from "react";
|
||||
import { OPACITY_ON_LOAD } from "../../Layout/animations";
|
||||
import { Box, Button, HStack, Input, InputGroup, InputRightAddon, Textarea, useDisclosure, Image, Icon, VStack, Text, useToast } from "@chakra-ui/react";
|
||||
import {
|
||||
FormControl,
|
||||
FormLabel,
|
||||
FormHelperText,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
InputGroup,
|
||||
InputRightAddon,
|
||||
Textarea,
|
||||
useDisclosure,
|
||||
Image,
|
||||
Icon,
|
||||
VStack,
|
||||
Text,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import { FormControl, FormLabel, FormHelperText } from "@chakra-ui/react";
|
||||
import { DeleteIcon, Search2Icon } from "@chakra-ui/icons";
|
||||
import SelectInvestorModal from "./SelectInvestorModal";
|
||||
import { Controller, useForm } from "react-hook-form"; // Import useForm
|
||||
import { yupResolver } from "@hookform/resolvers/yup"; // Import resolver for Yup
|
||||
import * as Yup from "yup"; // Import Yup for validation
|
||||
import { motion } from 'framer-motion'; // Import Framer Motion for animations
|
||||
import { motion } from "framer-motion"; // Import Framer Motion for animations
|
||||
import { bytesToMB } from "../../Constants/Constants";
|
||||
import { useCreateFawateerRequestMutation } from "../../Services/fawateer.maker.service";
|
||||
import ToastBox from "../../Components/ToastBox";
|
||||
@@ -23,60 +33,67 @@ 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')
|
||||
.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"),
|
||||
.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'),
|
||||
.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(),
|
||||
makerComment: Yup.string() .max(200, "Approve Comment cannot be more than 50 characters"),
|
||||
});
|
||||
|
||||
const CreateRequest = () => {
|
||||
const toast = useToast()
|
||||
const navigate=useNavigate()
|
||||
const toast = useToast();
|
||||
const navigate = useNavigate();
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const [selectedInvestor, setSelectorInvestor] = useState({});
|
||||
const [filePreview, setFilePreview] = useState(null); // State for previewing the file
|
||||
const [fileType, setFileType] = useState(null); // State to store file type for conditional rendering
|
||||
const[ isLoading, setIsLoading ] = useState(false)
|
||||
const [id, setId ] = useState(null)
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [id, setId] = useState(null);
|
||||
|
||||
// Initialize useForm with the resolver for Yup validation
|
||||
const {control, register, handleSubmit, setValue,reset, formState: { errors } } = useForm({
|
||||
const {
|
||||
control,
|
||||
register,
|
||||
watch,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
reset,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(validationSchema),
|
||||
});
|
||||
|
||||
|
||||
const [ creatFawaateerRequest ] = useCreateFawateerRequestMutation()
|
||||
|
||||
const [creatFawaateerRequest] = useCreateFawateerRequestMutation();
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
console.log(data);
|
||||
setIsLoading(true)
|
||||
|
||||
setIsLoading(true);
|
||||
|
||||
// Convert data to FormData
|
||||
const formData = new FormData();
|
||||
|
||||
// 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, data[key][0]); // Append the file
|
||||
} else {
|
||||
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, data[key][0]); // Append the file
|
||||
} else {
|
||||
formData.append(key, data[key]); // Append other fields
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
// Make the API call with formData
|
||||
const res = await creatFawaateerRequest({ data: formData, id });
|
||||
|
||||
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
@@ -84,39 +101,35 @@ const CreateRequest = () => {
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
reset()
|
||||
return
|
||||
reset();
|
||||
return;
|
||||
} else if (res?.data) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
setIsLoading(false);
|
||||
navigate('/fawateer-history')
|
||||
return
|
||||
navigate("/fawateer-history");
|
||||
return;
|
||||
} else {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
<ToastBox status={"error"} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"An error occurred"} />
|
||||
<ToastBox status={"error"} message={"An error occurred"} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
return
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Handle file change and preview
|
||||
const handleFileChange = (e) => {
|
||||
@@ -137,15 +150,12 @@ const CreateRequest = () => {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={38}>
|
||||
<Box
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
flexWrap={'wrap'}
|
||||
flexWrap={"wrap"}
|
||||
alignItems={"center"}
|
||||
mt={5}
|
||||
px={4}
|
||||
@@ -153,11 +163,16 @@ const CreateRequest = () => {
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
>
|
||||
{/* Investor Name Field */}
|
||||
<FormControl isRequired 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>
|
||||
<InputGroup size='sm'>
|
||||
<InputGroup size="sm">
|
||||
<Input
|
||||
bg={"#F5F8F6"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
@@ -170,11 +185,24 @@ const CreateRequest = () => {
|
||||
{...register("investorName")}
|
||||
_placeholder={{ fontSize: "sm" }}
|
||||
/>
|
||||
<InputRightAddon gap={2} color={'forestgreen.400'} onClick={onOpen} cursor={'pointer'} fontWeight={600} fontSize={'xs'}>
|
||||
<InputRightAddon
|
||||
gap={2}
|
||||
color={"forestgreen.400"}
|
||||
onClick={onOpen}
|
||||
cursor={"pointer"}
|
||||
fontWeight={600}
|
||||
fontSize={"xs"}
|
||||
>
|
||||
<Search2Icon /> Search
|
||||
</InputRightAddon>
|
||||
</InputGroup>
|
||||
<FormHelperText fontSize={'xs'} fontWeight={500} style={{ color: "red" }}>{errors.investorName?.message}</FormHelperText>
|
||||
<FormHelperText
|
||||
fontSize={"xs"}
|
||||
fontWeight={500}
|
||||
style={{ color: "red" }}
|
||||
>
|
||||
{errors.investorName?.message}
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
|
||||
{/* Client ID Field */}
|
||||
@@ -193,7 +221,13 @@ const CreateRequest = () => {
|
||||
placeholder={"Client ID"}
|
||||
{...register("clientId")}
|
||||
/>
|
||||
<FormHelperText fontSize={'xs'} fontWeight={500} style={{ color: "red" }}>{errors.clientId?.message}</FormHelperText>
|
||||
<FormHelperText
|
||||
fontSize={"xs"}
|
||||
fontWeight={500}
|
||||
style={{ color: "red" }}
|
||||
>
|
||||
{errors.clientId?.message}
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
|
||||
{/* Date Field */}
|
||||
@@ -208,10 +242,21 @@ const CreateRequest = () => {
|
||||
fontSize={"sm"}
|
||||
rounded={"sm"}
|
||||
type={"date"}
|
||||
max={new Date().toISOString().split("T")[0]} // Disable future dates
|
||||
{...register("transaction_date")}
|
||||
max={new Date().toLocaleDateString("en-CA")} // Ensures max is in local timezone
|
||||
{...register("transaction_date", {
|
||||
setValueAs: (value) => {
|
||||
// Convert date string to local timezone Date object
|
||||
return value ? new Date(value) : undefined;
|
||||
},
|
||||
})}
|
||||
/>
|
||||
<FormHelperText fontSize={'xs'} fontWeight={500} style={{ color: "red" }}>{errors.transaction_date?.message}</FormHelperText>
|
||||
<FormHelperText
|
||||
fontSize={"xs"}
|
||||
fontWeight={500}
|
||||
style={{ color: "red" }}
|
||||
>
|
||||
{errors.transaction_date?.message}
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
|
||||
{/* Amount Field */}
|
||||
@@ -220,19 +265,35 @@ const CreateRequest = () => {
|
||||
Amount (BHD)
|
||||
</FormLabel>
|
||||
<Controller
|
||||
name="transaction_amount"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<CurrencyInput bg={"#F5F8F6"} {...field} textAlign={'right'} fontSize={"sm"} type="number" size={"sm"} />
|
||||
)}
|
||||
/>
|
||||
<FormHelperText fontSize={'xs'} fontWeight={500} style={{ color: "red" }}>
|
||||
name="transaction_amount"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<CurrencyInput
|
||||
bg={"#F5F8F6"}
|
||||
{...field}
|
||||
textAlign={"right"}
|
||||
fontSize={"sm"}
|
||||
type="number"
|
||||
size={"sm"}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<FormHelperText
|
||||
fontSize={"xs"}
|
||||
fontWeight={500}
|
||||
style={{ color: "red" }}
|
||||
>
|
||||
{errors.transaction_amount?.message}
|
||||
</FormHelperText>
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
|
||||
{/* Support File Field with Preview */}
|
||||
<FormControl isRequired w={"49%"} mb={2} isInvalid={errors.spportFile_path}>
|
||||
<FormControl
|
||||
isRequired
|
||||
w={"49%"}
|
||||
mb={2}
|
||||
isInvalid={errors.spportFile_path}
|
||||
>
|
||||
<FormLabel textAlign={"left"} fontSize={"xs"} color={"gray.600"}>
|
||||
Support file
|
||||
</FormLabel>
|
||||
@@ -249,7 +310,13 @@ const CreateRequest = () => {
|
||||
{...register("spportFile_path")}
|
||||
// onChange={handleFileChange}
|
||||
/>
|
||||
<FormHelperText fontSize={'xs'} fontWeight={500} style={{ color: "red" }}>{errors.spportFile_path?.message}</FormHelperText>
|
||||
<FormHelperText
|
||||
fontSize={"xs"}
|
||||
fontWeight={500}
|
||||
style={{ color: "red" }}
|
||||
>
|
||||
{errors.spportFile_path?.message}
|
||||
</FormHelperText>
|
||||
|
||||
{/* Animated Preview */}
|
||||
{filePreview && fileType?.type.startsWith("image/") && (
|
||||
@@ -259,14 +326,55 @@ const CreateRequest = () => {
|
||||
transition={{ duration: 0.5 }}
|
||||
style={{ marginTop: "10px" }}
|
||||
>
|
||||
<Box position={'relative'} display={'flex'} alignContent={'flex-end'} gap={3} mt={2}>
|
||||
<Image src={filePreview} alt="File preview" maxW={"150px"} borderRadius="md" boxShadow="md" />
|
||||
<Icon onClick={()=> setFilePreview(null)} className="link" rounded={'md'} color={'red.700'} cursor={'pointer'} p={1.5} position={'absolute'} top={0} right={0} as={DeleteIcon} boxSize={7} />
|
||||
<VStack justifyItems={'flex-end'} alignItems={'flex-start'}>
|
||||
<Text as={'span'} color={'gray.600'} fontSize={'xs'}>File Name: <Text as={'span'} color={'GrayText'}> {fileType?.name}</Text></Text>
|
||||
<Text as={'span'} color={'gray.600'} fontSize={'xs'}>File Size: <Text as={'span'} color={'GrayText'}> {bytesToMB(fileType?.size)} Mb</Text></Text>
|
||||
<Text as={'span'} color={'gray.600'} fontSize={'xs'}>File Type: <Text as={'span'} color={'GrayText'}> {fileType?.type}</Text></Text>
|
||||
|
||||
<Box
|
||||
position={"relative"}
|
||||
display={"flex"}
|
||||
alignContent={"flex-end"}
|
||||
gap={3}
|
||||
mt={2}
|
||||
>
|
||||
<Image
|
||||
src={filePreview}
|
||||
alt="File preview"
|
||||
maxW={"150px"}
|
||||
borderRadius="md"
|
||||
boxShadow="md"
|
||||
/>
|
||||
<Icon
|
||||
onClick={() => setFilePreview(null)}
|
||||
className="link"
|
||||
rounded={"md"}
|
||||
color={"red.700"}
|
||||
cursor={"pointer"}
|
||||
p={1.5}
|
||||
position={"absolute"}
|
||||
top={0}
|
||||
right={0}
|
||||
as={DeleteIcon}
|
||||
boxSize={7}
|
||||
/>
|
||||
<VStack justifyItems={"flex-end"} alignItems={"flex-start"}>
|
||||
<Text as={"span"} color={"gray.600"} fontSize={"xs"}>
|
||||
File Name:{" "}
|
||||
<Text as={"span"} color={"GrayText"}>
|
||||
{" "}
|
||||
{fileType?.name}
|
||||
</Text>
|
||||
</Text>
|
||||
<Text as={"span"} color={"gray.600"} fontSize={"xs"}>
|
||||
File Size:{" "}
|
||||
<Text as={"span"} color={"GrayText"}>
|
||||
{" "}
|
||||
{bytesToMB(fileType?.size)} Mb
|
||||
</Text>
|
||||
</Text>
|
||||
<Text as={"span"} color={"gray.600"} fontSize={"xs"}>
|
||||
File Type:{" "}
|
||||
<Text as={"span"} color={"GrayText"}>
|
||||
{" "}
|
||||
{fileType?.type}
|
||||
</Text>
|
||||
</Text>
|
||||
</VStack>
|
||||
</Box>
|
||||
</motion.div>
|
||||
@@ -274,7 +382,7 @@ const CreateRequest = () => {
|
||||
</FormControl>
|
||||
|
||||
{/* Description Field */}
|
||||
<FormControl w={"100%"} mb={2} isInvalid={errors.makerComment}>
|
||||
<FormControl w={"100%"} mb={2} isInvalid={errors.makerComment}>
|
||||
<FormLabel textAlign={"left"} fontSize={"xs"} color={"gray.600"}>
|
||||
Description
|
||||
</FormLabel>
|
||||
@@ -286,13 +394,26 @@ const CreateRequest = () => {
|
||||
rounded={"sm"}
|
||||
placeholder={"Description"}
|
||||
{...register("makerComment")}
|
||||
maxLength={200}
|
||||
/>
|
||||
<FormHelperText fontSize={'xs'} fontWeight={500} style={{ color: "red" }}>{errors.makerComment?.message}</FormHelperText>
|
||||
<FormHelperText
|
||||
fontSize={"xs"}
|
||||
fontWeight={500}
|
||||
style={{ color: "red" }}
|
||||
>
|
||||
{errors.makerComment?.message}
|
||||
</FormHelperText>
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>
|
||||
Maximum length should be 200 characters. You have entered
|
||||
</Box>
|
||||
{watch("makerComment")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
|
||||
{/* Submit Button */}
|
||||
<HStack mt={2} w={'100%'} justifyContent={'flex-end'}>
|
||||
<Button
|
||||
<HStack mt={2} w={"100%"} justifyContent={"flex-end"}>
|
||||
<Button
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
@@ -305,7 +426,13 @@ const CreateRequest = () => {
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
<SelectInvestorModal setId={setId} setValue={setValue} onClose={onClose} isOpen={isOpen} onOpen={onOpen}/>
|
||||
<SelectInvestorModal
|
||||
setId={setId}
|
||||
setValue={setValue}
|
||||
onClose={onClose}
|
||||
isOpen={isOpen}
|
||||
onOpen={onOpen}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -138,7 +138,7 @@ import RequestRejectModal from "./RequestRejectModal";
|
||||
"Deposit Date",
|
||||
"Deposit Amount (BHD)",
|
||||
"Support Image",
|
||||
"Action",
|
||||
"Action",
|
||||
];
|
||||
|
||||
|
||||
|
||||
138
src/Pages/ForgetPassword.jsx
Normal file
138
src/Pages/ForgetPassword.jsx
Normal file
@@ -0,0 +1,138 @@
|
||||
import {
|
||||
Button,
|
||||
DrawerFooter,
|
||||
FormControl,
|
||||
FormErrorMessage,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Stack,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import * as yup from "yup";
|
||||
import React, { useState } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForgetPasswordMutation } from "../Services/forget.password.service";
|
||||
import ToastBox from "../Components/ToastBox";
|
||||
|
||||
const validationSchema = yup.object().shape({
|
||||
emailAddress: yup
|
||||
.string()
|
||||
.email("Invalid email format")
|
||||
.required("Email address is required")
|
||||
.min(6, "Email address must be at least 6 characters long")
|
||||
.max(255, "Email address can be at most 255 characters long"),
|
||||
});
|
||||
|
||||
const ForgetPassword = ({ isOpen, onClose, firstField }) => {
|
||||
const toast = useToast();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const [forgetPassword] = useForgetPasswordMutation();
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
reset, // Add reset from useForm
|
||||
} = useForm({
|
||||
resolver: yupResolver(validationSchema),
|
||||
});
|
||||
|
||||
const onSubmit = async (formData) => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const res = await forgetPassword(formData);
|
||||
if (res?.data?.statusCode === 200) {
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
handleClose();
|
||||
} else if (res?.error?.status === 400) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status="error" />
|
||||
),
|
||||
});
|
||||
handleClose();
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setIsLoading(false);
|
||||
onClose();
|
||||
reset(); // Reset form state when modal closes
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
isCentered
|
||||
isOpen={isOpen}
|
||||
onClose={handleClose}
|
||||
initialFocusRef={firstField}
|
||||
>
|
||||
<ModalOverlay />
|
||||
<ModalContent>
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalHeader fontSize="md">Forgot Password</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
<ModalBody pb={4}>
|
||||
<Stack spacing={4}>
|
||||
<FormControl isInvalid={errors.emailAddress} isRequired>
|
||||
<FormLabel fontSize="sm" mb={3} fontWeight={500}>
|
||||
Please Enter Email Address
|
||||
</FormLabel>
|
||||
<Controller
|
||||
name="emailAddress"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
size="md"
|
||||
fontSize="sm"
|
||||
focusBorderColor="forestGreen.300"
|
||||
rounded={4}
|
||||
type="text"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize="xs" fontWeight={500}>
|
||||
{errors.emailAddress?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
</Stack>
|
||||
</ModalBody>
|
||||
|
||||
<DrawerFooter mb={5}>
|
||||
<Button
|
||||
w="100%"
|
||||
colorScheme="forestGreen"
|
||||
rounded="md"
|
||||
size="md"
|
||||
type="submit"
|
||||
isLoading={isLoading}
|
||||
fontWeight={400}
|
||||
fontSize="sm"
|
||||
>
|
||||
Reset Password
|
||||
</Button>
|
||||
</DrawerFooter>
|
||||
</form>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ForgetPassword;
|
||||
@@ -56,7 +56,7 @@ const AddCashDetails = ({ isOpen, onClose, firstField, actionId, setActionId, da
|
||||
const [updateVideoArtifacts] = useUpdateVideoArtifactsMutation()
|
||||
// const {
|
||||
// data
|
||||
// } = useGetArtifactsQuery(id)
|
||||
// } = useGetArtifactsQuery(id)
|
||||
|
||||
const {
|
||||
control,
|
||||
@@ -91,11 +91,11 @@ const AddCashDetails = ({ isOpen, onClose, firstField, actionId, setActionId, da
|
||||
render: () => <ToastBox message={res?.error?.data?.message } status={"error"} />,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -8,8 +8,8 @@ import IODetails from "./IODetails";
|
||||
import KeyMerits from "./KeyMerits";
|
||||
import IOArtifacts from "./IOArtifacts";
|
||||
import Investors from "./Investors";
|
||||
import IOCashDetails from "./IOCashDetails";
|
||||
import IONAVDetails from "./IONAVDetails";
|
||||
// import IOCashDetails from "./IOCashDetailsold";
|
||||
// import IONAVDetails from "./IONAVDetailsOld";
|
||||
import InvestmentDocument from "./InvestmentDocument"; // Ensure this is the correct import
|
||||
import ViewIOdataHeader from "../ViewIO/ViewIOdataHeader";
|
||||
import { useParams } from "react-router-dom";
|
||||
@@ -17,6 +17,9 @@ import FullscreenLoaders from "../../../Components/Loaders/FullscreenLoaders";
|
||||
import { useGetIOprepopulateDataQuery } from "../../../Services/io.service";
|
||||
import UnderConstruction from "../../UnderConstruction";
|
||||
import Destribution from "./Destribution";
|
||||
import IOCashDetails from "./IOCashDetails/IOCashDetails";
|
||||
import IONAVDetails from "./IONAVDetails/IONAVDetails";
|
||||
import IOTransaction from "./IOTransaction/IOTransaction";
|
||||
|
||||
const CreateIO = () => {
|
||||
const id = useParams()?.id;
|
||||
@@ -75,6 +78,11 @@ const CreateIO = () => {
|
||||
Content: Destribution,
|
||||
isDisabled: id ? true : true,
|
||||
},
|
||||
{
|
||||
label: "IO Transaction",
|
||||
Content: IOTransaction,
|
||||
isDisabled: id ? true : true,
|
||||
},
|
||||
];
|
||||
|
||||
const [tabs, setTabs] = useState(initialTabsState);
|
||||
@@ -114,7 +122,8 @@ const CreateIO = () => {
|
||||
<Tab
|
||||
isDisabled={isDisabled}
|
||||
key={index}
|
||||
fontSize={"sm"}
|
||||
fontSize={"xs"}
|
||||
fontWeight={500}
|
||||
_selected={{
|
||||
color: "#004118",
|
||||
borderBottom: "2px solid #38a169",
|
||||
|
||||
@@ -1,37 +1,49 @@
|
||||
import React, { useContext, useEffect, useRef, useState } from 'react'
|
||||
import GlobalStateContext from '../../../Contexts/GlobalStateContext';
|
||||
import { Box, HStack, Input,Text, Table, Tbody, Th, Tr, Avatar, useDisclosure,Button, Badge } from '@chakra-ui/react';
|
||||
import { OPACITY_ON_LOAD } from '../../../Layout/animations';
|
||||
import Pagination from '../../../Components/Pagination';
|
||||
import NormalTable from '../../../Components/DataTable/NormalTable';
|
||||
import CustomAlertDialog from '../../../Components/CustomAlertDialog';
|
||||
import { formatDatee } from '../../../Components/FormField';
|
||||
import { AddIcon } from '@chakra-ui/icons';
|
||||
import AddIONav from './AddIONav';
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
|
||||
import {
|
||||
Box,
|
||||
HStack,
|
||||
Input,
|
||||
Text,
|
||||
Table,
|
||||
Tbody,
|
||||
Th,
|
||||
Tr,
|
||||
Avatar,
|
||||
useDisclosure,
|
||||
Button,
|
||||
Badge,
|
||||
} from "@chakra-ui/react";
|
||||
import { OPACITY_ON_LOAD } from "../../../Layout/animations";
|
||||
import Pagination from "../../../Components/Pagination";
|
||||
import NormalTable from "../../../Components/DataTable/NormalTable";
|
||||
import CustomAlertDialog from "../../../Components/CustomAlertDialog";
|
||||
import { formatDatee } from "../../../Components/FormField";
|
||||
import { AddIcon } from "@chakra-ui/icons";
|
||||
import AddIONav from "./AddIONav";
|
||||
|
||||
const Destribution = () => {
|
||||
const { navDetails, setNavDetails, IODetails } =
|
||||
useContext(GlobalStateContext);
|
||||
const firstField = useRef();
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
const firstField = useRef();
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
|
||||
console.log(IODetails?.ioNAVHistory);
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
};
|
||||
|
||||
console.log(IODetails?.ioNAVHistory);
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString('en-GB', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
const timer = setTimeout(() => {
|
||||
@@ -42,32 +54,38 @@ const Destribution = () => {
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
// Table setup
|
||||
const tableHeadRow = [
|
||||
// "Sr.No",
|
||||
"Date",
|
||||
"Amount",
|
||||
"% of Investment"
|
||||
];
|
||||
// Table setup
|
||||
const tableHeadRow = [
|
||||
// "Sr.No",
|
||||
"Date",
|
||||
"Amount",
|
||||
"% of Investment",
|
||||
];
|
||||
|
||||
// Table filter
|
||||
const filteredData = IODetails?.distributionToInvestor?.filter((item) => {
|
||||
const name = item?.transactionAmount;
|
||||
const searchLower = searchTerm.toLowerCase();
|
||||
const nameMatches = name.toLowerCase().includes(searchLower);
|
||||
return nameMatches;
|
||||
}).sort((b, a) => new Date(a.transactionDate) - new Date(b.transactionDate));
|
||||
// Table filter
|
||||
const filteredData = IODetails?.distributionToInvestor
|
||||
?.filter((item) => {
|
||||
const name = item?.transactionAmount;
|
||||
const searchLower = searchTerm.toLowerCase();
|
||||
const nameMatches = name.toLowerCase().includes(searchLower);
|
||||
return nameMatches;
|
||||
})
|
||||
.sort((b, a) => new Date(a.transactionDate) - new Date(b.transactionDate));
|
||||
|
||||
const extractedArray=filteredData?.map((item, index) => ({
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr.No": <Text
|
||||
justifyContent={"start"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-start web-text-small"
|
||||
>{item?.id}</Text>,
|
||||
"Date": (
|
||||
"Sr.No": (
|
||||
<Text
|
||||
justifyContent={"start"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-start web-text-small"
|
||||
>
|
||||
{item?.id}
|
||||
</Text>
|
||||
),
|
||||
Date: (
|
||||
<Text
|
||||
justifyContent={"center"}
|
||||
as={"span"}
|
||||
@@ -78,7 +96,7 @@ const Destribution = () => {
|
||||
{formatDate(item.transactionDate)}
|
||||
</Text>
|
||||
),
|
||||
"Amount": (
|
||||
Amount: (
|
||||
<Text
|
||||
justifyContent={"center"}
|
||||
as={"span"}
|
||||
@@ -86,11 +104,13 @@ const Destribution = () => {
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
<Badge ms={1} colorScheme="green" me={1}>$</Badge>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{`${parseFloat(item.transactionAmount || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}`}
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}`}
|
||||
</Text>
|
||||
),
|
||||
"% of Investment": (
|
||||
@@ -106,12 +126,8 @@ const Destribution = () => {
|
||||
),
|
||||
}));
|
||||
|
||||
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedNav = navDetails.filter(
|
||||
(sponsor) => sponsor.id !== actionId
|
||||
);
|
||||
const updatedNav = navDetails.filter((sponsor) => sponsor.id !== actionId);
|
||||
|
||||
setTimeout(() => {
|
||||
setNavDetails(updatedNav);
|
||||
@@ -121,12 +137,11 @@ const Destribution = () => {
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
|
||||
const Total = () => {
|
||||
return (
|
||||
<Table size="sm">
|
||||
<Tbody>
|
||||
<Tr backgroundColor="gray.50">
|
||||
<Tr backgroundColor="gray.50">
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
@@ -147,8 +162,13 @@ const Destribution = () => {
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
|
||||
<Badge ms={1} colorScheme="green" me={1}>$</Badge>{IODetails?.total_distributeToInvestor_amt?.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{IODetails?.total_distributeToInvestor_amt?.toLocaleString(
|
||||
undefined,
|
||||
{ minimumFractionDigits: 2, maximumFractionDigits: 2 }
|
||||
)}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
@@ -167,62 +187,52 @@ const Destribution = () => {
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} pb={0}>
|
||||
<Box bg="white.500">
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
pb={3}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
<NormalTable
|
||||
centered={true}
|
||||
emptyMessage={`We don't have any Sponers`}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={isLoading}
|
||||
viewActionId={actionId}
|
||||
setViewActionId={setActionId}
|
||||
total={<Total />}
|
||||
setMouseEnteredId={setMouseEnteredId}
|
||||
setMouseEntered={setMouseEntered}
|
||||
/>
|
||||
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
|
||||
return (<Box {...OPACITY_ON_LOAD} pb={0}>
|
||||
<Box bg="white.500">
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
pb={3}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
|
||||
</HStack>
|
||||
<AddIONav isOpen={isOpen} onClose={onClose} firstField={firstField} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
<NormalTable
|
||||
centered={true}
|
||||
emptyMessage={`We don't have any Sponers`}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={isLoading}
|
||||
viewActionId={actionId}
|
||||
setViewActionId={setActionId}
|
||||
total={<Total/>}
|
||||
setMouseEnteredId={setMouseEnteredId}
|
||||
setMouseEntered={setMouseEntered}
|
||||
/>
|
||||
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<AddIONav
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
firstField={firstField} />
|
||||
|
||||
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
export default Destribution
|
||||
export default Destribution;
|
||||
|
||||
@@ -116,7 +116,7 @@ const IOArtifacts = ({ enableNextTab, index, data }) => {
|
||||
setDeleteAlertVideo(false);
|
||||
setIsLoadingBtn(false);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} status="error" />,
|
||||
render: () => <ToastBox message={res?.data?.message} status="success" />,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -134,7 +134,7 @@ const IOArtifacts = ({ enableNextTab, index, data }) => {
|
||||
setDeleteAlertImage(false);
|
||||
setIsLoadingBtn(false);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} status="error" />,
|
||||
render: () => <ToastBox message={res?.data?.message} status="success" />,
|
||||
});
|
||||
|
||||
}
|
||||
@@ -372,7 +372,7 @@ const sortedDataVideo = [...(IObyID?.data?.artifactsVideo || [])]?.sort(
|
||||
Manage IO Images
|
||||
</Box>
|
||||
<HStack>
|
||||
|
||||
|
||||
|
||||
{IObyID?.data?.artifactsImage?.length !== 0 &&<SetDisplayOrderIOArtifactsImages data={sortedDataImage} />}
|
||||
<Button
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
DrawerOverlay,
|
||||
FormControl,
|
||||
FormErrorMessage,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Stack,
|
||||
@@ -26,7 +27,8 @@ import { useParams } from "react-router-dom";
|
||||
import ToastBox from "../../../Components/ToastBox";
|
||||
|
||||
const investmentVideoSchema = yup.object().shape({
|
||||
artifactName: yup.string().required("Artifact name is required"),
|
||||
artifactName: yup.string().required("Artifact name is required")
|
||||
.max(50, "Approve Comment cannot be more than 50 characters"),
|
||||
artifactStreamingURL: yup.string()
|
||||
.required("Artifact streaming URL is required")
|
||||
.url("Invalid URL format"),
|
||||
@@ -152,21 +154,25 @@ const IOArtifactsAdd = ({ isOpen, onClose, firstField, actionId, setActionId, da
|
||||
|
||||
<DrawerBody>
|
||||
<Stack spacing={4}>
|
||||
<FormControl isInvalid={errors.artifactName}>
|
||||
<FormControl isInvalid={errors.artifactName} isRequired>
|
||||
<FormLabel fontSize={"sm"}>Artifact Name</FormLabel>
|
||||
<Controller
|
||||
name="artifactName"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input {...field} fontSize={"sm"} type="text" size={"sm"} />
|
||||
<Input {...field} fontSize={"sm"} type="text" size={"sm"} maxLength={50} />
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.artifactName?.message}
|
||||
</FormErrorMessage>
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 50 characters. You have entered </Box>
|
||||
{watch("artifactName")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
|
||||
<FormControl isInvalid={errors.artifactStreamingURL}>
|
||||
<FormControl isInvalid={errors.artifactStreamingURL} isRequired>
|
||||
<FormLabel fontSize={"sm"}>Artifact Streaming URL</FormLabel>
|
||||
<Controller
|
||||
name="artifactStreamingURL"
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Drawer,
|
||||
DrawerBody,
|
||||
DrawerCloseButton,
|
||||
DrawerContent,
|
||||
DrawerFooter,
|
||||
DrawerHeader,
|
||||
DrawerOverlay,
|
||||
FormControl,
|
||||
FormErrorMessage,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Select,
|
||||
Stack,
|
||||
Textarea,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import * as yup from "yup";
|
||||
import React, { useState, useEffect, useContext } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { useParams } from "react-router-dom";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import { useCreateIoCashMutation, useCreateVideoArtifactsMutation, useUpdateVideoArtifactsMutation } from "../../../../Services/io.service";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import CurrencyInput from "../../../../Components/CurrencyInput";
|
||||
|
||||
const cashDetails = yup.object().shape({
|
||||
transactionDate: yup.string().required("Date is required"),
|
||||
ioTransType_xid: yup.number().required("Cash transaction is required"),
|
||||
transactionAmount: yup.number().required("Transaction Amount is required"),
|
||||
comments: yup.string().notRequired()
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const AddCaseDetails = ({ isOpen, onClose, firstField, actionId, setActionId, data, setActiveTab }) => {
|
||||
const params = useParams()
|
||||
const id = params?.id
|
||||
const [file, setFile] = useState("");
|
||||
const [fileName, setFileName] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [alert, setAlert] = useState(false);
|
||||
const toast = useToast();
|
||||
|
||||
console.log(isOpen);
|
||||
|
||||
|
||||
|
||||
|
||||
// ======================[ Cotext Api ]
|
||||
const { IODetails } = useContext(GlobalStateContext);
|
||||
const found = data?.find((item) => item?.id === actionId);
|
||||
|
||||
|
||||
const [createArtifactsVideo] = useCreateVideoArtifactsMutation()
|
||||
const [updateVideoArtifacts] = useUpdateVideoArtifactsMutation()
|
||||
// const {
|
||||
// data
|
||||
// } = useGetArtifactsQuery(id)
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
watch,
|
||||
reset,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(cashDetails),
|
||||
});
|
||||
|
||||
|
||||
const [createIoCash] = useCreateIoCashMutation()
|
||||
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
|
||||
setIsLoading(true)
|
||||
|
||||
try {
|
||||
|
||||
const res = await createIoCash({ data, id })
|
||||
if (res?.data) {
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
handleClose()
|
||||
setActiveTab(1)
|
||||
}else if(res?.error){
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.error?.data?.message } status={"error"} />,
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
const handleConfirm = () => {
|
||||
handleSubmit(onSubmit)();
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
handleSubmit(onSubmit)();
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setAlert(false)
|
||||
onClose()
|
||||
reset({
|
||||
transactionAmount:""
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Drawer
|
||||
size={"md"}
|
||||
isOpen={isOpen}
|
||||
placement="right"
|
||||
initialFocusRef={firstField}
|
||||
onClose={handleClose}
|
||||
>
|
||||
<DrawerOverlay />
|
||||
<DrawerContent>
|
||||
<DrawerCloseButton />
|
||||
<DrawerHeader fontSize={"sm"}>IO Cash Details</DrawerHeader>
|
||||
|
||||
<DrawerBody>
|
||||
<Stack spacing={4}>
|
||||
<FormControl isInvalid={errors.transactionDate} isRequired>
|
||||
<FormLabel fontSize={"sm"}>Date Selection</FormLabel>
|
||||
<Controller
|
||||
name="transactionDate"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
focusBorderColor="forestGreen.300" {...field} fontSize={"sm"} type="date" size={"sm"} />
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.transactionDate?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
|
||||
<FormControl isInvalid={errors.ioTransType_xid} isRequired>
|
||||
<FormLabel fontSize={"sm"}>Cash transaction</FormLabel>
|
||||
<Controller
|
||||
name="ioTransType_xid"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
{...field}
|
||||
placeholder="Select an option"
|
||||
fontSize={"sm"}
|
||||
size={"sm"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
>
|
||||
{IODetails?.ioCashTransaction?.map(({ id, transactionName }) => (
|
||||
<option key={id} value={id}>
|
||||
{transactionName}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.ioTransType_xid?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
|
||||
|
||||
|
||||
<FormControl isInvalid={errors.transactionAmount} isRequired>
|
||||
<FormLabel fontSize={"sm"}>Transaction Amount</FormLabel>
|
||||
<Controller
|
||||
name="transactionAmount"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<CurrencyInput {...field} textAlign={'right'} fontSize={"sm"} type="number" size={"sm"} />
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.transactionAmount?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
|
||||
|
||||
<FormControl isInvalid={errors.comments}>
|
||||
<FormLabel fontSize={"sm"}>Comment</FormLabel>
|
||||
<Controller
|
||||
name="comments"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Textarea {...field} textAlign={'left'}
|
||||
maxLength={200}
|
||||
focusBorderColor="forestGreen.300" fontSize={"sm"} type="text" size={"sm"} />
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.comments?.message}
|
||||
</FormErrorMessage>
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered </Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
|
||||
</Stack>
|
||||
</DrawerBody>
|
||||
|
||||
<DrawerFooter>
|
||||
<Button
|
||||
variant="outline"
|
||||
colorScheme={"forestGreen"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
mr={3}
|
||||
onClick={handleClose}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
colorScheme={"forestGreen"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
|
||||
onClick={() => setAlert(true)}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
</DrawerFooter>
|
||||
</DrawerContent>
|
||||
</Drawer>
|
||||
|
||||
|
||||
<CustomAlertDialog
|
||||
isOpen={alert}
|
||||
onClose={() => setAlert(false)}
|
||||
alertHandler={handleSave}
|
||||
message={"Are you sure you want to add cash details?"}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddCaseDetails;
|
||||
251
src/Pages/IO_Management/CreateIO/IOCashDetails/AddPending.jsx
Normal file
251
src/Pages/IO_Management/CreateIO/IOCashDetails/AddPending.jsx
Normal file
@@ -0,0 +1,251 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Drawer,
|
||||
DrawerBody,
|
||||
DrawerCloseButton,
|
||||
DrawerContent,
|
||||
DrawerFooter,
|
||||
DrawerHeader,
|
||||
DrawerOverlay,
|
||||
FormControl,
|
||||
FormErrorMessage,
|
||||
FormLabel,
|
||||
Input,
|
||||
Select,
|
||||
Stack,
|
||||
Textarea,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import * as yup from "yup";
|
||||
import React, { useState, useEffect, useContext } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { useParams } from "react-router-dom";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import { useCreateIoCashMutation, useCreateVideoArtifactsMutation, useUpdateVideoArtifactsMutation } from "../../../../Services/io.service";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import CurrencyInput from "../../../../Components/CurrencyInput";
|
||||
|
||||
const cashDetails = yup.object().shape({
|
||||
transactionDate: yup.string().required("Date is required"),
|
||||
ioTransType_xid: yup.number().required("Cash transaction is required"),
|
||||
transactionAmount: yup.number().required("Transaction Amount is required"),
|
||||
comments: yup.string().notRequired(),
|
||||
});
|
||||
|
||||
const AddPending = ({ isOpen, onClose, firstField, actionId, setActionId, data }) => {
|
||||
const params = useParams()
|
||||
const id = params?.id
|
||||
const [file, setFile] = useState("");
|
||||
const [fileName, setFileName] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [alert, setAlert] = useState(false);
|
||||
const toast = useToast();
|
||||
|
||||
|
||||
|
||||
// ======================[ Cotext Api ]
|
||||
const { IODetails } = useContext(GlobalStateContext);
|
||||
const found = data?.find((item) => item?.id === actionId);
|
||||
|
||||
|
||||
const [createArtifactsVideo] = useCreateVideoArtifactsMutation()
|
||||
const [updateVideoArtifacts] = useUpdateVideoArtifactsMutation()
|
||||
// const {
|
||||
// data
|
||||
// } = useGetArtifactsQuery(id)
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
watch,
|
||||
reset,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(cashDetails),
|
||||
});
|
||||
|
||||
|
||||
const [createIoCash] = useCreateIoCashMutation()
|
||||
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
|
||||
setIsLoading(true)
|
||||
|
||||
try {
|
||||
|
||||
const res = await createIoCash({ data, id })
|
||||
if (res?.data?.statusCode === 200) {
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
handleClose()
|
||||
}else if(res?.error?.status === 400){
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.error?.data?.message } status={"error"} />,
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
const handleConfirm = () => {
|
||||
handleSubmit(onSubmit)();
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
handleSubmit(onSubmit)();
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setAlert(false)
|
||||
onClose()
|
||||
reset({
|
||||
transactionAmount:""
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Drawer
|
||||
size={"md"}
|
||||
isOpen={isOpen}
|
||||
placement="right"
|
||||
initialFocusRef={firstField}
|
||||
onClose={handleClose}
|
||||
>
|
||||
<DrawerOverlay />
|
||||
<DrawerContent>
|
||||
<DrawerCloseButton />
|
||||
<DrawerHeader fontSize={"sm"}>IO Cash Details</DrawerHeader>
|
||||
|
||||
<DrawerBody>
|
||||
<Stack spacing={4}>
|
||||
<FormControl isInvalid={errors.transactionDate} isRequired>
|
||||
<FormLabel fontSize={"sm"}>Date Selection</FormLabel>
|
||||
<Controller
|
||||
name="transactionDate"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
focusBorderColor="forestGreen.300" {...field} fontSize={"sm"} type="date" size={"sm"} />
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.transactionDate?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
|
||||
<FormControl isInvalid={errors.ioTransType_xid} isRequired>
|
||||
<FormLabel fontSize={"sm"}>Cash transaction</FormLabel>
|
||||
<Controller
|
||||
name="ioTransType_xid"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
{...field}
|
||||
placeholder="Select an option"
|
||||
fontSize={"sm"}
|
||||
size={"sm"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
>
|
||||
{IODetails?.ioCashTransaction?.map(({ id, transactionName }) => (
|
||||
<option key={id} value={id}>
|
||||
{transactionName}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.ioTransType_xid?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
|
||||
|
||||
|
||||
<FormControl isInvalid={errors.transactionAmount} isRequired>
|
||||
<FormLabel fontSize={"sm"}>Transaction Amount</FormLabel>
|
||||
<Controller
|
||||
name="transactionAmount"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<CurrencyInput {...field} textAlign={'right'} fontSize={"sm"} type="number" size={"sm"} />
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.transactionAmount?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
|
||||
|
||||
<FormControl isInvalid={errors.comments}>
|
||||
<FormLabel fontSize={"sm"}>Comments</FormLabel>
|
||||
<Controller
|
||||
name="comments"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Textarea {...field} textAlign={'left'}
|
||||
focusBorderColor="forestGreen.300" fontSize={"sm"} type="text" size={"sm"} />
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.comments?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
</Stack>
|
||||
</DrawerBody>
|
||||
|
||||
<DrawerFooter>
|
||||
<Button
|
||||
variant="outline"
|
||||
colorScheme={"forestGreen"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
mr={3}
|
||||
onClick={handleClose}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
colorScheme={"forestGreen"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
|
||||
onClick={() => setAlert(true)}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
</DrawerFooter>
|
||||
</DrawerContent>
|
||||
</Drawer>
|
||||
|
||||
|
||||
<CustomAlertDialog
|
||||
isOpen={alert}
|
||||
onClose={() => setAlert(false)}
|
||||
alertHandler={handleSave}
|
||||
message={"Are you sure you want to add cash details?"}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddPending;
|
||||
251
src/Pages/IO_Management/CreateIO/IOCashDetails/AddRejected.jsx
Normal file
251
src/Pages/IO_Management/CreateIO/IOCashDetails/AddRejected.jsx
Normal file
@@ -0,0 +1,251 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Drawer,
|
||||
DrawerBody,
|
||||
DrawerCloseButton,
|
||||
DrawerContent,
|
||||
DrawerFooter,
|
||||
DrawerHeader,
|
||||
DrawerOverlay,
|
||||
FormControl,
|
||||
FormErrorMessage,
|
||||
FormLabel,
|
||||
Input,
|
||||
Select,
|
||||
Stack,
|
||||
Textarea,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import * as yup from "yup";
|
||||
import React, { useState, useEffect, useContext } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { useParams } from "react-router-dom";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import { useCreateIoCashMutation, useCreateVideoArtifactsMutation, useUpdateVideoArtifactsMutation } from "../../../../Services/io.service";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import CurrencyInput from "../../../../Components/CurrencyInput";
|
||||
|
||||
const cashDetails = yup.object().shape({
|
||||
transactionDate: yup.string().required("Date is required"),
|
||||
ioTransType_xid: yup.number().required("Cash transaction is required"),
|
||||
transactionAmount: yup.number().required("Transaction Amount is required"),
|
||||
comments: yup.string().notRequired(),
|
||||
});
|
||||
|
||||
const AddRejected = ({ isOpen, onClose, firstField, actionId, setActionId, data }) => {
|
||||
const params = useParams()
|
||||
const id = params?.id
|
||||
const [file, setFile] = useState("");
|
||||
const [fileName, setFileName] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [alert, setAlert] = useState(false);
|
||||
const toast = useToast();
|
||||
|
||||
|
||||
|
||||
// ======================[ Cotext Api ]
|
||||
const { IODetails } = useContext(GlobalStateContext);
|
||||
const found = data?.find((item) => item?.id === actionId);
|
||||
|
||||
|
||||
const [createArtifactsVideo] = useCreateVideoArtifactsMutation()
|
||||
const [updateVideoArtifacts] = useUpdateVideoArtifactsMutation()
|
||||
// const {
|
||||
// data
|
||||
// } = useGetArtifactsQuery(id)
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
watch,
|
||||
reset,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(cashDetails),
|
||||
});
|
||||
|
||||
|
||||
const [createIoCash] = useCreateIoCashMutation()
|
||||
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
|
||||
setIsLoading(true)
|
||||
|
||||
try {
|
||||
|
||||
const res = await createIoCash({ data, id })
|
||||
if (res?.data?.statusCode === 200) {
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
handleClose()
|
||||
}else if(res?.error?.status === 400){
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.error?.data?.message } status={"error"} />,
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
const handleConfirm = () => {
|
||||
handleSubmit(onSubmit)();
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
handleSubmit(onSubmit)();
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setAlert(false)
|
||||
onClose()
|
||||
reset({
|
||||
transactionAmount:""
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Drawer
|
||||
size={"md"}
|
||||
isOpen={isOpen}
|
||||
placement="right"
|
||||
initialFocusRef={firstField}
|
||||
onClose={handleClose}
|
||||
>
|
||||
<DrawerOverlay />
|
||||
<DrawerContent>
|
||||
<DrawerCloseButton />
|
||||
<DrawerHeader fontSize={"sm"}>IO Cash Details</DrawerHeader>
|
||||
|
||||
<DrawerBody>
|
||||
<Stack spacing={4}>
|
||||
<FormControl isInvalid={errors.transactionDate} isRequired>
|
||||
<FormLabel fontSize={"sm"}>Date Selection</FormLabel>
|
||||
<Controller
|
||||
name="transactionDate"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
focusBorderColor="forestGreen.300" {...field} fontSize={"sm"} type="date" size={"sm"} />
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.transactionDate?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
|
||||
<FormControl isInvalid={errors.ioTransType_xid} isRequired>
|
||||
<FormLabel fontSize={"sm"}>Cash transaction</FormLabel>
|
||||
<Controller
|
||||
name="ioTransType_xid"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
{...field}
|
||||
placeholder="Select an option"
|
||||
fontSize={"sm"}
|
||||
size={"sm"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
>
|
||||
{IODetails?.ioCashTransaction?.map(({ id, transactionName }) => (
|
||||
<option key={id} value={id}>
|
||||
{transactionName}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.ioTransType_xid?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
|
||||
|
||||
|
||||
<FormControl isInvalid={errors.transactionAmount} isRequired>
|
||||
<FormLabel fontSize={"sm"}>Transaction Amount</FormLabel>
|
||||
<Controller
|
||||
name="transactionAmount"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<CurrencyInput {...field} textAlign={'right'} fontSize={"sm"} type="number" size={"sm"} />
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.transactionAmount?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
|
||||
|
||||
<FormControl isInvalid={errors.comments}>
|
||||
<FormLabel fontSize={"sm"}>Comments</FormLabel>
|
||||
<Controller
|
||||
name="comments"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Textarea {...field} textAlign={'left'}
|
||||
focusBorderColor="forestGreen.300" fontSize={"sm"} type="text" size={"sm"} />
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.comments?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
</Stack>
|
||||
</DrawerBody>
|
||||
|
||||
<DrawerFooter>
|
||||
<Button
|
||||
variant="outline"
|
||||
colorScheme={"forestGreen"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
mr={3}
|
||||
onClick={handleClose}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
colorScheme={"forestGreen"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
|
||||
onClick={() => setAlert(true)}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
</DrawerFooter>
|
||||
</DrawerContent>
|
||||
</Drawer>
|
||||
|
||||
|
||||
<CustomAlertDialog
|
||||
isOpen={alert}
|
||||
onClose={() => setAlert(false)}
|
||||
alertHandler={handleSave}
|
||||
message={"Are you sure you want to add cash details?"}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddRejected;
|
||||
397
src/Pages/IO_Management/CreateIO/IOCashDetails/Approved.jsx
Normal file
397
src/Pages/IO_Management/CreateIO/IOCashDetails/Approved.jsx
Normal file
@@ -0,0 +1,397 @@
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
Table,
|
||||
Tag,
|
||||
Tbody,
|
||||
Text,
|
||||
Th,
|
||||
Tooltip,
|
||||
Tr,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import { AddIcon, DeleteIcon, EditIcon, ViewIcon } from "@chakra-ui/icons";
|
||||
import { LuFileSpreadsheet } from "react-icons/lu";
|
||||
import * as XLSX from "xlsx";
|
||||
import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
|
||||
import NormalTable from "../../../../Components/DataTable/NormalTable";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import AddCashDetails from "../AddCashDetails";
|
||||
import { debounce } from "../../../Admin/Contact";
|
||||
import AddApproved from "./AddCaseDetails";
|
||||
import { useUpdateIOCaseMutation } from "../../../../Services/io.service";
|
||||
import { useParams } from "react-router-dom";
|
||||
import AddCaseDetails from "./AddCaseDetails";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString();
|
||||
|
||||
const Approved = () => {
|
||||
const firstField = useRef();
|
||||
const params = useParams();
|
||||
const toast = useToast();
|
||||
const id = params?.id;
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const { IODetails, approved, setApproved } = useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
const timer = setTimeout(() => {
|
||||
setIsLoading(false);
|
||||
}, 1500);
|
||||
|
||||
// Cleanup the timer on component unmount
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
};
|
||||
|
||||
console.log("==============", IODetails?.ioCashStatusHistory?.Approved);
|
||||
|
||||
// Table filter
|
||||
const filteredData = IODetails?.ioCashStatusHistory?.Approved?.filter(
|
||||
(item) => {
|
||||
// Filter by name (case insensitive)
|
||||
const name = item.transactionDate;
|
||||
const searchLower = searchTerm.toLowerCase();
|
||||
const nameMatches = name.toLowerCase().includes(searchLower);
|
||||
return nameMatches;
|
||||
}
|
||||
);
|
||||
|
||||
const [updateIOCase] = useUpdateIOCaseMutation();
|
||||
|
||||
const tableHeadRow = [
|
||||
"Sr No.",
|
||||
"Transaction Date",
|
||||
"Transaction Type",
|
||||
"Amount",
|
||||
"Comments",
|
||||
"Update By",
|
||||
"Update On",
|
||||
];
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr No.": (
|
||||
<Text as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{index + 1}.
|
||||
</Text>
|
||||
),
|
||||
"Transaction Date": (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
{formatDate(item?.transactionDate)}
|
||||
</Text>
|
||||
),
|
||||
"Transaction Type": (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
{item?.transactionType}
|
||||
</Text>
|
||||
),
|
||||
Amount: (
|
||||
<Text as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{parseFloat(item?.transactionAmount || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
),
|
||||
Comments: (
|
||||
<Text w={"100px"} as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{item?.comments ? item?.comments : "---"}
|
||||
</Text>
|
||||
),
|
||||
"Update By": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
display={"flex"}
|
||||
alignItems={"center"}
|
||||
>
|
||||
{/* <Avatar
|
||||
mr={2}
|
||||
size="sm"
|
||||
name={item.creator?.firstName}
|
||||
src={item.creator?.profilePhoto}
|
||||
/> */}
|
||||
{item?.modifier?.firstName}
|
||||
</Text>
|
||||
),
|
||||
"Update On": (
|
||||
<Text w={"100px"} as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{formatDate(item.updatedAt)}
|
||||
</Text>
|
||||
),
|
||||
}));
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedSponsors = sponser.filter(
|
||||
(sponsor) => sponsor.id !== actionId
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
setCaseDetails(updatedSponsors);
|
||||
setDeleteAlert(false);
|
||||
setIsLoading(false);
|
||||
}, 100);
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
const ioCashExporteDetails = IODetails?.ioCashStatusHistory?.Approved?.map(
|
||||
(item, index) => ({
|
||||
"Transaction date": item?.transactionDate,
|
||||
"Transaction type": item?.transactionType,
|
||||
Amount: parseFloat(item?.transactionAmount) || 0,
|
||||
Comments: item?.comments,
|
||||
})
|
||||
);
|
||||
|
||||
const exportToExcelNew = (data, fileName) => {
|
||||
const worksheet = XLSX.utils.json_to_sheet(data);
|
||||
const workbook = XLSX.utils.book_new();
|
||||
XLSX.utils.book_append_sheet(workbook, worksheet, "Sheet1");
|
||||
|
||||
// Export file
|
||||
XLSX.writeFile(workbook, `${fileName}.xlsx`);
|
||||
};
|
||||
|
||||
const Total = () => {
|
||||
return (
|
||||
<Table size="sm">
|
||||
<Tbody backgroundColor="gray.50">
|
||||
<Tr>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="200px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
Balance in IO Cash
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="120px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
{" "}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="120px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
{" "}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="140px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{/* {IODetails?.ioCash} */}
|
||||
{parseFloat(IODetails?.ioCash || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="120px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
{}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="100px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
{" "}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="100px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
></Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="100px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
></Th>
|
||||
</Tr>
|
||||
</Tbody>
|
||||
</Table>
|
||||
);
|
||||
};
|
||||
|
||||
const handleAdd = async () => {
|
||||
try {
|
||||
const res = await updateIOCase(id);
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={res?.data?.message} />
|
||||
// ),
|
||||
// });
|
||||
setIsLoading(false);
|
||||
onOpen();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} pb={0}>
|
||||
<Box bg="white.500">
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
pb={3}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
|
||||
<HStack display={"flex"} alignItems={"center"}>
|
||||
<Button
|
||||
onClick={() =>
|
||||
exportToExcelNew(ioCashExporteDetails, "IO Cash History")
|
||||
}
|
||||
leftIcon={<LuFileSpreadsheet />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
variant={"outline"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
isDisabled={ioCashExporteDetails?.length === 0}
|
||||
>
|
||||
Export xls
|
||||
</Button>
|
||||
{/* <Button
|
||||
onClick={onOpen}
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme={"forestGreen"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
size={"sm"}
|
||||
fontWeight={500}
|
||||
>
|
||||
Add
|
||||
</Button> */}
|
||||
{/* {IODetails?.isInvestedAmount ? (
|
||||
localStorage?.getItem('role') ==="Maker" && <Button
|
||||
onClick={handleAdd}
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
>
|
||||
Add
|
||||
</Button>
|
||||
) : null} */}
|
||||
</HStack>
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
<NormalTable
|
||||
emptyMessage={`We don't have any Sponers`}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={isLoading}
|
||||
viewActionId={actionId}
|
||||
setViewActionId={setActionId}
|
||||
total={<Total />}
|
||||
setMouseEnteredId={setMouseEnteredId}
|
||||
setMouseEntered={setMouseEntered}
|
||||
/>
|
||||
|
||||
{/* <CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/> */}
|
||||
|
||||
<AddCaseDetails
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
firstField={firstField}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Approved;
|
||||
147
src/Pages/IO_Management/CreateIO/IOCashDetails/IOCashDetails.jsx
Normal file
147
src/Pages/IO_Management/CreateIO/IOCashDetails/IOCashDetails.jsx
Normal file
@@ -0,0 +1,147 @@
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Tab,
|
||||
TabList,
|
||||
TabPanel,
|
||||
TabPanels,
|
||||
Tabs,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useRef, useState } from "react";
|
||||
import Approved from "./Approved";
|
||||
import Pending from "./Pending";
|
||||
import Rejected from "./Rejected";
|
||||
import { AddIcon } from "@chakra-ui/icons";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import AddCaseDetails from "./AddCaseDetails";
|
||||
import { useUpdateIOCaseMutation } from "../../../../Services/io.service";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { encryptString, isMaker } from "../../../../Constants/Constants";
|
||||
|
||||
const IOCashDetails = () => {
|
||||
const params = useParams();
|
||||
const toast = useToast();
|
||||
const id = params?.id;
|
||||
const { IODetails } = useContext(GlobalStateContext);
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const firstField = useRef();
|
||||
|
||||
const [updateIOCase] = useUpdateIOCaseMutation();
|
||||
const [activeTab, setActiveTab] = useState(0);
|
||||
|
||||
const handleAdd = async () => {
|
||||
try {
|
||||
const res = await updateIOCase(id);
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={"res?.data?.message"} />
|
||||
// ),
|
||||
// });
|
||||
// setIsLoading(false);
|
||||
onOpen();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Tabs
|
||||
index={activeTab}
|
||||
onChange={(index) => setActiveTab(index)}
|
||||
variant="unstyled"
|
||||
>
|
||||
<Box
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
alignItems={"center"}
|
||||
borderBottom={"1px solid #ccc"}
|
||||
>
|
||||
<TabList>
|
||||
<Tab
|
||||
fontSize={"sm"}
|
||||
_selected={{
|
||||
color: "#004118",
|
||||
borderBottom: "2px solid #38a169",
|
||||
}}
|
||||
>
|
||||
Approved
|
||||
</Tab>
|
||||
<Tab
|
||||
fontSize={"sm"}
|
||||
_selected={{
|
||||
color: "#004118",
|
||||
borderBottom: "2px solid #38a169",
|
||||
}}
|
||||
>
|
||||
Pending
|
||||
{IODetails?.ioCashStatusHistory?.Pending.length > 0 && (
|
||||
<Badge rounded={"sm"} colorScheme="forestGreen" ms={2}>
|
||||
{IODetails?.ioCashStatusHistory?.Pending.length !== 0 &&
|
||||
IODetails?.ioCashStatusHistory?.Pending.length}
|
||||
</Badge>
|
||||
)}
|
||||
{/* <Badge rounded={"sm"} colorScheme="forestGreen" ms={2}>
|
||||
{IODetails?.ioCashStatusHistory?.Pending.length || 0}
|
||||
</Badge> */}
|
||||
</Tab>
|
||||
<Tab
|
||||
fontSize={"sm"}
|
||||
_selected={{
|
||||
color: "#004118",
|
||||
borderBottom: "2px solid #38a169",
|
||||
}}
|
||||
>
|
||||
Rejected
|
||||
</Tab>
|
||||
</TabList>
|
||||
{IODetails?.isInvestedAmount
|
||||
? isMaker() &&
|
||||
IODetails?.ioSatatus !== "Exited" && (
|
||||
<Button
|
||||
onClick={handleAdd}
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
>
|
||||
Add
|
||||
</Button>
|
||||
)
|
||||
: null}
|
||||
</Box>
|
||||
<TabPanels>
|
||||
<TabPanel>
|
||||
<Approved />
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<Pending />
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<Rejected />
|
||||
</TabPanel>
|
||||
</TabPanels>
|
||||
</Tabs>
|
||||
<AddCaseDetails
|
||||
setActiveTab={setActiveTab}
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
firstField={firstField}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default IOCashDetails;
|
||||
471
src/Pages/IO_Management/CreateIO/IOCashDetails/Pending.jsx
Normal file
471
src/Pages/IO_Management/CreateIO/IOCashDetails/Pending.jsx
Normal file
@@ -0,0 +1,471 @@
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
Table,
|
||||
Tag,
|
||||
Tbody,
|
||||
Text,
|
||||
Th,
|
||||
Tooltip,
|
||||
Tr,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
AddIcon,
|
||||
CheckIcon,
|
||||
CloseIcon,
|
||||
DeleteIcon,
|
||||
EditIcon,
|
||||
ViewIcon,
|
||||
} from "@chakra-ui/icons";
|
||||
import { LuFileSpreadsheet } from "react-icons/lu";
|
||||
import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
|
||||
import NormalTable from "../../../../Components/DataTable/NormalTable";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import AddCashDetails from "../AddCashDetails";
|
||||
import { debounce } from "../../../Admin/Contact";
|
||||
import AddPending from "./AddPending";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useUpdateIOCaseMutation } from "../../../../Services/io.service";
|
||||
import RequestApproveModal from "./RequestApproveModal";
|
||||
import RequestRejectModal from "./RequestRejectModal";
|
||||
import AddCaseDetails from "./AddCaseDetails";
|
||||
import { encryptString, isMaker } from "../../../../Constants/Constants";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString();
|
||||
|
||||
const Pending = () => {
|
||||
const toast = useToast();
|
||||
const params = useParams();
|
||||
const id = params?.id;
|
||||
const firstField = useRef();
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const { IODetails, approved, setApproved } = useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
|
||||
const [updateIOCase] = useUpdateIOCaseMutation();
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
onOpen: onConfirmOpen,
|
||||
onClose: onConfirmClose,
|
||||
} = useDisclosure();
|
||||
const {
|
||||
isOpen: isRejectOpen,
|
||||
onOpen: onRejectOpen,
|
||||
onClose: onRejectClose,
|
||||
} = useDisclosure();
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
const timer = setTimeout(() => {
|
||||
setIsLoading(false);
|
||||
}, 1500);
|
||||
|
||||
// Cleanup the timer on component unmount
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
};
|
||||
|
||||
// Table filter
|
||||
const filteredData = IODetails?.ioCashStatusHistory?.Pending?.filter(
|
||||
(item) => {
|
||||
// Filter by name (case insensitive)
|
||||
const name = item?.transactionDate;
|
||||
const searchLower = searchTerm?.toLowerCase();
|
||||
const nameMatches = name?.toLowerCase().includes(searchLower);
|
||||
return nameMatches;
|
||||
}
|
||||
);
|
||||
|
||||
const tableHeadRow = [
|
||||
"Sr No.",
|
||||
"Transaction Date",
|
||||
"Transaction Type",
|
||||
"Amount",
|
||||
"Comments",
|
||||
"Update By",
|
||||
"Update On",
|
||||
...(!isMaker() ? ["Actions"] : []),
|
||||
];
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr No.": (
|
||||
<Text as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{index + 1}.
|
||||
</Text>
|
||||
),
|
||||
"Transaction Date": (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
{formatDate(item?.transactionDate)}
|
||||
</Text>
|
||||
),
|
||||
"Transaction Type": (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
{item?.transactionType}
|
||||
</Text>
|
||||
),
|
||||
Amount: (
|
||||
<Text as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{parseFloat(item?.transactionAmount || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
),
|
||||
Comments: (
|
||||
<Text w={"100px"} as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{item?.comments}
|
||||
</Text>
|
||||
),
|
||||
"Update By": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
display={"flex"}
|
||||
alignItems={"center"}
|
||||
>
|
||||
{/* <Avatar
|
||||
mr={2}
|
||||
size="sm"
|
||||
name={item?.creator?.firstName}
|
||||
src={item?.creator?.profilePhoto}
|
||||
/> */}
|
||||
{item?.modifier?.firstName}
|
||||
</Text>
|
||||
),
|
||||
"Update On": (
|
||||
<Text w={"100px"} as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{formatDate(item.updatedAt)}
|
||||
</Text>
|
||||
),
|
||||
Actions: (
|
||||
<Box display={"flex"} justifyContent={"center"}>
|
||||
{!isMaker() ? (
|
||||
<Box>
|
||||
{index === 0 && (
|
||||
<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
<Tooltip
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
label="Approve"
|
||||
bg="#fff"
|
||||
color={"green.500"}
|
||||
placement="left-start"
|
||||
>
|
||||
<Button
|
||||
// colorScheme="forestGreen"
|
||||
// color="green.500"
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
textTransform={"inherit"}
|
||||
fontWeight={500}
|
||||
px={2}
|
||||
py={1}
|
||||
onClick={() => {
|
||||
setActionId(item.id);
|
||||
onConfirmOpen();
|
||||
}}
|
||||
colorScheme="green"
|
||||
variant={"solid"}
|
||||
cursor={"pointer"}
|
||||
>
|
||||
<CheckIcon fontSize={"12px"} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
label="Reject"
|
||||
bg="#fff"
|
||||
color={"red.500"}
|
||||
placement="left-start"
|
||||
>
|
||||
<Button
|
||||
colorScheme="red"
|
||||
// color="red.500"
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
textTransform={"inherit"}
|
||||
fontWeight={500}
|
||||
px={2}
|
||||
onClick={() => {
|
||||
setActionId(item.id);
|
||||
onRejectOpen();
|
||||
}}
|
||||
py={1}
|
||||
// variant={"solid"}
|
||||
>
|
||||
<CloseIcon fontSize={"10px"} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
) : (
|
||||
<Button
|
||||
colorScheme="green"
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
px={2}
|
||||
py={1}
|
||||
fontWeight={500}
|
||||
onClick={() => {
|
||||
setActionId(item.id);
|
||||
}}
|
||||
>
|
||||
<ViewIcon me={"4px"} /> View
|
||||
</Button>
|
||||
)}
|
||||
</Box>
|
||||
),
|
||||
}));
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedSponsors = sponser.filter(
|
||||
(sponsor) => sponsor.id !== actionId
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
setCaseDetails(updatedSponsors);
|
||||
setDeleteAlert(false);
|
||||
setIsLoading(false);
|
||||
}, 100);
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
const ioCashExporteDetails = IODetails?.ioCashStatusHistory?.Approved?.map(
|
||||
(item, index) => ({
|
||||
"Transaction date": item?.transactionDate,
|
||||
"Transaction type": item?.transactionType,
|
||||
Amount: parseFloat(item?.transactionAmount) || 0,
|
||||
Comments: item?.comments,
|
||||
})
|
||||
);
|
||||
|
||||
const Total = () => {
|
||||
return (
|
||||
<Table size="sm">
|
||||
<Tbody backgroundColor="gray.50">
|
||||
<Tr>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="130px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
Balance in IO Cash
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="150px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
{" "}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="150px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
{}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="100px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{parseFloat(IODetails?.ioCash || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="100px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
{" "}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="100px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
></Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="80px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
></Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="50px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
></Th>
|
||||
</Tr>
|
||||
</Tbody>
|
||||
</Table>
|
||||
);
|
||||
};
|
||||
|
||||
const handleAdd = async () => {
|
||||
try {
|
||||
const res = await updateIOCase(id);
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={res?.data?.message} />
|
||||
// ),
|
||||
// });
|
||||
setIsLoading(false);
|
||||
onOpen();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} pb={0}>
|
||||
<Box bg="white.500">
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
pb={3}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
|
||||
{/* <HStack display={"flex"} alignItems={"center"}>
|
||||
{IODetails?.isInvestedAmount ? (
|
||||
localStorage?.getItem('role') ==="Maker"&& <Button
|
||||
onClick={handleAdd}
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
>
|
||||
Add
|
||||
</Button>
|
||||
) : null}
|
||||
</HStack> */}
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
<NormalTable
|
||||
emptyMessage={`We don't have any Sponers`}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={isLoading}
|
||||
viewActionId={actionId}
|
||||
setViewActionId={setActionId}
|
||||
// total={<Total />}
|
||||
setMouseEnteredId={setMouseEnteredId}
|
||||
setMouseEntered={setMouseEntered}
|
||||
/>
|
||||
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
|
||||
<AddCaseDetails
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
firstField={firstField}
|
||||
/>
|
||||
|
||||
<RequestApproveModal
|
||||
// data={data?.data?.rows}
|
||||
isOpen={isConfirmOpen}
|
||||
onClose={onConfirmClose}
|
||||
id={actionId}
|
||||
// firstField={firstField}
|
||||
/>
|
||||
<RequestRejectModal
|
||||
isOpen={isRejectOpen}
|
||||
onClose={onRejectClose}
|
||||
id={actionId}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Pending;
|
||||
357
src/Pages/IO_Management/CreateIO/IOCashDetails/Rejected.jsx
Normal file
357
src/Pages/IO_Management/CreateIO/IOCashDetails/Rejected.jsx
Normal file
@@ -0,0 +1,357 @@
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
Table,
|
||||
Tag,
|
||||
Tbody,
|
||||
Text,
|
||||
Th,
|
||||
Tooltip,
|
||||
Tr,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import { AddIcon} from "@chakra-ui/icons";
|
||||
import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
|
||||
import NormalTable from "../../../../Components/DataTable/NormalTable";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import AddCashDetails from "../AddCashDetails";
|
||||
import AddRejected from "./AddRejected";
|
||||
import { useUpdateIOCaseMutation } from "../../../../Services/io.service";
|
||||
import { useParams } from "react-router-dom";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import AddCaseDetails from "./AddCaseDetails";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString();
|
||||
|
||||
const Rejected = () => {
|
||||
const params = useParams()
|
||||
const id = params?.id
|
||||
const toast = useToast();
|
||||
const firstField = useRef();
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const { IODetails, approved, setApproved } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
|
||||
const [updateIOCase] = useUpdateIOCaseMutation()
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
const timer = setTimeout(() => {
|
||||
setIsLoading(false);
|
||||
}, 1500);
|
||||
|
||||
// Cleanup the timer on component unmount
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// Table filter
|
||||
const filteredData = IODetails?.ioCashStatusHistory?.Reject?.filter((item) => {
|
||||
// Filter by name (case insensitive)
|
||||
const name = item.transactionDate;
|
||||
const searchLower = searchTerm.toLowerCase();
|
||||
const nameMatches = name.toLowerCase().includes(searchLower);
|
||||
return nameMatches;
|
||||
});
|
||||
|
||||
const tableHeadRow = [
|
||||
"Sr No.",
|
||||
"Transaction Date",
|
||||
"Transaction Type",
|
||||
"Amount",
|
||||
"Comments",
|
||||
"Update By",
|
||||
"Update On",
|
||||
];
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr No.": (
|
||||
<Text
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{index + 1}.
|
||||
</Text>
|
||||
),
|
||||
"Transaction Date": (
|
||||
<Text
|
||||
as={"span"}
|
||||
color={"gray.600"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{formatDate(item?.transactionDate)}
|
||||
</Text>
|
||||
),
|
||||
"Transaction Type": (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
{item?.transactionType}
|
||||
</Text>
|
||||
),
|
||||
"Amount": (
|
||||
<Text
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{parseFloat(item?.transactionAmount || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
),
|
||||
"Comments": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{item?.comments}
|
||||
</Text>
|
||||
),
|
||||
"Update By": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
display={"flex"}
|
||||
alignItems={"center"}
|
||||
>
|
||||
{/* <Avatar
|
||||
mr={2}
|
||||
size="sm"
|
||||
name={item.creator?.firstName}
|
||||
src={item.creator?.profilePhoto}
|
||||
/> */}
|
||||
{item?.modifier?.firstName}
|
||||
</Text>
|
||||
),
|
||||
"Update On": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{formatDate(item.updatedAt)}
|
||||
</Text>
|
||||
),
|
||||
}));
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedSponsors = sponser.filter(
|
||||
(sponsor) => sponsor.id !== actionId
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
setCaseDetails(updatedSponsors);
|
||||
setDeleteAlert(false);
|
||||
setIsLoading(false);
|
||||
}, 100);
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
const Total = () => {
|
||||
return (
|
||||
<Table size="sm">
|
||||
<Tbody backgroundColor="gray.50">
|
||||
<Tr>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="130px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
Balance in IO Cash
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="150px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
{" "}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="150px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
{}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="100px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
{"48,000.00"}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="100px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
>
|
||||
{" "}
|
||||
</Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="100px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
></Th>
|
||||
<Th
|
||||
textAlign={"center"}
|
||||
p={3}
|
||||
width="100px"
|
||||
color={"#004118"}
|
||||
whiteSpace="normal"
|
||||
wordBreak="normal"
|
||||
overflowWrap="normal"
|
||||
></Th>
|
||||
</Tr>
|
||||
</Tbody>
|
||||
</Table>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
const handleAdd = async () =>{
|
||||
try {
|
||||
const res = await updateIOCase(id)
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={res?.data?.message} />
|
||||
// ),
|
||||
// });
|
||||
setIsLoading(false);
|
||||
onOpen()
|
||||
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (error) {
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} pb={0}>
|
||||
<Box bg="white.500">
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
pb={3}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
|
||||
{/* <HStack display={"flex"} alignItems={"center"}>
|
||||
{IODetails?.isInvestedAmount ? (
|
||||
localStorage?.getItem('role') ==="Maker"&& <Button
|
||||
onClick={handleAdd}
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
>
|
||||
Add
|
||||
</Button>
|
||||
) : null}
|
||||
</HStack> */}
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
<NormalTable
|
||||
emptyMessage={`We don't have any Sponers`}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={isLoading}
|
||||
viewActionId={actionId}
|
||||
setViewActionId={setActionId}
|
||||
// total={<Total/>}
|
||||
setMouseEnteredId={setMouseEnteredId}
|
||||
setMouseEntered={setMouseEntered}
|
||||
/>
|
||||
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
|
||||
<AddCaseDetails
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
firstField={firstField}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Rejected;
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
Textarea,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import { useApproveIOCaseMutation } from "../../../../Services/io.service";
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
// comments: yup.string().required("Comment is required")
|
||||
// .max(50, "Investment name cannot be more than 50 characters"),
|
||||
comments: yup
|
||||
.string()
|
||||
.required("Comment is required")
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const RequestApproveModal = ({ isOpen, onClose, firstField ,id}) => {
|
||||
const [isBtnLoading , setIsBtnLoading] = useState(false)
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
const {
|
||||
register,
|
||||
reset,
|
||||
watch,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(conformModalSchema),
|
||||
});
|
||||
|
||||
const [ approveIOCase ] = useApproveIOCaseMutation()
|
||||
|
||||
|
||||
const onSubmit = async(data) => {
|
||||
console.log(data, "tewxttttt");
|
||||
setIsBtnLoading(true)
|
||||
try {
|
||||
const res = await approveIOCase({data,id})
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}else if(res?.data){
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
});
|
||||
onClose()
|
||||
setIsBtnLoading(false)
|
||||
}else{
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const handleFileChange = (event) => {
|
||||
const selectedFile = event.target.files[0];
|
||||
setFile(selectedFile);
|
||||
};
|
||||
|
||||
|
||||
const { data, isLoading } =
|
||||
(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
reset({
|
||||
investorAmount: data?.data?.investorAmount,
|
||||
});
|
||||
}
|
||||
}, [data, reset]);
|
||||
|
||||
const heandleOnClose = () =>{
|
||||
reset()
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal isCentered isOpen={isOpen} onClose={heandleOnClose} initialFocusRef={firstField}>
|
||||
<ModalOverlay />
|
||||
<ModalContent pb={4}>
|
||||
<ModalHeader fontSize={"md"}>Approve Comment</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
{isLoading ? (
|
||||
<FullscreenLoaders height={"50vh"} />
|
||||
) : (
|
||||
<Box as="form" onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalBody>
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormLabel fontSize="sm">Comment</FormLabel>
|
||||
<Textarea
|
||||
rows={6}
|
||||
focusBorderColor="green.400"
|
||||
name="comments"
|
||||
{...register("comments")}
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="md"
|
||||
placeholder={"Enter your checker comment...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comments && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comments.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered </Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
colorScheme="gray"
|
||||
mr={3}
|
||||
onClick={onClose}
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
colorScheme="forestGreen"
|
||||
variant="solid"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
isLoading={isBtnLoading}
|
||||
type="submit"
|
||||
>
|
||||
Send
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Box>
|
||||
)}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default RequestApproveModal;
|
||||
@@ -0,0 +1,172 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
Textarea,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import { useRejectIOCaseMutation } from "../../../../Services/io.service";
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
comments: yup.string().required("Comment is required")
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const RequestRejectModal = ({ isOpen, onClose, firstField ,id}) => {
|
||||
const [isBtnLoading , setIsBtnLoading] = useState(false)
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
const {
|
||||
register,
|
||||
reset,
|
||||
watch,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(conformModalSchema),
|
||||
});
|
||||
|
||||
const [ rejectIOCase ] = useRejectIOCaseMutation()
|
||||
|
||||
|
||||
const onSubmit = async(data) => {
|
||||
console.log(data, "tewxttttt");
|
||||
setIsBtnLoading(true)
|
||||
try {
|
||||
const res = await rejectIOCase({data,id})
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}else if(res?.data){
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
});
|
||||
onClose()
|
||||
setIsBtnLoading(false)
|
||||
}else{
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const handleFileChange = (event) => {
|
||||
const selectedFile = event.target.files[0];
|
||||
setFile(selectedFile);
|
||||
};
|
||||
|
||||
|
||||
const { data, isLoading } =
|
||||
(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
reset({
|
||||
investorAmount: data?.data?.investorAmount,
|
||||
});
|
||||
}
|
||||
}, [data, reset]);
|
||||
|
||||
const heandleOnClose = () =>{
|
||||
reset()
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal isCentered isOpen={isOpen} onClose={heandleOnClose} initialFocusRef={firstField}>
|
||||
<ModalOverlay />
|
||||
<ModalContent pb={4}>
|
||||
<ModalHeader fontSize={"md"}>Reject Comment</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
{isLoading ? (
|
||||
<FullscreenLoaders height={"50vh"} />
|
||||
) : (
|
||||
<Box as="form" onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalBody>
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormLabel fontSize="sm">Comment</FormLabel>
|
||||
<Textarea
|
||||
rows={6}
|
||||
focusBorderColor="green.400"
|
||||
name="comments"
|
||||
{...register("comments")}
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="md"
|
||||
placeholder={"Enter your comments...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comments && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comments.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered </Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
colorScheme="gray"
|
||||
mr={3}
|
||||
onClick={onClose}
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
colorScheme="forestGreen"
|
||||
variant="solid"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
isLoading={isBtnLoading}
|
||||
type="submit"
|
||||
>
|
||||
Send
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Box>
|
||||
)}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default RequestRejectModal;
|
||||
@@ -29,7 +29,7 @@ import { exportToExcel, exportToExcelNew } from "../../../Constants/Constants";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter
|
||||
|
||||
const IOCashDetails = () => {
|
||||
const IOCashDetailsOld = () => {
|
||||
const toast = useToast();
|
||||
const firstField = useRef();
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
@@ -75,7 +75,7 @@ const IOCashDetails = () => {
|
||||
"Update by ",
|
||||
"Update On",
|
||||
];
|
||||
|
||||
|
||||
const handleUpdateStatus = debounce((id) => {
|
||||
setCaseDetails((prevSponser) =>
|
||||
prevSponser.map((sponsor) =>
|
||||
@@ -134,9 +134,9 @@ const IOCashDetails = () => {
|
||||
</Badge>
|
||||
{/* {parseFloat(item.transactionAmount || 0).toLocaleString()} */}
|
||||
{`${parseFloat(item.transactionAmount || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}`}
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}`}
|
||||
</Text>
|
||||
),
|
||||
Comments: (
|
||||
@@ -180,8 +180,6 @@ const IOCashDetails = () => {
|
||||
),
|
||||
}));
|
||||
|
||||
|
||||
|
||||
const customHeaders = [
|
||||
{ label: "Date", key: "transactionDate" },
|
||||
{ label: "Transaction type", key: "transactionType" },
|
||||
@@ -192,12 +190,12 @@ const IOCashDetails = () => {
|
||||
// Add more headers as needed
|
||||
];
|
||||
|
||||
const ioCashExporteDetails = IODetails?.ioCashHistory?.map((item, index) =>({
|
||||
"Date": item?.transactionDate,
|
||||
const ioCashExporteDetails = IODetails?.ioCashHistory?.map((item, index) => ({
|
||||
Date: item?.transactionDate,
|
||||
"Transaction type": item?.transactionType,
|
||||
"Amount":parseFloat(item?.transactionAmount) || 0,
|
||||
"Comments": item?.comments
|
||||
}))
|
||||
Amount: parseFloat(item?.transactionAmount) || 0,
|
||||
Comments: item?.comments,
|
||||
}));
|
||||
|
||||
console.log(ioCashExporteDetails);
|
||||
|
||||
@@ -312,8 +310,7 @@ const IOCashDetails = () => {
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
|
||||
|
||||
<HStack display={"flex"} alignItems={"center"}>
|
||||
<HStack display={"flex"} alignItems={"center"}>
|
||||
<Button
|
||||
onClick={() =>
|
||||
exportToExcelNew(ioCashExporteDetails, "IO Cash History")
|
||||
@@ -324,25 +321,24 @@ const IOCashDetails = () => {
|
||||
variant={"outline"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
|
||||
isDisabled={ioCashExporteDetails?.length === 0}
|
||||
>
|
||||
Export xls
|
||||
</Button>
|
||||
|
||||
{IODetails?.isInvestedAmount ? (
|
||||
<Button
|
||||
onClick={onOpen}
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
>
|
||||
Add IO Cash
|
||||
</Button>
|
||||
) : null}
|
||||
</HStack>
|
||||
{IODetails?.isInvestedAmount ? (
|
||||
<Button
|
||||
onClick={onOpen}
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
>
|
||||
Add IO Cash
|
||||
</Button>
|
||||
) : null}
|
||||
</HStack>
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
@@ -376,4 +372,4 @@ const IOCashDetails = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default IOCashDetails;
|
||||
export default IOCashDetailsOld;
|
||||
@@ -12,11 +12,12 @@ import {
|
||||
useUpdateIOMutation,
|
||||
} from "../../../Services/io.service";
|
||||
import ToastBox from "../../../Components/ToastBox";
|
||||
import {
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import { useToast } from "@chakra-ui/react";
|
||||
import { formatDatee } from "../../../Components/FormField";
|
||||
import { formatDateToYYYYMMDD, removeTrailingZeros } from "../../../Constants/Constants";
|
||||
import {
|
||||
formatDateToYYYYMMDD,
|
||||
removeTrailingZeros,
|
||||
} from "../../../Constants/Constants";
|
||||
|
||||
const schema = yup.object().shape({
|
||||
investmentNameEnglish: yup
|
||||
@@ -25,7 +26,7 @@ const schema = yup.object().shape({
|
||||
.min(3, "IO name in English must be at least 3 characters long")
|
||||
.max(150, "IO name in English must be at most 150 characters long"),
|
||||
|
||||
investmentNameArabic: yup
|
||||
investmentNameArabic: yup
|
||||
.string()
|
||||
.required("IO name in Arabic is required")
|
||||
.min(3, "IO name in Arabic must be at least 3 characters long")
|
||||
@@ -42,15 +43,15 @@ const schema = yup.object().shape({
|
||||
.required("Description in Arabic is required")
|
||||
.min(10, "Description in Arabic must be at least 10 characters long")
|
||||
.max(2000, "Description in Arabic must be at most 500 characters long"),
|
||||
expectedReturnArabic: yup
|
||||
.string()
|
||||
.required("Expected return in Arabic is required"),
|
||||
expectedReturnArabic: yup
|
||||
.string()
|
||||
.required("Expected return in Arabic is required"),
|
||||
|
||||
goalAmount: yup
|
||||
.number()
|
||||
.typeError("Goal Amount is must be number")
|
||||
.required('Goal amount is required')
|
||||
.positive('Goal amount must be a positive number'),
|
||||
goalAmount: yup
|
||||
.number()
|
||||
.typeError("Goal Amount is must be number")
|
||||
.required("Goal amount is required")
|
||||
.positive("Goal amount must be a positive number"),
|
||||
closingDate: yup
|
||||
.date()
|
||||
.notRequired("Closing date is required")
|
||||
@@ -69,28 +70,25 @@ const schema = yup.object().shape({
|
||||
|
||||
InvestmentDetails: yup.string().notRequired(),
|
||||
|
||||
comment: yup.string().notRequired()
|
||||
// .min(10, "Comment must be at least 10 characters long")
|
||||
.max(100, "Comment must be at most 100 characters long"),
|
||||
|
||||
expectedReturn: yup
|
||||
comment: yup
|
||||
.string()
|
||||
.required("Expected return is required"),
|
||||
.notRequired()
|
||||
// .min(10, "Comment must be at least 10 characters long")
|
||||
.max(100, "Comment must be at most 100 characters long"),
|
||||
|
||||
expectedReturn: yup.string().required("Expected return is required"),
|
||||
});
|
||||
|
||||
const IODetails = ({ enableNextTab, index, data }) => {
|
||||
|
||||
const params = useParams();
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
|
||||
|
||||
const handleInputChangeCreate = (index, newValue) => {
|
||||
|
||||
const updatedValues = [...values];
|
||||
updatedValues[index].value = newValue;
|
||||
setValues(updatedValues);
|
||||
console.log(values);
|
||||
console.log(values);
|
||||
};
|
||||
|
||||
const handleInputChangeEdit = (index, newValue) => {
|
||||
@@ -143,9 +141,12 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
});
|
||||
|
||||
const miniValue = data?.country?.map(
|
||||
({ countryName, flagIcon, minInvestmentAmt, countryCode, id, currency }, index) => {
|
||||
(
|
||||
{ countryName, flagIcon, minInvestmentAmt, countryCode, id, currency },
|
||||
index
|
||||
) => {
|
||||
return {
|
||||
id:id,
|
||||
id: id,
|
||||
country: countryName,
|
||||
value: minInvestmentAmt,
|
||||
logo: flagIcon,
|
||||
@@ -154,18 +155,19 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
}
|
||||
);
|
||||
|
||||
const minInvestmentById = IObyID?.data?.minInvestmentAmt?.map(({minInvestmentAmt, country, currencyCode, country_xid,id })=>{
|
||||
console.log(currencyCode);
|
||||
return{
|
||||
_id:id,
|
||||
id:country_xid,
|
||||
country: country?.countryName,
|
||||
value: removeTrailingZeros(minInvestmentAmt),
|
||||
logo: country?.flagIcon,
|
||||
curr: currencyCode,
|
||||
const minInvestmentById = IObyID?.data?.minInvestmentAmt?.map(
|
||||
({ minInvestmentAmt, country, currencyCode, country_xid, id }) => {
|
||||
console.log(currencyCode);
|
||||
return {
|
||||
_id: id,
|
||||
id: country_xid,
|
||||
country: country?.countryName,
|
||||
value: removeTrailingZeros(minInvestmentAmt),
|
||||
logo: country?.flagIcon,
|
||||
curr: currencyCode,
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
);
|
||||
|
||||
const schemaEdit = yup.object().shape({
|
||||
investmentNameEnglish: yup
|
||||
@@ -173,74 +175,67 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
.required("IO name in English is required")
|
||||
.min(3, "IO name in English must be at least 3 characters long")
|
||||
.max(150, "IO name in English must be at most 150 characters long"),
|
||||
|
||||
|
||||
investmentNameArabic: yup
|
||||
.string()
|
||||
.required("IO name in Arabic is required")
|
||||
.min(3, "IO name in Arabic must be at least 3 characters long")
|
||||
.max(50, "IO name in Arabic must be at most 50 characters long"),
|
||||
|
||||
|
||||
descriptionEnglish: yup
|
||||
.string()
|
||||
.required("Description in English is required")
|
||||
.min(10, "Description in English must be at least 10 characters long")
|
||||
.max(1000, "Description in English must be at most 1000 characters long"),
|
||||
|
||||
|
||||
descriptionArabic: yup
|
||||
.string()
|
||||
.required("Description in Arabic is required")
|
||||
.min(10, "Description in Arabic must be at least 10 characters long")
|
||||
.max(2000, "Description in Arabic must be at most 500 characters long"),
|
||||
expectedReturnArabic: yup
|
||||
.string()
|
||||
.required("Expected return in Arabic is required"),
|
||||
|
||||
goalAmount: yup
|
||||
.number()
|
||||
.typeError("Goal Amount is must be number")
|
||||
.required('Goal amount is required')
|
||||
.positive('Goal amount must be a positive number')
|
||||
.min(IObyID?.data?.totalAmtInvestmentInUSD, `Goal amount should not be lesser then amount raised ${IObyID?.data?.totalAmtInvestmentInUSD}`),
|
||||
closingDate: yup
|
||||
.date()
|
||||
.notRequired("Closing date is required")
|
||||
.min(new Date(), "Closing date cannot be in the past"),
|
||||
|
||||
expectedReturnArabic: yup
|
||||
.string()
|
||||
.required("Expected return in Arabic is required"),
|
||||
|
||||
goalAmount: yup
|
||||
.number()
|
||||
.typeError("Goal Amount is must be number")
|
||||
.required("Goal amount is required")
|
||||
.positive("Goal amount must be a positive number")
|
||||
.min(
|
||||
IObyID?.data?.totalAmtInvestmentInUSD,
|
||||
`Goal amount should not be lesser then amount raised ${IObyID?.data?.totalAmtInvestmentInUSD}`
|
||||
),
|
||||
closingDate: yup.date().notRequired("Closing date is required"),
|
||||
|
||||
holdingPeriod: yup.string().required("Holding period is required"),
|
||||
holdingPeriodArabic: yup.string().required("Holding period is required"),
|
||||
isShariah: yup.string().required("CheckBox is required"),
|
||||
|
||||
|
||||
// minInvestmentAmount: yup
|
||||
// .number()
|
||||
// .required("Minimum investment is required")
|
||||
// .positive("Minimum investment must be a positive number")
|
||||
// .min(1, "Minimum investment must be at least 1"),
|
||||
|
||||
|
||||
ISIN: yup.string().notRequired(),
|
||||
|
||||
|
||||
InvestmentDetails: yup.string().notRequired(),
|
||||
|
||||
comment: yup.string().notRequired()
|
||||
.min(10, "Comment must be at least 10 characters long")
|
||||
.max(100, "Comment must be at most 100 characters long"),
|
||||
|
||||
expectedReturn: yup
|
||||
|
||||
comment: yup
|
||||
.string()
|
||||
.required("Expected return is required"),
|
||||
.notRequired()
|
||||
.min(10, "Comment must be at least 10 characters long")
|
||||
.max(100, "Comment must be at most 100 characters long"),
|
||||
|
||||
expectedReturn: yup.string().required("Expected return is required"),
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
const [values, setValues] = useState(id?minInvestmentById:miniValue);
|
||||
const [values, setValues] = useState(id ? minInvestmentById : miniValue);
|
||||
|
||||
console.log(values);
|
||||
|
||||
const formatNumber = (num) => {
|
||||
// Remove non-numeric characters and format with commas
|
||||
return num.replace(/\D/g, '')
|
||||
.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
return num.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
};
|
||||
// console.log(values);
|
||||
|
||||
@@ -254,10 +249,11 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(id ? schemaEdit : schema),
|
||||
mode: "all",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setIOloading(IObyIDisLoading)
|
||||
setIOloading(IObyIDisLoading);
|
||||
setIODetails({
|
||||
...IObyID?.data,
|
||||
});
|
||||
@@ -278,10 +274,9 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
minInvestmentAmount: IObyID?.data?.minInvestmentAmount,
|
||||
holdingPeriodArabic: IObyID?.data?.minInvestmentAmount,
|
||||
expectedReturnArabic: IObyID?.data?.minInvestmentAmount,
|
||||
isShariah: IObyID?.data?.isShariah
|
||||
isShariah: IObyID?.data?.isShariah,
|
||||
});
|
||||
}
|
||||
|
||||
}, [id, IObyID]);
|
||||
|
||||
//=======================[ Creator ]
|
||||
@@ -294,8 +289,10 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
isRequired: true,
|
||||
section: " ",
|
||||
width: "49%",
|
||||
maxLength:150,
|
||||
helperText:`Maximum length should be 150 characters. You have entered ${watch()?.investmentNameEnglish?.length || 0} characters.`
|
||||
maxLength: 150,
|
||||
helperText: `Maximum length should be 150 characters. You have entered ${
|
||||
watch()?.investmentNameEnglish?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
{
|
||||
label: "IO Name (Arabic)",
|
||||
@@ -306,8 +303,10 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
arabic: true,
|
||||
section: " ",
|
||||
width: "49%",
|
||||
maxLength:150,
|
||||
helperText:`Maximum length should be 150 characters. You have entered ${watch()?.investmentNameArabic?.length || 0} characters.`
|
||||
maxLength: 150,
|
||||
helperText: `Maximum length should be 150 characters. You have entered ${
|
||||
watch()?.investmentNameArabic?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
{
|
||||
label: "Description",
|
||||
@@ -317,8 +316,10 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
isRequired: true,
|
||||
section: " ",
|
||||
width: "49%",
|
||||
maxLength:1000,
|
||||
helperText:`Maximum length should be 1000 characters. You have entered ${watch()?.descriptionEnglish?.length || 0} characters.`
|
||||
maxLength: 1000,
|
||||
helperText: `Maximum length should be 1000 characters. You have entered ${
|
||||
watch()?.descriptionEnglish?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
{
|
||||
label: "Description (Arabic)",
|
||||
@@ -329,9 +330,10 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
arabic: true,
|
||||
section: " ",
|
||||
width: "49%",
|
||||
maxLength:1000,
|
||||
helperText:`Maximum length should be 1000 characters. You have entered ${watch()?.descriptionArabic?.length || 0} characters.`
|
||||
|
||||
maxLength: 1000,
|
||||
helperText: `Maximum length should be 1000 characters. You have entered ${
|
||||
watch()?.descriptionArabic?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
{
|
||||
label: "Holding Period",
|
||||
@@ -342,8 +344,10 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
section: " ",
|
||||
width: "49%",
|
||||
value: IObyID?.data?.holdingPeriod,
|
||||
maxLength:20,
|
||||
helperText:`Maximum length should be 20 characters. You have entered ${watch()?.holdingPeriod?.length || 0} characters.`
|
||||
maxLength: 20,
|
||||
helperText: `Maximum length should be 20 characters. You have entered ${
|
||||
watch()?.holdingPeriod?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
{
|
||||
label: "Holding Period (Arabic)",
|
||||
@@ -355,11 +359,12 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
section: " ",
|
||||
width: "49%",
|
||||
value: IObyID?.data?.holdingPeriodArabic,
|
||||
maxLength:20,
|
||||
helperText:`Maximum length should be 20 characters. You have entered ${watch()?.holdingPeriodArabic?.length || 0} characters.`
|
||||
maxLength: 20,
|
||||
helperText: `Maximum length should be 20 characters. You have entered ${
|
||||
watch()?.holdingPeriodArabic?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
label: "Expected Return",
|
||||
name: "expectedReturn",
|
||||
@@ -372,7 +377,7 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
|
||||
{
|
||||
label: "Expected Return (Arabic)",
|
||||
name: "expectedReturnArabic",
|
||||
name: "expectedReturnArabic",
|
||||
type: "text",
|
||||
isRequired: true,
|
||||
arabic: true,
|
||||
@@ -382,16 +387,15 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
},
|
||||
{
|
||||
label: "Shariah",
|
||||
name: "isShariah",
|
||||
name: "isShariah",
|
||||
type: "checkBox",
|
||||
value:IObyID?.data?.isShariah,
|
||||
value: IObyID?.data?.isShariah,
|
||||
// isRequired: true,
|
||||
section: " ",
|
||||
width: "32.3%",
|
||||
value: IObyID?.data?.isShariah,
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
label: "Investment Type",
|
||||
placeHolder: "Select option",
|
||||
@@ -429,19 +433,19 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
name: "closingDate",
|
||||
// value: "IObyID?.data?.closingDate",
|
||||
type: "date",
|
||||
isRequired: true,
|
||||
// isRequired: true,
|
||||
section: " ",
|
||||
width: "32.3%",
|
||||
dateValue:formatDatee(IObyID?.data?.closingDate),
|
||||
dateValue: formatDatee(IObyID?.data?.closingDate),
|
||||
// helperText: IObyID && `Current closing date is : ${formatDate(IObyID?.data?.closingDate)}`
|
||||
closingDate:true
|
||||
closingDate:id ? null : true
|
||||
},
|
||||
{
|
||||
label: "ISIN",
|
||||
placeHolder: "",
|
||||
name: "ISIN",
|
||||
type: "text",
|
||||
align:"right",
|
||||
align: "right",
|
||||
section: " ",
|
||||
width: "32.3%",
|
||||
},
|
||||
@@ -453,8 +457,10 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
section: " ",
|
||||
width: "32.3%",
|
||||
value: IObyID?.data?.InvestmentDetails,
|
||||
maxLength:20,
|
||||
helperText:`Maximum length should be 20 characters. You have entered ${watch()?.InvestmentDetails?.length || 0} characters.`
|
||||
maxLength: 20,
|
||||
helperText: `Maximum length should be 20 characters. You have entered ${
|
||||
watch()?.InvestmentDetails?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
|
||||
{
|
||||
@@ -463,10 +469,10 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
name: "table",
|
||||
type: "table",
|
||||
section: " ",
|
||||
width: "100%",
|
||||
width: "100%",
|
||||
isRequired: true,
|
||||
options: investmentTypeOptions,
|
||||
handleInputChange:id ? handleInputChangeEdit : handleInputChangeCreate,
|
||||
handleInputChange: id ? handleInputChangeEdit : handleInputChangeCreate,
|
||||
value: values,
|
||||
},
|
||||
|
||||
@@ -479,8 +485,10 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
width: "100%",
|
||||
options: investmentTypeOptions,
|
||||
value: IObyID?.data?.comment,
|
||||
maxLength:100,
|
||||
helperText:`Maximum length should be 100 characters. You have entered ${watch()?.comment?.length || 0} characters.`
|
||||
maxLength: 100,
|
||||
helperText: `Maximum length should be 100 characters. You have entered ${
|
||||
watch()?.comment?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
];
|
||||
const groupedFields = formFields.reduce((groups, field) => {
|
||||
@@ -493,30 +501,29 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
}, {});
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
|
||||
delete data.table;
|
||||
|
||||
setIsLoading(true);
|
||||
const updatedMinAmount = values?.map(({id, value, _id})=>{
|
||||
const updatedMinAmount = values?.map(({ id, value, _id }) => {
|
||||
return {
|
||||
id:_id,
|
||||
country_xid:id,
|
||||
minInvestmentAmt: Number(value)
|
||||
}
|
||||
})
|
||||
id: _id,
|
||||
country_xid: id,
|
||||
minInvestmentAmt: Number(value),
|
||||
};
|
||||
});
|
||||
|
||||
// console.log(formatDateToYYYYMMDD(data.closingDate));
|
||||
const formData = {
|
||||
...data,
|
||||
investmentType_xid: Number(data.investmentType),
|
||||
sponsor_xid: Number(data.sponserName),
|
||||
minInvestmentAmt:updatedMinAmount,
|
||||
closingDate: formatDateToYYYYMMDD(data.closingDate)
|
||||
minInvestmentAmt: updatedMinAmount,
|
||||
closingDate: formatDateToYYYYMMDD(data.closingDate),
|
||||
};
|
||||
|
||||
// console.log(formData);
|
||||
if (id) {
|
||||
console.log("========================",formData);
|
||||
console.log("========================", formData);
|
||||
const res = await updateIO({ data: formData, id });
|
||||
console.log(res);
|
||||
if (res?.data?.statusCode === 200) {
|
||||
@@ -526,20 +533,24 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
});
|
||||
navigate(`/view-io/${id}`);
|
||||
enableNextTab(index);
|
||||
} else if(res?.error?.status === 400){
|
||||
} else if (res?.error?.status === 400) {
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.error?.data?.message } status={"error"} />,
|
||||
});
|
||||
} else if(res?.error?.status === 500){
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
),
|
||||
});
|
||||
} else if (res?.error?.status === 500) {
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.error?.data?.message } status={"error"} />,
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
console.log("========================",formData);
|
||||
console.log("========================", formData);
|
||||
const res = await creatIO(formData);
|
||||
console.log(res?.error?.status);
|
||||
if (res?.data?.statusCode === 200) {
|
||||
@@ -549,15 +560,19 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
});
|
||||
navigate(`/view-io/${res?.data?.data}`);
|
||||
enableNextTab(index);
|
||||
} else if(res?.error?.status === 400){
|
||||
} else if (res?.error?.status === 400) {
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.error?.data?.message } status={"error"} />,
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
),
|
||||
});
|
||||
}else if(res?.error?.status === 500){
|
||||
} else if (res?.error?.status === 500) {
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.error?.data?.message } status={"error"} />,
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
),
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -566,7 +581,6 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ==========================
|
||||
// if (params?.id) {
|
||||
// return enableNextTab(index);
|
||||
@@ -584,9 +598,8 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
};
|
||||
|
||||
return IObyIDisLoading ? (
|
||||
<FullscreenLoaders height={'70vh'} />
|
||||
<FullscreenLoaders height={"70vh"} />
|
||||
) : (
|
||||
|
||||
<FormInputMain
|
||||
p={0.1}
|
||||
w={250}
|
||||
|
||||
266
src/Pages/IO_Management/CreateIO/IONAVDetails/AddNavDetails.jsx
Normal file
266
src/Pages/IO_Management/CreateIO/IONAVDetails/AddNavDetails.jsx
Normal file
@@ -0,0 +1,266 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Drawer,
|
||||
DrawerBody,
|
||||
DrawerCloseButton,
|
||||
DrawerContent,
|
||||
DrawerFooter,
|
||||
DrawerHeader,
|
||||
DrawerOverlay,
|
||||
FormControl,
|
||||
FormErrorMessage,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
HStack,
|
||||
Input,
|
||||
Select,
|
||||
Stack,
|
||||
Text,
|
||||
Textarea,
|
||||
VStack,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import * as yup from "yup";
|
||||
import React, { useState, useEffect, useContext } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { useParams } from "react-router-dom";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import CurrencyInput from "../../../../Components/CurrencyInput";
|
||||
import { useAddNavDetailsMutation } from "../../../../Services/io.service";
|
||||
import { formatDatee } from "../../../../Components/FormField";
|
||||
|
||||
const ioNav = yup.object().shape({
|
||||
transactionDate: yup.string().required("Date is required"),
|
||||
transactionAmount: yup.number().required("New NAV is required"),
|
||||
comments: yup.string().notRequired()
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const AddNavDetails = ({ isOpen, onClose, firstField, actionId, setActionId, data }) => {
|
||||
const params = useParams()
|
||||
const id = params?.id
|
||||
const [file, setFile] = useState("");
|
||||
const [fileName, setFileName] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [alert, setAlert] = useState(false);
|
||||
const toast = useToast();
|
||||
|
||||
|
||||
|
||||
// ======================[ Cotext Api ]
|
||||
const { IODetails } = useContext(GlobalStateContext);
|
||||
const found = data?.find((item) => item?.id === actionId);
|
||||
|
||||
|
||||
const [addNavDetails] = useAddNavDetailsMutation()
|
||||
// const {
|
||||
// data
|
||||
// } = useGetArtifactsQuery(id)
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
watch,
|
||||
reset,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(ioNav),
|
||||
});
|
||||
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
|
||||
setIsLoading(true)
|
||||
|
||||
try {
|
||||
|
||||
const res = await addNavDetails({ data, id })
|
||||
if (res?.data?.statusCode === 201) {
|
||||
setIsLoading(false);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
handleClose()
|
||||
}else if(res?.error?.status === 400){
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.error?.data?.message } status={"error"} />,
|
||||
});
|
||||
handleClose()
|
||||
}
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
const handleConfirm = () => {
|
||||
handleSubmit(onSubmit)();
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
handleSubmit(onSubmit)();
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setIsLoading(false);
|
||||
setAlert(false)
|
||||
onClose()
|
||||
reset({
|
||||
transactionDate:"",
|
||||
transactionAmount:"",
|
||||
comments:""
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const today = formatDatee(new Date(), 'yyyy-MM-dd');
|
||||
|
||||
function calculatePercentage(newNav, currNav) {
|
||||
const per = (newNav - currNav) / currNav * 100
|
||||
return per.toFixed(2)
|
||||
}
|
||||
|
||||
|
||||
console.log(calculatePercentage(1092500, 976070));
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Drawer
|
||||
size={"md"}
|
||||
isOpen={isOpen}
|
||||
placement="right"
|
||||
initialFocusRef={firstField}
|
||||
onClose={handleClose}
|
||||
>
|
||||
<DrawerOverlay />
|
||||
<DrawerContent>
|
||||
<DrawerCloseButton />
|
||||
<DrawerHeader fontSize={"sm"}>IO Nav Details</DrawerHeader>
|
||||
|
||||
<DrawerBody>
|
||||
<Stack spacing={4}>
|
||||
<FormControl isInvalid={errors.transactionDate} isRequired>
|
||||
<FormLabel fontSize={"sm"}>Date Selection</FormLabel>
|
||||
<Controller
|
||||
name="transactionDate"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input {...field}
|
||||
max={today} // Set max attribute to today’s date
|
||||
fontSize={"sm"} type="date" size={"sm"} />
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.transactionDate?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
|
||||
|
||||
<FormControl isInvalid={errors.transactionAmount} isRequired>
|
||||
<FormLabel fontSize={"sm"}>New NAV</FormLabel>
|
||||
<Controller
|
||||
name="transactionAmount"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<CurrencyInput {...field} textAlign={'right'} fontSize={"sm"} type="number" size={"sm"} />
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.transactionAmount?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
|
||||
<HStack justify={'start'} gap={10} bg={'green.100'} p={3} rounded={'md'} shadow={'md'}>
|
||||
<VStack align={'start'}>
|
||||
<Text as={'span'} fontSize={'sm'} fontWeight={500}>Current nav</Text>
|
||||
<Text as={'span'} fontSize={'sm'}>
|
||||
{parseFloat(IODetails?.ioNAV || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
</VStack>
|
||||
|
||||
<VStack align={'start'}>
|
||||
<Text as={'span'} fontSize={'sm'} fontWeight={500}>Live return %</Text>
|
||||
<Text as={'span'} fontSize={'sm'}>{calculatePercentage(watch()?.transactionAmount||IODetails?.ioNAV,IODetails?.ioNAV)}</Text>
|
||||
</VStack>
|
||||
</HStack>
|
||||
|
||||
|
||||
|
||||
<FormControl isInvalid={errors.comments}>
|
||||
<FormLabel fontSize={"sm"}>Comment</FormLabel>
|
||||
<Controller
|
||||
name="comments"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Textarea {...field} maxLength={200} fontSize={"sm"} type="text" size={"sm"} />
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.comments?.message}
|
||||
</FormErrorMessage>
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered </Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
|
||||
</Stack>
|
||||
</DrawerBody>
|
||||
|
||||
<DrawerFooter>
|
||||
<Button
|
||||
variant="outline"
|
||||
colorScheme={"forestGreen"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
mr={3}
|
||||
onClick={handleClose}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
colorScheme={"forestGreen"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
|
||||
onClick={() => setAlert(true)}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
</DrawerFooter>
|
||||
</DrawerContent>
|
||||
</Drawer>
|
||||
|
||||
|
||||
<CustomAlertDialog
|
||||
isOpen={alert}
|
||||
onClose={() => setAlert(false)}
|
||||
alertHandler={handleSave}
|
||||
message={"Are you sure you want to add NAV details?"}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddNavDetails;
|
||||
295
src/Pages/IO_Management/CreateIO/IONAVDetails/Approved.jsx
Normal file
295
src/Pages/IO_Management/CreateIO/IONAVDetails/Approved.jsx
Normal file
@@ -0,0 +1,295 @@
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
Text,
|
||||
Th,
|
||||
Tooltip,
|
||||
Tr,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import { AddIcon, DeleteIcon, EditIcon, ViewIcon } from "@chakra-ui/icons";
|
||||
import { LuFileSpreadsheet } from "react-icons/lu";
|
||||
import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
|
||||
import NormalTable from "../../../../Components/DataTable/NormalTable";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import * as XLSX from "xlsx";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import AddCashDetails from "../AddCashDetails";
|
||||
import { debounce } from "../../../Admin/Contact";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useUpdateIOCaseMutation } from "../../../../Services/io.service";
|
||||
import AddApproved from "./AddNavDetails";
|
||||
import AddNavDetails from "./AddNavDetails";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString();
|
||||
|
||||
const Approved = () => {
|
||||
const params = useParams();
|
||||
const toast = useToast();
|
||||
const id = params?.id;
|
||||
const firstField = useRef();
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const { IODetails, iONAVDetail, setIONAVDetail } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
const [updateIOCase] = useUpdateIOCaseMutation();
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
const timer = setTimeout(() => {
|
||||
setIsLoading(false);
|
||||
}, 1500);
|
||||
|
||||
// Cleanup the timer on component unmount
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
};
|
||||
|
||||
// Table filter
|
||||
const filteredData = IODetails?.ioNAVStatusHistory?.Approved?.filter(
|
||||
(item) => {
|
||||
// Filter by name (case insensitive)
|
||||
const name = item.transactionAmount;
|
||||
const searchLower = searchTerm?.toLowerCase();
|
||||
const nameMatches = name?.toLowerCase().includes(searchLower);
|
||||
return nameMatches;
|
||||
}
|
||||
);
|
||||
|
||||
const tableHeadRow = [
|
||||
"Sr No.",
|
||||
"Valuation date",
|
||||
"NAV",
|
||||
"Last Nav Update",
|
||||
"Investment Closed",
|
||||
"Comments",
|
||||
"Updated By",
|
||||
];
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr No.": (
|
||||
<Text as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{index + 1}.
|
||||
</Text>
|
||||
),
|
||||
"Valuation date": (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
{formatDate(item?.transactionDate)}
|
||||
</Text>
|
||||
),
|
||||
NAV: (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{parseFloat(item?.transactionAmount || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
),
|
||||
"Last Nav Update": (
|
||||
<Text
|
||||
justifyContent={"center"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item.previousNAVvalue && `${item.previousNAVvalue}`}
|
||||
</Text>
|
||||
),
|
||||
"Investment Closed": (
|
||||
<Text
|
||||
justifyContent={"center"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item?.initialNAVvalue && `${item?.initialNAVvalue}`}
|
||||
</Text>
|
||||
),
|
||||
Comments: (
|
||||
<Text w={"100px"} as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{item?.comments ? item?.comments : "---"}
|
||||
</Text>
|
||||
),
|
||||
"Updated By": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
display={"flex"}
|
||||
alignItems={"center"}
|
||||
>
|
||||
{/* <Avatar
|
||||
mr={2}
|
||||
size="sm"
|
||||
name={item.creator?.firstName}
|
||||
src={item.creator?.profilePhoto}
|
||||
/> */}
|
||||
{item?.modifier?.firstName}
|
||||
</Text>
|
||||
),
|
||||
}));
|
||||
|
||||
const handleAdd = async () => {
|
||||
try {
|
||||
const res = await updateIOCase(id);
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={res?.data?.message} />
|
||||
// ),
|
||||
// });
|
||||
setIsLoading(false);
|
||||
onOpen();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedSponsors = sponser.filter(
|
||||
(sponsor) => sponsor.id !== actionId
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
setCaseDetails(updatedSponsors);
|
||||
setDeleteAlert(false);
|
||||
setIsLoading(false);
|
||||
}, 100);
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
const exportToExcelNew = (data, fileName) => {
|
||||
const worksheet = XLSX.utils.json_to_sheet(data);
|
||||
const workbook = XLSX.utils.book_new();
|
||||
XLSX.utils.book_append_sheet(workbook, worksheet, "Sheet1");
|
||||
|
||||
// Export file
|
||||
XLSX.writeFile(workbook, `${fileName}.xlsx`);
|
||||
};
|
||||
|
||||
const ioNavExport = IODetails?.ioNAVStatusHistory?.Approved?.map(
|
||||
(item, index) => ({
|
||||
ID: item?.id, // Keep as integer if it's already a number
|
||||
"Valuation date": formatDate(item?.transactionDate), // Assuming this is a date, no conversion needed
|
||||
NAV: parseFloat(item?.transactionAmount) || 0, // Convert to float
|
||||
"Last Nav Update": parseFloat(item?.previousNAVvalue) || 0, // Convert to float
|
||||
"Investment Closed": parseFloat(item?.initialNAVvalue) || 0, // Convert to float
|
||||
Comments: item?.comments, // Keep as string
|
||||
// "Transaction Type": item?.transactionType,
|
||||
"Updated By": item?.creator?.firstName, // Keep as string
|
||||
// "Update On": formatDate(item?.updatedAt) // Assuming this is a date, no conversion needed
|
||||
})
|
||||
);
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} pb={0}>
|
||||
<Box bg="white.500">
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
pb={3}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
|
||||
<HStack display={"flex"} alignItems={"center"}>
|
||||
<Button
|
||||
onClick={() => exportToExcelNew(ioNavExport, "Io Nav details")}
|
||||
leftIcon={<LuFileSpreadsheet />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
variant={"outline"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
isDisabled={ioNavExport?.length === 0}
|
||||
>
|
||||
Export xls
|
||||
</Button>
|
||||
{/* {IODetails?.isInvestedAmount
|
||||
? localStorage?.getItem("role") === "Maker" && (
|
||||
<Button
|
||||
onClick={handleAdd}
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
>
|
||||
Add
|
||||
</Button>
|
||||
)
|
||||
: null} */}
|
||||
</HStack>
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
<NormalTable
|
||||
emptyMessage={`We don't have any Sponers`}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={isLoading}
|
||||
viewActionId={actionId}
|
||||
setViewActionId={setActionId}
|
||||
setMouseEnteredId={setMouseEnteredId}
|
||||
setMouseEntered={setMouseEntered}
|
||||
/>
|
||||
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
|
||||
<AddNavDetails
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
firstField={firstField}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Approved;
|
||||
192
src/Pages/IO_Management/CreateIO/IONAVDetails/IONAVDetails.jsx
Normal file
192
src/Pages/IO_Management/CreateIO/IONAVDetails/IONAVDetails.jsx
Normal file
@@ -0,0 +1,192 @@
|
||||
// import { Tab, TabList, TabPanel, TabPanels, Tabs } from "@chakra-ui/react";
|
||||
// import React from "react";
|
||||
// import Approved from "./Approved";
|
||||
// import Pending from "./Pending";
|
||||
// import Rejected from "./Rejected";
|
||||
|
||||
// const IONAVDetails = () => {
|
||||
// return (
|
||||
// <Tabs>
|
||||
// <TabList>
|
||||
// <Tab
|
||||
// fontSize={"sm"}
|
||||
// _selected={{
|
||||
// color: "#004118",
|
||||
// borderBottom: "2px solid #38a169",
|
||||
// }}
|
||||
// >
|
||||
// Approved
|
||||
// </Tab>
|
||||
// <Tab
|
||||
// fontSize={"sm"}
|
||||
// _selected={{
|
||||
// color: "#004118",
|
||||
// borderBottom: "2px solid #38a169",
|
||||
// }}
|
||||
// >
|
||||
// Pending
|
||||
// </Tab>
|
||||
// <Tab
|
||||
// fontSize={"sm"}
|
||||
// _selected={{
|
||||
// color: "#004118",
|
||||
// borderBottom: "2px solid #38a169",
|
||||
// }}
|
||||
// >
|
||||
// Rejected
|
||||
// </Tab>
|
||||
// </TabList>
|
||||
// <TabPanels>
|
||||
// <TabPanel>
|
||||
// <Approved />
|
||||
// </TabPanel>
|
||||
// <TabPanel>
|
||||
// <Pending />
|
||||
// </TabPanel>
|
||||
// <TabPanel>
|
||||
// <Rejected />
|
||||
// </TabPanel>
|
||||
// </TabPanels>
|
||||
// </Tabs>
|
||||
// );
|
||||
// };
|
||||
|
||||
// export default IONAVDetails;
|
||||
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Tab,
|
||||
TabList,
|
||||
TabPanel,
|
||||
TabPanels,
|
||||
Tabs,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useRef } from "react";
|
||||
import Approved from "./Approved";
|
||||
import Pending from "./Pending";
|
||||
import Rejected from "./Rejected";
|
||||
import { AddIcon } from "@chakra-ui/icons";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import { useParams } from "react-router-dom";
|
||||
import AddNavDetails from "./AddNavDetails";
|
||||
import { useUpdateIOCaseMutation } from "../../../../Services/io.service";
|
||||
import { encryptString, isMaker } from "../../../../Constants/Constants";
|
||||
|
||||
const IONAVDetails = () => {
|
||||
const params = useParams();
|
||||
const toast = useToast();
|
||||
const id = params?.id;
|
||||
const { IODetails } = useContext(GlobalStateContext);
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const firstField = useRef();
|
||||
|
||||
const [updateIOCase] = useUpdateIOCaseMutation();
|
||||
|
||||
const handleAdd = async () => {
|
||||
try {
|
||||
const res = await updateIOCase(id);
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={res?.data?.message} />
|
||||
// ),
|
||||
// });
|
||||
// setIsLoading(false);
|
||||
onOpen();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Tabs variant="unstyled">
|
||||
<Box
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
alignItems={"center"}
|
||||
borderBottom={"1px solid #ccc"}
|
||||
>
|
||||
<TabList>
|
||||
<Tab
|
||||
fontSize={"sm"}
|
||||
_selected={{
|
||||
color: "#004118",
|
||||
borderBottom: "2px solid #38a169",
|
||||
}}
|
||||
>
|
||||
Approved
|
||||
</Tab>
|
||||
<Tab
|
||||
fontSize={"sm"}
|
||||
_selected={{
|
||||
color: "#004118",
|
||||
borderBottom: "2px solid #38a169",
|
||||
}}
|
||||
>
|
||||
Pending
|
||||
{IODetails?.ioNAVStatusHistory?.Pending.length > 0 && (
|
||||
<Badge rounded={"sm"} colorScheme="forestGreen" ms={2}>
|
||||
{IODetails?.ioNAVStatusHistory?.Pending.length || 0}
|
||||
</Badge>
|
||||
)}
|
||||
</Tab>
|
||||
<Tab
|
||||
fontSize={"sm"}
|
||||
_selected={{
|
||||
color: "#004118",
|
||||
borderBottom: "2px solid #38a169",
|
||||
}}
|
||||
>
|
||||
Rejected
|
||||
</Tab>
|
||||
</TabList>
|
||||
{IODetails?.isInvestedAmount
|
||||
? isMaker() &&
|
||||
IODetails?.ioSatatus !== "Exited" && (
|
||||
<Button
|
||||
onClick={handleAdd}
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
>
|
||||
Add
|
||||
</Button>
|
||||
)
|
||||
: null}
|
||||
</Box>
|
||||
<TabPanels>
|
||||
<TabPanel>
|
||||
<Approved />
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<Pending />
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<Rejected />
|
||||
</TabPanel>
|
||||
</TabPanels>
|
||||
</Tabs>
|
||||
<AddNavDetails
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
firstField={firstField}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default IONAVDetails;
|
||||
353
src/Pages/IO_Management/CreateIO/IONAVDetails/Pending.jsx
Normal file
353
src/Pages/IO_Management/CreateIO/IONAVDetails/Pending.jsx
Normal file
@@ -0,0 +1,353 @@
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
Text,
|
||||
Tooltip,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
|
||||
import NormalTable from "../../../../Components/DataTable/NormalTable";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import { AddIcon, CheckIcon, CloseIcon, ViewIcon } from "@chakra-ui/icons";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useUpdateIOCaseMutation } from "../../../../Services/io.service";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import AddNavDetails from "./AddNavDetails";
|
||||
import RequestApproveModal from "./RequestApproveModal";
|
||||
import RequestRejectModal from "./RequestRejectModal";
|
||||
import { encryptString, isMaker } from "../../../../Constants/Constants";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString();
|
||||
|
||||
const Pending = () => {
|
||||
const params = useParams();
|
||||
const toast = useToast();
|
||||
const id = params?.id;
|
||||
const firstField = useRef();
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const { IODetails, iONAVDetail, setIONAVDetail } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
|
||||
const [updateIOCase] = useUpdateIOCaseMutation();
|
||||
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
onOpen: onConfirmOpen,
|
||||
onClose: onConfirmClose,
|
||||
} = useDisclosure();
|
||||
const {
|
||||
isOpen: isRejectOpen,
|
||||
onOpen: onRejectOpen,
|
||||
onClose: onRejectClose,
|
||||
} = useDisclosure();
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
const timer = setTimeout(() => {
|
||||
setIsLoading(false);
|
||||
}, 1500);
|
||||
|
||||
// Cleanup the timer on component unmount
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
};
|
||||
|
||||
// Table filter
|
||||
const filteredData = IODetails?.ioNAVStatusHistory?.Pending?.filter(
|
||||
(item) => {
|
||||
// Filter by name (case insensitive)
|
||||
const name = item?.transactionDate;
|
||||
const searchLower = searchTerm?.toLowerCase();
|
||||
const nameMatches = name?.toLowerCase().includes(searchLower);
|
||||
return nameMatches;
|
||||
}
|
||||
);
|
||||
|
||||
const tableHeadRow = [
|
||||
"Sr No.",
|
||||
"Valuation date",
|
||||
"NAV",
|
||||
"Last Nav Update",
|
||||
"Investment Closed",
|
||||
"Comments",
|
||||
"Updated By",
|
||||
...(!isMaker() ? ["Status"] : []),
|
||||
];
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr No.": (
|
||||
<Text as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{index + 1}.
|
||||
</Text>
|
||||
),
|
||||
"Valuation date": (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
{formatDate(item?.transactionDate)}
|
||||
</Text>
|
||||
),
|
||||
NAV: (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{parseFloat(item?.transactionAmount || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
),
|
||||
"Last Nav Update": (
|
||||
<Text
|
||||
justifyContent={"center"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item.previousNAVvalue && `${item.previousNAVvalue}`}
|
||||
</Text>
|
||||
),
|
||||
"Investment Closed": (
|
||||
<Text
|
||||
justifyContent={"center"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item?.initialNAVvalue && `${item?.initialNAVvalue}`}
|
||||
</Text>
|
||||
),
|
||||
Comments: (
|
||||
<Text w={"100px"} as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{item?.comments ? item?.comments : "---"}
|
||||
</Text>
|
||||
),
|
||||
"Updated By": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
display={"flex"}
|
||||
alignItems={"center"}
|
||||
>
|
||||
{/* <Avatar
|
||||
mr={2}
|
||||
size="sm"
|
||||
name={item.creator?.firstName}
|
||||
src={item.creator?.profilePhoto}
|
||||
/> */}
|
||||
{item?.modifier?.firstName}
|
||||
</Text>
|
||||
),
|
||||
Status: isMaker() ? (
|
||||
<Button
|
||||
colorScheme="green"
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
px={2}
|
||||
py={1}
|
||||
fontWeight={500}
|
||||
onClick={() => {
|
||||
setActionId(item.id);
|
||||
}}
|
||||
>
|
||||
<ViewIcon me={"4px"} /> View
|
||||
</Button>
|
||||
) : (
|
||||
<Box display={"flex"} justifyContent={"center"}>
|
||||
<Box>
|
||||
<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
<Tooltip
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
label="Approve"
|
||||
bg="#fff"
|
||||
color={"green.500"}
|
||||
placement="left-start"
|
||||
>
|
||||
<Button
|
||||
// colorScheme="forestGreen"
|
||||
// color="green.500"
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
textTransform={"inherit"}
|
||||
fontWeight={500}
|
||||
px={2}
|
||||
py={1}
|
||||
onClick={() => {
|
||||
setActionId(item.id);
|
||||
onConfirmOpen();
|
||||
}}
|
||||
colorScheme="green"
|
||||
variant={"solid"}
|
||||
cursor={"pointer"}
|
||||
>
|
||||
<CheckIcon fontSize={"12px"} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
label="Reject"
|
||||
bg="#fff"
|
||||
color={"red.500"}
|
||||
placement="left-start"
|
||||
>
|
||||
<Button
|
||||
colorScheme="red"
|
||||
// color="red.500"
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
textTransform={"inherit"}
|
||||
fontWeight={500}
|
||||
px={2}
|
||||
onClick={() => {
|
||||
setActionId(item.id);
|
||||
onRejectOpen();
|
||||
}}
|
||||
py={1}
|
||||
// variant={"solid"}
|
||||
>
|
||||
<CloseIcon fontSize={"10px"} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
),
|
||||
}));
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedSponsors = sponser.filter(
|
||||
(sponsor) => sponsor.id !== actionId
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
setCaseDetails(updatedSponsors);
|
||||
setDeleteAlert(false);
|
||||
setIsLoading(false);
|
||||
}, 100);
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
const handleAdd = async () => {
|
||||
try {
|
||||
const res = await updateIOCase(id);
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={res?.data?.message} />
|
||||
// ),
|
||||
// });
|
||||
setIsLoading(false);
|
||||
onOpen();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} pb={0}>
|
||||
<Box bg="white.500">
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
pb={3}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
{/* {IODetails?.isInvestedAmount
|
||||
? localStorage?.getItem("role") === "Maker" && (
|
||||
<Button
|
||||
onClick={handleAdd}
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
>
|
||||
Add
|
||||
</Button>
|
||||
)
|
||||
: null} */}
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
<NormalTable
|
||||
emptyMessage={`We don't have any Sponers`}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={isLoading}
|
||||
viewActionId={actionId}
|
||||
setViewActionId={setActionId}
|
||||
setMouseEnteredId={setMouseEnteredId}
|
||||
setMouseEntered={setMouseEntered}
|
||||
/>
|
||||
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
<AddNavDetails
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
firstField={firstField}
|
||||
/>
|
||||
<RequestApproveModal
|
||||
// data={data?.data?.rows}
|
||||
isOpen={isConfirmOpen}
|
||||
onClose={onConfirmClose}
|
||||
id={actionId}
|
||||
// firstField={firstField}
|
||||
/>
|
||||
<RequestRejectModal
|
||||
isOpen={isRejectOpen}
|
||||
onClose={onRejectClose}
|
||||
id={actionId}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Pending;
|
||||
257
src/Pages/IO_Management/CreateIO/IONAVDetails/Rejected.jsx
Normal file
257
src/Pages/IO_Management/CreateIO/IONAVDetails/Rejected.jsx
Normal file
@@ -0,0 +1,257 @@
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
Table,
|
||||
Tag,
|
||||
Tbody,
|
||||
Text,
|
||||
Th,
|
||||
Tooltip,
|
||||
Tr,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import { AddIcon, DeleteIcon, EditIcon, ViewIcon } from "@chakra-ui/icons";
|
||||
import { LuFileSpreadsheet } from "react-icons/lu";
|
||||
import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
|
||||
import NormalTable from "../../../../Components/DataTable/NormalTable";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import AddCashDetails from "../AddCashDetails";
|
||||
import { debounce } from "../../../Admin/Contact";
|
||||
import { useUpdateIOCaseMutation } from "../../../../Services/io.service";
|
||||
import { useParams } from "react-router-dom";
|
||||
import AddNavDetails from "./AddNavDetails";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString();
|
||||
|
||||
const Rejected = () => {
|
||||
const params = useParams();
|
||||
const toast = useToast();
|
||||
const id = params?.id;
|
||||
const firstField = useRef();
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const { IODetails, iONAVDetail, setIONAVDetail } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
const [updateIOCase] = useUpdateIOCaseMutation();
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
const timer = setTimeout(() => {
|
||||
setIsLoading(false);
|
||||
}, 1500);
|
||||
|
||||
// Cleanup the timer on component unmount
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
};
|
||||
|
||||
// Table filter
|
||||
const filteredData = IODetails?.ioNAVStatusHistory?.Reject?.filter((item) => {
|
||||
// Filter by name (case insensitive)
|
||||
const name = item.transactionAmount;
|
||||
const searchLower = searchTerm.toLowerCase();
|
||||
const nameMatches = name.toLowerCase().includes(searchLower);
|
||||
return nameMatches;
|
||||
});
|
||||
|
||||
const tableHeadRow = [
|
||||
"Sr No.",
|
||||
"Valuation date",
|
||||
"NAV",
|
||||
"Last Nav Update",
|
||||
"Investment Closed",
|
||||
"Comments",
|
||||
"Updated By",
|
||||
];
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr No.": (
|
||||
<Text as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{index + 1}.
|
||||
</Text>
|
||||
),
|
||||
"Valuation date": (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
{formatDate(item?.transactionDate)}
|
||||
</Text>
|
||||
),
|
||||
NAV: (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{parseFloat(item?.transactionAmount || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
),
|
||||
"Last Nav Update": (
|
||||
<Text
|
||||
justifyContent={"center"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item.previousNAVvalue && `${item.previousNAVvalue}`}
|
||||
</Text>
|
||||
),
|
||||
"Investment Closed": (
|
||||
<Text
|
||||
justifyContent={"center"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item?.initialNAVvalue && `${item?.initialNAVvalue}`}
|
||||
</Text>
|
||||
),
|
||||
Comments: (
|
||||
<Text w={"100px"} as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{item?.comments ? item?.comments : "---"}
|
||||
</Text>
|
||||
),
|
||||
"Updated By": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
display={"flex"}
|
||||
alignItems={"center"}
|
||||
>
|
||||
{/* <Avatar
|
||||
mr={2}
|
||||
size="sm"
|
||||
name={item.creator?.firstName}
|
||||
src={item.creator?.profilePhoto}
|
||||
/> */}
|
||||
{item?.modifier?.firstName}
|
||||
</Text>
|
||||
),
|
||||
}));
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedSponsors = sponser.filter(
|
||||
(sponsor) => sponsor.id !== actionId
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
setCaseDetails(updatedSponsors);
|
||||
setDeleteAlert(false);
|
||||
setIsLoading(false);
|
||||
}, 100);
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
const handleAdd = async () => {
|
||||
try {
|
||||
const res = await updateIOCase(id);
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={res?.data?.message} />
|
||||
// ),
|
||||
// });
|
||||
setIsLoading(false);
|
||||
onOpen();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} pb={0}>
|
||||
<Box bg="white.500">
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
pb={3}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
|
||||
{/* {IODetails?.isInvestedAmount
|
||||
? localStorage?.getItem("role") === "Maker" && (
|
||||
<Button
|
||||
onClick={handleAdd}
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
>
|
||||
Add
|
||||
</Button>
|
||||
)
|
||||
: null} */}
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
<NormalTable
|
||||
emptyMessage={`We don't have any Sponers`}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={isLoading}
|
||||
viewActionId={actionId}
|
||||
setViewActionId={setActionId}
|
||||
setMouseEnteredId={setMouseEnteredId}
|
||||
setMouseEntered={setMouseEntered}
|
||||
/>
|
||||
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
|
||||
<AddNavDetails
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
firstField={firstField}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Rejected;
|
||||
@@ -0,0 +1,176 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
Textarea,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import { useApproveIOCaseMutation, useApproveIONavMutation } from "../../../../Services/io.service";
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
// comments: yup.string().required("Comment is required")
|
||||
// .max(50, "Investment name cannot be more than 50 characters"),
|
||||
comments: yup
|
||||
.string()
|
||||
.required("Comment is required")
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const RequestApproveModal = ({ isOpen, onClose, firstField ,id}) => {
|
||||
const [isBtnLoading , setIsBtnLoading] = useState(false)
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
const {
|
||||
register,
|
||||
reset,
|
||||
watch,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(conformModalSchema),
|
||||
});
|
||||
|
||||
const [ approveIONav ] = useApproveIONavMutation()
|
||||
|
||||
|
||||
const onSubmit = async(data) => {
|
||||
console.log(data, "tewxttttt");
|
||||
setIsBtnLoading(true)
|
||||
try {
|
||||
const res = await approveIONav({data,id})
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}else if(res?.data){
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
});
|
||||
onClose()
|
||||
setIsBtnLoading(false)
|
||||
}else{
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const handleFileChange = (event) => {
|
||||
const selectedFile = event.target.files[0];
|
||||
setFile(selectedFile);
|
||||
};
|
||||
|
||||
|
||||
const { data, isLoading } =
|
||||
(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
reset({
|
||||
investorAmount: data?.data?.investorAmount,
|
||||
});
|
||||
}
|
||||
}, [data, reset]);
|
||||
|
||||
const heandleOnClose = () =>{
|
||||
reset()
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal isCentered isOpen={isOpen} onClose={heandleOnClose} initialFocusRef={firstField}>
|
||||
<ModalOverlay />
|
||||
<ModalContent pb={4}>
|
||||
<ModalHeader fontSize={"md"}>Approve Comment</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
{isLoading ? (
|
||||
<FullscreenLoaders height={"50vh"} />
|
||||
) : (
|
||||
<Box as="form" onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalBody>
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormLabel fontSize="sm">Comment</FormLabel>
|
||||
<Textarea
|
||||
rows={6}
|
||||
focusBorderColor="green.400"
|
||||
name="comments"
|
||||
{...register("comments")}
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="md"
|
||||
placeholder={"Enter your checker comment...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comments && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comments.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered</Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
colorScheme="gray"
|
||||
mr={3}
|
||||
onClick={onClose}
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
colorScheme="forestGreen"
|
||||
variant="solid"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
isLoading={isBtnLoading}
|
||||
type="submit"
|
||||
>
|
||||
Send
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Box>
|
||||
)}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default RequestApproveModal;
|
||||
@@ -0,0 +1,172 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
Textarea,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import { useRejectIOCaseMutation } from "../../../../Services/io.service";
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
comments: yup.string().required("Comment is required")
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const RequestRejectModal = ({ isOpen, onClose, firstField ,id}) => {
|
||||
const [isBtnLoading , setIsBtnLoading] = useState(false)
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
const {
|
||||
register,
|
||||
reset,
|
||||
watch,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(conformModalSchema),
|
||||
});
|
||||
|
||||
const [ rejectIOCase ] = useRejectIOCaseMutation()
|
||||
|
||||
|
||||
const onSubmit = async(data) => {
|
||||
console.log(data, "tewxttttt");
|
||||
setIsBtnLoading(true)
|
||||
try {
|
||||
const res = await rejectIOCase({data,id})
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}else if(res?.data){
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
});
|
||||
onClose()
|
||||
setIsBtnLoading(false)
|
||||
}else{
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const handleFileChange = (event) => {
|
||||
const selectedFile = event.target.files[0];
|
||||
setFile(selectedFile);
|
||||
};
|
||||
|
||||
|
||||
const { data, isLoading } =
|
||||
(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
reset({
|
||||
investorAmount: data?.data?.investorAmount,
|
||||
});
|
||||
}
|
||||
}, [data, reset]);
|
||||
|
||||
const heandleOnClose = () =>{
|
||||
reset()
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal isCentered isOpen={isOpen} onClose={heandleOnClose} initialFocusRef={firstField}>
|
||||
<ModalOverlay />
|
||||
<ModalContent pb={4}>
|
||||
<ModalHeader fontSize={"md"}>Reject Comment</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
{isLoading ? (
|
||||
<FullscreenLoaders height={"50vh"} />
|
||||
) : (
|
||||
<Box as="form" onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalBody>
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormLabel fontSize="sm">Comment</FormLabel>
|
||||
<Textarea
|
||||
rows={6}
|
||||
focusBorderColor="green.400"
|
||||
name="comments"
|
||||
{...register("comments")}
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="md"
|
||||
placeholder={"Enter your comments...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comments && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comments.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered </Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
colorScheme="gray"
|
||||
mr={3}
|
||||
onClick={onClose}
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
colorScheme="forestGreen"
|
||||
variant="solid"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
isLoading={isBtnLoading}
|
||||
type="submit"
|
||||
>
|
||||
Send
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Box>
|
||||
)}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default RequestRejectModal;
|
||||
@@ -0,0 +1,179 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
Textarea,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import { useApproveDistributedMutation } from "../../../../Services/io.service";
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
// comments: yup.string().required("Comment is required")
|
||||
// .max(50, "Investment name cannot be more than 50 characters"),
|
||||
comments: yup
|
||||
.string()
|
||||
.required("Comment is required")
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const ApproveDistrubationModal = ({ isOpen, onClose, firstField ,id, onBigModalClose}) => {
|
||||
const [isBtnLoading , setIsBtnLoading] = useState(false)
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
|
||||
|
||||
const {
|
||||
register,
|
||||
reset,
|
||||
watch,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(conformModalSchema),
|
||||
});
|
||||
|
||||
const [ approveDistributed ] = useApproveDistributedMutation()
|
||||
|
||||
|
||||
const onSubmit = async(data) => {
|
||||
setIsBtnLoading(true)
|
||||
try {
|
||||
const res = await approveDistributed({data,id})
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}else if(res?.data){
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
});
|
||||
onClose()
|
||||
onBigModalClose()
|
||||
setIsBtnLoading(false)
|
||||
}else{
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const handleFileChange = (event) => {
|
||||
const selectedFile = event.target.files[0];
|
||||
setFile(selectedFile);
|
||||
};
|
||||
|
||||
|
||||
const { data, isLoading } =
|
||||
(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
reset({
|
||||
investorAmount: data?.data?.investorAmount,
|
||||
});
|
||||
}
|
||||
}, [data, reset]);
|
||||
|
||||
const heandleOnClose = () =>{
|
||||
reset()
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal isCentered isOpen={isOpen} onClose={heandleOnClose} initialFocusRef={firstField}>
|
||||
<ModalOverlay />
|
||||
<ModalContent pb={4}>
|
||||
<ModalHeader fontSize={"md"}>Approve Comment</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
{isLoading ? (
|
||||
<FullscreenLoaders height={"50vh"} />
|
||||
) : (
|
||||
<Box as="form" onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalBody>
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormLabel fontSize="sm">Comment</FormLabel>
|
||||
<Textarea
|
||||
rows={6}
|
||||
focusBorderColor="green.400"
|
||||
name="comments"
|
||||
{...register("comments")}
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="md"
|
||||
placeholder={"Enter your checker comment...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comments && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comments.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}> Maximum length should be 200 characters. You have entered</Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
colorScheme="gray"
|
||||
mr={3}
|
||||
onClick={onClose}
|
||||
size={"xs"}
|
||||
rounded={"sm"}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
colorScheme="forestGreen"
|
||||
variant="solid"
|
||||
size={"xs"}
|
||||
rounded={"sm"}
|
||||
isLoading={isBtnLoading}
|
||||
type="submit"
|
||||
>
|
||||
Send
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Box>
|
||||
)}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ApproveDistrubationModal;
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
Textarea,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import { useApproveInvestedMutation } from "../../../../Services/io.service";
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
// comments: yup.string().required("Comment is required")
|
||||
// .max(50, "Investment name cannot be more than 50 characters"),
|
||||
comments: yup
|
||||
.string()
|
||||
.required("Comment is required")
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const ApproveInvestedModal = ({ isOpen, onClose, firstField ,id,onBigModalClose}) => {
|
||||
const [isBtnLoading , setIsBtnLoading] = useState(false)
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
const {
|
||||
register,
|
||||
reset,
|
||||
watch,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(conformModalSchema),
|
||||
});
|
||||
|
||||
const [ approveInvested ] = useApproveInvestedMutation()
|
||||
|
||||
|
||||
const onSubmit = async(data) => {
|
||||
setIsBtnLoading(true)
|
||||
try {
|
||||
const res = await approveInvested({data,id})
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}else if(res?.data){
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
});
|
||||
onClose()
|
||||
onBigModalClose()
|
||||
setIsBtnLoading(false)
|
||||
}else{
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const handleFileChange = (event) => {
|
||||
const selectedFile = event.target.files[0];
|
||||
setFile(selectedFile);
|
||||
};
|
||||
|
||||
|
||||
const { data, isLoading } =
|
||||
(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
reset({
|
||||
investorAmount: data?.data?.investorAmount,
|
||||
});
|
||||
}
|
||||
}, [data, reset]);
|
||||
|
||||
const heandleOnClose = () =>{
|
||||
reset()
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal isCentered isOpen={isOpen} onClose={heandleOnClose} initialFocusRef={firstField}>
|
||||
<ModalOverlay />
|
||||
<ModalContent pb={4}>
|
||||
<ModalHeader fontSize={"md"}>Approve Comment</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
{isLoading ? (
|
||||
<FullscreenLoaders height={"50vh"} />
|
||||
) : (
|
||||
<Box as="form" onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalBody>
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormLabel fontSize="sm">Comment</FormLabel>
|
||||
<Textarea
|
||||
rows={6}
|
||||
focusBorderColor="green.400"
|
||||
name="comments"
|
||||
{...register("comments")}
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="md"
|
||||
placeholder={"Enter your checker comment...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comments && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comments.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered</Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
colorScheme="gray"
|
||||
mr={3}
|
||||
onClick={onClose}
|
||||
size={"xs"}
|
||||
rounded={"sm"}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
colorScheme="forestGreen"
|
||||
variant="solid"
|
||||
size={"xs"}
|
||||
rounded={"sm"}
|
||||
isLoading={isBtnLoading}
|
||||
type="submit"
|
||||
>
|
||||
Send
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Box>
|
||||
)}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ApproveInvestedModal;
|
||||
|
||||
249
src/Pages/IO_Management/CreateIO/IOTransaction/Approved.jsx
Normal file
249
src/Pages/IO_Management/CreateIO/IOTransaction/Approved.jsx
Normal file
@@ -0,0 +1,249 @@
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
Table,
|
||||
Tag,
|
||||
Tbody,
|
||||
Text,
|
||||
Th,
|
||||
Tooltip,
|
||||
Tr,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import { AddIcon, DeleteIcon, EditIcon, ViewIcon } from "@chakra-ui/icons";
|
||||
import { LuFileSpreadsheet } from "react-icons/lu";
|
||||
import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
|
||||
import NormalTable from "../../../../Components/DataTable/NormalTable";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import AddCashDetails from "../AddCashDetails";
|
||||
import { debounce } from "../../../Admin/Contact";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString();
|
||||
|
||||
const Approved = () => {
|
||||
const toast = useToast();
|
||||
const firstField = useRef();
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const { IODetails, iOTransaction, setIOTransaction } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
const timer = setTimeout(() => {
|
||||
setIsLoading(false);
|
||||
}, 1500);
|
||||
|
||||
// Cleanup the timer on component unmount
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// Table filter
|
||||
const filteredData = IODetails?.ioTransactionRecords?.Approved?.filter((item) => {
|
||||
// Filter by name (case insensitive)
|
||||
const name = item?.transactionAmount;
|
||||
const searchLower = searchTerm?.toLowerCase();
|
||||
const nameMatches = name?.toLowerCase().includes(searchLower);
|
||||
return nameMatches;
|
||||
});
|
||||
|
||||
const tableHeadRow = [
|
||||
"Sr No.",
|
||||
"Transaction Date",
|
||||
"Transaction Name",
|
||||
"Amount",
|
||||
"Created By",
|
||||
"Created On",
|
||||
"Approved By",
|
||||
"Approved On",
|
||||
];
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr No.": (
|
||||
<Text
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{index + 1}.
|
||||
</Text>
|
||||
),
|
||||
"Transaction Date": (
|
||||
<Text
|
||||
as={"span"}
|
||||
color={"gray.600"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{formatDate(item?.transactionDate)}
|
||||
</Text>
|
||||
),
|
||||
"Transaction Name": (
|
||||
<Text
|
||||
as={"span"}
|
||||
color={"gray.600"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{item?.transactionType}
|
||||
</Text>
|
||||
),
|
||||
"Amount": (
|
||||
<Text
|
||||
as={"span"}
|
||||
color={"gray.600"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{/* {item?.transactionAmount} */}
|
||||
{parseFloat(item?.transactionAmount || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
),
|
||||
"Created By": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
textTransform={'capitalize'}
|
||||
>
|
||||
{item?.creator?.firstName}
|
||||
</Text>
|
||||
),
|
||||
"Created On": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{formatDate(item?.createdAt)}
|
||||
</Text>
|
||||
),
|
||||
"Approved By": (
|
||||
<>
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
textTransform={'capitalize'}
|
||||
>
|
||||
{item?.modifier?.firstName}
|
||||
</Text>
|
||||
{/* <Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
display={"flex"}
|
||||
alignItems={"center"}
|
||||
>
|
||||
<Avatar
|
||||
mr={2}
|
||||
size="sm"
|
||||
name={item.creator?.firstName}
|
||||
src={item.creator?.profilePhoto}
|
||||
/>
|
||||
{item?.creator?.firstName}
|
||||
</Text> */}
|
||||
</>
|
||||
),
|
||||
"Approved On": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{item?.modifier ? formatDate(item?.updatedAt) : "---" }
|
||||
{}
|
||||
</Text>
|
||||
),
|
||||
}));
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedSponsors = sponser.filter(
|
||||
(sponsor) => sponsor.id !== actionId
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
setCaseDetails(updatedSponsors);
|
||||
setDeleteAlert(false);
|
||||
setIsLoading(false);
|
||||
}, 100);
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} pb={0}>
|
||||
<Box bg="white.500">
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
pb={3}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
<NormalTable
|
||||
emptyMessage={`We don't have any Sponers`}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={isLoading}
|
||||
viewActionId={actionId}
|
||||
setViewActionId={setActionId}
|
||||
setMouseEnteredId={setMouseEnteredId}
|
||||
setMouseEntered={setMouseEntered}
|
||||
/>
|
||||
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Approved;
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
Textarea,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import {useApproveCancleTransactionMutation, useApproveExitTransactionMutation} from "../../../../Services/io.service";
|
||||
|
||||
|
||||
const ApprovedCancelTransaction = ({ isOpen, onClose, firstField ,id,onBigModalClose}) => {
|
||||
const [isBtnLoading , setIsBtnLoading] = useState(false)
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
const {
|
||||
register,
|
||||
reset,
|
||||
watch,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(),
|
||||
});
|
||||
|
||||
const [ approveCancleTransaction ] = useApproveCancleTransactionMutation()
|
||||
|
||||
|
||||
const onSubmit = async(data) => {
|
||||
setIsBtnLoading(true)
|
||||
try {
|
||||
const res = await approveCancleTransaction({data,id})
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}else if(res?.data){
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
});
|
||||
onClose()
|
||||
onBigModalClose()
|
||||
setIsBtnLoading(false)
|
||||
}else{
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const { data, isLoading } =
|
||||
(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
reset({
|
||||
investorAmount: data?.data?.investorAmount,
|
||||
});
|
||||
}
|
||||
}, [data, reset]);
|
||||
|
||||
const heandleOnClose = () =>{
|
||||
reset()
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal isCentered isOpen={isOpen} onClose={heandleOnClose} initialFocusRef={firstField}>
|
||||
<ModalOverlay />
|
||||
<ModalContent pb={4}>
|
||||
<ModalHeader fontSize={"md"}>Approve Comment</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
{isLoading ? (
|
||||
<FullscreenLoaders height={"50vh"} />
|
||||
) : (
|
||||
<Box as="form" onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalBody>
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormLabel fontSize="sm">Comment</FormLabel>
|
||||
<Textarea
|
||||
rows={6}
|
||||
focusBorderColor="green.400"
|
||||
name="comments"
|
||||
{...register("comments")}
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="md"
|
||||
placeholder={"Enter your checker comment...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comments && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comments.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered</Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
colorScheme="gray"
|
||||
mr={3}
|
||||
onClick={onClose}
|
||||
size={"xs"}
|
||||
rounded={"sm"}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
colorScheme="forestGreen"
|
||||
variant="solid"
|
||||
size={"xs"}
|
||||
rounded={"sm"}
|
||||
isLoading={isBtnLoading}
|
||||
type="submit"
|
||||
>
|
||||
Send
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Box>
|
||||
)}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ApprovedCancelTransaction;
|
||||
|
||||
175
src/Pages/IO_Management/CreateIO/IOTransaction/ApprovedExit.jsx
Normal file
175
src/Pages/IO_Management/CreateIO/IOTransaction/ApprovedExit.jsx
Normal file
@@ -0,0 +1,175 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
Textarea,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import { useApproveExitTransactionMutation } from "../../../../Services/io.service";
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
comments: yup
|
||||
.string()
|
||||
.required("Comment is required")
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const ApprovedExit = ({ isOpen, onClose, firstField ,id,onBigModalClose}) => {
|
||||
const [isBtnLoading , setIsBtnLoading] = useState(false)
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
const {
|
||||
register,
|
||||
reset,
|
||||
watch,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(conformModalSchema),
|
||||
});
|
||||
|
||||
const [ approveExitTransaction ] = useApproveExitTransactionMutation()
|
||||
|
||||
|
||||
const onSubmit = async(data) => {
|
||||
setIsBtnLoading(true)
|
||||
try {
|
||||
const res = await approveExitTransaction({data,id})
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}else if(res?.data){
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
});
|
||||
onClose()
|
||||
onBigModalClose()
|
||||
setIsBtnLoading(false)
|
||||
}else{
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const handleFileChange = (event) => {
|
||||
const selectedFile = event.target.files[0];
|
||||
setFile(selectedFile);
|
||||
};
|
||||
|
||||
|
||||
const { data, isLoading } =
|
||||
(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
reset({
|
||||
investorAmount: data?.data?.investorAmount,
|
||||
});
|
||||
}
|
||||
}, [data, reset]);
|
||||
|
||||
const heandleOnClose = () =>{
|
||||
reset()
|
||||
onClose()
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<Modal isCentered isOpen={isOpen} onClose={heandleOnClose} initialFocusRef={firstField}>
|
||||
<ModalOverlay />
|
||||
<ModalContent pb={4}>
|
||||
<ModalHeader fontSize={"md"}>Approve Comment</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
{isLoading ? (
|
||||
<FullscreenLoaders height={"50vh"} />
|
||||
) : (
|
||||
<Box as="form" onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalBody>
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormLabel fontSize="sm">Comment</FormLabel>
|
||||
<Textarea
|
||||
rows={6}
|
||||
focusBorderColor="green.400"
|
||||
name="comments"
|
||||
{...register("comments")}
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="md"
|
||||
placeholder={"Enter your checker comment...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comments && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comments.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered</Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
colorScheme="gray"
|
||||
mr={3}
|
||||
onClick={onClose}
|
||||
size={"xs"}
|
||||
rounded={"sm"}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
colorScheme="forestGreen"
|
||||
variant="solid"
|
||||
size={"xs"}
|
||||
rounded={"sm"}
|
||||
isLoading={isBtnLoading}
|
||||
type="submit"
|
||||
>
|
||||
Send
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Box>
|
||||
)}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ApprovedExit;
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import {
|
||||
Badge,
|
||||
Tab,
|
||||
TabList,
|
||||
TabPanel,
|
||||
TabPanels,
|
||||
Tabs,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext } from "react";
|
||||
import Approved from "./Approved";
|
||||
import Pending from "./Pending";
|
||||
import Rejected from "./Rejected";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
|
||||
const IOTransaction = () => {
|
||||
const { IODetails } = useContext(GlobalStateContext);
|
||||
return (
|
||||
<Tabs>
|
||||
<TabList>
|
||||
<Tab
|
||||
fontSize={"sm"}
|
||||
_selected={{
|
||||
color: "#004118",
|
||||
borderBottom: "2px solid #38a169",
|
||||
}}
|
||||
>
|
||||
Approved
|
||||
</Tab>
|
||||
<Tab
|
||||
fontSize={"sm"}
|
||||
_selected={{
|
||||
color: "#004118",
|
||||
borderBottom: "2px solid #38a169",
|
||||
}}
|
||||
>
|
||||
Pending
|
||||
{IODetails?.ioTransactionRecords?.Pending.length > 0 && (
|
||||
<Badge rounded={"sm"} colorScheme="forestGreen" ms={2}>
|
||||
{IODetails?.ioTransactionRecords?.Pending.length || 0}
|
||||
</Badge>
|
||||
)}
|
||||
</Tab>
|
||||
<Tab
|
||||
fontSize={"sm"}
|
||||
_selected={{
|
||||
color: "#004118",
|
||||
borderBottom: "2px solid #38a169",
|
||||
}}
|
||||
>
|
||||
Rejected
|
||||
</Tab>
|
||||
</TabList>
|
||||
<TabPanels>
|
||||
<TabPanel>
|
||||
<Approved />
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<Pending />
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<Rejected />
|
||||
</TabPanel>
|
||||
</TabPanels>
|
||||
</Tabs>
|
||||
);
|
||||
};
|
||||
|
||||
export default IOTransaction;
|
||||
293
src/Pages/IO_Management/CreateIO/IOTransaction/Pending.jsx
Normal file
293
src/Pages/IO_Management/CreateIO/IOTransaction/Pending.jsx
Normal file
@@ -0,0 +1,293 @@
|
||||
import { ViewIcon } from "@chakra-ui/icons";
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
Text,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import NormalTable from "../../../../Components/DataTable/NormalTable";
|
||||
import { isMaker } from "../../../../Constants/Constants";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
|
||||
import RequestApproveModal from "./RequestApproveModal";
|
||||
import RequestRejectModal from "./RequestRejectModal";
|
||||
import ViewAmountInvested from "./ViewAmountInvested";
|
||||
import ViewCancel from "./ViewCancel";
|
||||
import ViewDistributionInvestor from "./ViewDistributionInvestor";
|
||||
import ViewExit from "./ViewExit";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString();
|
||||
|
||||
const Pending = () => {
|
||||
const toast = useToast();
|
||||
const firstField = useRef();
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const { IODetails, iOTransaction, setIOTransaction } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
const [distributedAmt, setDistributedAmt] = useState();
|
||||
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
onOpen: onConfirmOpen,
|
||||
onClose: onConfirmClose,
|
||||
} = useDisclosure();
|
||||
const {
|
||||
isOpen: isRejectOpen,
|
||||
onOpen: onRejectOpen,
|
||||
onClose: onRejectClose,
|
||||
} = useDisclosure();
|
||||
const {
|
||||
isOpen: isInvestmentOpen,
|
||||
onOpen: onInvestmentOpen,
|
||||
onClose: onInvestmentClose,
|
||||
} = useDisclosure();
|
||||
const {
|
||||
isOpen: isDistInvestorOpen,
|
||||
onOpen: onDistInvestorOpen,
|
||||
onClose: onDistInvestorClose,
|
||||
} = useDisclosure();
|
||||
const {
|
||||
isOpen: isExitOpen,
|
||||
onOpen: onExitOpen,
|
||||
onClose: onExitClose,
|
||||
} = useDisclosure();
|
||||
const {
|
||||
isOpen: isCancelOpen,
|
||||
onOpen: onCancelOpen,
|
||||
onClose: onCancelClose,
|
||||
} = useDisclosure();
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
const timer = setTimeout(() => {
|
||||
setIsLoading(false);
|
||||
}, 1500);
|
||||
|
||||
// Cleanup the timer on component unmount
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
};
|
||||
|
||||
// Table filter
|
||||
// const filteredData = IODetails?.ioTransactionRecords?.Pending?.filter((item) => {
|
||||
// // Filter by name (case insensitive)
|
||||
// const name = item.transactionName;
|
||||
// const searchLower = searchTerm?.toLowerCase();
|
||||
// const nameMatches = name?.toLowerCase().includes(searchLower);
|
||||
// return nameMatches;
|
||||
// });
|
||||
|
||||
const tableHeadRow = [
|
||||
"Sr No.",
|
||||
"Transaction Date",
|
||||
"Transaction Name",
|
||||
"Amount",
|
||||
"Created By",
|
||||
"Created On",
|
||||
"Approved By",
|
||||
"Approved On",
|
||||
"Actions",
|
||||
];
|
||||
|
||||
const extractedArray = IODetails?.ioTransactionRecords?.Pending?.map(
|
||||
(item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr No.": (
|
||||
<Text as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{index + 1}.
|
||||
</Text>
|
||||
),
|
||||
"Transaction Date": (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
{formatDate(item?.transactionDate)}
|
||||
</Text>
|
||||
),
|
||||
"Transaction Name": (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
{item?.transactionType}
|
||||
</Text>
|
||||
),
|
||||
Amount: (
|
||||
<Text as={"span"} color={"gray.600"} fontWeight={"500"}>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{parseFloat(item?.transactionAmount || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
),
|
||||
// Amount:(
|
||||
// <div>
|
||||
// <ViewDistributionInvestor amount={item?.transactionAmount} />
|
||||
// </div>
|
||||
// ),
|
||||
"Created By": (
|
||||
<Text
|
||||
textTransform={"capitalize"}
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{item?.creator?.firstName}
|
||||
</Text>
|
||||
),
|
||||
"Created On": (
|
||||
<Text w={"100px"} as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{formatDate(item?.createdAt)}
|
||||
</Text>
|
||||
),
|
||||
"Approved By": (
|
||||
<Text
|
||||
textTransform={"capitalize"}
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{item?.modifier?.firstName}
|
||||
</Text>
|
||||
),
|
||||
"Approved On": (
|
||||
<Text w={"100px"} as={"span"} color={"gray.800"} fontWeight={"500"}>
|
||||
{item?.modifier ? formatDate(item?.updatedAt) : "---"}
|
||||
</Text>
|
||||
),
|
||||
Actions: (
|
||||
<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
<Button
|
||||
colorScheme="forestGreen"
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
px={2}
|
||||
py={1}
|
||||
fontWeight={500}
|
||||
onClick={() => {
|
||||
setActionId(item.id); // Set the action ID for all cases
|
||||
if (item?.transactionType === "Amount Invested") {
|
||||
onInvestmentOpen();
|
||||
} else if (item?.transactionType === "Distribution To Investor") {
|
||||
onDistInvestorOpen();
|
||||
setDistributedAmt(item?.transactionAmount);
|
||||
} else if (item?.transactionType === "Exit") {
|
||||
onExitOpen();
|
||||
} else if (item?.transactionType === "Cancel") {
|
||||
onCancelOpen();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{isMaker() ? <ViewIcon me={"4px"} /> : null}{" "}
|
||||
{isMaker() ? "View" : "Approve / Reject"}
|
||||
</Button>
|
||||
</Box>
|
||||
),
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedSponsors = sponser.filter(
|
||||
(sponsor) => sponsor.id !== actionId
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
setCaseDetails(updatedSponsors);
|
||||
setDeleteAlert(false);
|
||||
setIsLoading(false);
|
||||
}, 100);
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} pb={0}>
|
||||
<Box bg="white.500">
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
pb={3}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
<NormalTable
|
||||
emptyMessage={`We don't have any Sponers`}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={isLoading}
|
||||
viewActionId={actionId}
|
||||
setViewActionId={setActionId}
|
||||
setMouseEnteredId={setMouseEnteredId}
|
||||
setMouseEntered={setMouseEntered}
|
||||
/>
|
||||
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
|
||||
<ViewAmountInvested
|
||||
isOpen={isInvestmentOpen}
|
||||
onClose={onInvestmentClose}
|
||||
id={actionId}
|
||||
/>
|
||||
<ViewDistributionInvestor
|
||||
isOpen={isDistInvestorOpen}
|
||||
onClose={onDistInvestorClose}
|
||||
id={actionId}
|
||||
amount={distributedAmt}
|
||||
/>
|
||||
<ViewExit isOpen={isExitOpen} onClose={onExitClose} id={actionId} />
|
||||
<ViewCancel isOpen={isCancelOpen} onClose={onCancelClose} id={actionId} />
|
||||
<RequestApproveModal
|
||||
// data={data?.data?.rows}
|
||||
isOpen={isConfirmOpen}
|
||||
onClose={onConfirmClose}
|
||||
id={actionId}
|
||||
// firstField={firstField}
|
||||
/>
|
||||
<RequestRejectModal
|
||||
isOpen={isRejectOpen}
|
||||
onClose={onRejectClose}
|
||||
id={actionId}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Pending;
|
||||
219
src/Pages/IO_Management/CreateIO/IOTransaction/Rejected.jsx
Normal file
219
src/Pages/IO_Management/CreateIO/IOTransaction/Rejected.jsx
Normal file
@@ -0,0 +1,219 @@
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
Table,
|
||||
Tag,
|
||||
Tbody,
|
||||
Text,
|
||||
Th,
|
||||
Tooltip,
|
||||
Tr,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import { AddIcon, DeleteIcon, EditIcon, ViewIcon } from "@chakra-ui/icons";
|
||||
import { LuFileSpreadsheet } from "react-icons/lu";
|
||||
import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
|
||||
import NormalTable from "../../../../Components/DataTable/NormalTable";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import AddCashDetails from "../AddCashDetails";
|
||||
import { debounce } from "../../../Admin/Contact";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString();
|
||||
|
||||
const Rejected = () => {
|
||||
const toast = useToast();
|
||||
const firstField = useRef();
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const { IODetails, iOTransaction, setIOTransaction } =
|
||||
useContext(GlobalStateContext);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
const timer = setTimeout(() => {
|
||||
setIsLoading(false);
|
||||
}, 1500);
|
||||
|
||||
// Cleanup the timer on component unmount
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
|
||||
const formatDate = (date) => {
|
||||
return new Date(date).toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// Table filter
|
||||
// const filteredData = IODetails?.ioTransactionRecords?.Reject?.filter((item) => {
|
||||
// // Filter by name (case insensitive)
|
||||
// const name = item.transactionName;
|
||||
// const searchLower = searchTerm.toLowerCase();
|
||||
// const nameMatches = name.toLowerCase().includes(searchLower);
|
||||
// return nameMatches;
|
||||
// });
|
||||
|
||||
const tableHeadRow = [
|
||||
"Sr No.",
|
||||
"Transaction Name",
|
||||
"Amount",
|
||||
"Created By",
|
||||
"Created On",
|
||||
"Approved By",
|
||||
"Approved On",
|
||||
];
|
||||
|
||||
const extractedArray = IODetails?.ioTransactionRecords?.Reject?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr No.": (
|
||||
<Text
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{index + 1}.
|
||||
</Text>
|
||||
),
|
||||
"Transaction Name": (
|
||||
<Text
|
||||
as={"span"}
|
||||
color={"gray.600"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{item?.transactionType}
|
||||
</Text>
|
||||
),
|
||||
"Amount": (
|
||||
<Text
|
||||
as={"span"}
|
||||
color={"gray.600"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{parseFloat(item?.transactionAmount || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
),
|
||||
"Created By": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
textTransform={'capitalize'}
|
||||
>
|
||||
{item?.creator?.firstName}
|
||||
</Text>
|
||||
),
|
||||
"Created On": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{formatDate(item?.createdAt)}
|
||||
</Text>
|
||||
),
|
||||
"Approved By": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
textTransform={'capitalize'}
|
||||
>
|
||||
{item?.modifier?.firstName}
|
||||
</Text>
|
||||
),
|
||||
"Approved On": (
|
||||
<Text
|
||||
w={"100px"}
|
||||
as={"span"}
|
||||
color={"gray.800"}
|
||||
fontWeight={"500"}
|
||||
>
|
||||
{formatDate(item?.updatedAt)}
|
||||
</Text>
|
||||
),
|
||||
}));
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedSponsors = sponser.filter(
|
||||
(sponsor) => sponsor.id !== actionId
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
setCaseDetails(updatedSponsors);
|
||||
setDeleteAlert(false);
|
||||
setIsLoading(false);
|
||||
}, 100);
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} pb={0}>
|
||||
<Box bg="white.500">
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
pb={3}
|
||||
spacing="24px"
|
||||
>
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
<NormalTable
|
||||
emptyMessage={`We don't have any Sponers`}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={isLoading}
|
||||
viewActionId={actionId}
|
||||
setViewActionId={setActionId}
|
||||
setMouseEnteredId={setMouseEnteredId}
|
||||
setMouseEntered={setMouseEntered}
|
||||
/>
|
||||
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Rejected;
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
Textarea,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import { useApproveDistributionMutation, useApproveIOCaseMutation, useApproveIONavMutation } from "../../../../Services/io.service";
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
// comments: yup.string().required("Comment is required")
|
||||
// .max(50, "Investment name cannot be more than 50 characters"),
|
||||
comments: yup
|
||||
.string()
|
||||
.required("Comment is required")
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const RequestApproveModal = ({ isOpen, onClose, firstField ,id}) => {
|
||||
const [isBtnLoading , setIsBtnLoading] = useState(false)
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
const {
|
||||
register,
|
||||
reset,
|
||||
watch,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(conformModalSchema),
|
||||
});
|
||||
|
||||
const [ approveDistribution ] = useApproveDistributionMutation()
|
||||
|
||||
|
||||
const onSubmit = async(data) => {
|
||||
setIsBtnLoading(true)
|
||||
try {
|
||||
const res = await approveDistribution({data,id})
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}else if(res?.data){
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
});
|
||||
onClose()
|
||||
setIsBtnLoading(false)
|
||||
}else{
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const handleFileChange = (event) => {
|
||||
const selectedFile = event.target.files[0];
|
||||
setFile(selectedFile);
|
||||
};
|
||||
|
||||
|
||||
const { data, isLoading } =
|
||||
(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
reset({
|
||||
investorAmount: data?.data?.investorAmount,
|
||||
});
|
||||
}
|
||||
}, [data, reset]);
|
||||
|
||||
const heandleOnClose = () =>{
|
||||
reset()
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal isCentered isOpen={isOpen} onClose={heandleOnClose} initialFocusRef={firstField}>
|
||||
<ModalOverlay />
|
||||
<ModalContent pb={4}>
|
||||
<ModalHeader fontSize={"md"}>Approve Comment</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
{isLoading ? (
|
||||
<FullscreenLoaders height={"50vh"} />
|
||||
) : (
|
||||
<Box as="form" onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalBody>
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormLabel fontSize="sm">Comment</FormLabel>
|
||||
<Textarea
|
||||
rows={6}
|
||||
focusBorderColor="green.400"
|
||||
name="comments"
|
||||
{...register("comments")}
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="md"
|
||||
placeholder={"Enter your checker comment...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comments && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comments.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered</Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
colorScheme="gray"
|
||||
mr={3}
|
||||
onClick={onClose}
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
colorScheme="forestGreen"
|
||||
variant="solid"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
isLoading={isBtnLoading}
|
||||
type="submit"
|
||||
>
|
||||
Send
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Box>
|
||||
)}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default RequestApproveModal;
|
||||
@@ -0,0 +1,176 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
Textarea,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import { useApproveDistributionMutation, useApproveExitMutation, useApproveIOCaseMutation, useApproveIONavMutation } from "../../../../Services/io.service";
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
// comments: yup.string().required("Comment is required")
|
||||
// .max(50, "Investment name cannot be more than 50 characters"),
|
||||
comments: yup
|
||||
.string()
|
||||
.required("Comment is required")
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const RequestApproveModal = ({ isOpen, onClose, firstField ,id}) => {
|
||||
const [isBtnLoading , setIsBtnLoading] = useState(false)
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
const {
|
||||
register,
|
||||
reset,
|
||||
watch,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(conformModalSchema),
|
||||
});
|
||||
|
||||
const [ approveExit ] = useApproveExitMutation()
|
||||
|
||||
|
||||
const onSubmit = async(data) => {
|
||||
setIsBtnLoading(true)
|
||||
try {
|
||||
const res = await approveExit({data,id})
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}else if(res?.data){
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
});
|
||||
onClose()
|
||||
setIsBtnLoading(false)
|
||||
}else{
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const handleFileChange = (event) => {
|
||||
const selectedFile = event.target.files[0];
|
||||
setFile(selectedFile);
|
||||
};
|
||||
|
||||
|
||||
const { data, isLoading } =
|
||||
(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
reset({
|
||||
investorAmount: data?.data?.investorAmount,
|
||||
});
|
||||
}
|
||||
}, [data, reset]);
|
||||
|
||||
const heandleOnClose = () =>{
|
||||
reset()
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal isCentered isOpen={isOpen} onClose={heandleOnClose} initialFocusRef={firstField}>
|
||||
<ModalOverlay />
|
||||
<ModalContent pb={4}>
|
||||
<ModalHeader fontSize={"md"}>Approve Comment</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
{isLoading ? (
|
||||
<FullscreenLoaders height={"50vh"} />
|
||||
) : (
|
||||
<Box as="form" onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalBody>
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormLabel fontSize="sm">Comment</FormLabel>
|
||||
<Textarea
|
||||
rows={6}
|
||||
focusBorderColor="green.400"
|
||||
name="comments"
|
||||
{...register("comments")}
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="md"
|
||||
placeholder={"Enter your checker comment...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comments && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comments.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered</Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
colorScheme="gray"
|
||||
mr={3}
|
||||
onClick={onClose}
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
colorScheme="forestGreen"
|
||||
variant="solid"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
isLoading={isBtnLoading}
|
||||
type="submit"
|
||||
>
|
||||
Send
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Box>
|
||||
)}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default RequestApproveModal;
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
Textarea,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import { useRejectIOCaseMutation } from "../../../../Services/io.service";
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
comments: yup.string().required("Comment is required")
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const RequestRejectModal = ({ isOpen, onClose, firstField ,id, onBigModalClose}) => {
|
||||
const [isBtnLoading , setIsBtnLoading] = useState(false)
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
const {
|
||||
register,
|
||||
reset,
|
||||
watch,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(conformModalSchema),
|
||||
});
|
||||
|
||||
const [ rejectIOCase ] = useRejectIOCaseMutation()
|
||||
|
||||
|
||||
const handleFileChange = (event) => {
|
||||
const selectedFile = event.target.files[0];
|
||||
setFile(selectedFile);
|
||||
};
|
||||
|
||||
|
||||
const { data, isLoading } =
|
||||
(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
console.log("============data",data);
|
||||
|
||||
|
||||
const onSubmit = async(data) => {
|
||||
console.log(data, "tewxttttt");
|
||||
setIsBtnLoading(true)
|
||||
try {
|
||||
const res = await rejectIOCase({data, id})
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}else if(res?.data){
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
});
|
||||
onClose()
|
||||
onBigModalClose()
|
||||
setIsBtnLoading(false)
|
||||
}else{
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={'error'} message={"Something went wrong"} />
|
||||
),
|
||||
});
|
||||
setIsBtnLoading(false)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// useEffect(() => {
|
||||
// if (data) {
|
||||
// reset({
|
||||
// investorAmount: data?.data?.investorAmount,
|
||||
// });
|
||||
// }
|
||||
// }, [data, reset]);
|
||||
|
||||
const heandleOnClose = () =>{
|
||||
reset()
|
||||
onClose()
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal isCentered isOpen={isOpen} onClose={heandleOnClose} initialFocusRef={firstField}>
|
||||
<ModalOverlay />
|
||||
<ModalContent pb={4}>
|
||||
<ModalHeader fontSize={"md"}>Reject Comment</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
{isLoading ? (
|
||||
<FullscreenLoaders height={"50vh"} />
|
||||
) : (
|
||||
<Box as="form" onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalBody>
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormLabel fontSize="sm">Comment</FormLabel>
|
||||
<Textarea
|
||||
rows={6}
|
||||
focusBorderColor="green.400"
|
||||
name="comments"
|
||||
{...register("comments")}
|
||||
fontSize="sm"
|
||||
type="textarea"
|
||||
size="md"
|
||||
placeholder={"Enter your comments...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
/>
|
||||
{errors.comments && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comments.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 200 characters. You have entered</Box>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
colorScheme="gray"
|
||||
mr={3}
|
||||
onClick={onClose}
|
||||
size={"xs"}
|
||||
rounded={"sm"}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
colorScheme="forestGreen"
|
||||
variant="solid"
|
||||
size={"xs"}
|
||||
rounded={"sm"}
|
||||
isLoading={isBtnLoading}
|
||||
type="submit"
|
||||
>
|
||||
Send
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Box>
|
||||
)}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default RequestRejectModal;
|
||||
@@ -0,0 +1,295 @@
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useAmountIvestmentMutation } from "../../../../Services/io.service";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import CurrencyInput from "../../../../Components/CurrencyInput";
|
||||
import RequestRejectModal from "./RequestRejectModal";
|
||||
import ApproveInvestedModal from "./ApproveInvestedModal";
|
||||
import { formatDate } from "../../../Master/Sponser/Sponsers";
|
||||
import { encryptString, isMaker } from "../../../../Constants/Constants";
|
||||
|
||||
// Validation schema
|
||||
const validationSchema = yup.object().shape({
|
||||
transactionDate: yup.date().required("Date is required"),
|
||||
Total_Amount: yup.number().required("Amount is required"),
|
||||
amountInvested: yup.number().required("Amount to invest is required"),
|
||||
IoCash: yup
|
||||
.number()
|
||||
.positive("IO Cash must be positive")
|
||||
.required("IO Cash is required"),
|
||||
});
|
||||
|
||||
// Function to format currency
|
||||
const formatCurrency = (value) => {
|
||||
if (isNaN(value)) return "";
|
||||
const formatted = parseFloat(value).toFixed(2).toString();
|
||||
const [integer, decimal] = formatted.split(".");
|
||||
const formattedInteger = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
return decimal ? `${formattedInteger}.${decimal}` : formattedInteger;
|
||||
};
|
||||
|
||||
const ViewAmountInvested = ({ isOpen, onClose, id: investorId }) => {
|
||||
const params = useParams();
|
||||
const toast = useToast();
|
||||
const id = params?.id;
|
||||
const {
|
||||
control,
|
||||
register,
|
||||
handleSubmit,
|
||||
reset,
|
||||
watch,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(validationSchema),
|
||||
});
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const { IODetails } = useContext(GlobalStateContext);
|
||||
const [amountInvested] = useAmountIvestmentMutation();
|
||||
const [actionId, setActionId] = useState(false);
|
||||
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
onOpen: onConfirmOpen,
|
||||
onClose: onConfirmClose,
|
||||
} = useDisclosure();
|
||||
const {
|
||||
isOpen: isRejectOpen,
|
||||
onOpen: onRejectOpen,
|
||||
onClose: onRejectClose,
|
||||
} = useDisclosure();
|
||||
|
||||
useEffect(() => {
|
||||
if (IODetails?.totalAmtInvestmentInUSD) {
|
||||
const totalAmount = parseFloat(IODetails.totalAmtInvestmentInUSD);
|
||||
const ioCashUpdate = parseFloat(IODetails.totalAmtInvestmentInUSD);
|
||||
reset({
|
||||
Total_Amount: totalAmount,
|
||||
IoCash: ioCashUpdate,
|
||||
});
|
||||
}
|
||||
}, [IODetails, reset]);
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
console.log(data);
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const res = await amountInvested({ data, id });
|
||||
console.log(res);
|
||||
if (res?.data?.statusCode === 200) {
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
setIsLoading(false);
|
||||
onClose();
|
||||
} else if (res?.error?.status === 400) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (error) {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// const formatDate = (date) => new Date(date).toLocaleDateString();
|
||||
|
||||
const handleAmountChange = (e) => {
|
||||
// e might be an object or just a value, handle both cases
|
||||
const amount =
|
||||
typeof e === "object" && e.target
|
||||
? parseFloat(e.target.value) || 0
|
||||
: parseFloat(e) || 0;
|
||||
const totalAmount = parseFloat(IODetails?.totalAmtInvestmentInUSD) || 0;
|
||||
const ioCash = (totalAmount - amount).toFixed(2);
|
||||
|
||||
reset({
|
||||
amountInvested: parseFloat(amount),
|
||||
IoCash: parseFloat(ioCash),
|
||||
Total_Amount: IODetails?.totalAmtInvestmentInUSD,
|
||||
});
|
||||
};
|
||||
|
||||
console.log(
|
||||
"=========hitttt",
|
||||
IODetails?.ioTransactionRecords?.Pending?.[0]?.createdAt
|
||||
);
|
||||
|
||||
return (
|
||||
<Modal isOpen={isOpen} onClose={onClose}>
|
||||
<ModalOverlay />
|
||||
<ModalContent>
|
||||
<ModalHeader fontSize={"md"}>Amount Invested</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
<ModalBody>
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<FormControl
|
||||
mb={"15px"}
|
||||
isInvalid={!!errors.transactionDate}
|
||||
isRequired
|
||||
>
|
||||
<FormLabel as={"label"} fontSize={"sm"} fontWeight={500}>
|
||||
Date
|
||||
</FormLabel>
|
||||
<Input
|
||||
type="text"
|
||||
value={formatDate(
|
||||
IODetails?.ioTransactionRecords?.Pending?.[0]?.createdAt
|
||||
)}
|
||||
// value={IODetails?.ioTransactionRecords?.Pending?.[0]?.createdAt}
|
||||
size="sm"
|
||||
rounded={"sm"}
|
||||
textAlign={"end"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
fontSize={"sm"}
|
||||
readOnly
|
||||
/>
|
||||
{/* <Text>
|
||||
{IODetails?.ioTransactionRecords?.Approved?.[0]?.createdAt} dccd
|
||||
</Text> */}
|
||||
</FormControl>
|
||||
|
||||
<FormControl
|
||||
mb={"15px"}
|
||||
isInvalid={!!errors.Total_Amount}
|
||||
isReadOnly
|
||||
>
|
||||
<FormLabel as={"label"} fontSize={"sm"} fontWeight={500}>
|
||||
Amount
|
||||
</FormLabel>
|
||||
<Input
|
||||
type="text"
|
||||
value={formatCurrency(watch("Total_Amount") || 0)}
|
||||
size="sm"
|
||||
rounded={"sm"}
|
||||
textAlign={"end"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
fontSize={"sm"}
|
||||
readOnly
|
||||
/>
|
||||
</FormControl>
|
||||
|
||||
<FormControl
|
||||
mb={"15px"}
|
||||
isInvalid={!!errors.amountInvested}
|
||||
isRequired
|
||||
>
|
||||
<FormLabel as={"label"} fontSize={"sm"} fontWeight={500}>
|
||||
Amount to invest
|
||||
</FormLabel>
|
||||
<Input
|
||||
type="text"
|
||||
value={formatCurrency(
|
||||
IODetails?.ioTransactionRecords?.Pending?.[0]
|
||||
?.transactionAmount || 0
|
||||
)}
|
||||
size="sm"
|
||||
rounded={"sm"}
|
||||
textAlign={"end"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
fontSize={"sm"}
|
||||
readOnly
|
||||
/>
|
||||
</FormControl>
|
||||
|
||||
<FormControl mb={"15px"} isInvalid={!!errors.IoCash}>
|
||||
<FormLabel as={"label"} fontSize={"sm"} fontWeight={500}>
|
||||
IO Cash
|
||||
</FormLabel>
|
||||
<Input
|
||||
type="text"
|
||||
value={formatCurrency(
|
||||
(watch("Total_Amount") || 0) -
|
||||
(IODetails?.ioTransactionRecords?.Pending?.[0]
|
||||
?.transactionAmount || 0)
|
||||
)}
|
||||
size="sm"
|
||||
rounded={"sm"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
fontSize={"sm"}
|
||||
textAlign={"right"}
|
||||
readOnly
|
||||
/>
|
||||
</FormControl>
|
||||
|
||||
{!isMaker() && (
|
||||
<ModalFooter>
|
||||
<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
<Button
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
textTransform={"inherit"}
|
||||
fontWeight={500}
|
||||
px={3}
|
||||
py={2}
|
||||
onClick={() => {
|
||||
setActionId(id); // Use the `id` variable from params
|
||||
onConfirmOpen();
|
||||
}}
|
||||
colorScheme="forestGreen"
|
||||
variant={"solid"}
|
||||
cursor={"pointer"}
|
||||
>
|
||||
Approve
|
||||
</Button>
|
||||
<Button
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
textTransform={"inherit"}
|
||||
fontWeight={500}
|
||||
px={3}
|
||||
py={2}
|
||||
onClick={() => {
|
||||
setActionId(id); // Use the `id` variable from params
|
||||
onRejectOpen();
|
||||
}}
|
||||
>
|
||||
Reject
|
||||
</Button>
|
||||
</Box>
|
||||
</ModalFooter>
|
||||
)}
|
||||
</form>
|
||||
</ModalBody>
|
||||
</ModalContent>
|
||||
<ApproveInvestedModal
|
||||
isOpen={isConfirmOpen}
|
||||
onClose={onConfirmClose}
|
||||
onBigModalClose={onClose}
|
||||
id={investorId}
|
||||
/>
|
||||
<RequestRejectModal
|
||||
isOpen={isRejectOpen}
|
||||
onClose={onRejectClose}
|
||||
onBigModalClose={onClose}
|
||||
id={investorId}
|
||||
/>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ViewAmountInvested;
|
||||
369
src/Pages/IO_Management/CreateIO/IOTransaction/ViewCancel.jsx
Normal file
369
src/Pages/IO_Management/CreateIO/IOTransaction/ViewCancel.jsx
Normal file
@@ -0,0 +1,369 @@
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Table,
|
||||
Tbody,
|
||||
Text,
|
||||
Th,
|
||||
Tr,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import NormalData from "../../../../Components/DataTable/NormalTable";
|
||||
import { useContext, useState } from "react";
|
||||
import {
|
||||
useExitIOTransactionMutation,
|
||||
useGetDistributedToInvestorMutation,
|
||||
useGetDistributionInvestorMutation,
|
||||
useGetIOByIdQuery,
|
||||
} from "../../../../Services/io.service";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import ApprovedCancelTransaction from "./ApprovedCancelTransaction";
|
||||
import RequestRejectModal from "./RequestRejectModal";
|
||||
import { encryptString, isMaker } from "../../../../Constants/Constants";
|
||||
|
||||
const ViewCancel = ({ isOpen, onClose, id: cancleId }) => {
|
||||
const params = useParams();
|
||||
const toast = useToast();
|
||||
const id = params?.id;
|
||||
const [isCalculateLoading, setIsCalculateLoading] = useState(false);
|
||||
const [isFinalCalculateLoading, setIsFinalCalculateLoading] = useState(false);
|
||||
const [calcualtedData, setCalculatedDate] = useState(null);
|
||||
const [isCalcualtedData, setIsCalcualtedData] = useState(false);
|
||||
const { investors, setInvestors, slideFromRight, IODetails } =
|
||||
useContext(GlobalStateContext);
|
||||
|
||||
const [actionId, setActionId] = useState(false);
|
||||
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
onOpen: onConfirmOpen,
|
||||
onClose: onConfirmClose,
|
||||
} = useDisclosure();
|
||||
const {
|
||||
isOpen: isRejectOpen,
|
||||
onOpen: onRejectOpen,
|
||||
onClose: onRejectClose,
|
||||
} = useDisclosure();
|
||||
|
||||
const investorExit = yup.object().shape({
|
||||
amount: yup
|
||||
.string()
|
||||
.required("Amount is required")
|
||||
.test(
|
||||
"max",
|
||||
`Distribution amount should not be greater than IO cash amount ${IODetails?.ioCash}`,
|
||||
function (value) {
|
||||
const { ioCash } = IODetails || {}; // Safely get ioCash
|
||||
if (value && ioCash) {
|
||||
return parseFloat(value) <= parseFloat(ioCash); // Ensure both are compared as numbers
|
||||
}
|
||||
return true; // If ioCash is not available, skip validation
|
||||
}
|
||||
),
|
||||
});
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
reset,
|
||||
} = useForm({
|
||||
resolver: yupResolver(investorExit),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
console.log("hiit useEffectc");
|
||||
if (id && IODetails) {
|
||||
handleCalculate(id, {
|
||||
amount: IODetails?.ioMVNAV,
|
||||
});
|
||||
}
|
||||
reset({
|
||||
amount: IODetails?.ioMVNAV,
|
||||
});
|
||||
}, [IODetails, id]);
|
||||
|
||||
const handleCalculate = async (id, data) => {
|
||||
try {
|
||||
const res = await getDistributionInvestment({ id, data });
|
||||
console.log(res?.data?.data);
|
||||
|
||||
if (res?.error?.status === 401) {
|
||||
setIsCalculateLoading(false);
|
||||
setIsCalcualtedData(false);
|
||||
} else if (res?.data?.statusCode === 200) {
|
||||
setCalculatedDate(res?.data?.data);
|
||||
setIsCalculateLoading(false);
|
||||
setIsCalcualtedData(true);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const [getDistributionInvestment] = useGetDistributionInvestorMutation();
|
||||
|
||||
const investor = yup.object().shape({
|
||||
amount: yup.string().required("Amount is required"),
|
||||
});
|
||||
|
||||
// ====================================================[Table Setup]================================================================
|
||||
const tableHeadRow = [
|
||||
"Client ID",
|
||||
"First name",
|
||||
"Last name",
|
||||
"Investment amount",
|
||||
"Percentage",
|
||||
"Market Value",
|
||||
"Return on Investment",
|
||||
"Distribution",
|
||||
"Distribution Percent",
|
||||
"Total Return",
|
||||
"Total return on Investment",
|
||||
];
|
||||
|
||||
const extractedArray = IODetails?.investors?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Client ID": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "center"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item?.clientReference_id}
|
||||
</Text>
|
||||
),
|
||||
"First name": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "center"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item.firstName}
|
||||
</Text>
|
||||
),
|
||||
"Last name": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "center"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item.lastName}
|
||||
</Text>
|
||||
),
|
||||
"Investment amount": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "left"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{/* {`$${formatCurrency(item.InvestedAmount_USD)}`} */}
|
||||
{`${parseFloat(item.InvestedAmount_USD || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}`}
|
||||
</Text>
|
||||
),
|
||||
Percentage: (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "center"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item.Investor_Holidings} %
|
||||
</Text>
|
||||
),
|
||||
"Market Value": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "left"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{`${parseFloat(item.Market_Value || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}`}
|
||||
</Text>
|
||||
),
|
||||
"Return on Investment": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "center"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
h={6}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item.Return_On_Investment || 0} %
|
||||
</Text>
|
||||
),
|
||||
Distribution: (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "left"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{/* {`$${item.Distribution_Amt}`} */}
|
||||
{`${parseFloat(item.Distribution_Amt || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}`}
|
||||
</Text>
|
||||
),
|
||||
"Distribution Percent": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "center"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{/* {`$${item.Distribution_Amt}`} */}
|
||||
{`${parseFloat(item.Distribution_Per || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})} %`}
|
||||
</Text>
|
||||
),
|
||||
"Total Return": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "left"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
<Badge ms={1} colorScheme="green" me={1}>
|
||||
$
|
||||
</Badge>
|
||||
{/* {`$${formatCurrency(item.Total_Return) || 0}`} */}
|
||||
{`${parseFloat(item.Total_Return || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}`}
|
||||
</Text>
|
||||
),
|
||||
"Total return on Investment": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "center"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item.Total_Return_On_Investment || 0} %
|
||||
</Text>
|
||||
),
|
||||
}));
|
||||
|
||||
const handleClose = () => {
|
||||
onClose();
|
||||
setIsFinalCalculateLoading(false);
|
||||
setIsCalcualtedData(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal size={"xl"} isOpen={isOpen} onClose={handleClose}>
|
||||
<ModalOverlay />
|
||||
<ModalContent maxW={1000}>
|
||||
<ModalHeader fontSize={"md"}>Cancel Transaction</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
<ModalBody>
|
||||
<NormalData
|
||||
emptyMessage={`We don't have any Sponers `}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
/>
|
||||
</ModalBody>
|
||||
{!isMaker() && (
|
||||
<ModalFooter pt={0}>
|
||||
<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
<Button
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
textTransform={"inherit"}
|
||||
fontWeight={500}
|
||||
px={3}
|
||||
py={2}
|
||||
onClick={() => {
|
||||
setActionId(id); // Use the `id` variable from params
|
||||
onConfirmOpen();
|
||||
}}
|
||||
colorScheme="forestGreen"
|
||||
variant={"solid"}
|
||||
cursor={"pointer"}
|
||||
>
|
||||
Approve
|
||||
</Button>
|
||||
<Button
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
textTransform={"inherit"}
|
||||
fontWeight={500}
|
||||
px={3}
|
||||
py={2}
|
||||
onClick={() => {
|
||||
setActionId(id); // Use the `id` variable from params
|
||||
onRejectOpen();
|
||||
}}
|
||||
>
|
||||
Reject
|
||||
</Button>
|
||||
</Box>
|
||||
</ModalFooter>
|
||||
)}
|
||||
</ModalContent>
|
||||
<ApprovedCancelTransaction
|
||||
isOpen={isConfirmOpen}
|
||||
onClose={onConfirmClose}
|
||||
onBigModalClose={onClose}
|
||||
id={cancleId}
|
||||
/>
|
||||
<RequestRejectModal
|
||||
isOpen={isRejectOpen}
|
||||
onClose={onRejectClose}
|
||||
onBigModalClose={onClose}
|
||||
id={cancleId}
|
||||
/>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ViewCancel;
|
||||
@@ -0,0 +1,271 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Text,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import NormalData from "../../../../Components/DataTable/NormalTable";
|
||||
import { useContext, useState } from "react";
|
||||
import { useGetDistributionInvestorMutation } from "../../../../Services/io.service";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import ApproveDistrubationModal from "./ApproveDistrubationModal";
|
||||
import RequestRejectModal from "./RequestRejectModal";
|
||||
import { encryptString, isMaker } from "../../../../Constants/Constants";
|
||||
|
||||
const ViewDistributionInvestor = ({ isOpen, onClose, id: exitId, amount }) => {
|
||||
const params = useParams();
|
||||
const toast = useToast();
|
||||
const id = params?.id;
|
||||
const [isCalculateLoading, setIsCalculateLoading] = useState(false);
|
||||
const [isFinalCalculateLoading, setIsFinalCalculateLoading] = useState(false);
|
||||
const [calcualtedData, setCalculatedDate] = useState(null);
|
||||
const [isCalcualtedData, setIsCalcualtedData] = useState(false);
|
||||
const { IODetails } = useContext(GlobalStateContext);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
|
||||
const investorExit = yup.object().shape({
|
||||
amount: yup
|
||||
.string()
|
||||
.required("Amount is required")
|
||||
.test(
|
||||
"max",
|
||||
`Distribution amount should not be greater than IO cash amount ${IODetails?.ioCash}`,
|
||||
function (value) {
|
||||
const { ioCash } = IODetails || {}; // Safely get ioCash
|
||||
if (value && ioCash) {
|
||||
return parseFloat(value) <= parseFloat(ioCash); // Ensure both are compared as numbers
|
||||
}
|
||||
return true; // If ioCash is not available, skip validation
|
||||
}
|
||||
),
|
||||
});
|
||||
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
onOpen: onConfirmOpen,
|
||||
onClose: onConfirmClose,
|
||||
} = useDisclosure();
|
||||
const {
|
||||
isOpen: isRejectOpen,
|
||||
onOpen: onRejectOpen,
|
||||
onClose: onRejectClose,
|
||||
} = useDisclosure();
|
||||
|
||||
const {
|
||||
formState: { errors },
|
||||
reset,
|
||||
} = useForm({
|
||||
resolver: yupResolver(investorExit),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (id && IODetails) {
|
||||
handleCalculate(id, {
|
||||
amount: Math.abs(amount),
|
||||
});
|
||||
}
|
||||
reset({
|
||||
amount: amount,
|
||||
});
|
||||
}, [IODetails, id, amount]);
|
||||
|
||||
const handleCalculate = async (id, data) => {
|
||||
try {
|
||||
const res = await getDistributionInvestment({ id, data });
|
||||
console.log(res?.data?.data);
|
||||
|
||||
if (res?.error?.status === 401) {
|
||||
setIsCalculateLoading(false);
|
||||
setIsCalcualtedData(false);
|
||||
} else if (res?.data?.statusCode === 200) {
|
||||
setCalculatedDate(res?.data?.data);
|
||||
setIsCalculateLoading(false);
|
||||
setIsCalcualtedData(false);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const [getDistributionInvestment] = useGetDistributionInvestorMutation();
|
||||
|
||||
// ====================================================[Table Setup]================================================================
|
||||
const tableHeadRow = [
|
||||
"Sr No.",
|
||||
"Client Id",
|
||||
"First name",
|
||||
"Last Name",
|
||||
"Amount",
|
||||
"Holding (%)",
|
||||
"Distribution Amt($)",
|
||||
"Yeild (%)",
|
||||
];
|
||||
|
||||
const extractedArray = calcualtedData?.data?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr No.": (
|
||||
<Box
|
||||
w={9}
|
||||
display={"flex"}
|
||||
alignItems={"center"}
|
||||
isTruncated={true}
|
||||
h={25}
|
||||
>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{index + 1}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Client Id": (
|
||||
<Box w={90} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.clientId}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"First name": (
|
||||
<Box w={90} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.firstName}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Last Name": (
|
||||
<Box minW={24} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.lastName}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
Amount: (
|
||||
<Box minW={24} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.amount?.toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Holding (%)": (
|
||||
<Box minW={24} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.investor_holidings?.toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
%
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Distribution Amt($)": (
|
||||
<Box minW={24} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.distribution_amt?.toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Yeild (%)": (
|
||||
<Box minW={24} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.distribution_per?.toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
%
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
}));
|
||||
|
||||
const handleClose = () => {
|
||||
onClose();
|
||||
setIsFinalCalculateLoading(false);
|
||||
setIsCalcualtedData(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal size={"xl"} isOpen={isOpen} onClose={handleClose}>
|
||||
<ModalOverlay />
|
||||
<ModalContent maxW={1000}>
|
||||
<ModalHeader fontSize={"md"}>
|
||||
Distribution To Investor Transaction
|
||||
</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
<ModalBody>
|
||||
<NormalData
|
||||
emptyMessage={`We don't have any Sponers `}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
/>
|
||||
</ModalBody>
|
||||
{/* ...(localStorage?.getItem("role") !== "Maker" ? ["Status"] : []), */}
|
||||
{!isMaker() && (
|
||||
<ModalFooter pt={0}>
|
||||
<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
<Button
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
textTransform={"inherit"}
|
||||
fontWeight={500}
|
||||
px={3}
|
||||
py={2}
|
||||
onClick={() => {
|
||||
setActionId(id); // Use the `id` variable from params
|
||||
onConfirmOpen();
|
||||
}}
|
||||
colorScheme="forestGreen"
|
||||
variant={"solid"}
|
||||
cursor={"pointer"}
|
||||
>
|
||||
Approve
|
||||
</Button>
|
||||
<Button
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
textTransform={"inherit"}
|
||||
fontWeight={500}
|
||||
px={3}
|
||||
py={2}
|
||||
onClick={() => {
|
||||
setActionId(id); // Use the `id` variable from params
|
||||
onRejectOpen();
|
||||
}}
|
||||
>
|
||||
Reject
|
||||
</Button>
|
||||
</Box>
|
||||
</ModalFooter>
|
||||
)}
|
||||
</ModalContent>
|
||||
<ApproveDistrubationModal
|
||||
isOpen={isConfirmOpen}
|
||||
onClose={onConfirmClose}
|
||||
onBigModalClose={handleClose}
|
||||
id={exitId}
|
||||
/>
|
||||
<RequestRejectModal
|
||||
isOpen={isRejectOpen}
|
||||
onClose={onRejectClose}
|
||||
onBigModalClose={handleClose}
|
||||
id={exitId}
|
||||
/>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ViewDistributionInvestor;
|
||||
332
src/Pages/IO_Management/CreateIO/IOTransaction/ViewExit.jsx
Normal file
332
src/Pages/IO_Management/CreateIO/IOTransaction/ViewExit.jsx
Normal file
@@ -0,0 +1,332 @@
|
||||
import {
|
||||
Alert,
|
||||
AlertIcon,
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormErrorMessage,
|
||||
FormLabel,
|
||||
HStack,
|
||||
Input,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Switch,
|
||||
Table,
|
||||
Tbody,
|
||||
Text,
|
||||
Textarea,
|
||||
Th,
|
||||
Tr,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import NormalData from "../../../../Components/DataTable/NormalTable";
|
||||
import { useContext, useState } from "react";
|
||||
import { AddIcon } from "@chakra-ui/icons";
|
||||
import {
|
||||
useExitIOTransactionMutation,
|
||||
useGetDistributedToInvestorMutation,
|
||||
useGetDistributionInvestorMutation,
|
||||
useUpdateExitToInvestorMutation,
|
||||
} from "../../../../Services/io.service";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useEffect } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import ToastBox from "../../../../Components/ToastBox";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import ApprovedExit from "./ApprovedExit";
|
||||
import RequestRejectModal from "./RequestRejectModal";
|
||||
import { encryptString, isMaker } from "../../../../Constants/Constants";
|
||||
|
||||
const ViewExit = ({ isOpen, onClose, id: investerId }) => {
|
||||
const params = useParams();
|
||||
const toast = useToast();
|
||||
const id = params?.id;
|
||||
const [isCalculateLoading, setIsCalculateLoading] = useState(false);
|
||||
const [isFinalCalculateLoading, setIsFinalCalculateLoading] = useState(false);
|
||||
const [calcualtedData, setCalculatedDate] = useState(null);
|
||||
const [isCalcualtedData, setIsCalcualtedData] = useState(false);
|
||||
const { IODetails } = useContext(GlobalStateContext);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
onOpen: onConfirmOpen,
|
||||
onClose: onConfirmClose,
|
||||
} = useDisclosure();
|
||||
const {
|
||||
isOpen: isRejectOpen,
|
||||
onOpen: onRejectOpen,
|
||||
onClose: onRejectClose,
|
||||
} = useDisclosure();
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
reset,
|
||||
} = useForm({
|
||||
resolver: yupResolver(),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
console.log("hiit useEffectc");
|
||||
if (id && IODetails) {
|
||||
handleCalculate(id, {
|
||||
amount: IODetails?.ioMVNAV,
|
||||
});
|
||||
}
|
||||
reset({
|
||||
amount: IODetails?.ioMVNAV,
|
||||
});
|
||||
}, [IODetails, id]);
|
||||
|
||||
const handleCalculate = async (id, data) => {
|
||||
try {
|
||||
const res = await getDistributionInvestment({ id, data });
|
||||
console.log(res?.data?.data);
|
||||
|
||||
if (res?.error?.status === 401) {
|
||||
setIsCalculateLoading(false);
|
||||
setIsCalcualtedData(false);
|
||||
} else if (res?.data?.statusCode === 200) {
|
||||
setCalculatedDate(res?.data?.data);
|
||||
setIsCalculateLoading(false);
|
||||
setIsCalcualtedData(true);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const [getDistributionInvestment] = useGetDistributionInvestorMutation();
|
||||
|
||||
const investor = yup.object().shape({
|
||||
amount: yup.string().required("Amount is required"),
|
||||
});
|
||||
|
||||
// ====================================================[Table Setup]================================================================
|
||||
const tableHeadRow = [
|
||||
"Sr No.",
|
||||
"Client Id",
|
||||
"First name",
|
||||
"Last Name",
|
||||
"Amount",
|
||||
"Holding (%)",
|
||||
"Exit Amt($)",
|
||||
];
|
||||
|
||||
const extractedArray = calcualtedData?.data?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr No.": (
|
||||
<Box
|
||||
w={9}
|
||||
display={"flex"}
|
||||
alignItems={"center"}
|
||||
isTruncated={true}
|
||||
h={25}
|
||||
>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{index + 1}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Client Id": (
|
||||
<Box w={100} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.clientId}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"First name": (
|
||||
<Box minW={24} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.firstName}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Last Name": (
|
||||
<Box minW={24} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.lastName}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
Amount: (
|
||||
<Box minW={24} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.amount?.toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Holding (%)": (
|
||||
<Box minW={24} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.investor_holidings?.toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
%
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Exit Amt($)": (
|
||||
<Box minW={24} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.distribution_amt?.toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
}));
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
setIsCalculateLoading(true);
|
||||
|
||||
try {
|
||||
const res = await getDistributionInvestment({ id, data });
|
||||
console.log(res?.data?.data);
|
||||
|
||||
if (res?.error?.status === 401) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
),
|
||||
});
|
||||
setIsCalculateLoading(false);
|
||||
setIsCalcualtedData(false);
|
||||
} else if (res?.data?.statusCode === 200) {
|
||||
setCalculatedDate(res?.data?.data);
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
setIsCalculateLoading(false);
|
||||
setIsCalcualtedData(true);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
onClose();
|
||||
setIsFinalCalculateLoading(false);
|
||||
setIsCalcualtedData(false);
|
||||
};
|
||||
|
||||
console.log(id);
|
||||
|
||||
return (
|
||||
<Modal size={"xl"} isOpen={isOpen} onClose={handleClose}>
|
||||
<ModalOverlay />
|
||||
<ModalContent maxW={1000}>
|
||||
<ModalHeader fontSize={"md"}>Exit Transaction</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
<ModalBody>
|
||||
{/* <Text as="label" mb="5px" fontSize="sm" fontWeight={500}>
|
||||
Amount to Distribute
|
||||
</Text> */}
|
||||
<HStack
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
as={"form"}
|
||||
mb={4}
|
||||
alignItems={"center"}
|
||||
>
|
||||
{/* <Input placeholder="$00.00" size={"sm"} className="col" /> */}
|
||||
{/* <FormControl isInvalid={errors.amount} isRequired>*/}
|
||||
<Text textAlign={"right"} fontSize={"sm"}>
|
||||
Exit Amount :
|
||||
</Text>
|
||||
<Text
|
||||
textAlign={"start"}
|
||||
bg={"green.100"}
|
||||
p={2}
|
||||
rounded={"md"}
|
||||
fontSize={"sm"}
|
||||
pt={1}
|
||||
pb={1}
|
||||
fontWeight={600}
|
||||
>
|
||||
${" "}
|
||||
{parseFloat(IODetails?.ioMVNAV || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</Text>
|
||||
|
||||
{/* </FormControl> */}
|
||||
</HStack>
|
||||
|
||||
{/* {calcualtedData && ( */}
|
||||
<NormalData
|
||||
emptyMessage={`We don't have any Sponers `}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
// total={<Total />}
|
||||
// isLoading={isLoading}
|
||||
/>
|
||||
{/* ) } */}
|
||||
</ModalBody>
|
||||
{!isMaker() && (
|
||||
<ModalFooter pt={0}>
|
||||
<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
<Button
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
textTransform={"inherit"}
|
||||
fontWeight={500}
|
||||
px={3}
|
||||
py={2}
|
||||
onClick={() => {
|
||||
setActionId(id); // Use the `id` variable from params
|
||||
onConfirmOpen();
|
||||
}}
|
||||
colorScheme="forestGreen"
|
||||
variant={"solid"}
|
||||
cursor={"pointer"}
|
||||
>
|
||||
Approve
|
||||
</Button>
|
||||
<Button
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
textTransform={"inherit"}
|
||||
fontWeight={500}
|
||||
px={3}
|
||||
py={2}
|
||||
onClick={() => {
|
||||
setActionId(id); // Use the `id` variable from params
|
||||
onRejectOpen();
|
||||
}}
|
||||
>
|
||||
Reject
|
||||
</Button>
|
||||
</Box>
|
||||
</ModalFooter>
|
||||
)}
|
||||
</ModalContent>
|
||||
<ApprovedExit
|
||||
isOpen={isConfirmOpen}
|
||||
onClose={onConfirmClose}
|
||||
onBigModalClose={onClose}
|
||||
id={investerId}
|
||||
/>
|
||||
<RequestRejectModal
|
||||
isOpen={isRejectOpen}
|
||||
onClose={onRejectClose}
|
||||
onBigModalClose={onClose}
|
||||
id={investerId}
|
||||
/>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ViewExit;
|
||||
@@ -363,7 +363,7 @@ const InvestmentDocument = ({ control, errors, enableNextTab, index, }) => {
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message="Are you sure you want to delete the sponsor?"
|
||||
message="Are you sure you want to delete the Investment?"
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
|
||||
@@ -100,19 +100,19 @@ const Investors = ({ data }) => {
|
||||
0
|
||||
);
|
||||
|
||||
// Table setup
|
||||
// Table setup
|
||||
const tableHeadRow = [
|
||||
"Client ID",
|
||||
"First name",
|
||||
"Last name",
|
||||
"Investment amount",
|
||||
"First Name",
|
||||
"Last Name",
|
||||
"Investment Amount",
|
||||
"Percentage",
|
||||
"Market Value",
|
||||
"Return on Investment",
|
||||
"Distribution",
|
||||
"Distribution Percent",
|
||||
"Total Return",
|
||||
"Total return on Investment",
|
||||
"Total Return on Investment",
|
||||
];
|
||||
|
||||
const handleUpdateStatus = debounce((id) => {
|
||||
@@ -164,7 +164,7 @@ const Investors = ({ data }) => {
|
||||
"Distribution": parseFloat(item?.Distribution_Amt) || 0, // Convert to float
|
||||
"Distribution Percent": parseFloat(item?.Distribution_Per) || 0, // Convert to float
|
||||
"Total Return": parseFloat(item?.Total_Return) || 0, // Convert to float
|
||||
"Total return on Investment": parseFloat(item?.Total_Return_On_Investment) || 0, // Convert to float
|
||||
"Total Return on Investment": parseFloat(item?.Total_Return_On_Investment) || 0, // Convert to float
|
||||
}));
|
||||
|
||||
console.log(exportInvestorDetails);
|
||||
@@ -182,7 +182,7 @@ const Investors = ({ data }) => {
|
||||
{item?.clientReference_id}
|
||||
</Text>
|
||||
),
|
||||
"First name": (
|
||||
"First Name": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "center"}
|
||||
as={"span"}
|
||||
@@ -193,7 +193,7 @@ const Investors = ({ data }) => {
|
||||
{item.firstName}
|
||||
</Text>
|
||||
),
|
||||
"Last name": (
|
||||
"Last Name": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "center"}
|
||||
as={"span"}
|
||||
@@ -204,7 +204,7 @@ const Investors = ({ data }) => {
|
||||
{item.lastName}
|
||||
</Text>
|
||||
),
|
||||
"Investment amount": (
|
||||
"Investment Amount": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "left"}
|
||||
as={"span"}
|
||||
@@ -313,7 +313,7 @@ const Investors = ({ data }) => {
|
||||
})}`}
|
||||
</Text>
|
||||
),
|
||||
"Total return on Investment": (
|
||||
"Total Return on Investment": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "center"}
|
||||
as={"span"}
|
||||
@@ -508,7 +508,7 @@ console.log(IODetails?.investors);
|
||||
>
|
||||
Export xls
|
||||
</Button>
|
||||
<Box as="span">
|
||||
{/* <Box as="span">
|
||||
<Icon
|
||||
ms={0}
|
||||
animation={
|
||||
@@ -524,7 +524,7 @@ console.log(IODetails?.investors);
|
||||
_hover={{ bg: "gray.100" }}
|
||||
cursor={"pointer"}
|
||||
/>
|
||||
</Box>
|
||||
</Box> */}
|
||||
</Box>
|
||||
|
||||
<HStack
|
||||
|
||||
@@ -89,7 +89,7 @@ const KeyMerits = ({ enableNextTab, index, data: prepopData }) => {
|
||||
const res = await deleteKeyMerits(actionId);
|
||||
if (res?.data?.statusCode === 200) {
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
render: () => <ToastBox message={res?.data?.message} status={"success"} />,
|
||||
});
|
||||
setIsBtnLoading(false);
|
||||
setDeleteAlert(false);
|
||||
|
||||
@@ -297,7 +297,7 @@ const InvestmentEdit = ({ isOpen, onClose, thirdField, id, data }) => {
|
||||
onClose={() => setAlert(false)}
|
||||
alertHandler={handleConfirm}
|
||||
isLoading={isLoading}
|
||||
message="Are you sure you want to add this document?"
|
||||
message="Are you sure you want to add this Investment?"
|
||||
/>
|
||||
</Drawer>
|
||||
);
|
||||
|
||||
@@ -1,57 +1,29 @@
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import { OPACITY_ON_LOAD } from "../../../Layout/animations";
|
||||
import {
|
||||
Box,
|
||||
Divider,
|
||||
FormControl,
|
||||
FormLabel,
|
||||
Heading,
|
||||
Input,
|
||||
Select,
|
||||
Textarea,
|
||||
Button,
|
||||
Text,
|
||||
Image,
|
||||
Tabs,
|
||||
TabList,
|
||||
Tab,
|
||||
TabList,
|
||||
TabPanel,
|
||||
TabPanels,
|
||||
Tooltip,
|
||||
Switch,
|
||||
Tabs,
|
||||
useDisclosure,
|
||||
} from "@chakra-ui/react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import * as yup from "yup";
|
||||
import {
|
||||
AddIcon,
|
||||
CloseIcon,
|
||||
DeleteIcon,
|
||||
EditIcon,
|
||||
ViewIcon,
|
||||
WarningTwoIcon,
|
||||
} from "@chakra-ui/icons";
|
||||
import { TiWarning } from "react-icons/ti";
|
||||
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import FormField from "../../../Components/FormField";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import AddIOCharges from "../AddIOCharges";
|
||||
import FormInputMain from "../../../Components/FormInputMain";
|
||||
import DataTable from "../../../Components/DataTable/DataTable";
|
||||
import { debounce } from "../../Master/Sponser/AddSponser";
|
||||
import CustomAlertDialog from "../../../Components/CustomAlertDialog";
|
||||
import { formatDate } from "../../../Components/Functions/UTCConvertor";
|
||||
import IODetails from "./IODetails";
|
||||
import KeyMerits from "./KeyMerits";
|
||||
import IOArtifacts from "./IOArtifacts";
|
||||
import Investors from "./Investors";
|
||||
import IOCashDetails from "./IOCashDetails";
|
||||
import IONAVDetails from "./IONAVDetails";
|
||||
import * as yup from "yup";
|
||||
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
|
||||
import { OPACITY_ON_LOAD } from "../../../Layout/animations";
|
||||
import Distribution from "./Destribution";
|
||||
import InvestmentDocuments from "../InvestmentDocuments";
|
||||
import InvestmentDocument from "./InvestmentDocument";
|
||||
import Investors from "./Investors";
|
||||
import IOArtifacts from "./IOArtifacts";
|
||||
import IOCashDetails from "./IOCashDetails";
|
||||
import IODetails from "./IODetails";
|
||||
import IONAVDetails from "./IONAVDetails";
|
||||
import KeyMerits from "./KeyMerits";
|
||||
import { useAuthProfileQuery } from "../../Services/token.serivce";
|
||||
import { encryptString } from "../../Constants/Constants";
|
||||
|
||||
const schema = yup.object().shape({
|
||||
ioName: yup.string().required("Arabic name is required"),
|
||||
@@ -59,7 +31,9 @@ const schema = yup.object().shape({
|
||||
discription: yup.string().required("Description is required"),
|
||||
discriptionArabic: yup.string().required("Arabic Description is required"),
|
||||
typeName: yup.string().required("Investment type is required"),
|
||||
typeNameArabic: yup.string().required("Investment type arabic name is required"),
|
||||
typeNameArabic: yup
|
||||
.string()
|
||||
.required("Investment type arabic name is required"),
|
||||
sponserName: yup.string().required("Sponsorer name is required"),
|
||||
sponserNameArabic: yup
|
||||
.string()
|
||||
@@ -293,7 +267,7 @@ const EditViewIO = () => {
|
||||
isRequired: true,
|
||||
section: " ",
|
||||
width: "32.3%",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Name (Arabic)",
|
||||
placeHolder: " ",
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
DrawerOverlay,
|
||||
FormControl,
|
||||
FormErrorMessage,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Icon,
|
||||
Image,
|
||||
@@ -35,7 +36,7 @@ import { IoMdRemoveCircleOutline } from "react-icons/io";
|
||||
|
||||
const investmentImageSchema = yup.object().shape({
|
||||
artifactName: yup.string().required("Artifact image name is required")
|
||||
.max(25, "File name must be at most 25 characters"),
|
||||
.max(50, "Approve Comment cannot be more than 50 characters"),
|
||||
artifactPathName: yup.mixed().required("Artifact image is required"),
|
||||
});
|
||||
|
||||
@@ -226,19 +227,24 @@ const IOArtifactsAdd = ({
|
||||
<Controller
|
||||
name="artifactName"
|
||||
control={control}
|
||||
// maxLength={50}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
fontSize={"sm"}
|
||||
type="text"
|
||||
size={"sm"}
|
||||
maxLength={25}
|
||||
maxLength={50}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.artifactName?.message}
|
||||
</FormErrorMessage>
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 50 characters. You have entered </Box>
|
||||
{watch("artifactName")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
|
||||
<FormControl
|
||||
|
||||
@@ -60,9 +60,9 @@ export const investmentDocSchema = yup.object().shape({
|
||||
// return value && value.size <= 2 * 1024 * 1024; // 2MB in bytes
|
||||
// })
|
||||
fileName: yup.string().required("File name is required")
|
||||
.max(25, "File name must be at most 25 characters"), // Maximum length validation,
|
||||
.max(35, "File name must be at most 30 characters"), // Maximum length validation,
|
||||
documentNameArabic: yup.string().required("File name Arabic is required")
|
||||
.max(25, "File name must be at most 30 characters"),
|
||||
.max(25, "File name must be at most 35 characters"),
|
||||
});
|
||||
|
||||
const InvestmentDocuments = ({
|
||||
@@ -91,6 +91,7 @@ const InvestmentDocuments = ({
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
watch,
|
||||
reset,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
@@ -210,13 +211,17 @@ const InvestmentDocuments = ({
|
||||
fontSize="sm"
|
||||
type="text"
|
||||
size="sm"
|
||||
maxLength={25} // Maximum length constraint in the input field
|
||||
maxLength={30} // Maximum length constraint in the input field
|
||||
/>
|
||||
{errors.fileName && (
|
||||
<Text mt={1} fontSize="xs" fontWeight={500} color="red">
|
||||
{errors.fileName.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 30 characters. You have entered </Box>
|
||||
{watch("fileName")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
|
||||
|
||||
@@ -229,13 +234,17 @@ const InvestmentDocuments = ({
|
||||
type="text"
|
||||
size="sm"
|
||||
textAlign={'right'}
|
||||
maxLength={30} // Maximum length constraint in the input field
|
||||
maxLength={35} // Maximum length constraint in the input field
|
||||
/>
|
||||
{errors.documentNameArabic && (
|
||||
<Text mt={1} fontSize="xs" fontWeight={500} color="red">
|
||||
{errors.documentNameArabic.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Box as="span" me={1}>Maximum length should be 35 characters. You have entered </Box>
|
||||
{watch("documentNameArabic")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
|
||||
|
||||
|
||||
@@ -360,7 +360,7 @@ const KeyMeritsAdd = ({ isOpen, onClose, firstField, id, icons }) => {
|
||||
onClose={handleClose}
|
||||
// alertHandler={handleSave}
|
||||
alertHandler={handleConfirm}
|
||||
message={"Are you sure you want to add this key merit?"}
|
||||
message={"Are you sure you want to add this key merits?"}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -367,7 +367,7 @@ const KeyMeritsEdit = ({
|
||||
isOpen={alert}
|
||||
onClose={() => setAlert(false)}
|
||||
alertHandler={handleSave}
|
||||
message={"Are you sure you want to add this key merit?"}
|
||||
message={"Are you sure you want to update this key merits?"}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -46,7 +46,7 @@ const AmountInvested = ({ isOpen, onClose }) => {
|
||||
const toast = useToast();
|
||||
const id = params?.id;
|
||||
const {
|
||||
control,
|
||||
control,
|
||||
register,
|
||||
handleSubmit,
|
||||
reset,
|
||||
@@ -112,9 +112,19 @@ const AmountInvested = ({ isOpen, onClose }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleModalClose = () => {
|
||||
reset({
|
||||
transactionDate: "",
|
||||
Total_Amount: IODetails?.totalAmtInvestmentInUSD || 0,
|
||||
amountInvested: 0,
|
||||
IoCash: IODetails?.totalAmtInvestmentInUSD || 0,
|
||||
});
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal isOpen={isOpen} onClose={onClose}>
|
||||
<ModalOverlay />
|
||||
<Modal isOpen={isOpen} onClose={handleModalClose}>
|
||||
<ModalOverlay />
|
||||
<ModalContent>
|
||||
<ModalHeader fontSize={"md"}>Amount Invested</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
@@ -246,7 +256,7 @@ const AmountInvested = ({ isOpen, onClose }) => {
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
<Button size={"sm"} rounded={"sm"} mr={3} onClick={onClose}>
|
||||
<Button size={"sm"} rounded={"sm"} mr={3} onClick={handleModalClose}>
|
||||
Close
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
|
||||
@@ -28,8 +28,10 @@ import NormalData from "../../../../Components/DataTable/NormalTable";
|
||||
import { useContext, useState } from "react";
|
||||
import { AddIcon } from "@chakra-ui/icons";
|
||||
import {
|
||||
useAddIOTransactionMutation,
|
||||
useGetDistributedToInvestorMutation,
|
||||
useGetDistributionInvestorMutation,
|
||||
useSaveIOTransactionMutation,
|
||||
useUpdateExitToInvestorMutation,
|
||||
} from "../../../../Services/io.service";
|
||||
import { useParams } from "react-router-dom";
|
||||
@@ -42,6 +44,7 @@ import CurrencyInput from "../../../../Components/CurrencyInput";
|
||||
import { IoCalculator } from "react-icons/io5";
|
||||
import { debounce } from "../../../Master/Sponser/AddSponser";
|
||||
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
|
||||
import { validate } from "uuid";
|
||||
|
||||
|
||||
|
||||
@@ -101,6 +104,8 @@ const DistributionInvestor = ({ isOpen, onClose }) => {
|
||||
resolver: yupResolver(investorExit),
|
||||
});
|
||||
|
||||
|
||||
const [saveIOTransaction] = useSaveIOTransactionMutation();
|
||||
|
||||
|
||||
// ====================================================[Table Setup]================================================================
|
||||
@@ -314,45 +319,81 @@ const DistributionInvestor = ({ isOpen, onClose }) => {
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
// const onFinalSubmit = async (data) => {
|
||||
// setIsFinalCalculateLoading(true);
|
||||
// if (!isCalcualtedData) {
|
||||
// setIsFinalCalculateLoading(false);
|
||||
// return toast({
|
||||
// render: () => (
|
||||
// <ToastBox
|
||||
// message={"Please calculate investment first."}
|
||||
// status="warn"
|
||||
// />
|
||||
// ),
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
// const finalData = {
|
||||
// transactionAmount: data?.amount,
|
||||
// };
|
||||
|
||||
// try {
|
||||
// const res = await getFinalDistributionInvestment({ id, data: finalData });
|
||||
// console.log(finalData);
|
||||
|
||||
// if (res?.error?.status === 401) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox message={res?.error?.data?.message} status="error" />
|
||||
// ),
|
||||
// });
|
||||
// } else if (res?.data?.statusCode === 200) {
|
||||
// toast({
|
||||
// render: () => <ToastBox message={res?.data?.message} />,
|
||||
// });
|
||||
// handleClose();
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.error("An error occurred:", error);
|
||||
// } finally {
|
||||
// handleClose();
|
||||
// }
|
||||
// };
|
||||
|
||||
const onFinalSubmit = async (data) => {
|
||||
setIsFinalCalculateLoading(true);
|
||||
if (!isCalcualtedData) {
|
||||
setIsFinalCalculateLoading(false);
|
||||
return toast({
|
||||
render: () => (
|
||||
<ToastBox
|
||||
message={"Please calculate investment first."}
|
||||
status="warn"
|
||||
/>
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
const finalData = {
|
||||
const currentDate = new Date();
|
||||
const dataToSend = {
|
||||
transactionDate: currentDate,
|
||||
transactionAmount: data?.amount,
|
||||
};
|
||||
}
|
||||
|
||||
console.log("dataaaaaaa",dataToSend);
|
||||
|
||||
try {
|
||||
const res = await getFinalDistributionInvestment({ id, data: finalData });
|
||||
console.log(finalData);
|
||||
|
||||
if (res?.error?.status === 401) {
|
||||
const res = await saveIOTransaction({ id,data: dataToSend });
|
||||
console.log(res?.data?.data);
|
||||
onClose();
|
||||
if (!isCalcualtedData) {
|
||||
setIsFinalCalculateLoading(false);
|
||||
return toast({
|
||||
render: () => (
|
||||
<ToastBox
|
||||
message={"Please calculate investment first."}
|
||||
status="warn"
|
||||
/>
|
||||
),
|
||||
});
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status="error" />
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
} else if (res?.data?.statusCode === 200) {
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
handleClose();
|
||||
// setIsLoading(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("An error occurred:", error);
|
||||
} finally {
|
||||
handleClose();
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
@@ -454,7 +495,7 @@ const DistributionInvestor = ({ isOpen, onClose }) => {
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
<Button size={"sm"} rounded={"sm"} mr={3} onClick={onClose}>
|
||||
<Button size={"sm"} rounded={"sm"} mr={3} onClick={handleClose}>
|
||||
Close
|
||||
</Button>
|
||||
</>
|
||||
|
||||
@@ -28,6 +28,7 @@ import NormalData from "../../../../Components/DataTable/NormalTable";
|
||||
import { useContext, useState } from "react";
|
||||
import { AddIcon } from "@chakra-ui/icons";
|
||||
import {
|
||||
useExitIOTransactionMutation,
|
||||
useGetDistributedToInvestorMutation,
|
||||
useGetDistributionInvestorMutation,
|
||||
useUpdateExitToInvestorMutation,
|
||||
@@ -94,7 +95,7 @@ const Exit = ({ isOpen, onClose }) => {
|
||||
const res = await getDistributionInvestment({ id, data });
|
||||
console.log(res?.data?.data);
|
||||
|
||||
if (res?.error?.status === 401) {
|
||||
if (res?.error?.status === 401) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
@@ -122,7 +123,7 @@ const Exit = ({ isOpen, onClose }) => {
|
||||
const [getDistributionInvestment] = useGetDistributionInvestorMutation();
|
||||
const [getFinalDistributionInvestment] =
|
||||
useGetDistributedToInvestorMutation();
|
||||
const [updateExitToInvestor] = useUpdateExitToInvestorMutation();
|
||||
const [exitIOTransaction] = useExitIOTransactionMutation();
|
||||
|
||||
const investor = yup.object().shape({
|
||||
amount: yup.string().required("Amount is required"),
|
||||
@@ -340,46 +341,69 @@ const Exit = ({ isOpen, onClose }) => {
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const onFinalSubmit = async (data) => {
|
||||
console.log("hit");
|
||||
setIsFinalCalculateLoading(true);
|
||||
// if (!isCalcualtedData) {
|
||||
// setIsFinalCalculateLoading(false);
|
||||
// return toast({
|
||||
// render: () => (
|
||||
// <ToastBox
|
||||
// message={"Please calculate investment first."}
|
||||
// status="warn"
|
||||
// />
|
||||
// ),
|
||||
// });
|
||||
// }
|
||||
// const onFinalSubmit = async (data) => {
|
||||
// console.log("hit");
|
||||
// setIsFinalCalculateLoading(true);
|
||||
// const finalData = {
|
||||
// transactionAmount: IODetails?.ioMVNAV,
|
||||
// };
|
||||
|
||||
const finalData = {
|
||||
// try {
|
||||
// const res = await exitIOTransaction({ id, data: finalData });
|
||||
// console.log(finalData);
|
||||
|
||||
// if (res?.error?.status === 401) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox message={res?.error?.data?.message} status="error" />
|
||||
// ),
|
||||
// });
|
||||
// } else if (res?.data?.statusCode === 200) {
|
||||
// toast({
|
||||
// render: () => <ToastBox message={res?.data?.message} />,
|
||||
// });
|
||||
// handleClose();
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.error("An error occurred:", error);
|
||||
// } finally {
|
||||
// handleClose();
|
||||
// }
|
||||
// };
|
||||
|
||||
const onFinalSubmit = async () => {
|
||||
setIsCalculateLoading(true);
|
||||
const currentDate = new Date();
|
||||
const dataToSend = {
|
||||
transactionDate: currentDate,
|
||||
transactionAmount: IODetails?.ioMVNAV,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
const res = await updateExitToInvestor({ id, data: finalData });
|
||||
console.log(finalData);
|
||||
const res = await exitIOTransaction({ id,data: dataToSend });
|
||||
console.log(res?.data?.data);
|
||||
|
||||
if (res?.error?.status === 401) {
|
||||
toast({
|
||||
onClose();
|
||||
if (!isCalcualtedData) {
|
||||
setIsFinalCalculateLoading(false);
|
||||
return toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status="error" />
|
||||
<ToastBox
|
||||
message={"Please calculate investment first."}
|
||||
status="warn"
|
||||
/>
|
||||
),
|
||||
});
|
||||
} else if (res?.data?.statusCode === 200) {
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
handleClose();
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("An error occurred:", error);
|
||||
} finally {
|
||||
handleClose();
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
@@ -389,7 +413,7 @@ const Exit = ({ isOpen, onClose }) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal size={"xl"} isOpen={isOpen} onClose={handleClose}>
|
||||
<Modal size={"xl"} isOpen={isOpen} onClose={handleClose} >
|
||||
<ModalOverlay />
|
||||
<ModalContent maxW={1000}>
|
||||
<ModalHeader fontSize={"md"}>Exit Transaction</ModalHeader>
|
||||
@@ -435,7 +459,7 @@ const Exit = ({ isOpen, onClose }) => {
|
||||
{/* ) } */}
|
||||
</ModalBody>
|
||||
<ModalFooter pt={0}>
|
||||
{isCalcualtedData ? (
|
||||
{/* {isCalcualtedData ? ( */}
|
||||
<>
|
||||
<Button
|
||||
bg={"hsla(139, 100%, 14%, 1)"}
|
||||
@@ -455,9 +479,9 @@ const Exit = ({ isOpen, onClose }) => {
|
||||
Close
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
{/* ) : (
|
||||
""
|
||||
)}
|
||||
)} */}
|
||||
</ModalFooter>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
|
||||
@@ -55,7 +55,7 @@ const UpdateIONav = ({ isOpen, onClose }) => {
|
||||
|
||||
const [createIoNav] = useCreateIoNavMutation()
|
||||
|
||||
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
|
||||
@@ -17,6 +17,9 @@ import {
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
FormErrorMessage,
|
||||
Text,
|
||||
Textarea,
|
||||
Box,
|
||||
} from "@chakra-ui/react";
|
||||
import {
|
||||
useGetIOprepopulateDataQuery,
|
||||
@@ -37,6 +40,8 @@ const UpdateIOStatus = ({ isOpen, onClose, status }) => {
|
||||
const { data } = useGetIOprepopulateDataQuery();
|
||||
const [updateStatusIo] = useUpdateStatusIoMutation();
|
||||
const [updateCancleStatus] = useUpdateCancleStatusToMutation();
|
||||
const [message, setMessage] = useState(null);
|
||||
const [messageError, setMessageError] = useState(null);
|
||||
|
||||
// useEffect(() => {
|
||||
// setSelectedStatusId(status?.[0]?.id);
|
||||
@@ -47,22 +52,26 @@ const UpdateIOStatus = ({ isOpen, onClose, status }) => {
|
||||
setSelectedStatusId(id);
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
const handleSubmit = async (data) => {
|
||||
if (!selectedStatusId) {
|
||||
setError("Please select status");
|
||||
return;
|
||||
}
|
||||
if (!message) {
|
||||
return setMessageError("message is required");
|
||||
}
|
||||
setError("");
|
||||
setIsLoading(true);
|
||||
try {
|
||||
let res;
|
||||
|
||||
// If selectedItem is 'Cancelled', make the updateCancelStatus API call
|
||||
if (selectedItem === "Cancelled") {
|
||||
if (selectedItem === import.meta.env.VITE_STATUS_CANCELLED) {
|
||||
res = await updateCancleStatus({
|
||||
id
|
||||
id: id,
|
||||
data: { comments: message },
|
||||
});
|
||||
}
|
||||
}
|
||||
// Otherwise, make the updateStatusIo API call
|
||||
else {
|
||||
res = await updateStatusIo({
|
||||
@@ -72,7 +81,7 @@ const UpdateIOStatus = ({ isOpen, onClose, status }) => {
|
||||
id,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
console.log("API Response:", res);
|
||||
setIsLoading(false);
|
||||
handleClose();
|
||||
@@ -84,6 +93,8 @@ const UpdateIOStatus = ({ isOpen, onClose, status }) => {
|
||||
const handleClose = () => {
|
||||
setSelectedItem(null);
|
||||
setSelectedStatusId(null);
|
||||
setMessage(null);
|
||||
setMessageError(null);
|
||||
onClose();
|
||||
setError("");
|
||||
};
|
||||
@@ -119,17 +130,18 @@ const UpdateIOStatus = ({ isOpen, onClose, status }) => {
|
||||
mb={1.5}
|
||||
textTransform={"none"}
|
||||
colorScheme={
|
||||
selectedItem === "Draft"
|
||||
selectedItem === import.meta.env.VITE_STATUS_DRAFT
|
||||
? "gray"
|
||||
: selectedItem === "Processing"
|
||||
: selectedItem ===
|
||||
import.meta.env.VITE_STATUS_PROCESSING
|
||||
? "yellow"
|
||||
: selectedItem === "Open"
|
||||
: selectedItem === import.meta.env.VITE_STATUS_OPEN
|
||||
? "blue"
|
||||
: selectedItem === "Closed"
|
||||
: selectedItem === import.meta.env.VITE_STATUS_CLOSED
|
||||
? "green"
|
||||
: selectedItem === "Exited"
|
||||
: selectedItem === import.meta.env.VITE_STATUS_EXITED
|
||||
? "red"
|
||||
: selectedItem === "Cancelled"
|
||||
: selectedItem === import.meta.env.VITE_STATUS_CANCELLED
|
||||
? "orange"
|
||||
: "purple"
|
||||
}
|
||||
@@ -161,17 +173,19 @@ const UpdateIOStatus = ({ isOpen, onClose, status }) => {
|
||||
mb={1.5}
|
||||
textTransform={"none"}
|
||||
colorScheme={
|
||||
statusAdmin === "Draft"
|
||||
statusAdmin === import.meta.env.VITE_STATUS_DRAFT
|
||||
? "gray"
|
||||
: statusAdmin === "Processing"
|
||||
: statusAdmin ===
|
||||
import.meta.env.VITE_STATUS_PROCESSING
|
||||
? "yellow"
|
||||
: statusAdmin === "Open"
|
||||
: statusAdmin === import.meta.env.VITE_STATUS_OPEN
|
||||
? "blue"
|
||||
: statusAdmin === "Closed"
|
||||
: statusAdmin === import.meta.env.VITE_STATUS_CLOSED
|
||||
? "green"
|
||||
: statusAdmin === "Exited"
|
||||
: statusAdmin === import.meta.env.VITE_STATUS_EXITED
|
||||
? "red"
|
||||
: statusAdmin === "Cancelled"
|
||||
: statusAdmin ===
|
||||
import.meta.env.VITE_STATUS_CANCELLED
|
||||
? "orange"
|
||||
: "purple"
|
||||
}
|
||||
@@ -191,6 +205,24 @@ const UpdateIOStatus = ({ isOpen, onClose, status }) => {
|
||||
{error}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
{selectedItem === import.meta.env.VITE_STATUS_CANCELLED && (
|
||||
<FormControl mt={5} isRequired>
|
||||
<FormLabel fontSize={"sm"} fontWeight={400}>
|
||||
Message
|
||||
</FormLabel>
|
||||
<Textarea
|
||||
resize={"none"}
|
||||
rounded={5}
|
||||
size="sm"
|
||||
onChange={(e) => setMessage(e.target.value)}
|
||||
/>
|
||||
</FormControl>
|
||||
)}
|
||||
{messageError && (
|
||||
<Text fontSize={"sm"} color={"red"}>
|
||||
{messageError}
|
||||
</Text>
|
||||
)}
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
|
||||
@@ -97,7 +97,6 @@ const ViewIOTable = () => {
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
});
|
||||
|
||||
console.log(data);
|
||||
|
||||
// ===============================[ Table Header ]
|
||||
const tableHeadRow = [
|
||||
@@ -242,17 +241,17 @@ const ViewIOTable = () => {
|
||||
textTransform={"none"}
|
||||
// variant={"solid"}
|
||||
colorScheme={
|
||||
item?.ioStatus?.statusAdmin === "Draft"
|
||||
item?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_DRAFT
|
||||
? "gray"
|
||||
: item?.ioStatus?.statusAdmin === "Processing"
|
||||
: item?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_PROCESSING
|
||||
? "yellow"
|
||||
: item?.ioStatus?.statusAdmin === "Open"
|
||||
: item?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_OPEN
|
||||
? "blue"
|
||||
: item?.ioStatus?.statusAdmin === "Closed"
|
||||
: item?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_CLOSED
|
||||
? "green"
|
||||
: item?.ioStatus?.statusAdmin === "Exited"
|
||||
: item?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_EXITED
|
||||
? "red"
|
||||
: item?.ioStatus?.statusAdmin === "Canclled"
|
||||
: item?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_CANCELLED
|
||||
? "orange"
|
||||
: "purple"
|
||||
}
|
||||
|
||||
@@ -1,52 +1,61 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Input,
|
||||
keyframes,
|
||||
Stack,
|
||||
Tab,
|
||||
TabList,
|
||||
TabPanel,
|
||||
TabPanels,
|
||||
Tabs,
|
||||
Text,
|
||||
useDisclosure,
|
||||
useDisclosure
|
||||
} from "@chakra-ui/react";
|
||||
import { useContext, useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import FormInputView from "../../../Components/FormInputView";
|
||||
import { useForm } from "react-hook-form"; // assuming react-hook-form is used
|
||||
import { OPACITY_ON_LOAD } from "../../../Layout/animations";
|
||||
import { ArrowBackIcon } from "@chakra-ui/icons";
|
||||
import CustomAlertDialog from "../../../Components/CustomAlertDialog";
|
||||
import InvestmentDocument from "../CreateIO/InvestmentDocument";
|
||||
import Investors from "../CreateIO/Investors";
|
||||
import IOArtifacts from "../CreateIO/IOArtifacts";
|
||||
import KeyMerits from "../CreateIO/KeyMerits";
|
||||
import ViewIOdataHeader from "./ViewIOdataHeader";
|
||||
import ViewIOdetails from "./ViewIOdetails";
|
||||
import ViewIOdocs from "./ViewIOdocs";
|
||||
import ViewKeyMerits from "./ViewKeyMerits";
|
||||
import ViewIOartifacts from "./ViewIOartifacts";
|
||||
import ViewInvestors from "./ViewInvestors";
|
||||
import ViewIOcash from "./ViewIOcash";
|
||||
import ViewIOnav from "./ViewIOnav";
|
||||
import ViewDistribution from "./ViewDistribution";
|
||||
import InvestmentDocument from "../CreateIO/InvestmentDocument";
|
||||
import KeyMerits from "../CreateIO/KeyMerits";
|
||||
import Investors from "../CreateIO/Investors";
|
||||
import EditIO from "../EditIO/EditIO";
|
||||
import IOArtifacts from "../CreateIO/IOArtifacts";
|
||||
import IOCashDetails from "../CreateIO/IOCashDetails";
|
||||
import IONAVDetails from "../CreateIO/IONAVDetails";
|
||||
import { useGetIOprepopulateDataQuery } from "../../../Services/io.service";
|
||||
import UnderConstruction from "../../UnderConstruction";
|
||||
// import IOCashDetails from "../CreateIO/IOCashDetailsold";
|
||||
// import IONAVDetails from "../CreateIO/IONAVDetailsOld";
|
||||
import { GoDotFill } from "react-icons/go";
|
||||
import {
|
||||
useGetIOByIdQuery,
|
||||
useGetIOprepopulateDataQuery,
|
||||
} from "../../../Services/io.service";
|
||||
import Destribution from "../CreateIO/Destribution";
|
||||
import IOCashDetails from "../CreateIO/IOCashDetails/IOCashDetails";
|
||||
import IONAVDetails from "../CreateIO/IONAVDetails/IONAVDetails";
|
||||
import IOTransaction from "../CreateIO/IOTransaction/IOTransaction";
|
||||
|
||||
const rotate = keyframes`
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
`;
|
||||
|
||||
const ViewIOdata = () => {
|
||||
const params = useParams();
|
||||
const id = params?.id;
|
||||
const { data, error, isLoading } = useGetIOprepopulateDataQuery();
|
||||
const { data, error, isLoading, refetch } = useGetIOprepopulateDataQuery();
|
||||
const {
|
||||
data: IObyID,
|
||||
isLoading: IObyIDisLoading,
|
||||
error: IObyIDerror,
|
||||
refetch: IObyIDrefetch,
|
||||
} = useGetIOByIdQuery(id, { skip: !id });
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const navigate = useNavigate();
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const [isRefetchLoading, setIsRefetchLoading] = useState(false);
|
||||
const { IODetails, setIODetails } = useContext(GlobalStateContext);
|
||||
console.log(IODetails?.isInvestedAmount);
|
||||
|
||||
const tabs = [
|
||||
{ label: "IO Details", content: <ViewIOdetails data={data?.data} /> },
|
||||
@@ -64,9 +73,22 @@ const ViewIOdata = () => {
|
||||
label: "Distribution to Investors",
|
||||
content: <Destribution data={data?.data} />,
|
||||
},
|
||||
{
|
||||
label: "IO Transaction",
|
||||
content: <IOTransaction data={data?.data} />,
|
||||
},
|
||||
// { label: "Distribution to Investors", content: <UnderConstruction h={'75vh'} /> },
|
||||
];
|
||||
|
||||
const handleRefresh = async () => {
|
||||
setIsRefetchLoading(true);
|
||||
|
||||
await IObyIDrefetch();
|
||||
setIsRefetchLoading(false);
|
||||
};
|
||||
|
||||
console.log(IODetails?.ioNAVHistory);
|
||||
|
||||
return (
|
||||
<Box
|
||||
{...OPACITY_ON_LOAD}
|
||||
@@ -87,7 +109,7 @@ const ViewIOdata = () => {
|
||||
|
||||
<Tabs mt={4}>
|
||||
<TabList justifyContent={"space-between"} pe={4} alignItems={"center"}>
|
||||
<Box display={"flex"}>
|
||||
<Box display={"flex"} position={"relative"} w={"100%"}>
|
||||
{tabs.map(({ label }, index) => (
|
||||
<Tab
|
||||
px={3}
|
||||
@@ -96,20 +118,86 @@ const ViewIOdata = () => {
|
||||
index === 1 ||
|
||||
index === 2 ||
|
||||
index === 3 ||
|
||||
index === 4
|
||||
index === 4 ||
|
||||
index === 8
|
||||
? false
|
||||
: !IODetails?.isInvestedAmount
|
||||
}
|
||||
// isDisabled={
|
||||
// index === 0 ||
|
||||
// index === 1 ||
|
||||
// index === 2 ||
|
||||
// index === 3 ||
|
||||
// index === 4
|
||||
// ? false
|
||||
// : !IODetails?.isInvestedAmount
|
||||
// }
|
||||
key={index}
|
||||
fontSize={"sm"}
|
||||
fontSize={"xs"}
|
||||
_selected={{
|
||||
color: "#004118",
|
||||
borderBottom: "2px solid #38a169",
|
||||
}}
|
||||
fontWeight={500}
|
||||
position={"relative"}
|
||||
>
|
||||
{label}
|
||||
{label}{" "}
|
||||
{(index === 5 &&
|
||||
IODetails?.ioCashStatusHistory?.Pending?.length !== 0) ||
|
||||
(index === 6 &&
|
||||
IODetails?.ioNAVStatusHistory?.Pending?.length !== 0) ||
|
||||
(index === 8 &&
|
||||
IODetails?.ioTransactionRecords?.Pending?.length !== 0) ? (
|
||||
<Box
|
||||
as="span"
|
||||
right={0}
|
||||
color={"forestGreen"}
|
||||
top={1}
|
||||
position={"absolute"}
|
||||
>
|
||||
<GoDotFill />
|
||||
</Box>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Tab>
|
||||
))}
|
||||
{/* <Box as="span" position={"absolute"} right={2} bottom={1}>
|
||||
<Icon
|
||||
ms={0}
|
||||
animation={
|
||||
isRefetchLoading ? `${rotate} 1s linear infinite` : "none"
|
||||
}
|
||||
bg={"gray.50"}
|
||||
onClick={handleRefresh}
|
||||
fontWeight={600}
|
||||
as={RepeatIcon}
|
||||
boxSize={8}
|
||||
p={2}
|
||||
rounded={"full"}
|
||||
_hover={{ bg: "gray.100" }}
|
||||
cursor={"pointer"}
|
||||
/>
|
||||
</Box> */}
|
||||
<Stack
|
||||
position={"absolute"}
|
||||
right={1}
|
||||
bottom={1}
|
||||
direction="row"
|
||||
spacing={4}
|
||||
>
|
||||
<Button
|
||||
isLoading={isRefetchLoading}
|
||||
loadingText="Refresh"
|
||||
colorScheme="forestGreen"
|
||||
variant="solid"
|
||||
size={"xs"}
|
||||
onClick={handleRefresh}
|
||||
fontWeight={400}
|
||||
>
|
||||
Refresh
|
||||
</Button>
|
||||
</Stack>
|
||||
</Box>
|
||||
</TabList>
|
||||
<TabPanels>
|
||||
|
||||
@@ -1,56 +1,59 @@
|
||||
import {
|
||||
Button,
|
||||
Divider,
|
||||
Badge,
|
||||
Box,
|
||||
HStack,
|
||||
Icon,
|
||||
Image,
|
||||
Menu,
|
||||
MenuButton,
|
||||
MenuItem,
|
||||
MenuList,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Portal,
|
||||
Text,
|
||||
useDisclosure,
|
||||
MenuItemOption,
|
||||
MenuGroup,
|
||||
MenuOptionGroup,
|
||||
MenuDivider,
|
||||
Badge,
|
||||
Box,
|
||||
Icon,
|
||||
HStack,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import header from "../../../assets/IOheader.png";
|
||||
import { useContext, useRef } from "react";
|
||||
import { GrGallery } from "react-icons/gr";
|
||||
import { HiDotsVertical } from "react-icons/hi";
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
import { useParams } from "react-router-dom";
|
||||
import Loader01 from "../../../Components/Loaders/Loader01";
|
||||
import ToastBox from "../../../Components/ToastBox";
|
||||
import {
|
||||
decryptString,
|
||||
encryptString,
|
||||
isMaker,
|
||||
} from "../../../Constants/Constants";
|
||||
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
|
||||
import { useUpdateTransactionMutation } from "../../../Services/io.service";
|
||||
import AmountInvested from "./HeaderModal/AmountInvested";
|
||||
import FeesExpenses from "./HeaderModal/FeesExpenses";
|
||||
import DistributionSponsor from "./HeaderModal/DistributionSponsor";
|
||||
import Cancle from "./HeaderModal/Cancle";
|
||||
import DistributionInvestor from "./HeaderModal/DistributionInvestor";
|
||||
import DistributionSponsor from "./HeaderModal/DistributionSponsor";
|
||||
import Exit from "./HeaderModal/Exit";
|
||||
import FeesExpenses from "./HeaderModal/FeesExpenses";
|
||||
import UpdateIONav from "./HeaderModal/UpdateIONav";
|
||||
import UpdateIOStatus from "./HeaderModal/UpdateIOStatus";
|
||||
import { useContext, useRef } from "react";
|
||||
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
|
||||
import Exit from "./HeaderModal/Exit";
|
||||
import Cancle from "./HeaderModal/Cancle";
|
||||
import { AddIcon } from "@chakra-ui/icons";
|
||||
import { GrGallery } from "react-icons/gr";
|
||||
import Loader01 from "../../../Components/Loaders/Loader01";
|
||||
import { useAuthProfileQuery } from "../../../Services/token.serivce";
|
||||
// import { formatCurrency } from "../../../Components/CurrencyInput";
|
||||
// import { removeTrailingZeros } from "../../../Constants/Constants";
|
||||
|
||||
const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
const params = useParams();
|
||||
const toast = useToast();
|
||||
const id = params?.id;
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const btnRef = useRef();
|
||||
const { IODetails, isIOloading } = useContext(GlobalStateContext);
|
||||
|
||||
const { data: authProfile } = useAuthProfileQuery();
|
||||
if (authProfile?.data?.role) {
|
||||
localStorage.setItem("role", encryptString(authProfile.data.role));
|
||||
} else {
|
||||
console.warn("Role is undefined or null. Skipping localStorage update.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
const {
|
||||
isOpen: isInvestmentOpen,
|
||||
onOpen: onInvestmentOpen,
|
||||
@@ -102,17 +105,89 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
fontSize: "0.875rem",
|
||||
fontWeight: "400",
|
||||
};
|
||||
|
||||
const [updateTransaction] = useUpdateTransactionMutation();
|
||||
|
||||
console.log(
|
||||
import.meta.env.VITE_IMAGE_URL +
|
||||
IODetails?.artifactsImage?.[0]?.artifactPathName
|
||||
);
|
||||
const handleDistributionInvestors = async () => {
|
||||
try {
|
||||
const res = await updateTransaction(id);
|
||||
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={res?.data?.message} />
|
||||
// ),
|
||||
// });
|
||||
// setIsLoading(false);
|
||||
onDistInvestorOpen();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
// setIsLoading(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleExit = async () => {
|
||||
try {
|
||||
const res = await updateTransaction(id);
|
||||
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={res?.data?.message} />
|
||||
// ),
|
||||
// });
|
||||
// setIsLoading(false);
|
||||
onExitOpen();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
// setIsLoading(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleInvestment = async () => {
|
||||
try {
|
||||
const res = await updateTransaction(id);
|
||||
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={res?.data?.message} />
|
||||
// ),
|
||||
// });
|
||||
// setIsLoading(false);
|
||||
onInvestmentOpen();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
// setIsLoading(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
const menu = [
|
||||
{
|
||||
id: 1,
|
||||
title: "Amount Invested",
|
||||
onClickFunction: onInvestmentOpen,
|
||||
onClickFunction: handleInvestment,
|
||||
},
|
||||
// {
|
||||
// id:2,
|
||||
@@ -127,7 +202,7 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
{
|
||||
id: 6,
|
||||
title: "Distribution To Investors",
|
||||
onClickFunction: onDistInvestorOpen,
|
||||
onClickFunction: handleDistributionInvestors,
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
@@ -137,7 +212,7 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
{
|
||||
id: 8,
|
||||
title: "Exit",
|
||||
onClickFunction: onExitOpen,
|
||||
onClickFunction: handleExit,
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
@@ -162,8 +237,8 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
apiTransactionTitles?.includes(item.id)
|
||||
);
|
||||
|
||||
|
||||
const balanceAmount = IODetails?.goalAmount - IODetails?.totalAmtInvestmentInUSD
|
||||
const balanceAmount =
|
||||
IODetails?.goalAmount - IODetails?.totalAmtInvestmentInUSD;
|
||||
|
||||
return IODetails?.investmentNameEnglish ? (
|
||||
<Box
|
||||
@@ -172,19 +247,19 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
justifyContent={"space-between"}
|
||||
gap={8}
|
||||
bg={
|
||||
IODetails?.ioStatus?.statusAdmin === "Draft"
|
||||
IODetails?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_DRAFT
|
||||
? "#EDF2F7"
|
||||
: IODetails?.ioStatus?.statusAdmin === "Processing"
|
||||
: IODetails?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_PROCESSING
|
||||
? "#FEFBBF"
|
||||
: IODetails?.ioStatus?.statusAdmin === "Open"
|
||||
: IODetails?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_OPEN
|
||||
? "#BEE2F8"
|
||||
: IODetails?.ioStatus?.statusAdmin === "Closed"
|
||||
: IODetails?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_CLOSED
|
||||
? "#C6F6D5"
|
||||
: IODetails?.ioStatus?.statusAdmin === "Exited"
|
||||
: IODetails?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_EXITED
|
||||
? "#FED7D7"
|
||||
: IODetails?.ioStatus?.statusAdmin === "Cancelled"
|
||||
: IODetails?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_CANCELLED
|
||||
? "#E9D8FD"
|
||||
: IODetails?.ioStatus?.statusAdmin === "DeActivate"
|
||||
: IODetails?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_DEACTIVATE
|
||||
? "#E9D8FD"
|
||||
: null
|
||||
}
|
||||
@@ -229,7 +304,6 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
</Box>
|
||||
|
||||
<Box>
|
||||
|
||||
<Box display={"flex"} gap={2} pb={1}>
|
||||
<Text
|
||||
as={"span"}
|
||||
@@ -247,7 +321,7 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
<Box display={"flex"} gap={2} pb={1}>
|
||||
<Box display={"flex"} gap={2} pb={1}>
|
||||
<Text
|
||||
as={"span"}
|
||||
fontSize={"xs"}
|
||||
@@ -264,7 +338,7 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
<Box display={"flex"} gap={2} pb={1}>
|
||||
<Box display={"flex"} gap={2} pb={1}>
|
||||
<Text
|
||||
as={"span"}
|
||||
fontSize={"xs"}
|
||||
@@ -275,18 +349,13 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
IO ID :-
|
||||
</Text>
|
||||
<Text as={"span"} fontSize={"xs"} fontWeight={"500"}>
|
||||
{IODetails?.io_id
|
||||
? IODetails?.io_id
|
||||
: "---"}
|
||||
{IODetails?.io_id ? IODetails?.io_id : "---"}
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
</Box>
|
||||
|
||||
</HStack>
|
||||
|
||||
<Box gap={8} me={12} w={"220px"}>
|
||||
|
||||
<Box gap={8} me={12} w={"220px"}>
|
||||
<Box display={"flex"} justifyContent={"space-between"} gap={2} pb={1}>
|
||||
<Text
|
||||
as={"span"}
|
||||
@@ -316,10 +385,13 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
</Text>
|
||||
<Text as={"span"} fontSize={"xs"} fontWeight={"500"}>
|
||||
{/* {IODetails?.ioCash ? formatCurrency(removeTrailingZeros(IODetails?.ioCash)) : "00.00"} */}
|
||||
{parseFloat(IODetails?.totalAmtInvestmentInUSD || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
{parseFloat(IODetails?.totalAmtInvestmentInUSD || 0).toLocaleString(
|
||||
undefined,
|
||||
{
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
}
|
||||
)}
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
@@ -360,17 +432,17 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
textTransform={"none"}
|
||||
// variant={"solid"}
|
||||
colorScheme={
|
||||
IODetails?.ioStatus?.statusAdmin === "Draft"
|
||||
IODetails?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_DRAFT
|
||||
? "gray"
|
||||
: IODetails?.ioStatus?.statusAdmin === "Processing"
|
||||
: IODetails?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_PROCESSING
|
||||
? "yellow"
|
||||
: IODetails?.ioStatus?.statusAdmin === "Open"
|
||||
: IODetails?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_OPEN
|
||||
? "blue"
|
||||
: IODetails?.ioStatus?.statusAdmin === "Closed"
|
||||
: IODetails?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_CLOSED
|
||||
? "green"
|
||||
: IODetails?.ioStatus?.statusAdmin === "Exited"
|
||||
: IODetails?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_EXITED
|
||||
? "red"
|
||||
: IODetails?.ioStatus?.statusAdmin === "Cancelled"
|
||||
: IODetails?.ioStatus?.statusAdmin === import.meta.env.VITE_STATUS_CANCELLED
|
||||
? "purple"
|
||||
: "purple"
|
||||
}
|
||||
@@ -444,39 +516,41 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
alignItems={"start"}
|
||||
height={"95px"}
|
||||
>
|
||||
<Menu>
|
||||
<MenuButton
|
||||
className="link p-1 rounded-1 "
|
||||
bg={"#fff"}
|
||||
_hover={{ backgroundColor: "#fff !important" }}
|
||||
onClick={onOpen}
|
||||
ref={btnRef}
|
||||
>
|
||||
<HiDotsVertical className="rubix-text-dark fs-6" />
|
||||
</MenuButton>
|
||||
<MenuList fontSize={"sm"}>
|
||||
<MenuItem
|
||||
_hover={{
|
||||
bg: "#fff",
|
||||
}}
|
||||
as={"span"}
|
||||
fontWeight={600}
|
||||
className="border-bottom"
|
||||
{isMaker() && (
|
||||
<Menu>
|
||||
<MenuButton
|
||||
className="link p-1 rounded-1 "
|
||||
bg={"#fff"}
|
||||
_hover={{ backgroundColor: "#fff !important" }}
|
||||
onClick={onOpen}
|
||||
ref={btnRef}
|
||||
>
|
||||
Tansaction
|
||||
</MenuItem>
|
||||
|
||||
{filteredMenu?.map(({ id, title, onClickFunction }) => (
|
||||
<HiDotsVertical className="rubix-text-dark fs-6" />
|
||||
</MenuButton>
|
||||
<MenuList fontSize={"sm"}>
|
||||
<MenuItem
|
||||
key={id}
|
||||
onClick={onClickFunction}
|
||||
_hover={{
|
||||
bg: "#fff",
|
||||
}}
|
||||
as={"span"}
|
||||
fontWeight={600}
|
||||
className="border-bottom"
|
||||
>
|
||||
{title}
|
||||
Tansaction
|
||||
</MenuItem>
|
||||
))}
|
||||
</MenuList>
|
||||
</Menu>
|
||||
|
||||
{filteredMenu?.map(({ id, title, onClickFunction }) => (
|
||||
<MenuItem
|
||||
key={id}
|
||||
onClick={onClickFunction}
|
||||
className="border-bottom"
|
||||
>
|
||||
{title}
|
||||
</MenuItem>
|
||||
))}
|
||||
</MenuList>
|
||||
</Menu>
|
||||
)}
|
||||
|
||||
{/* Modals */}
|
||||
<AmountInvested isOpen={isInvestmentOpen} onClose={onInvestmentClose} />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Box, Button } from "@chakra-ui/react";
|
||||
import { Box, Button, Text } from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect } from "react";
|
||||
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
@@ -240,11 +240,6 @@ const ViewIOdetails = () => {
|
||||
width: "32.3%",
|
||||
value: IObyID?.data?.isShariah,
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
label: "Investment Type",
|
||||
placeHolder: "Select option",
|
||||
@@ -351,19 +346,22 @@ const ViewIOdetails = () => {
|
||||
|
||||
return (
|
||||
<Box position={"relative"}>
|
||||
<Button
|
||||
position={"absolute"}
|
||||
top={"-62px"}
|
||||
right={0}
|
||||
onClick={() => navigate(`/create-io/${params?.id}`)}
|
||||
ps={4}
|
||||
pe={4}
|
||||
colorScheme="forestGreen"
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
>
|
||||
Edit IO
|
||||
</Button>
|
||||
<Box display={"flex"} justifyContent={"space-between"}>
|
||||
<Text></Text>
|
||||
<Button
|
||||
// position={"absolute"}
|
||||
// top={"-62px"}
|
||||
right={0}
|
||||
onClick={() => navigate(`/create-io/${params?.id}`)}
|
||||
ps={4}
|
||||
pe={4}
|
||||
colorScheme="forestGreen"
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
>
|
||||
Edit IO
|
||||
</Button>
|
||||
</Box>
|
||||
<FormInputView groupedFields={groupedFields} />
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -203,7 +203,7 @@ const BankDetails = () => {
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={38}>
|
||||
<HStack>
|
||||
<Text as={'span'} fontSize={'sm'} fontWeight={700}>Bank Deatils</Text>
|
||||
<Text as={'span'} fontSize={'sm'} fontWeight={700}>Bank Details</Text>
|
||||
</HStack>
|
||||
<HStack
|
||||
display={"flex"}
|
||||
|
||||
@@ -1,35 +1,31 @@
|
||||
import { ViewIcon } from "@chakra-ui/icons";
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
Select,
|
||||
Switch,
|
||||
Tag,
|
||||
Text,
|
||||
Tooltip,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useState, useRef } from "react";
|
||||
import { OPACITY_ON_LOAD } from "../../../Layout/animations";
|
||||
import NormalTable from "../../../Components/DataTable/NormalTable";
|
||||
import { Link, Link as RouterLink, useNavigate } from "react-router-dom";
|
||||
import {
|
||||
ViewIcon,
|
||||
} from "@chakra-ui/icons";
|
||||
import Pagination from "../../../Components/Pagination";
|
||||
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
|
||||
import CustomAlertDialog from "../../../Components/CustomAlertDialog";
|
||||
import ToastBox from "../../../Components/ToastBox";
|
||||
import { debounce } from "../../Master/Sponser/AddSponser";
|
||||
import InvestmentDetailsEdit from "./InvestmentDetailsEdit";
|
||||
import { useGetInvestorsQuery } from "../../../Services/investor.details.service";
|
||||
import { TABLE_PAGINATION } from "../../../Constants/Paginations";
|
||||
import { exportToExcel, exportToExcelNew, generateSerialNumber } from "../../../Constants/Constants";
|
||||
import React, { useContext, useEffect, useRef, useState } from "react";
|
||||
import { LuFileSpreadsheet } from "react-icons/lu";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import CustomAlertDialog from "../../../Components/CustomAlertDialog";
|
||||
import NormalTable from "../../../Components/DataTable/NormalTable";
|
||||
import Pagination from "../../../Components/Pagination";
|
||||
import {
|
||||
exportToExcelNew,
|
||||
generateSerialNumber,
|
||||
} from "../../../Constants/Constants";
|
||||
import { INVESTOR_TABLE_PAGINATION } from "../../../Constants/Paginations";
|
||||
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
|
||||
import { OPACITY_ON_LOAD } from "../../../Layout/animations";
|
||||
import { useGetInvestorsQuery } from "../../../Services/investor.details.service";
|
||||
import InvestmentDetailsEdit from "./InvestmentDetailsEdit";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter
|
||||
|
||||
@@ -51,10 +47,11 @@ const InvestorDetails = () => {
|
||||
} = useDisclosure();
|
||||
const btnRef = React.useRef();
|
||||
|
||||
|
||||
// =========================== [Use State] =============================
|
||||
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
// =========================== [Use State] =============================
|
||||
const [pageSize, setPageSize] = useState(INVESTOR_TABLE_PAGINATION?.size);
|
||||
const [currentPage, setCurrentPage] = useState(
|
||||
INVESTOR_TABLE_PAGINATION?.page
|
||||
);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
|
||||
|
||||
@@ -75,20 +72,19 @@ const InvestorDetails = () => {
|
||||
data: investorDetails,
|
||||
isLoading: investorDetailsLoading,
|
||||
error,
|
||||
} = useGetInvestorsQuery({
|
||||
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
|
||||
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search userStatus KYCStatus investorType_xid
|
||||
search: debouncedSearchTerm,
|
||||
userStatus: status,
|
||||
KYCStatus: kyc,
|
||||
country_xid: country
|
||||
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
}
|
||||
);
|
||||
|
||||
} = useGetInvestorsQuery(
|
||||
{
|
||||
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
|
||||
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search userStatus KYCStatus investorType_xid
|
||||
search: debouncedSearchTerm,
|
||||
userStatus: status,
|
||||
KYCStatus: kyc,
|
||||
country_xid: country,
|
||||
},
|
||||
{
|
||||
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
|
||||
}
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
// Simulate loading
|
||||
@@ -103,47 +99,48 @@ const InvestorDetails = () => {
|
||||
// ====================================================[Table Setup]================================================================
|
||||
const tableHeadRow = [
|
||||
"Sr No",
|
||||
|
||||
"Client ID",
|
||||
"First Name",
|
||||
"Last Name",
|
||||
"Country",
|
||||
"Country",
|
||||
"Phone Number",
|
||||
"E-mail ID",
|
||||
"Type",
|
||||
// "Type",
|
||||
"Wallet Balance",
|
||||
"Investor Portfolio",
|
||||
"KYC Status",
|
||||
"Status",
|
||||
// "Status",
|
||||
"Action",
|
||||
];
|
||||
|
||||
|
||||
// ====================================================[Table Filter]================================================================
|
||||
const exportInvestor = investorDetails?.data?.rows?.map((item, idx) => ({
|
||||
"Id": parseInt(item?.id, 10) || item?.id, // Convert to integer, fallback to string if conversion fails
|
||||
const exportInvestor = investorDetails?.data?.rows?.map((item) => ({
|
||||
Id: parseInt(item?.id, 10) || item?.id, // Convert to integer, fallback to string if conversion fails
|
||||
"Client ID": item?.clientReference_id, // This is likely a string
|
||||
"First Name": item?.principal?.firstName,
|
||||
"Last Name": item?.principal?.lastName,
|
||||
"Country": item?.country?.countryName,
|
||||
Country: item?.country?.countryName,
|
||||
"Phone Number": item?.principal?.mobileNumber, // Skipping integer conversion, as this is likely a string
|
||||
"E-mail ID": item?.principal?.emailAddress,
|
||||
"Type": item?.investor_type?.investorTypeName,
|
||||
"Status": item.ioStatus ? "Ban" : "Unban",
|
||||
"KYC Status": item.KYCStatus ? "Completed" : "Not complete"
|
||||
"Wallet Balance": item?.principal?.WalletBalance_InInvCur, // Skipping integer conversion, as this is likely a string
|
||||
"Investor Portfolio": item?.principal?.Portfolio_InInvCur,
|
||||
// Type: item?.investor_type?.investorTypeName,
|
||||
// Status: item.ioStatus ? "Ban" : "Unban",
|
||||
"KYC Status": item.KYCStatus ? "Completed" : "Not complete",
|
||||
}));
|
||||
|
||||
const extractedArray = investorDetails?.data?.rows?.map((item, idx) => ({
|
||||
id: item?.id,
|
||||
"Sr No": (
|
||||
<Text
|
||||
w={'24px'}
|
||||
w={"24px"}
|
||||
justifyContent={slideFromRight ? "right" : "left"}
|
||||
as={"span"}
|
||||
color={"gray.600"}
|
||||
className="d-flex align-items-center fw-bold web-text-small"
|
||||
>
|
||||
{/* {item.id} */}
|
||||
{generateSerialNumber(idx,currentPage, pageSize )}
|
||||
|
||||
{generateSerialNumber(idx, currentPage, pageSize)}
|
||||
</Text>
|
||||
),
|
||||
"Client ID": (
|
||||
@@ -151,7 +148,7 @@ const InvestorDetails = () => {
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item.clientReference_id}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
),
|
||||
"First Name": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
@@ -188,42 +185,87 @@ const InvestorDetails = () => {
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Type": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} >
|
||||
<Badge color={"forestGreen.500"} variant={'ghost'} fontWeight={"700"} px={2} py={0.5}>
|
||||
{item?.investor_type?.investorTypeName}
|
||||
// Type: (
|
||||
// <Box w={"auto"} isTruncated={true}>
|
||||
// <Text as={"span"}>
|
||||
// <Badge
|
||||
// color={"forestGreen.500"}
|
||||
// variant={"ghost"}
|
||||
// fontWeight={"700"}
|
||||
// px={2}
|
||||
// py={0.5}
|
||||
// >
|
||||
// {item?.investor_type?.investorTypeName}
|
||||
// </Badge>
|
||||
// </Text>
|
||||
// </Box>
|
||||
// ),
|
||||
// Status: (
|
||||
// <Box w={"auto"} isTruncated={true}>
|
||||
// <Badge
|
||||
// fontWeight={"700"}
|
||||
// textTransform={"none"}
|
||||
// colorScheme={item.ioStatus ? "red" : "green"}
|
||||
// px={2}
|
||||
// py={0.5}
|
||||
// >
|
||||
// {item.ioStatus ? "Ban" : "Unban"}
|
||||
// </Badge>
|
||||
// </Box>
|
||||
// ),
|
||||
"Wallet Balance": (
|
||||
<Box
|
||||
display={"flex"}
|
||||
justifyContent={"end"}
|
||||
w={"130px"}
|
||||
isTruncated={true}
|
||||
>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{/* {formatCurrency(removeTrailingZeros(item?.investorAmount))} */}
|
||||
{parseFloat(item?.WalletBalance_InInvCur || 0).toLocaleString(
|
||||
undefined,
|
||||
{
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
}
|
||||
)}
|
||||
<Badge ms={1} colorScheme="green">
|
||||
{item?.currencyCode}
|
||||
</Badge>
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
Status: (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Badge
|
||||
fontWeight={"700"}
|
||||
textTransform={"none"}
|
||||
colorScheme={item.ioStatus ? "red" : "green"}
|
||||
px={2}
|
||||
py={0.5}
|
||||
"Investor Portfolio": (
|
||||
<Box
|
||||
display={"flex"}
|
||||
justifyContent={"end"}
|
||||
w={"130px"}
|
||||
isTruncated={true}
|
||||
>
|
||||
{item.ioStatus ? "Ban" : "Unban"}
|
||||
</Badge>
|
||||
</Box>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{parseFloat(item?.Portfolio_InInvCur || 0).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
<Badge ms={1} colorScheme="green">
|
||||
{item?.currencyCode}
|
||||
</Badge>
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"KYC Status": (
|
||||
<Box w={"auto"} display={'flex'} alignItems={'center'} isTruncated={true}>
|
||||
<Box w={"auto"} display={"flex"} alignItems={"center"} isTruncated={true}>
|
||||
<Text
|
||||
as={'span'}
|
||||
as={"span"}
|
||||
fontWeight={"700"}
|
||||
textTransform={"none"}
|
||||
color={item?.KYCStatus === true ? "green" : "yellow.500"}
|
||||
px={2}
|
||||
py={0.5}
|
||||
variant={'solid'}
|
||||
|
||||
variant={"solid"}
|
||||
>
|
||||
{/* {item.KYCStatus ? "Completed" : "Not complete"} */}
|
||||
{item?.KYCStatus === true ? "Completed" : "NotCompleted"}
|
||||
{item?.KYCStatus === true ? "Completed" : "Not Completed"}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
@@ -238,7 +280,7 @@ const InvestorDetails = () => {
|
||||
placement="top"
|
||||
>
|
||||
<Button
|
||||
isDisabled={item.ioStatus}
|
||||
isDisabled={item.ioStatus}
|
||||
onClick={() => {
|
||||
navigate(`/investor-details/profile-view/${item.id}`);
|
||||
}}
|
||||
@@ -269,7 +311,6 @@ const InvestorDetails = () => {
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={38}>
|
||||
<Box bg="white.500">
|
||||
@@ -324,7 +365,7 @@ const InvestorDetails = () => {
|
||||
KYC Status
|
||||
</option>
|
||||
<option value="">KYC Status</option>
|
||||
<option value="0">Incompleted</option>
|
||||
<option value="0">Not Completed</option>
|
||||
<option value="1">Completed</option>
|
||||
</Select>
|
||||
|
||||
@@ -340,7 +381,7 @@ const InvestorDetails = () => {
|
||||
Country
|
||||
</option>
|
||||
<option value="">All</option>
|
||||
<option value="1">Behrain</option>
|
||||
<option value="1">Bahrain</option>
|
||||
<option value="2">Kuwait</option>
|
||||
<option value="3">Oman</option>
|
||||
<option value="4">Qatar</option>
|
||||
@@ -349,35 +390,29 @@ const InvestorDetails = () => {
|
||||
</Select>
|
||||
|
||||
<Pagination
|
||||
isLoading={investorDetailsLoading}
|
||||
isLoading={investorDetailsLoading}
|
||||
pageSize={pageSize}
|
||||
setPageSize={setPageSize}
|
||||
currentPage={currentPage}
|
||||
setCurrentPage={setCurrentPage}
|
||||
totalItems={investorDetails?.data?.totalItems}
|
||||
|
||||
/>
|
||||
|
||||
</HStack>
|
||||
|
||||
|
||||
<Button
|
||||
onClick={() =>
|
||||
exportToExcelNew(exportInvestor, "Investor Details")
|
||||
}
|
||||
leftIcon={<LuFileSpreadsheet />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
variant={"outline"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
w={100}
|
||||
me={2}
|
||||
|
||||
isDisabled={exportInvestor?.length === 0}
|
||||
>
|
||||
Export xls
|
||||
</Button>
|
||||
onClick={() => exportToExcelNew(exportInvestor, "Investor Details")}
|
||||
leftIcon={<LuFileSpreadsheet />}
|
||||
colorScheme="forestGreen"
|
||||
size={"sm"}
|
||||
variant={"outline"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
w={100}
|
||||
me={2}
|
||||
isDisabled={exportInvestor?.length === 0}
|
||||
>
|
||||
Export xls
|
||||
</Button>
|
||||
</HStack>
|
||||
<InvestmentDetailsEdit
|
||||
id={actionId}
|
||||
|
||||
@@ -49,7 +49,7 @@ const Kyc = () => {
|
||||
<HStack spacing={4} mb={4}>
|
||||
<FormControl>
|
||||
<FormLabel mb={1} fontSize={"sm"}>
|
||||
House/Unit
|
||||
Address line 1
|
||||
</FormLabel>
|
||||
<Input
|
||||
bg={"#ccc3"}
|
||||
@@ -62,7 +62,7 @@ const Kyc = () => {
|
||||
</FormControl>
|
||||
<FormControl>
|
||||
<FormLabel mb={1} fontSize={"sm"}>
|
||||
Road/Street
|
||||
Address line 2
|
||||
</FormLabel>
|
||||
<Input
|
||||
bg={"#ccc3"}
|
||||
@@ -150,6 +150,22 @@ const Kyc = () => {
|
||||
/>
|
||||
</FormControl>
|
||||
</HStack>
|
||||
<HStack spacing={4} mb={4}>
|
||||
<FormControl>
|
||||
<FormLabel mb={1} fontSize={"sm"}>
|
||||
PEP Status
|
||||
</FormLabel>
|
||||
<Input
|
||||
bg={"#ccc3"}
|
||||
border={"none"}
|
||||
size={"sm"}
|
||||
value={data?.data?.KYC?.PEPStatus ? "Yes" : "No"}
|
||||
type="text"
|
||||
readOnly
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControl></FormControl>
|
||||
</HStack>
|
||||
{/* <HStack spacing={4}>
|
||||
<FormControl>
|
||||
<FormLabel mb={1} fontSize={"sm"}>Address</FormLabel>
|
||||
|
||||
@@ -3,7 +3,7 @@ import Input01 from "../Components/Inputs/Input01";
|
||||
import logo from "../assets/logo2.png";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { loginUser } from "../Redux/Slice/auth";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import Button01 from "../Components/Buttons/Button01";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForm } from "react-hook-form";
|
||||
@@ -12,12 +12,15 @@ import Loader01 from "../Components/Loaders/Loader01";
|
||||
import Asset1 from "../assets/asset1.png";
|
||||
import Asset2 from "../assets/asset2.png";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormLabel,
|
||||
Input,
|
||||
InputGroup,
|
||||
InputRightElement,
|
||||
Text,
|
||||
useDisclosure,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import GlobalStateContext from "../Contexts/GlobalStateContext";
|
||||
@@ -28,6 +31,7 @@ import { useLoginMutation } from "../Services/token.serivce";
|
||||
|
||||
// import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import * as Yup from "yup";
|
||||
import ForgetPassword from "./ForgetPassword";
|
||||
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
@@ -50,6 +54,8 @@ const Login = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const [login] = useLoginMutation()
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const firstField = useRef();
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -205,7 +211,7 @@ const Login = () => {
|
||||
)}
|
||||
</FormControl>
|
||||
|
||||
<FormControl className="mb-4">
|
||||
<FormControl className="mb-2">
|
||||
<FormLabel className="rubix-text-dark ps-1 web-text-medium fw-bold">
|
||||
Password <span className="text-danger">*</span>
|
||||
</FormLabel>
|
||||
@@ -238,6 +244,9 @@ const Login = () => {
|
||||
</span>
|
||||
)}
|
||||
</FormControl>
|
||||
<Box fontSize={"sm"} display={"flex"} justifyContent={"end"} mt={0}>
|
||||
<Text fontWeight={500} cursor={"pointer"} onClick={onOpen}>Forgot Password?</Text>
|
||||
</Box>
|
||||
|
||||
<Button
|
||||
isLoading={isLoading}
|
||||
@@ -247,6 +256,8 @@ const Login = () => {
|
||||
color={"whitesmoke"}
|
||||
colorScheme="green.500"
|
||||
size="lg"
|
||||
fontWeight={500}
|
||||
fontSize={"md"}
|
||||
>
|
||||
Log In
|
||||
</Button>
|
||||
@@ -317,6 +328,11 @@ const Login = () => {
|
||||
src={Asset2}
|
||||
alt="bg-img"
|
||||
/>
|
||||
<ForgetPassword
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
firstField={firstField}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -30,8 +30,37 @@ import {
|
||||
} from "../../../Services/exchange.rate.service";
|
||||
import ToastBox from "../../../Components/ToastBox";
|
||||
import { getTomorrowDate } from "../../../Constants/Constants";
|
||||
import * as yup from "yup";
|
||||
import FullscreenLoaders from "../../../Components/Loaders/FullscreenLoaders";
|
||||
|
||||
// const editExchange = yup.object().shape({
|
||||
// rate: yup
|
||||
// .number()
|
||||
// .required("Rate is required")
|
||||
// .positive("Rate must be greater than 0")
|
||||
// .test(
|
||||
// "is-decimal",
|
||||
// "Rate must have at most 8 decimal places",
|
||||
// (value) =>
|
||||
// value !== undefined && value.toString().match(/^\d+(\.\d{1,8})?$/)
|
||||
// ),
|
||||
// });
|
||||
|
||||
const editExchange = yup.object().shape({
|
||||
rate: yup
|
||||
.string()
|
||||
.required("Rate is required")
|
||||
.matches(
|
||||
/^\d+\.\d{8}$/,
|
||||
"Rate must have exactly 8 decimal places"
|
||||
)
|
||||
.test(
|
||||
"is-positive",
|
||||
"Rate must be greater than 0",
|
||||
(value) => parseFloat(value) > 0
|
||||
),
|
||||
});
|
||||
|
||||
// Convert date to YYYY-MM-DD format
|
||||
const formatDateValue = (date) => {
|
||||
if (!date) return "";
|
||||
@@ -57,8 +86,9 @@ const EditExchangeRate = ({
|
||||
const toast = useToast();
|
||||
const {} = useDisclosure();
|
||||
const [isBtnLoading, setIsBtnLoading] = useState(false);
|
||||
const [rateError, setRateError] = useState("");
|
||||
|
||||
const { data, isLoading, errors } = useGetExchangeRateByIdQuery(id, {
|
||||
const { data, isLoading, errors,refetch, isFetching } = useGetExchangeRateByIdQuery(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
@@ -67,17 +97,45 @@ const EditExchangeRate = ({
|
||||
const [rate, setRate] = useState("");
|
||||
const [alert, setAlert] = useState(false);
|
||||
|
||||
console.log(rate);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (id) {refetch()}
|
||||
if (foundObject) {
|
||||
setRate(foundObject.rate);
|
||||
const numericRate = parseFloat(foundObject.rate) || 0; // Convert to number or default to 0 if invalid
|
||||
setRate(numericRate.toFixed(8)); // Set rate with exactly 8 decimal places
|
||||
}
|
||||
}, [foundObject]);
|
||||
}, [foundObject, isOpen]);
|
||||
|
||||
|
||||
// useEffect(()=>{
|
||||
// if (id) {
|
||||
// refetch()
|
||||
// }
|
||||
// },[isOpen])
|
||||
|
||||
const validateRate = async () => {
|
||||
try {
|
||||
await editExchange.validate({ rate });
|
||||
setRateError(""); // Clear validation error if valid
|
||||
return true;
|
||||
} catch (error) {
|
||||
setRateError(error.message); // Display validation error
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
const isValid = await validateRate();
|
||||
if (!isValid) {
|
||||
return; // Prevent submission if validation fails
|
||||
}
|
||||
|
||||
setIsBtnLoading(true);
|
||||
try {
|
||||
const data = {
|
||||
rate: rate,
|
||||
rate,
|
||||
};
|
||||
const res = await updateExchange({ data, id });
|
||||
if (res?.data?.statusCode === 200) {
|
||||
@@ -88,9 +146,31 @@ const EditExchangeRate = ({
|
||||
setAlert(false);
|
||||
onClose();
|
||||
}
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
setIsBtnLoading(false);
|
||||
// Handle error
|
||||
}
|
||||
};
|
||||
|
||||
const checkValidate = async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
// Wait for the validation to complete
|
||||
const isValid = await validateRate();
|
||||
|
||||
if (!isValid) {
|
||||
return; // Prevent submission if validation fails
|
||||
} else {
|
||||
setAlert(true); // Only trigger modal if validation passes
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (rate) {
|
||||
validateRate();
|
||||
}
|
||||
}, [rate]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Drawer
|
||||
@@ -100,18 +180,13 @@ const EditExchangeRate = ({
|
||||
onClose={onClose}
|
||||
finalFocusRef={btnRef}
|
||||
>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
setAlert(true);
|
||||
}}
|
||||
>
|
||||
<form onSubmit={(e) => checkValidate(e)}>
|
||||
<DrawerOverlay />
|
||||
<DrawerContent>
|
||||
<DrawerCloseButton />
|
||||
<DrawerHeader fontSize={"md"}>Edit rate</DrawerHeader>
|
||||
|
||||
{isLoading ? (
|
||||
{isFetching ? (
|
||||
<FullscreenLoaders />
|
||||
) : (
|
||||
<>
|
||||
@@ -153,16 +228,26 @@ const EditExchangeRate = ({
|
||||
<Text fontSize={"sm"}>{formatDate(getTomorrowDate())}</Text>
|
||||
</FormControl>
|
||||
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormControl mb={4} isRequired isInvalid={!!rateError}>
|
||||
<FormLabel fontSize={"sm"}>Rate</FormLabel>
|
||||
<Input
|
||||
required
|
||||
type="number"
|
||||
placeholder="Type rate here..."
|
||||
size={"sm"}
|
||||
value={rate}
|
||||
onChange={(e) => setRate(e.target.value)}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
// Match numbers with at most 8 decimal places
|
||||
if (/^\d*\.?\d{0,8}$/.test(value)) {
|
||||
setRate(value);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{rateError && (
|
||||
<Text color="red.500" fontSize="sm" mt={1}>
|
||||
{rateError}
|
||||
</Text>
|
||||
)}
|
||||
</FormControl>
|
||||
</DrawerBody>
|
||||
<DrawerFooter>
|
||||
@@ -173,6 +258,15 @@ const EditExchangeRate = ({
|
||||
size={"sm"}
|
||||
mr={3}
|
||||
onClick={onClose}
|
||||
// onClick={() => {
|
||||
// window.location.reload();
|
||||
// onClose();
|
||||
// }}
|
||||
// onClick={() => {
|
||||
// setRate("");
|
||||
// setRateError("");
|
||||
// onClose();
|
||||
// }}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
|
||||
@@ -24,7 +24,7 @@ export const addInvestmentType = yup.object().shape({
|
||||
.string()
|
||||
.required("Investment type is required")
|
||||
.max(50, "Investment name cannot be more than 50 characters"),
|
||||
note: yup.string().optional().max(255, "Note cannot exceed 255 characters"),
|
||||
// note: yup.string().optional().max(255, "Note cannot exceed 255 characters"),
|
||||
investmentTypeNameArabic: yup
|
||||
.string()
|
||||
.required("Investment type in required"),
|
||||
@@ -199,7 +199,7 @@ const AddInvestmentType = () => {
|
||||
placeHolder: " ",
|
||||
name: "note",
|
||||
type: "textarea",
|
||||
// isRequired: true,
|
||||
isRequired: false,
|
||||
section: "",
|
||||
maxLength: 255,
|
||||
helperText: `Maximum length should be 255 characters. You have entered ${
|
||||
@@ -211,7 +211,7 @@ const AddInvestmentType = () => {
|
||||
placeHolder: " ",
|
||||
name: "noteArabic",
|
||||
type: "textarea",
|
||||
// isRequired: true,
|
||||
isRequired: false,
|
||||
arabic: true,
|
||||
section: "",
|
||||
maxLength: 255,
|
||||
@@ -254,7 +254,7 @@ const AddInvestmentType = () => {
|
||||
placeHolder: " ",
|
||||
name: "note",
|
||||
type: "textarea",
|
||||
// isRequired: true,
|
||||
isRequired: false,
|
||||
section: "",
|
||||
maxLength: 255,
|
||||
helperText: `Maximum length should be 255 characters. You have entered ${
|
||||
@@ -266,7 +266,7 @@ const AddInvestmentType = () => {
|
||||
placeHolder: " ",
|
||||
name: "noteArabic",
|
||||
type: "textarea",
|
||||
// isRequired: true,
|
||||
isRequired: false,
|
||||
arabic: true,
|
||||
section: "",
|
||||
maxLength: 255,
|
||||
@@ -316,7 +316,7 @@ const AddInvestmentType = () => {
|
||||
|
||||
<Box display={"flex"} justifyContent={"space-between"} alignItems={"center"} mt={5} px={4} mb={5}>
|
||||
<Text fontSize={"sm"} mb={0} onClick={() => navigate(-1)} cursor={"pointer"}>
|
||||
<ArrowBackIcon fontSize={"xl"} me={2} />Add Details
|
||||
<ArrowBackIcon fontSize={"xl"} me={2} />{params?.id ? "Edit Details" : "Add Details"}
|
||||
</Text>
|
||||
<SwitchButton isSwitchOn={isSwitchOn} setIsSwitchOn={setIsSwitchOn} />
|
||||
</Box>
|
||||
@@ -338,7 +338,7 @@ const AddInvestmentType = () => {
|
||||
isOpen={alert}
|
||||
onClose={() => setAlert(false)}
|
||||
alertHandler={handleConfirm}
|
||||
message={id ? "Are you sure you want to update this document?" : " Are you sure you want to add this document?"}
|
||||
message={id ? "Are you sure you want to update this Investment Type?" : " Are you sure you want to add this Investment Type?"}
|
||||
isLoading={isLoadingBtn}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
@@ -232,16 +232,49 @@ const InvestmentType = () => {
|
||||
|
||||
// ==================== [Delete Function] =======================
|
||||
|
||||
// const handleDelete = async () => {
|
||||
// console.log(actionId);
|
||||
// setIsLoading(true);
|
||||
// try {
|
||||
// const response = await deleteInvestmentType(actionId);
|
||||
// console.log(response);
|
||||
// setIsLoading(false);
|
||||
// setDeleteAlert(false);
|
||||
// } catch (error) {}
|
||||
// };
|
||||
|
||||
const handleDelete = async () => {
|
||||
console.log(actionId);
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const response = await deleteInvestmentType(actionId);
|
||||
console.log(response);
|
||||
console.log(response?.data);
|
||||
|
||||
if (response?.error?.data?.code === 400) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={response?.error?.data?.message} status="error" />
|
||||
),
|
||||
});
|
||||
} else if (
|
||||
response?.data?.statusCode === 201 ||
|
||||
response?.data?.statusCode === 200
|
||||
) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={response?.data?.message} status="success" />
|
||||
),
|
||||
});
|
||||
}
|
||||
setIsLoading(false);
|
||||
setDeleteAlert(false);
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={38}>
|
||||
@@ -315,7 +348,7 @@ const InvestmentType = () => {
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sponers?"}
|
||||
message={"Are you sure you want to delete Investment Type?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
|
||||
@@ -301,7 +301,7 @@ const AddSponser = () => {
|
||||
{/* ===================== [Switch Button] ======================== */}
|
||||
<Box display={"flex"} justifyContent={"space-between"} alignItems={"center"} mt={5} px={4}>
|
||||
<Text fontSize={"sm"} mb={0} onClick={() => navigate(-1)} cursor={"pointer"}>
|
||||
<ArrowBackIcon fontSize={"xl"} me={2} />Add Details
|
||||
<ArrowBackIcon fontSize={"xl"} me={2} />{params?.id ? "Edit Details" : "Add Details"}
|
||||
</Text>
|
||||
<SwitchButton isSwitchOn={isSwitchOn} setIsSwitchOn={setIsSwitchOn} />
|
||||
</Box>
|
||||
|
||||
@@ -187,13 +187,13 @@ const Sponser = () => {
|
||||
console.log(response?.data);
|
||||
if(response?.error?.data?.code === 400){
|
||||
toast({
|
||||
render: () => <ToastBox message={response?.error?.data?.message} status={'warn'} />,
|
||||
render: () => <ToastBox message={response?.error?.data?.message} status={'error'} />,
|
||||
});
|
||||
setIsLoading(false);
|
||||
setDeleteAlert(false);
|
||||
} else if(response?.data?.statusCode === 201 || response?.data?.statusCode === 200){
|
||||
toast({
|
||||
render: () => <ToastBox message={response?.data?.message} status={'error'} />,
|
||||
render: () => <ToastBox message={response?.data?.message} status={'success'} />,
|
||||
});
|
||||
setIsLoading(false);
|
||||
setDeleteAlert(false);
|
||||
@@ -201,7 +201,7 @@ const Sponser = () => {
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
|
||||
console.log(isSponserLoading);
|
||||
|
||||
|
||||
|
||||
@@ -1,26 +1,21 @@
|
||||
import { CheckIcon, CloseIcon, InfoIcon } from "@chakra-ui/icons";
|
||||
import {
|
||||
Avatar,
|
||||
Box,
|
||||
ButtonGroup,
|
||||
Editable,
|
||||
EditableInput,
|
||||
EditablePreview,
|
||||
EditableTextarea,
|
||||
Flex,
|
||||
HStack,
|
||||
Heading,
|
||||
Icon,
|
||||
IconButton,
|
||||
Input,
|
||||
Text,
|
||||
VStack,
|
||||
useEditableControls,
|
||||
useEditableControls
|
||||
} from "@chakra-ui/react";
|
||||
import React from "react";
|
||||
import { OPACITY_ON_LOAD } from "../../Layout/animations";
|
||||
import { CheckIcon, CloseIcon, EditIcon, InfoIcon } from "@chakra-ui/icons";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { FaEarthAmericas } from "react-icons/fa6";
|
||||
import logoMini from "../../assets/propic.png";
|
||||
import { OPACITY_ON_LOAD } from "../../Layout/animations";
|
||||
import { useAuthProfileQuery } from "../../Services/token.serivce";
|
||||
|
||||
const Profile = () => {
|
||||
/* Here's a custom control */
|
||||
@@ -53,19 +48,56 @@ const Profile = () => {
|
||||
)
|
||||
);
|
||||
}
|
||||
const { data } = useAuthProfileQuery();
|
||||
|
||||
|
||||
// Array of fields to render
|
||||
const fields = [
|
||||
{ name: "firstName", label: "First Name", defaultValue: "Faisal" },
|
||||
{ name: "lastName", label: "Last Name", defaultValue: "Aljalahma" },
|
||||
{ name: "email", label: "Email Address", defaultValue: "f.aljalahma@tanamicapital.com" },
|
||||
{ name: "mobile", label: "Mobile Number", defaultValue: "9898767876" },
|
||||
{ name: "role", label: "Role", defaultValue: "Maker" },
|
||||
];
|
||||
|
||||
|
||||
|
||||
const [fields, setFields] = useState([
|
||||
{
|
||||
name: "firstName",
|
||||
label: "First Name",
|
||||
defaultValue: null,
|
||||
},
|
||||
{
|
||||
name: "lastName",
|
||||
label: "Last Name",
|
||||
defaultValue: null,
|
||||
},
|
||||
{
|
||||
name: "email",
|
||||
label: "Email Address",
|
||||
defaultValue: null,
|
||||
},
|
||||
{
|
||||
name: "mobile",
|
||||
label: "Mobile Number",
|
||||
defaultValue: null,
|
||||
},
|
||||
{ name: "role", label: "Role", defaultValue: null },
|
||||
]);
|
||||
useEffect(() => {
|
||||
setFields([
|
||||
{
|
||||
name: "firstName",
|
||||
label: "First Name",
|
||||
defaultValue: data?.data?.firstName || null,
|
||||
},
|
||||
{
|
||||
name: "lastName",
|
||||
label: "Last Name",
|
||||
defaultValue: data?.data?.lastName || null,
|
||||
},
|
||||
{
|
||||
name: "email",
|
||||
label: "Email Address",
|
||||
defaultValue: data?.data?.emailAddress || null,
|
||||
},
|
||||
{
|
||||
name: "mobile",
|
||||
label: "Mobile Number",
|
||||
defaultValue: data?.data?.mobileNumber || null,
|
||||
},
|
||||
{ name: "role", label: "Role", defaultValue: data?.data?.role || null },
|
||||
]);
|
||||
}, [data]);
|
||||
|
||||
return (
|
||||
<VStack
|
||||
@@ -114,7 +146,7 @@ const Profile = () => {
|
||||
color={"gray.700"}
|
||||
fontWeight={500}
|
||||
>
|
||||
Faisal Aljalahma
|
||||
{data?.data?.firstName + " " + data?.data?.lastName}
|
||||
</Text>
|
||||
|
||||
<Text
|
||||
@@ -123,7 +155,7 @@ const Profile = () => {
|
||||
color={"gray.500"}
|
||||
fontWeight={400}
|
||||
>
|
||||
f.aljalahma@tanamicapital.com
|
||||
{data?.data?.emailAddress}
|
||||
</Text>
|
||||
</VStack>
|
||||
</HStack>
|
||||
@@ -150,16 +182,16 @@ const Profile = () => {
|
||||
fontWeight={500}
|
||||
>
|
||||
{" "}
|
||||
<Icon as={FaEarthAmericas} /> Maker
|
||||
<Icon as={FaEarthAmericas} /> {data?.data?.role}
|
||||
</Text>
|
||||
</VStack>
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
{/*
|
||||
<Heading as="h3" size="sm">
|
||||
About you
|
||||
</Heading>
|
||||
|
||||
<Box
|
||||
rounded="md"
|
||||
boxShadow="base"
|
||||
@@ -170,55 +202,56 @@ const Profile = () => {
|
||||
alignItems="flex-start"
|
||||
p={6}
|
||||
gap={0}
|
||||
|
||||
pb={6}
|
||||
>
|
||||
|
||||
{fields?.map((item) => (
|
||||
<VStack alignItems={"flex-start"} w={"100%"} gap={1.5} mb={6} key={item?.label}>
|
||||
<Text
|
||||
as={"span"}
|
||||
fontSize="xs"
|
||||
fontWeight="semibold"
|
||||
color={"gray.500"}
|
||||
>
|
||||
{item?.label}
|
||||
</Text>
|
||||
<Editable
|
||||
position={"relative"}
|
||||
gap={0}
|
||||
defaultValue={item?.defaultValue}
|
||||
w="100%"
|
||||
>
|
||||
<EditablePreview
|
||||
cursor={'pointer'}
|
||||
p={2}
|
||||
rounded={"sm"}
|
||||
w={"100%"}
|
||||
_hover={{
|
||||
bg: "gray.100",
|
||||
}}
|
||||
fontSize="sm"
|
||||
transition={"0.5s"}
|
||||
/>
|
||||
<Input
|
||||
as={EditableInput}
|
||||
ps={2}
|
||||
size={'sm'}
|
||||
fontSize="sm"
|
||||
rounded={"sm"}
|
||||
_focus={{
|
||||
borderColor:"blue.500"
|
||||
}}
|
||||
/>
|
||||
<EditableControls />
|
||||
</Editable>
|
||||
</VStack>
|
||||
))}
|
||||
|
||||
|
||||
|
||||
</Box>
|
||||
{fields?.map((item) => (
|
||||
<VStack
|
||||
alignItems={"flex-start"}
|
||||
w={"100%"}
|
||||
gap={1.5}
|
||||
mb={6}
|
||||
key={item?.label}
|
||||
>
|
||||
<Text
|
||||
as={"span"}
|
||||
fontSize="xs"
|
||||
fontWeight="semibold"
|
||||
color={"gray.500"}
|
||||
>
|
||||
{item?.label}
|
||||
</Text>
|
||||
<Editable
|
||||
position={"relative"}
|
||||
gap={0}
|
||||
defaultValue={item?.defaultValue}
|
||||
w="100%"
|
||||
>
|
||||
<EditablePreview
|
||||
cursor={"pointer"}
|
||||
p={2}
|
||||
rounded={"sm"}
|
||||
w={"100%"}
|
||||
_hover={{
|
||||
bg: "gray.100",
|
||||
}}
|
||||
fontSize="sm"
|
||||
transition={"0.5s"}
|
||||
/>
|
||||
<Input
|
||||
as={EditableInput}
|
||||
ps={2}
|
||||
size={"sm"}
|
||||
fontSize="sm"
|
||||
rounded={"sm"}
|
||||
_focus={{
|
||||
borderColor: "blue.500",
|
||||
}}
|
||||
/>
|
||||
<EditableControls />
|
||||
</Editable>
|
||||
</VStack>
|
||||
))}
|
||||
</Box> */}
|
||||
</VStack>
|
||||
</VStack>
|
||||
);
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
import { Box, Image, Spinner, Text } from '@chakra-ui/react'
|
||||
import React from 'react'
|
||||
import logo from '../assets/logo2.png'
|
||||
import { Box, Image, Spinner, Text } from "@chakra-ui/react";
|
||||
import React from "react";
|
||||
import logo from "../assets/logo2.png";
|
||||
|
||||
const SplashScreen = () => {
|
||||
return (
|
||||
<Box
|
||||
h={'100vh'}
|
||||
display={'flex'}
|
||||
justifyContent={'center'}
|
||||
alignItems={'center'}
|
||||
flexDirection={'column'}
|
||||
gap={10}
|
||||
h={"100vh"}
|
||||
display={"flex"}
|
||||
justifyContent={"center"}
|
||||
alignItems={"center"}
|
||||
flexDirection={"column"}
|
||||
gap={10}
|
||||
>
|
||||
<Image src={logo} />
|
||||
{/* <Spinner color='green.900' size='md' /> */}
|
||||
<div className="dot-spinner">
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
</div>
|
||||
<Image src={logo} />
|
||||
<Spinner color='green.900' size='md' />
|
||||
{/* <div className="dot-spinner">
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
<div className="dot-spinner__dot"></div>
|
||||
</div> */}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default SplashScreen
|
||||
export default SplashScreen;
|
||||
|
||||
373
src/Pages/SubAdmin/SubAdmin.jsx
Normal file
373
src/Pages/SubAdmin/SubAdmin.jsx
Normal file
@@ -0,0 +1,373 @@
|
||||
import { AddIcon, DeleteIcon, EditIcon } from "@chakra-ui/icons";
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Input,
|
||||
Switch,
|
||||
Text,
|
||||
Tooltip,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useState } from "react";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
import CustomAlertDialog from "../../Components/CustomAlertDialog";
|
||||
import NormalTable from "../../Components/DataTable/NormalTable";
|
||||
import ToastBox from "../../Components/ToastBox";
|
||||
import {
|
||||
CHECKER_ID,
|
||||
generateSerialNumber,
|
||||
MAKER_ID,
|
||||
SUPER_ADMIN_ID,
|
||||
} from "../../Constants/Constants";
|
||||
import GlobalStateContext from "../../Contexts/GlobalStateContext";
|
||||
import { OPACITY_ON_LOAD } from "../../Layout/animations";
|
||||
import {
|
||||
useDeleteUserMutation,
|
||||
useGetSubAdminMasterQuery,
|
||||
useToggleStatusMutation,
|
||||
} from "../../Services/subadmin.service";
|
||||
|
||||
export const formatDate = (date) => {
|
||||
const d = new Date(date);
|
||||
const year = d.getFullYear();
|
||||
const month = String(d.getMonth() + 1).padStart(2, "0"); // Months are 0-indexed
|
||||
const day = String(d.getDate()).padStart(2, "0");
|
||||
|
||||
return `${day}/${month}/${year}`;
|
||||
};
|
||||
|
||||
const SubAdmin = () => {
|
||||
const navigate = useNavigate();
|
||||
const toast = useToast();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
const [actionId, setActionId] = useState(false);
|
||||
const [mouseEntered, setMouseEntered] = useState(false);
|
||||
const [mouseEnteredId, setMouseEnteredId] = useState("");
|
||||
// const [deleteSponser] = useDeleteSponserMutation();
|
||||
const { slideFromRight } = useContext(GlobalStateContext);
|
||||
|
||||
// =========================== [Use State] =============================
|
||||
// const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
|
||||
// const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
// const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
|
||||
|
||||
// Debounce the search term to avoid making a request on every keystroke
|
||||
// useEffect(() => {
|
||||
// const handler = setTimeout(() => {
|
||||
// setDebouncedSearchTerm(searchTerm);
|
||||
// }, 500); // Adjust delay as needed
|
||||
// return () => {
|
||||
// clearTimeout(handler);
|
||||
// };
|
||||
// }, [searchTerm]);
|
||||
|
||||
const { data: subAdmin, isLoading: isSponserLoading } =
|
||||
useGetSubAdminMasterQuery();
|
||||
|
||||
const [deleteUser] = useDeleteUserMutation();
|
||||
|
||||
const [toggleStatus] = useToggleStatusMutation();
|
||||
|
||||
// useEffect(() => {
|
||||
// if (subAdmin?.data) {
|
||||
// setIsSwitchOn(subAdmin?.role?.role);
|
||||
// console.log(subAdmin);
|
||||
// }
|
||||
// }, [subAdmin]);
|
||||
|
||||
// ==============================[Table Filter]========================
|
||||
|
||||
const filteredData = subAdmin?.data?.filter((item) => {
|
||||
const name = item.firstName;
|
||||
const searchLower = searchTerm?.toLowerCase();
|
||||
const nameMatches = name?.toLowerCase().includes(searchLower);
|
||||
return nameMatches;
|
||||
});
|
||||
|
||||
const handleToggleStatus = async (isMaker, id) => {
|
||||
// console.log("hit");
|
||||
const data = {
|
||||
role_xid: isMaker ? CHECKER_ID : MAKER_ID,
|
||||
};
|
||||
console.log("=======================", data);
|
||||
try {
|
||||
const res = await toggleStatus({ id, data });
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
} else if (res) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox
|
||||
status={"success"}
|
||||
message={res?.message || "Status updated successfully!"}
|
||||
/>
|
||||
),
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox
|
||||
status={"error"}
|
||||
message={error?.data?.message || "Something went wrong"}
|
||||
/>
|
||||
),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// ====================================================[Table Setup]================================================================
|
||||
|
||||
const tableHeadRow = [
|
||||
"Sr No",
|
||||
"First Name",
|
||||
"Last Name",
|
||||
"Email Address",
|
||||
"Role",
|
||||
"Action",
|
||||
];
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
"Sr No": (
|
||||
<Text
|
||||
w={"24px"}
|
||||
justifyContent={slideFromRight ? "right" : "left"}
|
||||
as={"span"}
|
||||
color={"gray.600"}
|
||||
className="d-flex align-items-center fw-bold web-text-small"
|
||||
>
|
||||
{/* {item.id} */}
|
||||
{generateSerialNumber(index)}
|
||||
</Text>
|
||||
),
|
||||
"First Name": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "left"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item?.firstName}
|
||||
</Text>
|
||||
),
|
||||
"Last Name": (
|
||||
<Text
|
||||
justifyContent={slideFromRight ? "right" : "left"}
|
||||
as={"span"}
|
||||
color={"teal.900"}
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item?.lastName}
|
||||
</Text>
|
||||
),
|
||||
"Email Address": (
|
||||
<Box isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.emailAddress}
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
Role: (
|
||||
<Box isTruncated={true}>
|
||||
<Badge
|
||||
py={"2px"}
|
||||
me={2}
|
||||
fontWeight={600}
|
||||
bg={item?.role[0]?.role === "Maker" ? "#00ffcc" : "#b3ff99"}
|
||||
px={item?.role[0]?.role === "Maker" ? "12px" : "5px"}
|
||||
>
|
||||
{item?.role[0]?.role}
|
||||
</Badge>
|
||||
{/* <Switch
|
||||
onChange={() =>
|
||||
handleToggleStatus(item?.role[0]?.role === "Maker", item?.id)
|
||||
}
|
||||
isChecked={item?.role[0]?.role === "Maker"}
|
||||
// colorScheme={item?.role[0]?.role === "Maker" ? "green" : "teal"}
|
||||
sx={{
|
||||
".chakra-switch__track": {
|
||||
bg: item?.role[0]?.role === "Maker" ? "#00ffcc" : "#b3ff99", // "Off" state color
|
||||
},
|
||||
}}
|
||||
/> */}
|
||||
{/* <RoleSwitchButton
|
||||
setIsSwitchOn={setIsSwitchOn}
|
||||
isSwitchOn={item?.role[0]?.role === "Maker"}
|
||||
onClick={() => handleToggleStatus(item?.role[0]?.role=== "Maker")}
|
||||
/> */}
|
||||
</Box>
|
||||
),
|
||||
Action: (
|
||||
<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
<Tooltip
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
label="Edit"
|
||||
bg="#fff"
|
||||
color={"blue.500"}
|
||||
placement="top"
|
||||
>
|
||||
<Button
|
||||
onClick={() => navigate(`/subadmin/subadmin-update/${item.id}`)}
|
||||
// _hover={{ color: "blue.500" }}
|
||||
// color="blue.400"
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
colorScheme="blue"
|
||||
>
|
||||
<EditIcon />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
label="Delete"
|
||||
bg="#fff"
|
||||
color={"red.500"}
|
||||
placement="top"
|
||||
>
|
||||
<Button
|
||||
isDisabled={item?.id === SUPER_ADMIN_ID}
|
||||
onClick={() => {
|
||||
setActionId(item?.id);
|
||||
setDeleteAlert(true);
|
||||
}}
|
||||
// _hover={{ color: "red.500" }}
|
||||
// color="red"
|
||||
// disabled={true}
|
||||
rounded={"sm"}
|
||||
size={"xs"}
|
||||
colorScheme="red"
|
||||
variant={"solid"}
|
||||
>
|
||||
<DeleteIcon />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
),
|
||||
}));
|
||||
|
||||
// =========================== [ Delete Function ] =================================
|
||||
|
||||
const handleDelete = async () => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const response = await deleteUser(actionId);
|
||||
if (response?.error?.data?.code === 400) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox
|
||||
message={response?.error?.data?.message}
|
||||
status={"error"}
|
||||
/>
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
setDeleteAlert(false);
|
||||
} else if (
|
||||
response?.data?.statusCode === 201 ||
|
||||
response?.data?.statusCode === 200
|
||||
) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={response?.data?.message} status={"success"} />
|
||||
),
|
||||
});
|
||||
setIsLoading(false);
|
||||
setDeleteAlert(false);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={38}>
|
||||
<Box bg="white.500">
|
||||
<HStack
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
ps={1}
|
||||
pe={1}
|
||||
pb={4}
|
||||
pt={4}
|
||||
spacing="24px"
|
||||
>
|
||||
{/* =======================[Search Input]======================== */}
|
||||
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
placeholder="Search..."
|
||||
size="sm"
|
||||
rounded="sm"
|
||||
focusBorderColor="green.500"
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
|
||||
<HStack display={"flex"} alignItems={"center"}>
|
||||
{/* ====================[Pagination]===================== */}
|
||||
|
||||
{/* <Pagination
|
||||
isLoading={isSponserLoading}
|
||||
pageSize={pageSize}
|
||||
setPageSize={setPageSize}
|
||||
currentPage={currentPage}
|
||||
setCurrentPage={setCurrentPage}
|
||||
totalItems={subAdmin?.data?.totalItems}
|
||||
/> */}
|
||||
|
||||
{/* =====================[Add Button]===================== */}
|
||||
|
||||
<Link to={"/subadmin/subadmin-update"}>
|
||||
<Button
|
||||
leftIcon={<AddIcon />}
|
||||
colorScheme={"forestGreen"}
|
||||
rounded={"sm"}
|
||||
fontSize={"xs"}
|
||||
size={"sm"}
|
||||
>
|
||||
Add
|
||||
</Button>
|
||||
</Link>
|
||||
</HStack>
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
{/* =================== [Data Table] ===================== */}
|
||||
|
||||
<NormalTable
|
||||
emptyMessage={`We don't have any Sponers `}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
isLoading={isSponserLoading}
|
||||
viewActionId={actionId}
|
||||
setViewActionId={setActionId}
|
||||
setMouseEnteredId={setMouseEnteredId}
|
||||
setMouseEntered={setMouseEntered}
|
||||
/>
|
||||
|
||||
{/* ======================== [Modal] ======================== */}
|
||||
|
||||
<CustomAlertDialog
|
||||
onClose={() => setDeleteAlert(false)}
|
||||
isOpen={deleteAlert}
|
||||
message={"Are you sure you want to delete sub-admin?"}
|
||||
alertHandler={handleDelete}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default SubAdmin;
|
||||
354
src/Pages/SubAdmin/SubAdminUpdateCreate.jsx
Normal file
354
src/Pages/SubAdmin/SubAdminUpdateCreate.jsx
Normal file
@@ -0,0 +1,354 @@
|
||||
import { ArrowBackIcon } from "@chakra-ui/icons";
|
||||
import { Box, Text, useToast } from "@chakra-ui/react";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import * as yup from "yup";
|
||||
import CustomAlertDialog from "../../Components/CustomAlertDialog";
|
||||
import FormInputMain from "../../Components/FormInputMain";
|
||||
import FullscreenLoaders from "../../Components/Loaders/FullscreenLoaders";
|
||||
import RoleSwitchButton from "../../Components/RoleSwitchButton";
|
||||
import ToastBox from "../../Components/ToastBox";
|
||||
import {
|
||||
isMaker
|
||||
} from "../../Constants/Constants";
|
||||
import { OPACITY_ON_LOAD } from "../../Layout/animations";
|
||||
import {
|
||||
useCreateSubAdminMutation,
|
||||
useGetSubAdminByIdQuery,
|
||||
useUpdateSubAdminMutation,
|
||||
} from "../../Services/subadmin.service";
|
||||
// ======================= [validation] =========================
|
||||
const addSubAdminSchema = yup.object().shape({
|
||||
firstName: yup
|
||||
.string()
|
||||
.required("First Name is required")
|
||||
.min(3, "First Name must be at least 3 characters long")
|
||||
.max(35, "First Name cannot exceed 35 characters")
|
||||
.matches(/^[^\d]+$/, "First Name cannot contain numbers"),
|
||||
|
||||
lastName: yup.string().required("Last Name is required")
|
||||
.min(3, "Last Name must be at least 3 characters long")
|
||||
.max(35, "Last Name cannot exceed 35 characters")
|
||||
.matches(/^[^\d]+$/, "Last Name cannot contain numbers"),
|
||||
emailAddress:yup.
|
||||
string()
|
||||
.required("Email address is required")
|
||||
.min(6, "Email address must be at least 6 characters long")
|
||||
.max(255, "Email address can be at most 255 characters long"),
|
||||
});
|
||||
|
||||
// ==================== [debounce] ========================
|
||||
|
||||
export function debounce(func, delay) {
|
||||
let debounceTimer;
|
||||
return function (...args) {
|
||||
clearTimeout(debounceTimer);
|
||||
debounceTimer = setTimeout(() => func.apply(this, args), delay);
|
||||
};
|
||||
}
|
||||
|
||||
const SubAdminUpdateCreate = () => {
|
||||
const toast = useToast();
|
||||
const params = useParams();
|
||||
const navigate = useNavigate();
|
||||
const id = params?.id;
|
||||
|
||||
// =====================[useState]=======================
|
||||
|
||||
const [isLoadingBtn, setIsLoadingBtn] = useState(false);
|
||||
const [alert, setAlert] = useState(false);
|
||||
const [form, setForm] = useState();
|
||||
const [isSwitchOn, setIsSwitchOn] = useState(false);
|
||||
|
||||
const [createSubAdmin] = useCreateSubAdminMutation();
|
||||
const [updateSubAdmin] = useUpdateSubAdminMutation();
|
||||
|
||||
// Fetch sponsor data only if id exists
|
||||
const { data: subAdminByIdData, isLoading } = useGetSubAdminByIdQuery(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
// ======================== [validators] ===========================
|
||||
|
||||
const {
|
||||
control,
|
||||
watch,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
reset,
|
||||
} = useForm({
|
||||
resolver: yupResolver(addSubAdminSchema),
|
||||
mode: "all",
|
||||
});
|
||||
|
||||
// ========================== [useEffect] ================================
|
||||
|
||||
useEffect(() => {
|
||||
if (subAdminByIdData?.data) {
|
||||
reset({
|
||||
firstName: subAdminByIdData?.data?.firstName,
|
||||
lastName: subAdminByIdData?.data?.lastName,
|
||||
emailAddress: subAdminByIdData?.data?.emailAddress,
|
||||
});
|
||||
setIsSwitchOn(isMaker(subAdminByIdData?.data?.role[0]?.role));
|
||||
}
|
||||
}, [subAdminByIdData, reset]);
|
||||
|
||||
if (isLoading) {
|
||||
return <FullscreenLoaders />;
|
||||
}
|
||||
|
||||
// ============================ [API]===============================
|
||||
|
||||
const handleConfirm = async () => {
|
||||
setIsLoadingBtn(true);
|
||||
const id = params?.id;
|
||||
console.log(isSwitchOn);
|
||||
|
||||
if (id) {
|
||||
try {
|
||||
const formData = {
|
||||
...form,
|
||||
role_xid: !isSwitchOn ? 2 : 1,
|
||||
};
|
||||
await updateSubAdmin({ data: formData, id }).then((response) => {
|
||||
if (response?.data?.statusCode) {
|
||||
toast({
|
||||
render: () => <ToastBox message={response?.data?.message} />,
|
||||
});
|
||||
|
||||
setIsLoadingBtn(false);
|
||||
setAlert(false);
|
||||
navigate("/subadmin");
|
||||
} else if (response?.error?.status === 400) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox
|
||||
message={response?.error?.data?.message}
|
||||
status={"error"}
|
||||
/>
|
||||
),
|
||||
});
|
||||
|
||||
setIsLoadingBtn(false);
|
||||
setAlert(false);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
setIsLoadingBtn(false);
|
||||
navigate("/subadmin");
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const formData = {
|
||||
...form,
|
||||
role_xid: isSwitchOn ? 1 : 2,
|
||||
};
|
||||
await createSubAdmin(formData).then((response) => {
|
||||
console.log(response);
|
||||
if (response?.data?.statusCode === 201) {
|
||||
toast({
|
||||
render: () => <ToastBox message={response?.data?.message} />,
|
||||
});
|
||||
|
||||
setIsLoadingBtn(false);
|
||||
navigate("/subadmin");
|
||||
} else if (response?.error?.status === 400) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox
|
||||
message={response?.error?.data?.message}
|
||||
status={"error"}
|
||||
/>
|
||||
),
|
||||
});
|
||||
|
||||
setIsLoadingBtn(false);
|
||||
setAlert(false);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
setIsLoadingBtn(false);
|
||||
navigate("/subadmin");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ====================== [Update Form Object] =========================
|
||||
|
||||
const formFields = [
|
||||
{
|
||||
label: "First Name",
|
||||
placeHolder: " ",
|
||||
name: "firstName",
|
||||
type: "text",
|
||||
isRequired: true,
|
||||
section: "",
|
||||
maxLength: 35,
|
||||
helperText: `Maximum length should be 35 characters. You have entered ${
|
||||
watch()?.firstName?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
{
|
||||
label: "Last Name",
|
||||
name: "lastName",
|
||||
placeHolder: " ",
|
||||
type: "text",
|
||||
isRequired: true,
|
||||
section: "",
|
||||
maxLength: 35,
|
||||
helperText: `Maximum length should be 35 characters. You have entered ${
|
||||
watch()?.lastName?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
{
|
||||
label: "Email address",
|
||||
name: "emailAddress",
|
||||
placeHolder: " ",
|
||||
type: "email",
|
||||
isRequired: true,
|
||||
section: "",
|
||||
},
|
||||
];
|
||||
|
||||
// ==================== [Create Form Object] =======================
|
||||
|
||||
const formEditFields = [
|
||||
{
|
||||
label: "First Name",
|
||||
placeHolder: " ",
|
||||
name: "firstName",
|
||||
type: "text",
|
||||
isRequired: true,
|
||||
section: "",
|
||||
maxLength: 35,
|
||||
helperText: `Maximum length should be 35 characters. You have entered ${
|
||||
watch()?.firstName?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
{
|
||||
label: "Last Name",
|
||||
name: "lastName",
|
||||
placeHolder: " ",
|
||||
type: "text",
|
||||
isRequired: true,
|
||||
section: "",
|
||||
maxLength: 35,
|
||||
helperText: `Maximum length should be 35 characters. You have entered ${
|
||||
watch()?.lastName?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
{
|
||||
label: "Email Address",
|
||||
name: "emailAddress",
|
||||
placeHolder: " ",
|
||||
type: "email",
|
||||
isRequired: true,
|
||||
section: "",
|
||||
},
|
||||
];
|
||||
|
||||
// ====================== [Group Create Fields] =========================
|
||||
|
||||
const groupedEditFields = formEditFields.reduce((groups, field) => {
|
||||
const { section } = field;
|
||||
if (!groups[section]) {
|
||||
groups[section] = [];
|
||||
}
|
||||
groups[section].push(field);
|
||||
return groups;
|
||||
}, {});
|
||||
|
||||
// ====================== [Group Update Fields] =======================
|
||||
|
||||
const groupedFields = formFields.reduce((groups, field) => {
|
||||
const { section } = field;
|
||||
if (!groups[section]) {
|
||||
groups[section] = [];
|
||||
}
|
||||
groups[section].push(field);
|
||||
return groups;
|
||||
}, {});
|
||||
|
||||
// ==================== [On Submit] ========================
|
||||
// console.log(errors);
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
console.log("Hit");
|
||||
|
||||
if (Object.keys(errors).length === 0) {
|
||||
setForm(data);
|
||||
setAlert(true);
|
||||
}
|
||||
};
|
||||
|
||||
return isLoading ? (
|
||||
<FullscreenLoaders />
|
||||
) : (
|
||||
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={14}>
|
||||
{/* ===================== [Switch Button] ======================== */}
|
||||
<Box
|
||||
display={"flex"}
|
||||
justifyContent={"space-between"}
|
||||
alignItems={"center"}
|
||||
mt={5}
|
||||
px={4}
|
||||
>
|
||||
<Text
|
||||
fontSize={"sm"}
|
||||
mb={0}
|
||||
onClick={() => navigate(-1)}
|
||||
cursor={"pointer"}
|
||||
>
|
||||
<ArrowBackIcon fontSize={"xl"} me={2} />
|
||||
{params?.id ? "Edit Details" : "Add Details"}
|
||||
</Text>
|
||||
{/* {params?.id ? (
|
||||
""
|
||||
) : (
|
||||
<RoleSwitchButton
|
||||
isSwitchOn={isSwitchOn}
|
||||
setIsSwitchOn={setIsSwitchOn}
|
||||
/>
|
||||
)} */}
|
||||
<RoleSwitchButton
|
||||
isSwitchOn={isSwitchOn}
|
||||
setIsSwitchOn={setIsSwitchOn}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
{/* ====================== [Form Input] ====================== */}
|
||||
|
||||
<FormInputMain
|
||||
groupedFields={params?.id ? groupedEditFields : groupedFields}
|
||||
control={control}
|
||||
errors={errors}
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
submitTitle={params?.id ? "Update" : "Submit"}
|
||||
></FormInputMain>
|
||||
|
||||
{/* ======================= [Modal] =========================== */}
|
||||
|
||||
<CustomAlertDialog
|
||||
isOpen={alert}
|
||||
onClose={() => setAlert(false)}
|
||||
alertHandler={handleConfirm}
|
||||
message={
|
||||
id
|
||||
? "Are you sure you want to update this?"
|
||||
: "Are you sure you want to add this?"
|
||||
}
|
||||
isLoading={isLoadingBtn}
|
||||
/>
|
||||
|
||||
{/* <DummyComponent /> */}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default SubAdminUpdateCreate;
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Heading,
|
||||
HStack,
|
||||
@@ -36,7 +37,8 @@ const FILE_TYPES = ["image/jpeg", "image/png", "image/gif"];
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
investorAmount: yup.string().required("Investor amount is required"),
|
||||
comment: yup.string().notRequired(),
|
||||
comment: yup.string().notRequired()
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const DrawalRequestApprove = ({
|
||||
@@ -59,6 +61,7 @@ const DrawalRequestApprove = ({
|
||||
const {
|
||||
control,
|
||||
register,
|
||||
watch,
|
||||
reset,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
@@ -259,12 +262,17 @@ const DrawalRequestApprove = ({
|
||||
size="sm"
|
||||
placeholder={"Enter your comments...."}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comment && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comment.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Text as={"span"} me={1}>Maximum length should be 200 characters. You have entered</Text>
|
||||
{watch("checkerComment")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
FormLabel,
|
||||
Input,
|
||||
Modal,
|
||||
@@ -24,7 +25,8 @@ import {
|
||||
import { useDepositRejectMutation } from "../../../Services/drawal.request.service";
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
comments: yup.string().required("Comment is required"),
|
||||
comments: yup.string().required("Comment is required")
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
|
||||
const DrawalRequestReject = ({ isOpen, onClose, firstField ,id}) => {
|
||||
@@ -34,6 +36,7 @@ import { useDepositRejectMutation } from "../../../Services/drawal.request.servi
|
||||
|
||||
const {
|
||||
register,
|
||||
watch,
|
||||
reset,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
@@ -101,16 +104,21 @@ import { useDepositRejectMutation } from "../../../Services/drawal.request.servi
|
||||
placeholder={"Enter your comments...."}
|
||||
rounded={"md"}
|
||||
resize={"none"}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.comments && (
|
||||
<Text fontSize="xs" color="red">
|
||||
{errors.comments.message}
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Text as={"span"} me={1}>Maximum length should be 200 characters. You have entered</Text>
|
||||
{watch("comments")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
<Button
|
||||
colorScheme="gray"
|
||||
mr={3}
|
||||
onClick={onClose}
|
||||
|
||||
@@ -104,25 +104,23 @@ export const nav = [
|
||||
title: "INVESTORS REQUEST",
|
||||
type: "title",
|
||||
},
|
||||
{
|
||||
title: "Fawateer Deposit",
|
||||
submenu: [
|
||||
{
|
||||
title: "Aprover Request",
|
||||
path: "/fawateer",
|
||||
icon: RiMoneyDollarBoxLine,
|
||||
},
|
||||
{
|
||||
title: "View History",
|
||||
path: "/fawateer-history",
|
||||
icon: RiExchangeBoxLine,
|
||||
},
|
||||
],
|
||||
type: "accordion",
|
||||
Icon: HiOutlineBanknotes,
|
||||
}
|
||||
,
|
||||
|
||||
{
|
||||
title: "Fawateer Deposit",
|
||||
submenu: [
|
||||
{
|
||||
title: "Aprover Request",
|
||||
path: "/fawateer",
|
||||
icon: RiMoneyDollarBoxLine,
|
||||
},
|
||||
{
|
||||
title: "View History",
|
||||
path: "/fawateer-history",
|
||||
icon: RiExchangeBoxLine,
|
||||
},
|
||||
],
|
||||
type: "accordion",
|
||||
Icon: HiOutlineBanknotes,
|
||||
},
|
||||
{
|
||||
title: "Bank Deposit",
|
||||
submenu: [
|
||||
@@ -233,6 +231,11 @@ export const nav = [
|
||||
path: "/bank-details",
|
||||
icon: RiBankLine,
|
||||
},
|
||||
{
|
||||
title: "Sub Admin",
|
||||
path: "/subadmin",
|
||||
icon: RiFileUserLine,
|
||||
},
|
||||
],
|
||||
type: "accordion",
|
||||
Icon: MdOutlineAdminPanelSettings,
|
||||
|
||||
@@ -46,6 +46,8 @@ import EmailNotification from "../Pages/EmailNotification/EmailNotification";
|
||||
import User from "../Pages/User/User";
|
||||
import AddUser from "../Pages/User/AddUser";
|
||||
import Profile from "../Pages/Profile/Profile";
|
||||
import SubAdmin from "../Pages/SubAdmin/SubAdmin";
|
||||
import SubAdminUpdateCreate from "../Pages/SubAdmin/SubAdminUpdateCreate";
|
||||
|
||||
export const RouteLink = [
|
||||
// =============[ Tanami ]================
|
||||
@@ -123,6 +125,9 @@ export const RouteLink = [
|
||||
// { path: "/bank-details", Component: UnderConstruction },
|
||||
{ path: "/bank-details/edit-bank-details/:id", Component: EditBankDetails },
|
||||
{ path: "/profile", Component: Profile },
|
||||
{ path: "/subadmin", Component: SubAdmin },
|
||||
{ path: "/subadmin/subadmin-update/:id", Component: SubAdminUpdateCreate },
|
||||
{ path: "/subadmin/subadmin-update", Component: SubAdminUpdateCreate },
|
||||
|
||||
|
||||
|
||||
@@ -134,8 +139,5 @@ export const RouteLink = [
|
||||
// { path: "/fawateer-approver", Component: ApproveRequest },
|
||||
// { path: "/approver-history", Component: ApproveHistory },
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
];
|
||||
|
||||
@@ -20,9 +20,9 @@ export const banInvestorDetails = createApi({
|
||||
|
||||
|
||||
getUnbanInvestor: builder.query({
|
||||
query: ({ page, size, searchTerm, userStatus, KYCStatus, country_xid }) => {
|
||||
query: ({ page, size, search, userStatus, KYCStatus, country_xid }) => {
|
||||
// Start with the base URL, including searchTerm
|
||||
let baseURL = `/investorDetails/admin/getAllUnbanned?search=${searchTerm || ""}&userStatus=${userStatus ||""}&KYCStatus=${KYCStatus || ""}&country_xid=${country_xid||""}`;
|
||||
let baseURL = `/investorDetails/admin/getAllUnbanned?search=${search || ""}&userStatus=${userStatus ||""}&KYCStatus=${KYCStatus || ""}&country_xid=${country_xid||""}`;
|
||||
|
||||
// Conditionally append kycStatus if it's defined
|
||||
if (KYCStatus) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user