-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.tsx
53 lines (47 loc) · 1.26 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React, { useState } from "react";
import { Input, Button } from "@nextui-org/react";
import useFetchWithMsal from "../../hooks/useFetchWithMsal.jsx";
import { loginRequest } from "../../authConfig.js";
const GetUserInfoForm = () => {
const BASE_URL = process.env.REACT_APP_BASE_URL;
const [netID, setNetID] = useState<string>("");
const { execute } = useFetchWithMsal(loginRequest);
const handleGetUser = async () => {
try {
execute(
"GET",
`${BASE_URL}/default/api/v1/get_user?netid=${netID}`,
null
).then((response) => {
console.log(response);
});
} catch (error) {
console.log(error);
}
};
const handleSubmit = (event) => {
if (netID !== "") {
event.preventDefault();
handleGetUser();
setNetID("");
}
};
return (
<div>
<p>Get User</p>
<form onSubmit={handleSubmit}>
<div className="flex flex-col m-2">
<div className="mb-2">
<Input
placeholder="NetID"
value={netID}
onChange={(event) => setNetID(event.target.value)}
/>
</div>
<Button type="submit">Submit</Button>
</div>
</form>
</div>
);
};
export default GetUserInfoForm;