import {
Box,
Button,
Drawer,
DrawerBody,
DrawerCloseButton,
DrawerContent,
DrawerFooter,
DrawerHeader,
DrawerOverlay,
FormControl,
FormHelperText,
FormLabel,
Input,
Text,
useDisclosure,
} from "@chakra-ui/react";
import React, { useContext, useRef, useState, useEffect } from "react";
import { FiEdit3 } from "react-icons/fi";
import { BiMessageSquareEdit } from "react-icons/bi";
import { TbEdit } from "react-icons/tb";
import GlobalStateContext from "../../Contexts/GlobalStateContext";
import { AddIcon } from "@chakra-ui/icons";
// Convert date to YYYY-MM-DD format
const formatDateValue = (date) => {
if (!date) return "";
const d = new Date(date);
let month = "" + (d.getMonth() + 1);
let day = "" + d.getDate();
const year = d.getFullYear();
if (month.length < 2) month = "0" + month;
if (day.length < 2) day = "0" + day;
return [year, month, day].join("-");
};
const AddIOCharges = ({ setCharges, charges }) => {
const btnRef = useRef();
const { isOpen, onOpen, onClose } = useDisclosure();
const [chargeTitle, setChargeTitle] = useState("");
const [chargeValue, setChargeValue] = useState(0.0);
const handleSave = () => {
setCharges([
...charges,
{
title: chargeTitle,
value: chargeValue,
},
]);
setChargeTitle("");
setChargeValue("");
setTimeout(() => {
onClose();
}, 100);
};
return (
<>
}
ref={btnRef}
onClick={onOpen}
// colorScheme="forestGreen"
color={"green.500"}
size={"xs"}
// variant={"ghost"}
rounded={"md"}
ms={"auto"}
>
Add Charges
Add charges
Charge title
setChargeTitle(e.target.value)}
fontSize={"sm"}
type="text"
size={"sm"}
placeholder="Charge title"
/>
Charge value
setChargeValue(e.target.value)}
fontSize={"sm"}
type="number"
size={"sm"}
placeholder="00.00$"
/>
Please enter value in Dollars
>
);
};
export default AddIOCharges;