mirror of
https://github.com/openziti/zrok.git
synced 2024-12-22 14:50:55 +01:00
better idiom (#221)
This commit is contained in:
parent
569dfce1ce
commit
2770090d84
@ -3,6 +3,7 @@ import {useFormik} from "formik";
|
||||
import {GetAgentApi} from "./model/api.ts";
|
||||
import {Box, Button, Modal, TextField, Typography} from "@mui/material";
|
||||
import {modalStyle} from "./model/theme.ts";
|
||||
import * as React from "react";
|
||||
|
||||
interface NewAccessModalProps {
|
||||
close: () => void;
|
||||
@ -10,7 +11,7 @@ interface NewAccessModalProps {
|
||||
}
|
||||
|
||||
const NewAccessModal = ({ close, isOpen }: NewAccessModalProps) => {
|
||||
const [errorMessage, setErrorMessage] = useState(<></>);
|
||||
const [errorMessage, setErrorMessage] = useState(null as React.JSX.Element);
|
||||
|
||||
const newAccessForm = useFormik({
|
||||
initialValues: {
|
||||
@ -18,14 +19,14 @@ const NewAccessModal = ({ close, isOpen }: NewAccessModalProps) => {
|
||||
bindAddress: "",
|
||||
},
|
||||
onSubmit: v => {
|
||||
setErrorMessage(<></>);
|
||||
setErrorMessage(null as React.JSX.Element);
|
||||
GetAgentApi().agentAccessPrivate(v)
|
||||
.then(r => {
|
||||
close();
|
||||
})
|
||||
.catch(e => {
|
||||
e.response.json().then(ex => {
|
||||
setErrorMessage(<p>{ex.message}</p>);
|
||||
setErrorMessage(<span>{ex.message}</span>);
|
||||
console.log(ex.message);
|
||||
})
|
||||
});
|
||||
@ -38,7 +39,7 @@ const NewAccessModal = ({ close, isOpen }: NewAccessModalProps) => {
|
||||
<Typography>
|
||||
<h2>Access...</h2>
|
||||
</Typography>
|
||||
{errorMessage}
|
||||
<Typography color={"red"}><h3>{errorMessage}</h3></Typography>
|
||||
<form onSubmit={newAccessForm.handleSubmit}>
|
||||
<TextField
|
||||
fullWidth
|
||||
|
@ -3,6 +3,7 @@ import {GetAgentApi} from "./model/api.ts";
|
||||
import {useState} from "react";
|
||||
import {Box, Button, Checkbox, FormControlLabel, MenuItem, Modal, TextField, Typography} from "@mui/material";
|
||||
import {modalStyle} from "./model/theme.ts";
|
||||
import * as React from "react";
|
||||
|
||||
interface NewShareModalProps {
|
||||
close: () => void;
|
||||
@ -10,7 +11,7 @@ interface NewShareModalProps {
|
||||
}
|
||||
|
||||
const NewShareModal = ({ close, isOpen }: NewShareModalProps) => {
|
||||
const [errorMessage, setErrorMessage] = useState(<></>);
|
||||
const [errorMessage, setErrorMessage] = useState(null as React.JSX.Element);
|
||||
|
||||
const form = useFormik({
|
||||
initialValues: {
|
||||
@ -20,7 +21,7 @@ const NewShareModal = ({ close, isOpen }: NewShareModalProps) => {
|
||||
insecure: false,
|
||||
},
|
||||
onSubmit: v => {
|
||||
setErrorMessage(<></>);
|
||||
setErrorMessage(null as React.JSX.Element);
|
||||
switch(v.shareMode) {
|
||||
case "public":
|
||||
GetAgentApi().agentSharePublic(v)
|
||||
@ -29,7 +30,7 @@ const NewShareModal = ({ close, isOpen }: NewShareModalProps) => {
|
||||
})
|
||||
.catch(e => {
|
||||
e.response().json().then(ex => {
|
||||
setErrorMessage(<p>{ex.message}</p>);
|
||||
setErrorMessage(<span>{ex.message}</span>);
|
||||
console.log(ex.message);
|
||||
})
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user