|
1 |
| -import { useState } from 'react' |
2 |
| -import reactLogo from './assets/react.svg' |
3 |
| -import viteLogo from '/vite.svg' |
| 1 | +import { useRef, useState } from 'react' |
4 | 2 | import './App.css'
|
| 3 | +import { tier, decodeTier } from './tiers' |
| 4 | +import Header from './Header'; |
| 5 | +import BadCode from './BadCode'; |
5 | 6 |
|
6 | 7 | function App() {
|
7 |
| - const [count, setCount] = useState(0) |
| 8 | + const codeInput = useRef<HTMLInputElement>(null) |
| 9 | + const [currentTier, setCurrentTier] = useState<tier | null>(null); |
| 10 | + |
| 11 | + function updateTier() { |
| 12 | + var code = codeInput.current?.value || null |
| 13 | + if(!code) { |
| 14 | + setCurrentTier(null) |
| 15 | + return |
| 16 | + } |
| 17 | + |
| 18 | + var tier = decodeTier(code) |
| 19 | + if(!tier) { |
| 20 | + setCurrentTier(null) |
| 21 | + return |
| 22 | + } |
| 23 | + |
| 24 | + setCurrentTier(tier) |
| 25 | + } |
8 | 26 |
|
9 | 27 | return (
|
10 | 28 | <>
|
11 |
| - <div> |
12 |
| - <a href="https://vitejs.dev" target="_blank"> |
13 |
| - <img src={viteLogo} className="logo" alt="Vite logo" /> |
14 |
| - </a> |
15 |
| - <a href="https://react.dev" target="_blank"> |
16 |
| - <img src={reactLogo} className="logo react" alt="React logo" /> |
17 |
| - </a> |
18 |
| - </div> |
19 |
| - <h1>Vite + React</h1> |
20 |
| - <div className="card"> |
21 |
| - <button onClick={() => setCount((count) => count + 1)}> |
22 |
| - count is {count} |
23 |
| - </button> |
24 |
| - <p> |
25 |
| - Edit <code>src/App.tsx</code> and save to test HMR |
26 |
| - </p> |
| 29 | + <Header inputRef={codeInput} updateFun={updateTier} /> |
| 30 | + |
| 31 | + <div className='centered-display'> |
| 32 | + {!currentTier ? <BadCode /> : <div> |
| 33 | + <span>{JSON.stringify(currentTier, null, 4)}</span> |
| 34 | + </div>} |
27 | 35 | </div>
|
28 |
| - <p className="read-the-docs"> |
29 |
| - Click on the Vite and React logos to learn more |
30 |
| - </p> |
31 | 36 | </>
|
32 | 37 | )
|
33 | 38 | }
|
|
0 commit comments