test request

This commit is contained in:
Primakov Alexandr Alexandrovich 2024-02-15 16:39:59 +03:00
parent f7a8c9e077
commit a401290920
2 changed files with 24 additions and 4 deletions

View File

@ -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>

View File

@ -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>
); );
}; };