basic components and schema added

This commit is contained in:
Wenszel
2021-03-13 16:01:03 +01:00
parent 5e52ff6fe4
commit 3b6fa7eab6
7 changed files with 79 additions and 2 deletions
+2 -1
View File
@@ -1,9 +1,10 @@
import './App.css';
import NameInput from './components/NameInput';
function App() {
return (
<div>
Hello World!
<NameInput></NameInput>
</div>
);
}
+6
View File
@@ -0,0 +1,6 @@
import React from 'react';
const GameBoard = () => {
}
export default GameBoard
+30
View File
@@ -0,0 +1,30 @@
import React, { useState } from 'react';
const NameInput = ()=>{
const [inputValue, setInputValue] = useState('');
const handleInputChange = (e) => {
setInputValue(e.target.value);
}
const handleButtonClick = () => {
const request = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: inputValue })
};
fetch('localhost:3000/adduser', request)
.then(response => {
if(response.status == 200){
//redirect
}else{
//error
}
});
}
return(
<div>
<input placeholder = "Podaj swoje imię" type="text" onChange={handleInputChange}/>
<input type="submit" onClick={handleButtonClick}/>
</div>
)
}
export default NameInput;
+15
View File
@@ -0,0 +1,15 @@
import React, { useEffect } from 'react';
const Navbar = () => {
const [names, setNames] = useState([]);
useEffect(
//fetching names, time and other data
);
return(
<div>
{names.map((name)=>{
<h1>{name}</h1>
})}
</div>
);
}