diff --git a/web/src/features/dialog/InputDialog.tsx b/web/src/features/dialog/InputDialog.tsx index add0bc8..f2c3c61 100644 --- a/web/src/features/dialog/InputDialog.tsx +++ b/web/src/features/dialog/InputDialog.tsx @@ -7,12 +7,15 @@ import { ModalBody, Box, Input, + InputGroup, + InputRightElement, Text, Button, Checkbox, Select, } from "@chakra-ui/react"; import React from "react"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useNuiEvent } from "../../hooks/useNuiEvent"; import { useLocales } from "../../providers/LocaleProvider"; import { debugData } from "../../utils/debugData"; @@ -26,6 +29,7 @@ interface Props { type: RowType; label: string; options?: { value: string; label: string }[]; + password?: boolean; }[]; } @@ -37,7 +41,7 @@ debugData([ rows: [ { type: "input", label: "Locker number" }, { type: "checkbox", label: "Some checkbox" }, - { type: "input", label: "Locker PIN" }, + { type: "input", label: "Locker PIN", password: true }, { type: "checkbox", label: "Some other checkbox" }, { type: "select", @@ -62,7 +66,15 @@ const InputDialog: React.FC = () => { const [visible, setVisible] = React.useState(false); const { locale } = useLocales(); + const [passwordStates, setPasswordStates] = React.useState>([]); + const handlePasswordStates = (index: number) => { + setPasswordStates({ + ...passwordStates, [index]: !passwordStates[index] + }) + } + useNuiEvent("openDialog", (data) => { + setPasswordStates([]); setFields(data); setInputData([]); setVisible(true); @@ -104,9 +116,26 @@ const InputDialog: React.FC = () => { {row.type === "input" && ( {row.label} - handleChange(e.target.value, index)} - /> + + handleChange(e.target.value, index)} + type={!row.password || passwordStates[index] ? "text" : "password"} + /> + {row.password && ( + handlePasswordStates(index)} + children={ + + } + /> + )} + )} {row.type === "checkbox" && (