import React, { useState, useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import { Label, Input } from "reactstrap"; import Select from "react-select"; import { useTranslation } from "react-i18next"; import { getMcfTypes } from "../../redux/actions/datas"; const DataUpdateSolidWaste = ({ editingDataInput, setEditingDataInput }) => { const { t } = useTranslation(); const dispatch = useDispatch(); const datasStore = useSelector((state) => state.datas); const [mcfTypesOptions, setMcfTypesOptions] = useState([]); useEffect(() => { setMcfTypesOptions( datasStore?.mcfTypes?.map((mcfType) => { return { value: mcfType?.id, label: `${mcfType?.typeName} (${mcfType?.value})`, }; }) ); }, [datasStore?.mcfTypes]); useEffect(() => { dispatch(getMcfTypes()); }, []); let solidWasteTypes = [ { label: "Evsel", value: "domestic" }, { label: "Bahçe", value: "garden" }, { label: "Kağıt", value: "paper" }, { label: "Ağaç", value: "tree" }, { label: "Tekstil", value: "textile" }, { label: "Endüstriyel", value: "industrial" }, ]; return ( <>
{solidWasteTypes.map((type, index) => (
{ const inputValue = e.target.value; const onlyNumbers = inputValue.replace(/[^0-9]/g, ""); const parsedNumber = Math.min( 100, Math.max(0, parseInt(onlyNumbers, 10)) ); setEditingDataInput({ ...editingDataInput, [type.value]: { ...editingDataInput?.[type.value], inputValue: parsedNumber, }, }); }} onKeyDown={(e) => { if (e.key === "e" || e.key === "E") { e.preventDefault(); } }} />
))}
{ const inputValue = e.target.value; const onlyNumbers = inputValue.replace(/[^0-9]/g, ""); const parsedNumber = Math.min( 100, Math.max(0, parseInt(onlyNumbers, 10)) ); setEditingDataInput({ ...editingDataInput, frec: parsedNumber, }); }} onKeyDown={(e) => { if (e.key === "e" || e.key === "E") { e.preventDefault(); } }} />
); }; export default DataUpdateSolidWaste;