Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions frontend/src/components/createUser.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export default function CreateUser() {
function onSubmission(event){

var firstName = event.target.elements.firstName.value;
var lastName = event.target.elements.lastName.value;
console.log(firstName);
console.log(lastName);
var fullName = event.target.elements.fullName.value;
var email = event.target.elements.email.value;
console.log(fullName);
console.log(email);

fetch("https://jsonplaceholder.typicode.com/users", {
method: "POST",
body: JSON.stringify({
firstName,
lastName,
fullName,
email,
}),
headers: {
"Content-type": "application/json; charset=UTF-8",
Expand All @@ -28,12 +28,12 @@ export default function CreateUser() {
<br/>
<form onSubmit={onSubmission}>
<div className="mb-3">
<label className="form-label">First Name</label>
<input type="text" className="form-control" id="firstName"/>
<label className="form-label">Full Name</label>
<input type="text" className="form-control" id="fullName"/>
</div>
<div className="mb-3">
<label className="form-label">Last Name</label>
<input type="text" className="form-control" id="lastName"/>
<label className="form-label">Email</label>
<input type="text" className="form-control" id="email"/>
</div>
<button type="submit" className="btn btn-primary">Submit</button>
</form>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/user.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export default function User({id,firstName,lastName}) {
export default function User({id,fullName,email}) {
return (
<tr>
<th scope="row">{id}</th>
<td>{firstName}</td>
<td>{lastName}</td>
<td>{fullName}</td>
<td>{email}</td>
<td>
<span class="badge rounded-pill text-bg-primary">Go</span>
<span class="badge rounded-pill text-bg-secondary">Python</span>
Expand Down
47 changes: 22 additions & 25 deletions frontend/src/components/userlist.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React, { useState, useEffect } from 'react';
import User from "./user";

export default function UserList() {

const [data, setData] = useState([]);

function reloadUserList(event){
console.log(event);
fetch("https://jsonplaceholder.typicode.com/users", {
Expand All @@ -13,41 +16,35 @@ export default function UserList() {
.then(response => response.json())
.then(data => {
console.log(data);
setData(data);
alert(JSON.stringify(data));
})
};

return (


<div>
<br/>
<h3>User List</h3>

<br/>

<form onSubmit={reloadUserList}>
<button type="submit" className="btn btn-dark">Relod Users</button>
</form>

<button type="simpleQuery" className="btn btn-dark" onClick={reloadUserList}>Reload User List</button>
<br/>
<table class="table">
<thead>
<tr>
<th scope="col">#ID</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Skills</th>
</tr>
</thead>
<tbody>
<User id="1" firstName="Tom" lastName="Victor" />
{/* <User />
<User />
<User />
<User /> */}
</tbody>
</table>
<table class="table">
<thead>
<tr>
<th scope="col">#ID</th>
<th scope="col">Full Name</th>
<th scope="col">Email</th>
<th scope="col">Skills</th>
</tr>
</thead>
<tbody>
{
data.map((item)=>(
<User id={item.id} fullName={item.name} email={item.email} />
))
}
</tbody>
</table>
</div>


Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func main() {
})
})

r.Use(static.Serve("/", static.LocalFile("./skillmap/build", true)))
r.Use(static.Serve("/", static.LocalFile("./frontend/build", true)))

r.Run() // listen and serve on 0.0.0.0:8080
}