diff --git a/web/src/features/dialog/InputDialog.tsx b/web/src/features/dialog/InputDialog.tsx index 3ebd40e..a3e3521 100644 --- a/web/src/features/dialog/InputDialog.tsx +++ b/web/src/features/dialog/InputDialog.tsx @@ -13,7 +13,7 @@ import { useLocales } from "../../providers/LocaleProvider"; import { debugData } from "../../utils/debugData"; import { fetchNui } from "../../utils/fetchNui"; import { Row } from "../../interfaces/dialog"; - +import InputNumber from "./components/number"; import Input from "./components/input"; import CheckboxField from "./components/checkbox"; import SelectField from "./components/select"; @@ -42,6 +42,7 @@ interface Props { // { value: "option3", label: "Option 3" }, // ], // }, +// { type: "number", label: "Number counter" }, // ], // }, // }, @@ -52,7 +53,9 @@ const InputDialog: React.FC = () => { heading: "", rows: [{ type: "input", label: "" }], }); - const [inputData, setInputData] = React.useState>([]); + const [inputData, setInputData] = React.useState< + Array + >([]); const [passwordStates, setPasswordStates] = React.useState([]); const [visible, setVisible] = React.useState(false); @@ -77,7 +80,7 @@ const InputDialog: React.FC = () => { fetchNui("inputData"); }; - const handleChange = (value: string | boolean, index: number) => { + const handleChange = (value: string | number | boolean, index: number) => { setInputData((previousData) => { previousData[index] = value; return previousData; @@ -129,6 +132,13 @@ const InputDialog: React.FC = () => { handleChange={handleChange} /> )} + {row.type === "number" && ( + + )} ))} diff --git a/web/src/features/dialog/components/input.tsx b/web/src/features/dialog/components/input.tsx index 270f254..7ee7436 100644 --- a/web/src/features/dialog/components/input.tsx +++ b/web/src/features/dialog/components/input.tsx @@ -12,7 +12,7 @@ import { Row } from "../../../interfaces/dialog"; interface Props { row: Row; index: number; - handleChange: (value: string | boolean, index: number) => void; + handleChange: (value: string | number | boolean, index: number) => void; passwordStates: boolean[]; handlePasswordStates: (index: number) => void; } diff --git a/web/src/features/dialog/components/number.tsx b/web/src/features/dialog/components/number.tsx new file mode 100644 index 0000000..e5b138e --- /dev/null +++ b/web/src/features/dialog/components/number.tsx @@ -0,0 +1,33 @@ +import { + Box, + Text, + NumberInput, + NumberInputField, + NumberInputStepper, + NumberIncrementStepper, + NumberDecrementStepper, +} from "@chakra-ui/react"; +import { Row } from "../../../interfaces/dialog"; + +interface Props { + row: Row; + index: number; + handleChange: (value: string | number | boolean, index: number) => void; +} + +const InputNumber: React.FC = (props) => { + return ( + + {props.row.label} + props.handleChange(+e, props.index)}> + + + + + + + + ); +}; + +export default InputNumber; diff --git a/web/src/interfaces/dialog.ts b/web/src/interfaces/dialog.ts index b829624..8ec560c 100644 --- a/web/src/interfaces/dialog.ts +++ b/web/src/interfaces/dialog.ts @@ -1,6 +1,6 @@ import { IconProp } from "@fortawesome/fontawesome-svg-core"; -type RowType = "input" | "checkbox" | "select"; +type RowType = "input" | "checkbox" | "select" | "number"; export interface Row { type: RowType;