|
@@ -1,7 +1,27 @@
|
|
|
-import React from 'react';
|
|
|
|
|
|
|
+import React, { useState } from 'react';
|
|
|
import "./css/landingpage.css";
|
|
import "./css/landingpage.css";
|
|
|
|
|
|
|
|
export default function LandingPage({ message, newGame, joinGame }) {
|
|
export default function LandingPage({ message, newGame, joinGame }) {
|
|
|
|
|
+ const [showCodeInput, setShowCodeInput] = useState(false);
|
|
|
|
|
+ const [code, setCode] = useState("");
|
|
|
|
|
+
|
|
|
|
|
+ function handleCodeChange(e) {
|
|
|
|
|
+ const value = e.target.value;
|
|
|
|
|
+ if (value.length > 4) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (value === "") {
|
|
|
|
|
+ setCode(value);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const parsedCode = parseInt(e.target.value);
|
|
|
|
|
+ if (isNaN(parsedCode)) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ setCode(parsedCode)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
return <div className="landing-page row h-100 align-content-center justify-content-center flex-md-column">
|
|
return <div className="landing-page row h-100 align-content-center justify-content-center flex-md-column">
|
|
|
<button className="btn btn-primary mb-5" onClick={newGame}>Start een nieuw spel</button>
|
|
<button className="btn btn-primary mb-5" onClick={newGame}>Start een nieuw spel</button>
|
|
|
{showCodeInput ?
|
|
{showCodeInput ?
|