-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
44 lines (37 loc) · 863 Bytes
/
App.tsx
File metadata and controls
44 lines (37 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { useState } from 'react'
import Assessment from './Assessment'
import Home from './Home'
function App() {
const [page, setPage] = useState<'home' | 'assessment'>('home')
const [name, setName] = useState('')
const [solution, setSolution] = useState('')
const [error, setError] = useState('')
const handleStart = () => {
const trimmedName = name.trim()
if (!trimmedName) {
setError('Enter name')
return
}
setError('')
console.log(trimmedName)
setPage('assessment')
}
if (page === 'assessment') {
return (
<Assessment
solution={solution}
onSolutionChange={setSolution}
onBack={() => setPage('home')}
/>
)
}
return (
<Home
name={name}
error={error}
onNameChange={setName}
onStart={handleStart}
/>
)
}
export default App