diff --git a/src/Constants/Constants.js b/src/Constants/Constants.js index abc82ee..aaf5bd7 100644 --- a/src/Constants/Constants.js +++ b/src/Constants/Constants.js @@ -205,4 +205,17 @@ export const exportToExcelNew = (data, fileName = "exported_data.xlsx") => { // Write the workbook to a file XLSX.writeFile(workbook, fileWithExtension); -}; \ No newline at end of file +}; + + +export function formatDateToYYYYMMDD(dateString) { + const date = new Date(dateString); + + // Extract individual date components + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are 0-based + const day = String(date.getDate()).padStart(2, '0'); + + // Combine the formatted parts + return `${year}-${month}-${day}`; +} \ No newline at end of file diff --git a/src/Pages/IO_Management/CreateIO/CreateIO.jsx b/src/Pages/IO_Management/CreateIO/CreateIO.jsx index e049632..cc0599e 100644 --- a/src/Pages/IO_Management/CreateIO/CreateIO.jsx +++ b/src/Pages/IO_Management/CreateIO/CreateIO.jsx @@ -21,9 +21,6 @@ import Destribution from "./Destribution"; const CreateIO = () => { const id = useParams()?.id; const { data, error, isLoading } = useGetIOprepopulateDataQuery(); - - - console.log(data?.data); const enableNextTab = (index) => { setTabs((prevTabs) => { diff --git a/src/Pages/IO_Management/CreateIO/IODetails.jsx b/src/Pages/IO_Management/CreateIO/IODetails.jsx index f2b2997..18ff85c 100644 --- a/src/Pages/IO_Management/CreateIO/IODetails.jsx +++ b/src/Pages/IO_Management/CreateIO/IODetails.jsx @@ -16,7 +16,7 @@ import { useToast, } from "@chakra-ui/react"; import { formatDatee } from "../../../Components/FormField"; -import { removeTrailingZeros } from "../../../Constants/Constants"; +import { formatDateToYYYYMMDD, removeTrailingZeros } from "../../../Constants/Constants"; const schema = yup.object().shape({ investmentNameEnglish: yup @@ -154,10 +154,6 @@ const IODetails = ({ enableNextTab, index, data }) => { } ); - console.log(IObyID?.data?.minInvestmentAmt); - - - const minInvestmentById = IObyID?.data?.minInvestmentAmt?.map(({minInvestmentAmt, country, currencyCode, country_xid,id })=>{ console.log(currencyCode); return{ @@ -288,9 +284,6 @@ const IODetails = ({ enableNextTab, index, data }) => { }, [id, IObyID]); - - // const minInvestmentById = - //=======================[ Creator ] const formFields = [ { @@ -490,151 +483,6 @@ const IODetails = ({ enableNextTab, index, data }) => { helperText:`Maximum length should be 100 characters. You have entered ${watch()?.comment?.length || 0} characters.` }, ]; - //=======================[ Editor ] - // const formEditFields = [ - // { - // label: "IO Name", - // value: IObyID?.data?.investmentNameEnglish, - // name: "investmentNameEnglish", - // type: "text", - // section: " ", - // width: "49%", - // isRequired: true, - // }, - // { - // label: "IO Name (Arabic)", - // name: "investmentNameArabic", - // type: "text", - // value: IObyID?.data?.investmentNameArabic, - // isRequired: true, - // arabic: true, - // section: " ", - // width: "49%", - // }, - // { - // label: "Description", - // name: "descriptionEnglish", - // value: IObyID?.data?.descriptionEnglish, - // type: "textarea", - // isRequired: true, - // section: " ", - // width: "49%", - // }, - // { - // label: "Description (Arabic)", - // name: "descriptionArabic", - // value: IObyID?.data?.descriptionArabic, - // type: "textarea", - // isRequired: true, - // arabic: true, - // section: " ", - // width: "49%", - // }, - - // { - // label: "Goal Amount", - // placeHolder: "$00.00", - // value: IObyID?.data?.goalAmount, - // name: "goalAmount", - // type: "number", - // isRequired: true, - // section: " ", - // width: "32.3%", - // }, - // { - // label: "Closing Date", - // name: "closingDate", - // type: "date", - // isRequired: true, - // value: IObyID?.data?.closingDate, - // section: " ", - // width: "32.3%", - // }, - // { - // label: "Holding Period", - // name: "holdingPeriod", - // value: IObyID?.data?.holdingPeriod, - // type: "number", - // isRequired: true, - // placeHolder: "1Y", - // section: " ", - // width: "32.3%", - // }, - // { - // label: "Minimum Investment Amount", - // placeHolder: "$00.00", - // name: "minInvestmentAmount", - // value: IObyID?.data?.minInvestmentAmount, - // type: "number", - // isRequired: true, - // section: " ", - // width: "32.3%", - // }, - // { - // label: "ISIN", - // placeHolder: "$00.00", - // name: "ISIN", - // value: IObyID?.data?.ISIN, - // type: "number", - // section: " ", - // width: "32.3%", - // }, - // { - // label: "Investment Details", - // placeHolder: "", - // name: "InvestmentDetails", - // value: IObyID?.data?.InvestmentDetails, - // type: "text", - // section: " ", - // width: "32.3%", - // }, - // { - // label: "Expected Return Estimated", - // placeHolder: "$00.00", - // name: "expectedReturn", - // type: "number", - // isRequired: true, - // value: IObyID?.data?.expectedReturn, - // section: " ", - // width: "32.3%", - // }, - - // { - // label: "Investment Type", - // placeHolder: "Select option", - // value: IObyID?.data?.investmentType_xid, - // name: "investmentType_xid", - // type: "select", - // isRequired: true, - // section: " ", - // width: "32.3%", - // options: investmentTypeOptions, - // }, - // { - // label: "Sponsorer Name", - // placeHolder: "Select option", - // name: "sponsor_xid", - // type: "select", - // options: sponserNameOption, - // value: IObyID?.data?.sponsor_xid, - // section: " ", - // isRequired: true, - // width: "32.3%", - // }, - - // { - // label: "Comment", - // placeHolder: "Enter comment here", - // name: "comment", - // type: "textarea", - // value: IObyID?.data?.comment, - // section: " ", - // width: "100%", - // // options: investmentTypeOptions, - // }, - // ]; - - // ======================[ Form Contructor Filter ] const groupedFields = formFields.reduce((groups, field) => { const { section } = field; if (!groups[section]) { @@ -645,13 +493,10 @@ const IODetails = ({ enableNextTab, index, data }) => { }, {}); const onSubmit = async (data) => { - console.log(data); + delete data.table; + setIsLoading(true); - // console.log(data); - - // console.log(); - const updatedMinAmount = values?.map(({id, value, _id})=>{ return { id:_id, @@ -660,16 +505,18 @@ const IODetails = ({ enableNextTab, index, data }) => { } }) + // console.log(formatDateToYYYYMMDD(data.closingDate)); const formData = { ...data, investmentType_xid: Number(data.investmentType), sponsor_xid: Number(data.sponserName), - minInvestmentAmt:updatedMinAmount + minInvestmentAmt:updatedMinAmount, + closingDate: formatDateToYYYYMMDD(data.closingDate) }; - // console.log(formData); // console.log(formData); if (id) { + console.log("========================",formData); const res = await updateIO({ data: formData, id }); console.log(res); if (res?.data?.statusCode === 200) { @@ -692,6 +539,7 @@ const IODetails = ({ enableNextTab, index, data }) => { } } else { try { + console.log("========================",formData); const res = await creatIO(formData); console.log(res?.error?.status); if (res?.data?.statusCode === 200) { diff --git a/src/Routes/Nav.js b/src/Routes/Nav.js index c581df5..e32d493 100644 --- a/src/Routes/Nav.js +++ b/src/Routes/Nav.js @@ -223,11 +223,11 @@ export const nav = [ path: "/contact", icon: LuContact, }, - { - title: "Users", - path: "/users", - icon: RiFileUserLine, - }, + // { + // title: "Users", + // path: "/users", + // icon: RiFileUserLine, + // }, { title: "Bank Details", path: "/bank-details", diff --git a/src/Routes/Routes.js b/src/Routes/Routes.js index dce9d96..519daaa 100644 --- a/src/Routes/Routes.js +++ b/src/Routes/Routes.js @@ -116,8 +116,8 @@ export const RouteLink = [ // { path: "/contact", Component: UnderConstruction }, // { path: "/users", Component: Users }, { path: "/email", Component: EmailNotification }, - { path: "/users", Component: User }, - { path: "/users/add-user", Component: AddUser }, + // { path: "/users", Component: User }, + // { path: "/users/add-user", Component: AddUser }, { path: "/bank-details", Component: BankDetails }, // { path: "/bank-details", Component: UnderConstruction }, { path: "/bank-details/edit-bank-details/:id", Component: EditBankDetails },