basic components and schema added
This commit is contained in:
+2
-1
@@ -1,9 +1,10 @@
|
||||
import './App.css';
|
||||
import NameInput from './components/NameInput';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div>
|
||||
Hello World!
|
||||
<NameInput></NameInput>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
|
||||
const GameBoard = () => {
|
||||
|
||||
}
|
||||
export default GameBoard
|
||||
@@ -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;
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user