Merge branch 'dev' of http://git.wdipl.com/Siddhesh.More/tanami-admin-panel into feature-dev
This commit is contained in:
2071
package-lock.json
generated
2071
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -151,7 +151,7 @@ const CreateIO = () => {
|
||||
}, []);
|
||||
|
||||
const tableHeadRow = [
|
||||
"Sponsorer name",
|
||||
"Sponsor name",
|
||||
"Address",
|
||||
"Mobile no",
|
||||
"Created At",
|
||||
@@ -191,7 +191,7 @@ const CreateIO = () => {
|
||||
|
||||
const extractedArray = filteredData?.map((item) => ({
|
||||
id: item?.id,
|
||||
"Sponsorer name": (
|
||||
"Sponsor name": (
|
||||
<Text
|
||||
justifyContent={"left"}
|
||||
as={"span"}
|
||||
@@ -413,7 +413,7 @@ const CreateIO = () => {
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Sponsorer Name (English)",
|
||||
label: "Sponsor Name (English)",
|
||||
placeHolder: " ",
|
||||
name: "sponserName",
|
||||
type: "text",
|
||||
|
||||
@@ -9,12 +9,11 @@ import { Input } from "@chakra-ui/react";
|
||||
// };
|
||||
|
||||
export const formatCurrency = (value) => {
|
||||
if (!value) return '';
|
||||
const [integer, decimal] = value?.split('.');
|
||||
const formattedInteger = integer?.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
if (value === undefined || value === null) return ''; // Handle undefined or null values
|
||||
const [integer, decimal] = String(value).split('.'); // Convert value to string before splitting
|
||||
const formattedInteger = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
return decimal ? `${formattedInteger}.${decimal}` : formattedInteger;
|
||||
};
|
||||
|
||||
const CurrencyInput = forwardRef(({ value, onChange, ...props }, ref) => {
|
||||
|
||||
|
||||
|
||||
@@ -404,7 +404,7 @@ const FormField = ({
|
||||
w={6}
|
||||
h={6}
|
||||
src={
|
||||
" https://tanami.betadelivery.com/" +
|
||||
import.meta.env.VITE_IMAGE_URL +
|
||||
item?.logo
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -26,7 +26,7 @@ const ImageViewer = ({ src, isOpen, onClose }) => {
|
||||
rounded={6}
|
||||
w={"100%"}
|
||||
h={"100%"}
|
||||
src={"https://tanami.betadelivery.com/" + src}
|
||||
src={import.meta.env.VITE_IMAGE_URL + src}
|
||||
/>
|
||||
</ModalBody>
|
||||
</ModalContent>
|
||||
|
||||
@@ -36,7 +36,6 @@ import { useGetDepositRequestQuery } from "../../../Services/deposit.request.ser
|
||||
import { current } from "@reduxjs/toolkit";
|
||||
import { TABLE_PAGINATION } from "../../../Constants/Paginations";
|
||||
import { removeTrailingZeros } from "../../../Constants/Constants";
|
||||
import { formatCurrency } from "../../../Components/CurrencyInput";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter
|
||||
|
||||
@@ -179,7 +178,9 @@ const DepositRequest = () => {
|
||||
"Amount in Investor currency": (
|
||||
<Box display={'flex'} justifyContent={'end'} w={"100px"} isTruncated={true}>
|
||||
<Text as={"span"} color={"teal.900"}>
|
||||
{formatCurrency(removeTrailingZeros(item?.investorAmount))} <Badge ms={1} colorScheme="green">{item?.currencyCode}</Badge>
|
||||
{/* {formatCurrency(removeTrailingZeros(item?.investorAmount))} */}
|
||||
{parseFloat(item?.investorAmount||0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
|
||||
<Badge ms={1} colorScheme="green">{item?.currencyCode}</Badge>
|
||||
</Text>
|
||||
</Box>
|
||||
),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
FormControl,
|
||||
@@ -137,7 +138,7 @@ const DepositRequestApprove = ({ isOpen, onClose, firstField, id, data:requestDa
|
||||
<Box as="form" onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalBody>
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormLabel fontSize="sm">Deposit Amount (SAR)</FormLabel>
|
||||
<FormLabel fontSize="sm">Deposit Amount <Badge colorScheme="green">{fileredData?.currencyCode}</Badge></FormLabel>
|
||||
<Input
|
||||
focusBorderColor="green.400"
|
||||
name="investorAmount"
|
||||
|
||||
@@ -229,7 +229,7 @@ const filteredData = data?.data?.rows
|
||||
colorScheme={"forestGreen"}
|
||||
>
|
||||
<Link
|
||||
href={"https://tanami.betadelivery.com/" + item?.supporting_FileName}
|
||||
href={import.meta.env.VITE_IMAGE_URL + item?.supporting_FileName}
|
||||
isExternal
|
||||
>
|
||||
<Box
|
||||
|
||||
@@ -113,7 +113,9 @@ const AddCashDetails = ({ isOpen, onClose, firstField, actionId, setActionId, da
|
||||
const handleClose = () => {
|
||||
setAlert(false)
|
||||
onClose()
|
||||
reset()
|
||||
reset({
|
||||
transactionAmount:""
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -180,7 +180,7 @@ const IOArtifacts = ({ enableNextTab, index, data }) => {
|
||||
colorScheme={"forestGreen"}
|
||||
>
|
||||
<Link
|
||||
href={"https://tanami.betadelivery.com/" + item?.artifactPathName}
|
||||
href={import.meta.env.VITE_IMAGE_URL + item?.artifactPathName}
|
||||
isExternal
|
||||
>
|
||||
<Box
|
||||
|
||||
@@ -81,7 +81,7 @@ const IOCashDetails = () => {
|
||||
const searchLower = searchTerm.toLowerCase();
|
||||
const nameMatches = name.toLowerCase().includes(searchLower);
|
||||
return nameMatches;
|
||||
});
|
||||
}).sort((b, a) => new Date(a.createdAt) - new Date(b.createdAt));
|
||||
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
@@ -116,7 +116,7 @@ const IOCashDetails = () => {
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item.transactionAmount}
|
||||
{`$${parseFloat(item.transactionAmount||0).toLocaleString()}`}
|
||||
</Text>
|
||||
),
|
||||
"Comments": (
|
||||
|
||||
@@ -209,7 +209,7 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
investmentNameArabic: IObyID?.data?.investmentNameArabic,
|
||||
descriptionEnglish: IObyID?.data?.descriptionEnglish,
|
||||
descriptionArabic: IObyID?.data?.descriptionArabic,
|
||||
goalAmount: removeTrailingZeros(IObyID?.data?.goalAmount),
|
||||
goalAmount: IObyID?.data?.goalAmount,
|
||||
closingDate: formatDatee(IObyID?.data?.closingDate),
|
||||
holdingPeriod: IObyID?.data?.holdingPeriod,
|
||||
ISIN: IObyID?.data?.ISIN,
|
||||
@@ -341,7 +341,7 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
value: IObyID?.data?.investmentType_xid,
|
||||
},
|
||||
{
|
||||
label: "Sponsorer Name",
|
||||
label: "Sponsor Name",
|
||||
placeHolder: "Select option",
|
||||
name: "sponserName",
|
||||
type: "select",
|
||||
@@ -354,7 +354,7 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
{
|
||||
label: "Goal Amount",
|
||||
placeHolder: "$00.00",
|
||||
value: removeTrailingZeros(IObyID?.data?.goalAmount),
|
||||
value: IObyID?.data?.goalAmount,
|
||||
name: "goalAmount",
|
||||
type: "number",
|
||||
isRequired: true,
|
||||
@@ -624,6 +624,11 @@ const IODetails = ({ enableNextTab, index, data }) => {
|
||||
toast({
|
||||
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"} />,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
setIsLoading(false);
|
||||
|
||||
@@ -54,7 +54,7 @@ const IONAVDetails = () => {
|
||||
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) => ({
|
||||
id: item?.id,
|
||||
@@ -78,7 +78,9 @@ const IONAVDetails = () => {
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{`${item.transactionAmount}`}
|
||||
{/* {`${item.transactionAmount}`} */}
|
||||
|
||||
{`$${parseFloat(item.transactionAmount||0).toLocaleString()}`}
|
||||
</Text>
|
||||
),
|
||||
"Last NAV update": (
|
||||
|
||||
@@ -37,7 +37,7 @@ import SetDisplayOrder from "./SetDisplayOrder";
|
||||
|
||||
const downloadFile = (filePath, fileName) => {
|
||||
|
||||
fetch("https://tanami.betadelivery.com/" + filePath)
|
||||
fetch(import.meta.env.VITE_IMAGE_URL+filePath)
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error("Network response was not ok");
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
Box,
|
||||
Button,
|
||||
HStack,
|
||||
Icon,
|
||||
Input,
|
||||
Menu,
|
||||
MenuButton,
|
||||
@@ -24,21 +25,40 @@ import {
|
||||
} from "@chakra-ui/react";
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import { OPACITY_ON_LOAD } from "../../../Layout/animations";
|
||||
import DataTable from "../../../Components/DataTable/DataTable";
|
||||
import NormalTable from "../../../Components/DataTable/NormalTable";
|
||||
import { HiDotsVertical } from "react-icons/hi";
|
||||
import { Link, Link as RouterLink } from "react-router-dom";
|
||||
import { Link, Link as RouterLink, useParams } from "react-router-dom";
|
||||
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 { formatCurrency } from "../../../Components/CurrencyInput";
|
||||
import { FiRefreshCw } from "react-icons/fi";
|
||||
import { useGetIOByIdQuery } from "../../../Services/io.service";
|
||||
import { RepeatIcon } from "@chakra-ui/icons";
|
||||
|
||||
const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter
|
||||
|
||||
const Investors = () => {
|
||||
const Investors = ({data}) => {
|
||||
const params = useParams()
|
||||
const id = params?.id
|
||||
const toast = useToast();
|
||||
const { investors, setInvestors, slideFromRight } =
|
||||
const { investors, setInvestors, slideFromRight, IODetails } =
|
||||
useContext(GlobalStateContext);
|
||||
|
||||
|
||||
console.log(params?.id);
|
||||
|
||||
const {
|
||||
data: IObyID,
|
||||
isLoading: IObyIDisLoading,
|
||||
error: IObyIDerror,
|
||||
refetch
|
||||
} = useGetIOByIdQuery(id, { skip: !id });
|
||||
|
||||
|
||||
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [deleteAlert, setDeleteAlert] = useState(false);
|
||||
@@ -84,6 +104,7 @@ const Investors = () => {
|
||||
"Market Value",
|
||||
"Return on Investment",
|
||||
"Distribution",
|
||||
"Distribution Percent",
|
||||
"Total Return",
|
||||
"Total return on Investment",
|
||||
];
|
||||
@@ -100,15 +121,17 @@ const Investors = () => {
|
||||
}, 300);
|
||||
|
||||
// Table filter
|
||||
const filteredData = investors.filter((item) => {
|
||||
const filteredData = IODetails?.investors?.filter((item) => {
|
||||
const name = item.firstName;
|
||||
const searchLower = searchTerm.toLowerCase();
|
||||
const nameMatches = name.toLowerCase().includes(searchLower);
|
||||
return nameMatches;
|
||||
});
|
||||
|
||||
|
||||
|
||||
const [ extractedArray, setExtractedArray ] = useState(filteredData?.map((item, index) => ({
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Client ID": (
|
||||
<Text
|
||||
@@ -118,7 +141,7 @@ const Investors = () => {
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item.clientId}
|
||||
{item?.clientReference_id}
|
||||
</Text>
|
||||
),
|
||||
"First name": (
|
||||
@@ -151,7 +174,8 @@ const Investors = () => {
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{`$${item.investedAmount}`}
|
||||
{/* {`$${formatCurrency(item.InvestedAmount_USD)}`} */}
|
||||
{`$${parseFloat(item.InvestedAmount_USD||0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`}
|
||||
</Text>
|
||||
),
|
||||
"Percentage": (
|
||||
@@ -162,7 +186,7 @@ const Investors = () => {
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item.percentage}
|
||||
{item.Investor_Holidings} %
|
||||
</Text>
|
||||
),
|
||||
"Market Value": (
|
||||
@@ -173,7 +197,7 @@ const Investors = () => {
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{`$${item.marketValue}`}
|
||||
{`$${parseFloat(item.Market_Value ||0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`}
|
||||
</Text>
|
||||
),
|
||||
"Return on Investment": (
|
||||
@@ -185,7 +209,7 @@ const Investors = () => {
|
||||
h={6}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item.returnOnInvestment}
|
||||
{item.Return_On_Investment || 0} %
|
||||
</Text>
|
||||
),
|
||||
"Distribution": (
|
||||
@@ -196,7 +220,20 @@ const Investors = () => {
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{`$${item.distribution}`}
|
||||
{/* {`$${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": (
|
||||
@@ -207,7 +244,8 @@ const Investors = () => {
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{`$${item.totalReturn}`}
|
||||
{/* {`$${formatCurrency(item.Total_Return) || 0}`} */}
|
||||
{`$${parseFloat(item.Total_Return||0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`}
|
||||
</Text>
|
||||
),
|
||||
"Total return on Investment": (
|
||||
@@ -218,10 +256,10 @@ const Investors = () => {
|
||||
fontWeight={"500"}
|
||||
className="d-flex align-items-center web-text-small"
|
||||
>
|
||||
{item.totalReturnOnInvestment}
|
||||
{item.Total_Return_On_Investment||0} %
|
||||
</Text>
|
||||
),
|
||||
})));
|
||||
}));
|
||||
|
||||
const handleDelete = () => {
|
||||
const updatedSponsors = sponser.filter(
|
||||
@@ -357,6 +395,11 @@ const Investors = () => {
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
const handleRefresh = () =>{
|
||||
refetch()
|
||||
}
|
||||
|
||||
return (
|
||||
<Box {...OPACITY_ON_LOAD} pb={0}>
|
||||
<Box bg="white.500">
|
||||
@@ -365,7 +408,9 @@ const Investors = () => {
|
||||
justifyContent={"space-between"}
|
||||
pb={3}
|
||||
spacing="24px"
|
||||
|
||||
>
|
||||
<span>
|
||||
<Input
|
||||
type="search"
|
||||
width={300}
|
||||
@@ -376,19 +421,22 @@ const Investors = () => {
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
<Icon ms={3} bg={"gray.100"} onClick={handleRefresh} fontWeight={600} as={RepeatIcon} boxSize={8} p={2} rounded={'md'} _hover={{bg:'gray.100'}} cursor={'pointer'} />
|
||||
</span>
|
||||
|
||||
{/* <HStack display={"flex"} alignItems={"center"}>
|
||||
<Pagination totalItems={10} />
|
||||
</HStack> */}
|
||||
<HStack bg={'#C6F6D5'} ps={4} pe={4} pt={1.5} pb={1.5} rounded={'md'} boxShadow={'sm'} display={"flex"} alignItems={"end"} flexDirection={'column'} >
|
||||
<Text fontWeight={600} fontSize={'sm'} as={'span'}>$ {parseFloat(IODetails?.totalAmtInvestmentInUSD).toLocaleString()}</Text>
|
||||
<Text fontWeight={600} color={'gray.500'} fontSize={'xs'} as={'span'}>Total Investment Amount ( USD )</Text>
|
||||
|
||||
</HStack>
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
<DataTable
|
||||
<NormalTable
|
||||
centered={true}
|
||||
emptyMessage={`We don't have any Sponers `}
|
||||
tableHeadRow={tableHeadRow}
|
||||
data={extractedArray}
|
||||
setData={setExtractedArray}
|
||||
isLoading={isLoading}
|
||||
viewActionId={actionId}
|
||||
setViewActionId={setActionId}
|
||||
|
||||
@@ -136,7 +136,7 @@ const KeyMerits = ({ enableNextTab, index, data: prepopData }) => {
|
||||
p={1}
|
||||
justifyContent={"center"}
|
||||
alignItems={"center"}
|
||||
src={" https://tanami.betadelivery.com/" + item?.icon?.iconFilePath}
|
||||
src={import.meta.env.VITE_IMAGE_URL+ item?.icon?.iconFilePath}
|
||||
w={8}
|
||||
h={8}
|
||||
/>
|
||||
|
||||
@@ -63,7 +63,7 @@ const SetDisplayOrder = ({ data }) => {
|
||||
p={1}
|
||||
justifyContent={"center"}
|
||||
alignItems={"center"}
|
||||
src={"https://tanami.betadelivery.com/" + item?.icon?.iconFilePath}
|
||||
src={import.meta.env.VITE_IMAGE_URL + item?.icon?.iconFilePath}
|
||||
w={8}
|
||||
h={8}
|
||||
/>
|
||||
|
||||
@@ -260,7 +260,7 @@ const IOArtifactsAdd = ({
|
||||
<Image
|
||||
rounded={"md"}
|
||||
src={
|
||||
"https://tanami.betadelivery.com/" +
|
||||
import.meta.env.VITE_IMAGE_URL +
|
||||
watch()?.artifactPathName
|
||||
}
|
||||
alt="Image Preview"
|
||||
|
||||
@@ -285,7 +285,7 @@ const KeyMeritsAdd = ({ isOpen, onClose, firstField, id, icons }) => {
|
||||
>
|
||||
<Box display="flex" alignItems="center">
|
||||
{selectedImageIcon && <Image
|
||||
src={`https://tanami.betadelivery.com/${selectedImageIcon}`}
|
||||
src={`${import.meta.env.VITE_IMAGE_URL}${selectedImageIcon}`}
|
||||
alt={selectedImageIcon}
|
||||
boxSize="1rem"
|
||||
mr="12px"
|
||||
@@ -305,7 +305,7 @@ const KeyMeritsAdd = ({ isOpen, onClose, firstField, id, icons }) => {
|
||||
>
|
||||
<Box display="flex" alignItems="center">
|
||||
<Image
|
||||
src={`https://tanami.betadelivery.com/${iconFilePath}`}
|
||||
src={`${import.meta.env.VITE_IMAGE_URL}${iconFilePath}`}
|
||||
alt={iconName}
|
||||
boxSize="1rem"
|
||||
mr="12px"
|
||||
|
||||
@@ -284,7 +284,7 @@ const KeyMeritsEdit = ({
|
||||
>
|
||||
<Box display="flex" alignItems="center">
|
||||
{selectedImageIcon&&<Image
|
||||
src={`https://tanami.betadelivery.com/${selectedImageIcon}`}
|
||||
src={`${import.meta.env.VITE_IMAGE_URL}${selectedImageIcon}`}
|
||||
alt={selectedImageIcon}
|
||||
boxSize="1rem"
|
||||
mr="12px"
|
||||
@@ -304,7 +304,7 @@ const KeyMeritsEdit = ({
|
||||
>
|
||||
<Box display="flex" alignItems="center">
|
||||
<Image
|
||||
src={`https://tanami.betadelivery.com/${iconFilePath}`}
|
||||
src={`${import.meta.env.VITE_IMAGE_URL}${iconFilePath}`}
|
||||
alt={iconName}
|
||||
boxSize="1rem"
|
||||
mr="12px"
|
||||
|
||||
@@ -52,9 +52,9 @@ const AmountInvested = ({ isOpen, onClose }) => {
|
||||
const [amountInvested] = useAmountIvestmentMutation();
|
||||
|
||||
useEffect(() => {
|
||||
if (IODetails?.goalAmount) {
|
||||
const totalAmount = parseFloat(IODetails.goalAmount);
|
||||
const ioCashUpdate = parseFloat(IODetails.goalAmount)
|
||||
if (IODetails?.totalAmtInvestmentInUSD) {
|
||||
const totalAmount = parseFloat(IODetails.totalAmtInvestmentInUSD);
|
||||
const ioCashUpdate = parseFloat(IODetails.totalAmtInvestmentInUSD)
|
||||
reset({
|
||||
Total_Amount: totalAmount,
|
||||
IoCash: ioCashUpdate,
|
||||
@@ -90,13 +90,13 @@ const AmountInvested = ({ isOpen, onClose }) => {
|
||||
|
||||
const handleAmountChange = (e) => {
|
||||
const amount = parseFloat(e.target.value) || 0;
|
||||
const totalAmount = parseFloat(IODetails?.goalAmount) || 0;
|
||||
const totalAmount = parseFloat(IODetails?.totalAmtInvestmentInUSD) || 0;
|
||||
const ioCash = (totalAmount - amount).toFixed(2);
|
||||
|
||||
reset({
|
||||
amountInvested: parseFloat(amount),
|
||||
IoCash: parseFloat(ioCash),
|
||||
Total_Amount: IODetails?.goalAmount
|
||||
Total_Amount: IODetails?.totalAmtInvestmentInUSD
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ const UpdateIOStatus = ({ isOpen, onClose, status }) => {
|
||||
setSelectedItem(null)
|
||||
setSelectedStatusId(null)
|
||||
onClose()
|
||||
setError("")
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -76,7 +76,7 @@ const ViewIOTable = () => {
|
||||
const tableHeadRow = [
|
||||
"IO ID",
|
||||
"IO Name",
|
||||
"Sponsorer",
|
||||
"Sponsor",
|
||||
"Investment Type",
|
||||
"Goal Amount",
|
||||
"Holding Period",
|
||||
|
||||
@@ -55,8 +55,8 @@ const ViewIOdata = () => {
|
||||
{ label: "Investment documents", content: <InvestmentDocument data={data?.data} /> },
|
||||
{ label: "Key merits", content: <KeyMerits data={data?.data} /> },
|
||||
{ label: "IO artifacts", content: <IOArtifacts data={data?.data} /> },
|
||||
// { label: "Investors", content: <Investors data={data?.data} /> },
|
||||
{ label: "Investors", content: <UnderConstruction h={'75vh'} /> },
|
||||
{ label: "Investors", content: <Investors data={data?.data} /> },
|
||||
// { label: "Investors", content: <UnderConstruction h={'75vh'} /> },
|
||||
{ label: "IO Cash Details", content: <IOCashDetails data={data?.data} /> },
|
||||
{ label: "IO NAV Details", content: <IONAVDetails data={data?.data} /> },
|
||||
// { label: "Distribution to Investors", content: <IONAVDetails data={data?.data} /> },
|
||||
@@ -85,7 +85,8 @@ const ViewIOdata = () => {
|
||||
index === 0 ||
|
||||
index === 1 ||
|
||||
index === 2 ||
|
||||
index === 3 ?
|
||||
index === 3 ||
|
||||
index === 4 ?
|
||||
false :
|
||||
!IODetails?.isInvestedAmount}
|
||||
key={index}
|
||||
|
||||
@@ -41,8 +41,8 @@ import Cancle from "./HeaderModal/Cancle";
|
||||
import { AddIcon } from "@chakra-ui/icons";
|
||||
import { GrGallery } from "react-icons/gr";
|
||||
import Loader01 from "../../../Components/Loaders/Loader01";
|
||||
import { formatCurrency } from "../../../Components/CurrencyInput";
|
||||
import { removeTrailingZeros } from "../../../Constants/Constants";
|
||||
// import { formatCurrency } from "../../../Components/CurrencyInput";
|
||||
// import { removeTrailingZeros } from "../../../Constants/Constants";
|
||||
|
||||
const ViewIOdataHeader = ({data, isLoading}) => {
|
||||
const params = useParams();
|
||||
@@ -51,6 +51,7 @@ const ViewIOdataHeader = ({data, isLoading}) => {
|
||||
const btnRef = useRef();
|
||||
const { IODetails, isIOloading } = useContext(GlobalStateContext);
|
||||
|
||||
|
||||
const {
|
||||
isOpen: isInvestmentOpen,
|
||||
onOpen: onInvestmentOpen,
|
||||
@@ -104,6 +105,10 @@ const ViewIOdataHeader = ({data, isLoading}) => {
|
||||
};
|
||||
|
||||
|
||||
console.log(import.meta.env.VITE_IMAGE_URL +
|
||||
IODetails?.artifactsImage?.[0]?.artifactPathName);
|
||||
|
||||
|
||||
|
||||
const menu = [
|
||||
{
|
||||
@@ -208,7 +213,7 @@ const filteredMenu = menu?.filter(item => apiTransactionTitles?.includes(item.id
|
||||
w={"100%"}
|
||||
objectFit={"cover"}
|
||||
src={
|
||||
" https://tanami.betadelivery.com/" +
|
||||
import.meta.env.VITE_IMAGE_URL +
|
||||
IODetails?.artifactsImage?.[0]?.artifactPathName
|
||||
}
|
||||
alt={IODetails?.ioName}
|
||||
@@ -241,7 +246,7 @@ const filteredMenu = menu?.filter(item => apiTransactionTitles?.includes(item.id
|
||||
|
||||
<Box display={"flex"} flexDirection={"column"} gap={2}>
|
||||
<Text as={"span"} fontSize={"xs"} color={"gray.500"} fontWeight={"500"}>
|
||||
Sponsorer Name
|
||||
Sponsor Name
|
||||
</Text>
|
||||
<Text as={"span"} fontSize={"sm"} fontWeight={"500"}>
|
||||
{IODetails?.sponsor?.sponsorName
|
||||
@@ -294,7 +299,8 @@ const filteredMenu = menu?.filter(item => apiTransactionTitles?.includes(item.id
|
||||
IO MV
|
||||
</Text>
|
||||
<Text as={"span"} fontSize={"sm"} fontWeight={"500"}>
|
||||
{IODetails?.ioNAV ? formatCurrency(removeTrailingZeros(IODetails?.ioNAV)) : "00.00"}
|
||||
{/* {IODetails?.ioNAV ? formatCurrency(removeTrailingZeros(IODetails?.ioNAV)) : "00.00"} */}
|
||||
{parseFloat(IODetails?.ioNAV||0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
@@ -303,7 +309,8 @@ const filteredMenu = menu?.filter(item => apiTransactionTitles?.includes(item.id
|
||||
IO cash
|
||||
</Text>
|
||||
<Text as={"span"} fontSize={"sm"} fontWeight={"500"}>
|
||||
{IODetails?.ioCash ? formatCurrency(removeTrailingZeros(IODetails?.ioCash)) : "00.00"}
|
||||
{/* {IODetails?.ioCash ? formatCurrency(removeTrailingZeros(IODetails?.ioCash)) : "00.00"} */}
|
||||
{parseFloat(IODetails?.ioCash||0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
@@ -312,7 +319,8 @@ const filteredMenu = menu?.filter(item => apiTransactionTitles?.includes(item.id
|
||||
IO NAV
|
||||
</Text>
|
||||
<Text as={"span"} fontSize={"sm"} fontWeight={"500"}>
|
||||
{IODetails?.ioMVNAV ? formatCurrency(removeTrailingZeros(IODetails?.ioMVNAV)) : "00.00"}
|
||||
{/* {IODetails?.ioMVNAV ? formatCurrency(removeTrailingZeros(IODetails?.ioMVNAV)) : "00.00"} */}
|
||||
{parseFloat(IODetails?.ioMVNAV||0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ const ViewIOdetails = () => {
|
||||
width: "32.3%",
|
||||
},
|
||||
{
|
||||
label: "Sponsorer Name",
|
||||
label: "Sponsor Name",
|
||||
placeHolder: "Select option",
|
||||
name: "sponsor_xid",
|
||||
type: "select",
|
||||
@@ -263,7 +263,8 @@ const ViewIOdetails = () => {
|
||||
{
|
||||
label: "Goal Amount",
|
||||
placeHolder: "$00.00",
|
||||
value: IObyID?.data?.goalAmount ? formatCurrency(removeTrailingZeros(IObyID?.data?.goalAmount)) : "---",
|
||||
value: IObyID?.data?.goalAmount?parseFloat(IObyID?.data?.goalAmount||0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : "---",
|
||||
|
||||
name: "goalAmount",
|
||||
type: "number",
|
||||
isRequired: true,
|
||||
|
||||
@@ -3,7 +3,7 @@ import axios from "axios";
|
||||
// Create an Axios instance for API calls
|
||||
export const api = axios.create({
|
||||
// baseURL: `https://tanami.betadelivery.com/api/v1`,
|
||||
baseURL: `https://sprint4.tanami.betadelivery.com/api/v1`, // Replace with your API base URL
|
||||
baseURL: import.meta.env.VITE_BAS_URL, // Replace with your API base URL
|
||||
timeout: 10000, // Adjust timeout as needed
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
101
src/Services/deposite.service.js
Normal file
101
src/Services/deposite.service.js
Normal file
@@ -0,0 +1,101 @@
|
||||
//sponser.service
|
||||
// Need to use the React-specific entry point to import createApi
|
||||
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
|
||||
import { api } from "./api.service";
|
||||
|
||||
const baseUrl = api?.defaults.baseURL;
|
||||
|
||||
// const baseUrl = `${import.meta.env.VITE_API_BASE_URL}/${import.meta.env.VITE_API_VERSION}`
|
||||
|
||||
// Define a service using a base URL and expected endpoints
|
||||
export const deposite = createApi({
|
||||
reducerPath: "deposite",
|
||||
baseQuery: fetchBaseQuery({ baseUrl: baseUrl }),
|
||||
tagTypes: ["gtDeposite"],
|
||||
endpoints: (builder) => ({
|
||||
|
||||
|
||||
|
||||
// ======[Get All]=====
|
||||
|
||||
getSponserMaster: builder.query({
|
||||
query: ({ page, size }) => `/sponsor/admin?page=${page}&size=${size}`,
|
||||
providesTags: ["getSponser"],
|
||||
}),
|
||||
|
||||
|
||||
// ========[Get Active]========
|
||||
|
||||
getActiveSponserMaster: builder.query({
|
||||
query: () => `/sponsor/admin/active`,
|
||||
providesTags: ["getSponser"],
|
||||
}),
|
||||
|
||||
getSponserMasterActive: builder.query({
|
||||
query: () => "/sponsor/admin/active",
|
||||
}),
|
||||
|
||||
|
||||
// ======[Get ID]=====
|
||||
|
||||
getSponserById: builder.query({
|
||||
query: (id) => `/sponsor/admin/${id}`,
|
||||
providesTags: ["getSponser"],
|
||||
}),
|
||||
|
||||
// ========[Toggle Status]========
|
||||
|
||||
toggleStatus: builder.mutation({
|
||||
query: ({ id }) => ({
|
||||
url: `/sponsor/admin/toggle-status/${id}`,
|
||||
method: "PATCH",
|
||||
}),
|
||||
invalidatesTags: ["getSponser"],
|
||||
}),
|
||||
|
||||
// ========[Create Sponser]========
|
||||
|
||||
createSponser: builder.mutation({
|
||||
query: (data) => ({
|
||||
url: `/sponsor/admin`,
|
||||
method: "POST",
|
||||
body: data,
|
||||
}),
|
||||
invalidatesTags: ["getSponser"],
|
||||
}),
|
||||
|
||||
// ========[Update Sponser]========
|
||||
|
||||
updateSponser: builder.mutation({
|
||||
query: ({ data, id }) => ({
|
||||
url: `/sponsor/admin/${id}`,
|
||||
method: "PATCH",
|
||||
body: data,
|
||||
}),
|
||||
invalidatesTags: ["getSponser"],
|
||||
}),
|
||||
|
||||
// ========[Delete Sponser]========
|
||||
|
||||
deleteSponser: builder.mutation({
|
||||
query: (id) => ({
|
||||
url: `/sponsor/admin/delete/${id}`,
|
||||
method: "DELETE",
|
||||
}),
|
||||
invalidatesTags: ["getSponser"],
|
||||
}),
|
||||
|
||||
}),
|
||||
});
|
||||
|
||||
// Export hooks for usage in functional components
|
||||
export const {
|
||||
useGetSponserMasterQuery,
|
||||
useGetSponserMasterActiveQuery,
|
||||
useToggleStatusMutation,
|
||||
useCreateSponserMutation,
|
||||
useUpdateSponserMutation,
|
||||
useGetSponserByIdQuery,
|
||||
useDeleteSponserMutation,
|
||||
useGetActiveSponserMasterQuery
|
||||
} = sponserMaster;
|
||||
@@ -22,7 +22,7 @@ export const exchangeRate = createApi({
|
||||
query: (id) => `/currencyExchange/admin/${id}`,
|
||||
providesTags: ["getAllExchangeRate"],
|
||||
}),
|
||||
|
||||
|
||||
updateExchangeRate: builder.mutation({
|
||||
query: ({ data, id }) => ({
|
||||
url: `/currencyExchange/admin/${id}`,
|
||||
|
||||
@@ -24,7 +24,7 @@ export const ioService = createApi({
|
||||
|
||||
|
||||
|
||||
// =====[create]
|
||||
// =====[create]
|
||||
createInvestmentDocuments: builder.mutation({
|
||||
query: ({data, id}) => ({
|
||||
url: `/io/admin/document/${id}`,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
|
||||
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
|
||||
|
||||
// Define a base query function with RTK Query
|
||||
// export const baseQuery = fetchBaseQuery({
|
||||
@@ -12,17 +12,14 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
|
||||
// },
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
// Define a base query function with token refresh logic
|
||||
export const baseQuery = async (args, api, extraOptions) => {
|
||||
export const baseQuery = async (args, api, extraOptions) => {
|
||||
let result = await fetchBaseQuery({
|
||||
baseUrl: 'https://sprint4.tanami.betadelivery.com/api/v1',
|
||||
baseUrl: import.meta.env.VITE_BAS_URL,
|
||||
prepareHeaders: (headers) => {
|
||||
const token = localStorage.getItem('accessToken');
|
||||
const token = localStorage.getItem("accessToken");
|
||||
if (token) {
|
||||
headers.set('x-auth-token', token);
|
||||
headers.set("x-auth-token", token);
|
||||
}
|
||||
return headers;
|
||||
},
|
||||
@@ -30,38 +27,47 @@ export const baseQuery = async (args, api, extraOptions) => {
|
||||
|
||||
if (result.error && result.error.status === 401) {
|
||||
// Handle token refresh
|
||||
const refreshToken = localStorage.getItem('refreshToken');
|
||||
const refreshToken = localStorage.getItem("refreshToken");
|
||||
if (refreshToken) {
|
||||
try {
|
||||
const refreshResult = await fetchBaseQuery({
|
||||
baseUrl: 'https://sprint4.tanami.betadelivery.com/api/v1',
|
||||
})({
|
||||
url: '/auth/user/regenerate-token',
|
||||
method: 'POST',
|
||||
body: { refreshToken },
|
||||
}, api, extraOptions);
|
||||
baseUrl: import.meta.env.VITE_BAS_URL,
|
||||
})(
|
||||
{
|
||||
url: "/auth/user/regenerate-token",
|
||||
method: "POST",
|
||||
body: { refreshToken },
|
||||
},
|
||||
api,
|
||||
extraOptions
|
||||
);
|
||||
|
||||
if (refreshResult.data) {
|
||||
|
||||
// Save new tokens
|
||||
localStorage.setItem('accessToken', refreshResult.data.access.token);
|
||||
localStorage.setItem('refreshToken', refreshResult.data.refresh.token);
|
||||
localStorage.setItem('refreshTokenExp', refreshResult.data.refresh.expires);
|
||||
localStorage.setItem("accessToken", refreshResult.data.access.token);
|
||||
localStorage.setItem(
|
||||
"refreshToken",
|
||||
refreshResult.data.refresh.token
|
||||
);
|
||||
localStorage.setItem(
|
||||
"refreshTokenExp",
|
||||
refreshResult.data.refresh.expires
|
||||
);
|
||||
|
||||
// Retry the original request with the new token
|
||||
result = await fetchBaseQuery({
|
||||
baseUrl: 'https://sprint4.tanami.betadelivery.com/api/v1',
|
||||
baseUrl: import.meta.env.VITE_BAS_URL,
|
||||
prepareHeaders: (headers) => {
|
||||
const token = localStorage.getItem('accessToken');
|
||||
const token = localStorage.getItem("accessToken");
|
||||
if (token) {
|
||||
headers.set('x-auth-token', token);
|
||||
headers.set("x-auth-token", token);
|
||||
}
|
||||
return headers;
|
||||
},
|
||||
})(args, api, extraOptions);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to refresh token:', err);
|
||||
console.error("Failed to refresh token:", err);
|
||||
// Handle refresh failure (e.g., redirect to login)
|
||||
}
|
||||
}
|
||||
@@ -72,32 +78,32 @@ export const baseQuery = async (args, api, extraOptions) => {
|
||||
|
||||
// Create an RTK Query API slice
|
||||
export const apiSlice = createApi({
|
||||
reducerPath: 'api',
|
||||
reducerPath: "api",
|
||||
baseQuery: baseQuery,
|
||||
endpoints: (builder) => ({
|
||||
login: builder.mutation({
|
||||
query: (credentials) => ({
|
||||
url: '/auth/admin',
|
||||
method: 'POST',
|
||||
url: "/auth/admin",
|
||||
method: "POST",
|
||||
body: credentials,
|
||||
}),
|
||||
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
||||
try {
|
||||
const { data } = await queryFulfilled;
|
||||
// Store tokens in local storage
|
||||
localStorage.setItem('accessToken', data?.data?.access?.token) ;
|
||||
localStorage.setItem('refreshToken', data?.data?.refresh?.token);
|
||||
localStorage.setItem("accessToken", data?.data?.access?.token);
|
||||
localStorage.setItem("refreshToken", data?.data?.refresh?.token);
|
||||
// localStorage.setItem('refreshTokenExp', data?.data?.refresh?.expires);
|
||||
localStorage.setItem('accessTokenExp', data?.data?.access?.expires);
|
||||
localStorage.setItem("accessTokenExp", data?.data?.access?.expires);
|
||||
} catch (error) {
|
||||
console.error('Login failed:', error);
|
||||
console.error("Login failed:", error);
|
||||
}
|
||||
},
|
||||
}),
|
||||
refreshToken: builder.mutation({
|
||||
query: (refreshToken) => ({
|
||||
url: '/auth/user/regenerate-token',
|
||||
method: 'POST',
|
||||
url: "/auth/user/regenerate-token",
|
||||
method: "POST",
|
||||
body: { refreshToken },
|
||||
}),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user