test request
This commit is contained in:
parent
f7a8c9e077
commit
a401290920
@ -48,6 +48,24 @@ export const Journal = () => {
|
|||||||
check();
|
check();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const [answer, setAnswer] = useState(null);
|
||||||
|
|
||||||
|
const send = async () => {
|
||||||
|
if (keycloak.authenticated) {
|
||||||
|
keycloak;
|
||||||
|
const rq = await fetch(`${getConfigValue("journal.back.url")}/test`, {
|
||||||
|
headers: {
|
||||||
|
accept: "application/json",
|
||||||
|
authorization: `Bearer ${keycloak.token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const data = await rq.json();
|
||||||
|
setAnswer(data);
|
||||||
|
} else {
|
||||||
|
setAnswer({ message: 'Пользователь не авторизован' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const [value, setValue] = useState("");
|
const [value, setValue] = useState("");
|
||||||
const handleChange = useCallback(
|
const handleChange = useCallback(
|
||||||
(event) => {
|
(event) => {
|
||||||
@ -70,6 +88,10 @@ export const Journal = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<StartWrapper>
|
<StartWrapper>
|
||||||
|
<IconButton onClick={send} title="Запрос">
|
||||||
|
<ArrowImg src={arrow} />
|
||||||
|
</IconButton>
|
||||||
|
<pre>{JSON.stringify(answer, null, 4)}</pre>
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<InputWrapper>
|
<InputWrapper>
|
||||||
<InputLabel htmlFor="input">Название новой лекции:</InputLabel>
|
<InputLabel htmlFor="input">Название новой лекции:</InputLabel>
|
||||||
|
@ -64,12 +64,10 @@ const Input = ({ onStart }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const MainPage = () => {
|
export const MainPage = () => {
|
||||||
const [shoList, setShoList] = useState(false);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MainWrapper>
|
<MainWrapper>
|
||||||
{!shoList && <Input onStart={() => setShoList(true)} />}
|
{/* {!shoList && <Input onStart={() => setShoList(true)} />} */}
|
||||||
{shoList && <Journal />}
|
<Journal />
|
||||||
</MainWrapper>
|
</MainWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user