import { Box, Button, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerFooter, DrawerHeader, DrawerOverlay, FormControl, FormErrorMessage, FormLabel, Input, Stack, Textarea, useToast, } from "@chakra-ui/react"; import * as yup from "yup"; import React, { useState, useEffect } 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 { useCreateVideoArtifactsMutation, useUpdateVideoArtifactsMutation } from "../../../Services/io.service"; import { useParams } from "react-router-dom"; import ToastBox from "../../../Components/ToastBox"; const investmentVideoSchema = yup.object().shape({ transactionDate: yup.string().required("Artifact name is required"), ioTransType_xid: yup.number().required("Artifact name is required"), transactionAmount: yup.number().required("Artifact name is required"), comments: yup.string().notRequired(), }); const AddCashDetails = ({ 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(); const found = data?.find((item) => item?.id === actionId); console.log(found); const [ createArtifactsVideo ] = useCreateVideoArtifactsMutation() const [ updateVideoArtifacts ] = useUpdateVideoArtifactsMutation() // const { // data // } = useGetArtifactsQuery(id) const { control, handleSubmit, watch, reset, formState: { errors }, } = useForm({ resolver: yupResolver(investmentVideoSchema), }); const onSubmit = async (data) => { console.log(data); // setIsLoading(true) // try { // if (found) { // const res = await updateVideoArtifacts({data, id: found?.id}) // if (res?.data?.statusCode === 200) { // toast({ // render: () => , // }); // setAlert(false); // setIsLoading(false) // handleClose(); // } // } else { // const res = await createArtifactsVideo({data, id}) // if (res?.data?.statusCode === 200) { // toast({ // render: () => , // }); // setAlert(false); // setIsLoading(false) // handleClose(); // } // } // } catch (error) { // console.log(error); // } }; const handleConfirm = () => { handleSubmit(onSubmit)(); }; const handleSave = () => { handleSubmit(onSubmit)(); }; const handleClose = () => { onClose() reset() } return ( <> IO Cash Details Date Selection ( )} /> {errors.transactionDate?.message} Cash transaction ( )} /> {errors.ioTransType_xid?.message} Transaction Amount ( )} /> {errors.transactionAmount?.message} Comments (