From f7a8da789ca83168a117cf43708eef968b814f63 Mon Sep 17 00:00:00 2001 From: "Siddhesh.More" Date: Mon, 12 Aug 2024 15:35:39 +0530 Subject: [PATCH] update --- src/Pages/Dashbaord.jsx | 8 +- src/Pages/IO_Management/CreateIO/AddIONav.jsx | 234 ++++++++++++++++++ .../IO_Management/CreateIO/IONAVDetails.jsx | 95 +++++-- src/Pages/IO_Management/IOArtifactsAdd.jsx | 5 +- src/Pages/IO_Management/KeyMeritsAdd.jsx | 2 +- .../ViewIO/HeaderModal/UpdateIONav.jsx | 6 +- .../ViewIO/HeaderModal/UpdateIOStatus.jsx | 47 +++- .../IO_Management/ViewIO/ViewIOTable.jsx | 25 +- .../IO_Management/ViewIO/ViewIOdataHeader.jsx | 35 +-- 9 files changed, 392 insertions(+), 65 deletions(-) create mode 100644 src/Pages/IO_Management/CreateIO/AddIONav.jsx diff --git a/src/Pages/Dashbaord.jsx b/src/Pages/Dashbaord.jsx index 5f71e43..dda5aeb 100644 --- a/src/Pages/Dashbaord.jsx +++ b/src/Pages/Dashbaord.jsx @@ -126,12 +126,12 @@ const Dashbaord = () => { - + - Exchange rate currency - - {/* */} + {/* Exchange rate currency + */} + diff --git a/src/Pages/IO_Management/CreateIO/AddIONav.jsx b/src/Pages/IO_Management/CreateIO/AddIONav.jsx new file mode 100644 index 0000000..ad7c533 --- /dev/null +++ b/src/Pages/IO_Management/CreateIO/AddIONav.jsx @@ -0,0 +1,234 @@ +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 CustomAlertDialog from "../../../Components/CustomAlertDialog"; + import { v4 as uuidv4 } from "uuid"; + import { useCreateIoCashMutation, useCreateIoNavMutation, useCreateVideoArtifactsMutation, useUpdateVideoArtifactsMutation } from "../../../Services/io.service"; + import { useParams } from "react-router-dom"; + import ToastBox from "../../../Components/ToastBox"; + import GlobalStateContext from "../../../Contexts/GlobalStateContext"; + import CurrencyInput from "../../../Components/CurrencyInput"; +import { formatDatee } from "../../../Components/FormField"; + + const ioNav = yup.object().shape({ + transactionDate: yup.string().required("Artifact name is required"), + transactionAmount: yup.number().required("Artifact name is required"), + comments: yup.string().notRequired(), + }); + + const AddIONav = ({ 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 [createIoNav] = useCreateIoNavMutation() + // const { + // data + // } = useGetArtifactsQuery(id) + + const { + control, + handleSubmit, + watch, + reset, + formState: { errors }, + } = useForm({ + resolver: yupResolver(ioNav), + }); + + + const [createIoCash] = useCreateIoCashMutation() + + + const onSubmit = async (data) => { + + setIsLoading(true) + + try { + + const res = await createIoNav({ data, id }) + if (res?.data?.statusCode === 201) { + setIsLoading(false); + toast({ + render: () => , + }); + handleClose() + }else if(res?.error?.status === 400){ + setIsLoading(false); + toast({ + render: () => , + }); + } + + + } catch (error) { + console.log(error); + + } + + }; + + + + const handleConfirm = () => { + handleSubmit(onSubmit)(); + }; + + const handleSave = () => { + handleSubmit(onSubmit)(); + }; + + const handleClose = () => { + setAlert(false) + onClose() + reset({ + transactionDate:"", + transactionAmount:"", + comments:"" + }) + } + + + + +const today = formatDatee(new Date(), 'yyyy-MM-dd'); + + + + return ( + <> + + + + + IO Nav Details + + + + + Date Selection + ( + + )} + /> + + {errors.transactionDate?.message} + + + + + + + Transaction Amount + ( + + )} + /> + + {errors.transactionAmount?.message} + + + + + + + Comments + ( +