1
0
Fork 0

make TOTPNew page hide input boxes in QR mode

This commit is contained in:
ChaotiCryptidz 2022-01-22 11:56:00 +00:00
parent 222512af05
commit 8132de764d

View file

@ -32,7 +32,7 @@ export class TOTPNewForm extends Component<
}
errorMessageRef = createRef<ErrorMessage>();
uriInputRef = createRef<HTMLInputElement>();
nameInputRef = createRef<HTMLInputElement>();
async onSubmit(data: FormData): Promise<void> {
const parms = {
@ -56,6 +56,7 @@ export class TOTPNewForm extends Component<
<Form onSubmit={(data) => this.onSubmit(data)}>
<Margin>
<input
ref={this.nameInputRef}
class="uk-input uk-form-width-medium"
name="name"
type="text"
@ -64,8 +65,10 @@ export class TOTPNewForm extends Component<
/>
</Margin>
<p hidden={this.state.qrMode}>{i18next.t("totp_new_info")}</p>
{!this.state.qrMode && <p>{i18next.t("totp_new_info")}</p>}
{!this.state.qrMode && (
<>
<Margin>
<input
class="uk-input uk-form-width-medium"
@ -79,20 +82,23 @@ export class TOTPNewForm extends Component<
<Margin>
<input
class="uk-input uk-form-width-medium"
ref={this.uriInputRef}
name="uri"
type="text"
hidden={this.state.qrMode}
placeholder={i18next.t("totp_new_uri_input")}
/>
</Margin>
{/* TODO: please redo this to be more like Unseal page qr mode */}
</>
)}
{this.state.qrMode && (
<QRScanner
onScan={(uri) => {
this.uriInputRef.current.value = uri;
let formData = new FormData();
formData.set("key", "");
formData.set("name", this.nameInputRef.current.value)
formData.set("uri", uri);
this.onSubmit(formData);
this.setState({ qrMode: !this.state.qrMode });
}}
/>