import { Col, Grid, NumberInput, Select } from "@mantine/core"; import { useEffect, useState } from "react"; import { byteToUnitAndSize, unitAndSizeToByte, } from "../../utils/fileSize.util"; const FileSizeInput = ({ label, value, onChange, }: { label: string; value: number; onChange: (number: number) => void; }) => { const [unit, setUnit] = useState("MB"); const [size, setSize] = useState(100); useEffect(() => { const { unit, size } = byteToUnitAndSize(value); setUnit(unit); setSize(size); }, [value]); return ( { if (value) { setSize(value); onChange(unitAndSizeToByte(unit, value)); } }} />