diff --git a/web/src/components/App.tsx b/web/src/components/App.tsx index 132c6b5..d353cc2 100644 --- a/web/src/components/App.tsx +++ b/web/src/components/App.tsx @@ -2,6 +2,7 @@ import Notifications from "./Notifications"; import CircleProgressbar from "./CircleProgressbar"; import Progressbar from "./Progressbar"; import TextUI from "./TextUI"; +import InputDialog from "./InputDialog"; const App: React.FC = () => { return ( @@ -10,6 +11,7 @@ const App: React.FC = () => { + ); }; diff --git a/web/src/components/InputDialog.tsx b/web/src/components/InputDialog.tsx new file mode 100644 index 0000000..c6a1365 --- /dev/null +++ b/web/src/components/InputDialog.tsx @@ -0,0 +1,101 @@ +import { + Modal, + ModalOverlay, + ModalContent, + ModalFooter, + ModalHeader, + ModalBody, + Box, + Input, + Text, + Button, +} from "@chakra-ui/react"; +import React from "react"; +import { useNuiEvent } from "../hooks/useNuiEvent"; +import { debugData } from "../utils/debugData"; +import { fetchNui } from "../utils/fetchNui"; + +interface Props { + heading: string; + inputs: string[]; +} + +// debugData([ +// { +// action: "openDialog", +// data: { +// heading: "Police locker", +// inputs: ["Locker number", "Locker PIN"], +// }, +// }, +// ]); + +const InputDialog: React.FC = () => { + const [inputOptions, setInputOptions] = React.useState({ + heading: "", + inputs: [""], + }); + const [inputData, setInputData] = React.useState([]); + const [visible, setVisible] = React.useState(false); + + useNuiEvent("openDialog", (data) => { + setInputOptions(data); + setVisible(true); + }); + + const handleClose = () => { + setVisible(false); + fetchNui("inputData"); + }; + + const handleChange = ( + e: React.ChangeEvent, + index: number + ) => { + setInputData((previousData) => { + previousData[index] = e.target.value; + return previousData; + }); + }; + + const handleConfirm = () => { + setVisible(false); + fetchNui("inputData", inputData); + }; + + return ( + <> + + + + {inputOptions.heading} + + {inputOptions.inputs.map((input: string, index: number) => ( + + {input} + handleChange(e, index)} /> + + ))} + + + + + + + + + ); +}; + +export default InputDialog;