Compare commits
7 Commits
6c2a38becb
...
bug-fix/9.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69f76bbdce | ||
|
|
25df0d6160 | ||
|
|
51727d4de1 | ||
|
|
1539493641 | ||
|
|
d63ac2eb2b | ||
|
|
9eca3ae9fc | ||
|
|
b620cd410d |
@@ -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();
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 IMAGE_URI = import.meta.env.VITE_API_IMAGE_URL
|
||||
export const INVESTOR_TABLE_PAGINATION = { page: 1, size: 500 }
|
||||
@@ -217,7 +217,7 @@ const IOArtifactsAdd = ({ isOpen, onClose, firstField, actionId, setActionId, da
|
||||
isOpen={alert}
|
||||
onClose={() => setAlert(false)}
|
||||
alertHandler={handleSave}
|
||||
message={"Are you sure you want to update this artifact?"}
|
||||
message={"Are you sure you want to add this artifact?"}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -107,7 +107,8 @@ const IOCashDetails = () => {
|
||||
</Tab>
|
||||
</TabList>
|
||||
{IODetails?.isInvestedAmount
|
||||
? isMaker() && (
|
||||
? isMaker() &&
|
||||
IODetails?.ioSatatus !== "Exited" && (
|
||||
<Button
|
||||
onClick={handleAdd}
|
||||
leftIcon={<AddIcon />}
|
||||
|
||||
@@ -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,73 +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);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
@@ -253,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,
|
||||
});
|
||||
@@ -277,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 ]
|
||||
@@ -293,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)",
|
||||
@@ -305,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",
|
||||
@@ -316,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)",
|
||||
@@ -328,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",
|
||||
@@ -341,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)",
|
||||
@@ -354,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",
|
||||
@@ -371,7 +377,7 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
|
||||
{
|
||||
label: "Expected Return (Arabic)",
|
||||
name: "expectedReturnArabic",
|
||||
name: "expectedReturnArabic",
|
||||
type: "text",
|
||||
isRequired: true,
|
||||
arabic: true,
|
||||
@@ -381,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",
|
||||
@@ -428,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%",
|
||||
},
|
||||
@@ -452,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.`,
|
||||
},
|
||||
|
||||
{
|
||||
@@ -462,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,
|
||||
},
|
||||
|
||||
@@ -478,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) => {
|
||||
@@ -492,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) {
|
||||
@@ -525,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) {
|
||||
@@ -548,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) {
|
||||
@@ -565,7 +581,6 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ==========================
|
||||
// if (params?.id) {
|
||||
// return enableNextTab(index);
|
||||
@@ -583,9 +598,8 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
};
|
||||
|
||||
return IObyIDisLoading ? (
|
||||
<FullscreenLoaders height={'70vh'} />
|
||||
<FullscreenLoaders height={"70vh"} />
|
||||
) : (
|
||||
|
||||
<FormInputMain
|
||||
p={0.1}
|
||||
w={250}
|
||||
|
||||
@@ -153,7 +153,8 @@ const IONAVDetails = () => {
|
||||
</Tab>
|
||||
</TabList>
|
||||
{IODetails?.isInvestedAmount
|
||||
? isMaker() && (
|
||||
? isMaker() &&
|
||||
IODetails?.ioSatatus !== "Exited" && (
|
||||
<Button
|
||||
onClick={handleAdd}
|
||||
leftIcon={<AddIcon />}
|
||||
|
||||
@@ -137,6 +137,11 @@ const Pending = () => {
|
||||
})}
|
||||
</Text>
|
||||
),
|
||||
// Amount:(
|
||||
// <div>
|
||||
// <ViewDistributionInvestor amount={item?.transactionAmount} />
|
||||
// </div>
|
||||
// ),
|
||||
"Created By": (
|
||||
<Text
|
||||
textTransform={"capitalize"}
|
||||
@@ -200,6 +205,8 @@ const Pending = () => {
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedSponsors = sponser.filter(
|
||||
(sponsor) => sponsor.id !== actionId
|
||||
|
||||
@@ -172,7 +172,7 @@ const ViewDistributionInvestor = ({ isOpen, onClose, id: exitId, amount }) => {
|
||||
"Distriution Amt($)": (
|
||||
<Box minW={24} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
||||
{item?.distribution_amt?.toLocaleString(undefined, {
|
||||
{IODetails?.ioTransactionRecords?.Pending[index]?.transactionAmount?.toLocaleString(undefined, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
|
||||
@@ -360,7 +360,7 @@ const IOArtifactsAdd = ({
|
||||
isOpen={alert}
|
||||
onClose={handleAlertClose}
|
||||
alertHandler={handleSave}
|
||||
message={"Are you sure you want to update this artifact?"}
|
||||
message={"Are you sure you want to add this artifact?"}
|
||||
isLoading={loading}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -112,8 +112,18 @@ 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}>
|
||||
<Modal isOpen={isOpen} onClose={handleModalClose}>
|
||||
<ModalOverlay />
|
||||
<ModalContent>
|
||||
<ModalHeader fontSize={"md"}>Amount Invested</ModalHeader>
|
||||
@@ -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>
|
||||
|
||||
@@ -495,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>
|
||||
</>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ViewIcon } from "@chakra-ui/icons";
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
@@ -11,23 +11,21 @@ import {
|
||||
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
|
||||
|
||||
@@ -49,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("");
|
||||
|
||||
@@ -73,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
|
||||
@@ -104,43 +102,41 @@ const InvestorDetails = () => {
|
||||
"Client ID",
|
||||
"First Name",
|
||||
"Last Name",
|
||||
"Country",
|
||||
"Country",
|
||||
"Phone Number",
|
||||
"E-mail ID",
|
||||
"Type",
|
||||
"Type",
|
||||
"KYC 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
|
||||
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"
|
||||
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": (
|
||||
@@ -148,7 +144,7 @@ const InvestorDetails = () => {
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{item.clientReference_id}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
),
|
||||
"First Name": (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
@@ -185,39 +181,44 @@ const InvestorDetails = () => {
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
"Type": (
|
||||
Type: (
|
||||
<Box w={"auto"} isTruncated={true}>
|
||||
<Text as={"span"} >
|
||||
<Badge color={"forestGreen.500"} variant={'ghost'} fontWeight={"700"} px={2} py={0.5}>
|
||||
<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>
|
||||
<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>
|
||||
),
|
||||
"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"}
|
||||
@@ -235,7 +236,7 @@ const InvestorDetails = () => {
|
||||
placement="top"
|
||||
>
|
||||
<Button
|
||||
isDisabled={item.ioStatus}
|
||||
isDisabled={item.ioStatus}
|
||||
onClick={() => {
|
||||
navigate(`/investor-details/profile-view/${item.id}`);
|
||||
}}
|
||||
@@ -266,7 +267,6 @@ const InvestorDetails = () => {
|
||||
setIsLoading(true);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={38}>
|
||||
<Box bg="white.500">
|
||||
@@ -346,35 +346,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}
|
||||
|
||||
Reference in New Issue
Block a user