2024-07-08 12:22:27 +05:30
|
|
|
import React, { useEffect, useState } from "react";
|
2024-07-05 15:28:02 +05:30
|
|
|
import { OPACITY_ON_LOAD } from "../../../Layout/animations";
|
2024-06-26 17:45:13 +05:30
|
|
|
import {
|
|
|
|
|
Box,
|
2024-07-05 12:07:52 +05:30
|
|
|
Tabs,
|
|
|
|
|
TabList,
|
|
|
|
|
Tab,
|
|
|
|
|
TabPanel,
|
|
|
|
|
TabPanels,
|
2024-06-26 17:45:13 +05:30
|
|
|
} from "@chakra-ui/react";
|
2024-07-08 12:22:27 +05:30
|
|
|
import { useForm } from "react-hook-form";
|
2024-06-26 17:45:13 +05:30
|
|
|
import { yupResolver } from "@hookform/resolvers/yup";
|
|
|
|
|
import * as yup from "yup";
|
2024-07-05 15:28:02 +05:30
|
|
|
import IODetails from "./IODetails";
|
|
|
|
|
import KeyMerits from "./KeyMerits";
|
|
|
|
|
import IOArtifacts from "./IOArtifacts";
|
|
|
|
|
import Investors from "./Investors";
|
|
|
|
|
import IOCashDetails from "./IOCashDetails";
|
|
|
|
|
import IONAVDetails from "./IONAVDetails";
|
2024-07-08 12:22:27 +05:30
|
|
|
import InvestmentDocument from "./InvestmentDocument"; // Ensure this is the correct import
|
2024-07-08 20:42:55 +05:30
|
|
|
import ViewIOdataHeader from "../ViewIO/ViewIOdataHeader";
|
2024-06-26 17:45:13 +05:30
|
|
|
|
|
|
|
|
const schema = yup.object().shape({
|
2024-07-08 12:22:27 +05:30
|
|
|
ioName: yup.string().required("IO name english is required"),
|
|
|
|
|
ioNameArabic: yup.string().required("IO name arabic is required"),
|
|
|
|
|
discription: yup.string().required("Discription in english is required"),
|
|
|
|
|
discriptionArabic: yup.string().required("Discription in Arabic is required"),
|
|
|
|
|
typeName: yup.string().required("Investment type in english is required"),
|
|
|
|
|
typeNameArabic: yup.string().required("Investment type in arabic is required"),
|
|
|
|
|
sponserName: yup.string().required("Sponser name is required"),
|
2024-07-03 12:13:09 +05:30
|
|
|
sponserNameArabic: yup
|
|
|
|
|
.string()
|
2024-07-08 12:22:27 +05:30
|
|
|
.required("Sponser name arabic is required"),
|
|
|
|
|
goalAmount: yup.string().required("Goal amount is required"),
|
2024-07-08 20:42:55 +05:30
|
|
|
|
2024-07-08 12:22:27 +05:30
|
|
|
|
|
|
|
|
|
2024-07-03 12:13:09 +05:30
|
|
|
holdingPeriod: yup.string().required("Sponser name is required"),
|
2024-07-08 12:22:27 +05:30
|
|
|
ioStatus: yup.string().required("Investment Object name is required"),
|
2024-07-03 12:13:09 +05:30
|
|
|
ioStartusArabic: yup.string().required("Sponser name is required"),
|
|
|
|
|
closingDate: yup.string().required("Investment Object name is required"),
|
|
|
|
|
minInvestment: yup.string().required("Sponser name is required"),
|
|
|
|
|
maxInvestment: yup.string().required("Arabic name is required"),
|
|
|
|
|
expectedReturn: yup.string().required("Investment Object name is required"),
|
|
|
|
|
originalValue: yup.string().required("Sponser name is required"),
|
|
|
|
|
keyname: yup.string().required("Arabic name is required"),
|
|
|
|
|
keyNameArabic: yup.string().required("Investment Object name is required"),
|
|
|
|
|
keyDescription: yup.string().required("Sponser name is required"),
|
|
|
|
|
keyDescriptionArabic: yup.string().required("Sponser name is required"),
|
|
|
|
|
docType: yup.string().required("Sponser name is required"),
|
2024-06-27 11:50:59 +05:30
|
|
|
destributedAmount: yup
|
|
|
|
|
.number()
|
|
|
|
|
.required("Distributed Amount is required")
|
|
|
|
|
.positive("Must be a positive number"),
|
|
|
|
|
year: yup.string().required("Year is required"),
|
|
|
|
|
tenure: yup
|
|
|
|
|
.number()
|
|
|
|
|
.required("Tenure is required")
|
|
|
|
|
.positive("Must be a positive number"),
|
|
|
|
|
annualReturn: yup
|
|
|
|
|
.number()
|
|
|
|
|
.required("Annual Return is required")
|
|
|
|
|
.positive("Must be a positive number"),
|
|
|
|
|
miniInvest: yup
|
|
|
|
|
.number()
|
|
|
|
|
.required("Minimum Invest is required")
|
|
|
|
|
.positive("Must be a positive number"),
|
|
|
|
|
quaterly: yup.string().required("Quaterly is required"),
|
|
|
|
|
targetClose: yup.date().required("Target close date is required"),
|
|
|
|
|
annualyield: yup
|
|
|
|
|
.number()
|
|
|
|
|
.required("Annual Yield is required")
|
|
|
|
|
.positive("Must be a positive number"),
|
2024-07-05 12:07:52 +05:30
|
|
|
iconUpload: yup.mixed().required("Profile image is required"),
|
|
|
|
|
bannerImages: yup.mixed().required("Profile image is required"),
|
|
|
|
|
otherImage: yup.mixed().required("Profile image is required"),
|
|
|
|
|
docAttach: yup.mixed().required("Profile image is required"),
|
|
|
|
|
videos: yup.mixed().required("Profile image is required"),
|
2024-06-26 17:45:13 +05:30
|
|
|
});
|
|
|
|
|
|
2024-06-25 12:05:39 +05:30
|
|
|
const CreateIO = () => {
|
2024-06-26 17:45:13 +05:30
|
|
|
const {
|
|
|
|
|
control,
|
|
|
|
|
handleSubmit,
|
|
|
|
|
formState: { errors },
|
|
|
|
|
} = useForm({
|
|
|
|
|
resolver: yupResolver(schema),
|
|
|
|
|
});
|
|
|
|
|
|
2024-07-08 12:22:27 +05:30
|
|
|
const enableNextTab = (index) => {
|
|
|
|
|
setTabs((prevTabs) => {
|
|
|
|
|
const newTabs = [...prevTabs];
|
|
|
|
|
if (index < newTabs.length - 1) {
|
|
|
|
|
newTabs[index + 1].isDisabled = false;
|
|
|
|
|
setActiveIndex(index + 1); // Switch to the next tab
|
|
|
|
|
}
|
|
|
|
|
return newTabs;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-05 20:05:18 +05:30
|
|
|
const initialTabsState = [
|
2024-07-05 16:16:03 +05:30
|
|
|
{
|
|
|
|
|
label: "IO Details",
|
2024-07-08 12:22:27 +05:30
|
|
|
Content: IODetails,
|
2024-07-05 16:16:03 +05:30
|
|
|
isDisabled: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "Investment documents",
|
2024-07-08 12:22:27 +05:30
|
|
|
Content: InvestmentDocument,
|
2024-07-05 20:05:18 +05:30
|
|
|
isDisabled: true,
|
2024-07-05 16:16:03 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "Key merits",
|
2024-07-08 12:22:27 +05:30
|
|
|
Content: KeyMerits,
|
|
|
|
|
isDisabled: true,
|
2024-07-05 16:16:03 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "IO artifacts",
|
2024-07-08 12:22:27 +05:30
|
|
|
Content: IOArtifacts,
|
|
|
|
|
isDisabled: true,
|
2024-07-05 16:16:03 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "Investors",
|
2024-07-08 12:22:27 +05:30
|
|
|
Content: Investors,
|
|
|
|
|
isDisabled: false,
|
2024-07-05 16:16:03 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "IO Cash Details",
|
2024-07-08 12:22:27 +05:30
|
|
|
Content: IOCashDetails,
|
2024-07-05 20:05:18 +05:30
|
|
|
isDisabled: false,
|
2024-07-05 16:16:03 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "IO NAV Details",
|
2024-07-08 12:22:27 +05:30
|
|
|
Content: IONAVDetails,
|
2024-07-05 20:05:18 +05:30
|
|
|
isDisabled: false,
|
2024-07-05 16:16:03 +05:30
|
|
|
},
|
2024-07-05 15:28:02 +05:30
|
|
|
];
|
2024-06-26 17:45:13 +05:30
|
|
|
|
2024-07-05 20:05:18 +05:30
|
|
|
const [tabs, setTabs] = useState(initialTabsState);
|
|
|
|
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
|
|
|
|
2024-07-05 12:07:52 +05:30
|
|
|
|
|
|
|
|
|
2024-06-26 17:45:13 +05:30
|
|
|
const onSubmit = (data) => {
|
2024-07-05 20:05:18 +05:30
|
|
|
data.preventDefault();
|
|
|
|
|
enableNextTab(0);
|
2024-06-28 15:11:57 +05:30
|
|
|
};
|
2024-06-26 17:45:13 +05:30
|
|
|
|
2024-06-25 12:05:39 +05:30
|
|
|
return (
|
2024-07-05 15:28:02 +05:30
|
|
|
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={10}>
|
2024-07-08 20:42:55 +05:30
|
|
|
<Box paddingInline={"12px"} mt={2}>
|
|
|
|
|
{/* <span
|
|
|
|
|
onClick={() => navigate(-1)}
|
|
|
|
|
style={{ fontSize: "15px", cursor: "pointer" }}
|
|
|
|
|
>
|
|
|
|
|
<ArrowBackIcon cursor={"pointer"} /> Back
|
|
|
|
|
</span> */}
|
|
|
|
|
<ViewIOdataHeader />
|
|
|
|
|
</Box>
|
2024-07-08 12:22:27 +05:30
|
|
|
<Tabs index={activeIndex} onChange={(index) => setActiveIndex(index)} mt={2}>
|
2024-07-05 12:07:52 +05:30
|
|
|
<TabList>
|
2024-07-05 16:16:03 +05:30
|
|
|
{tabs.map(({ label, isDisabled }, index) => (
|
|
|
|
|
<Tab
|
|
|
|
|
isDisabled={isDisabled}
|
|
|
|
|
key={index}
|
|
|
|
|
fontSize={"sm"}
|
|
|
|
|
_selected={{
|
|
|
|
|
color: "#004118",
|
|
|
|
|
borderBottom: "2px solid #38a169",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{label}
|
|
|
|
|
</Tab>
|
|
|
|
|
))}
|
2024-07-05 12:07:52 +05:30
|
|
|
</TabList>
|
|
|
|
|
|
|
|
|
|
<TabPanels>
|
2024-07-08 12:22:27 +05:30
|
|
|
{tabs.map(({ Content }, index) => (
|
2024-07-05 20:05:18 +05:30
|
|
|
<TabPanel key={index}>
|
2024-07-08 12:22:27 +05:30
|
|
|
<Content index={index} enableNextTab={enableNextTab} control={control} errors={errors} handleSubmit={handleSubmit} />
|
2024-07-05 20:05:18 +05:30
|
|
|
</TabPanel>
|
2024-07-05 16:16:03 +05:30
|
|
|
))}
|
2024-07-05 12:07:52 +05:30
|
|
|
</TabPanels>
|
|
|
|
|
</Tabs>
|
2024-06-25 12:05:39 +05:30
|
|
|
</Box>
|
2024-06-26 17:45:13 +05:30
|
|
|
);
|
|
|
|
|
};
|
2024-06-25 12:05:39 +05:30
|
|
|
|
2024-06-26 17:45:13 +05:30
|
|
|
export default CreateIO;
|