feat: add task creation board
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { FormEvent, useEffect, useRef, useState } from 'react'
|
||||
import TaskBoard from './TaskBoard'
|
||||
|
||||
type User = {
|
||||
id: string
|
||||
@ -55,19 +56,19 @@ function App() {
|
||||
setActiveUser(user)
|
||||
}
|
||||
|
||||
const switchUser = () => {
|
||||
const logOut = () => {
|
||||
window.localStorage.removeItem(ACTIVE_USER_KEY)
|
||||
setActiveUser(null)
|
||||
setShowCreateUser(false)
|
||||
}
|
||||
|
||||
if (loadState === 'loading') {
|
||||
return <main>Laddar HemHub…</main>
|
||||
return <main className="panel">Laddar HemHub…</main>
|
||||
}
|
||||
|
||||
if (loadState === 'error') {
|
||||
return (
|
||||
<main>
|
||||
<main className="panel">
|
||||
<h1>HemHub</h1>
|
||||
<p>Kunde inte ansluta till HemHub.</p>
|
||||
<button type="button" onClick={() => void loadUsers()}>
|
||||
@ -78,16 +79,7 @@ function App() {
|
||||
}
|
||||
|
||||
if (activeUser) {
|
||||
return (
|
||||
<main>
|
||||
<h1>HemHub</h1>
|
||||
<h2>Hej {activeUser.name}</h2>
|
||||
<p>Du är vald som aktiv användare.</p>
|
||||
<button type="button" onClick={switchUser}>
|
||||
Byt användare
|
||||
</button>
|
||||
</main>
|
||||
)
|
||||
return <TaskBoard activeUserName={activeUser.name} onLogOut={logOut} />
|
||||
}
|
||||
|
||||
if (showCreateUser) {
|
||||
@ -104,7 +96,7 @@ function App() {
|
||||
}
|
||||
|
||||
return (
|
||||
<main>
|
||||
<main className="panel">
|
||||
<h1>HemHub</h1>
|
||||
<h2>Vem är du?</h2>
|
||||
<div className="user-list">
|
||||
@ -183,7 +175,7 @@ function CreateUserForm({ hasExistingUsers, onCancel, onCreated }: CreateUserFor
|
||||
}
|
||||
|
||||
return (
|
||||
<main>
|
||||
<main className="panel">
|
||||
<h1>HemHub</h1>
|
||||
<h2>Skapa användare</h2>
|
||||
<form onSubmit={(event) => void submit(event)}>
|
||||
|
||||
Reference in New Issue
Block a user