diff options
| author | Nidboj132 <28981031+Nidboj132@users.noreply.github.com> | 2024-09-14 18:02:38 +0200 |
|---|---|---|
| committer | Nidboj132 <28981031+Nidboj132@users.noreply.github.com> | 2024-09-14 18:02:38 +0200 |
| commit | b0bddd40b9743f78d48a45ae802fbe4ac3a59961 (patch) | |
| tree | 932524a95b7510f1fe31ffbb356c3670e795b7e0 /frontend | |
| parent | refactor: unofficial rankings implementation (diff) | |
| download | lphub-b0bddd40b9743f78d48a45ae802fbe4ac3a59961.tar.gz lphub-b0bddd40b9743f78d48a45ae802fbe4ac3a59961.tar.bz2 lphub-b0bddd40b9743f78d48a45ae802fbe4ac3a59961.zip | |
refactor: rules
Diffstat (limited to 'frontend')
| -rw-r--r-- | frontend/src/App.tsx | 2 | ||||
| -rw-r--r-- | frontend/src/css/Rules.css | 3 | ||||
| -rw-r--r-- | frontend/src/pages/Rules.tsx | 37 |
3 files changed, 42 insertions, 0 deletions
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 095cbbe..3980e1b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx | |||
| @@ -11,6 +11,7 @@ import Maps from './pages/Maps'; | |||
| 11 | import User from './pages/User'; | 11 | import User from './pages/User'; |
| 12 | import Homepage from './pages/Homepage'; | 12 | import Homepage from './pages/Homepage'; |
| 13 | import UploadRunDialog from './components/UploadRunDialog'; | 13 | import UploadRunDialog from './components/UploadRunDialog'; |
| 14 | import Rules from './pages/Rules'; | ||
| 14 | import About from './pages/About'; | 15 | import About from './pages/About'; |
| 15 | import { Game } from './types/Game'; | 16 | import { Game } from './types/Game'; |
| 16 | import { API } from './api/Api'; | 17 | import { API } from './api/Api'; |
| @@ -59,6 +60,7 @@ const App: React.FC = () => { | |||
| 59 | <Route path="/games" element={<Games games={games} />} /> | 60 | <Route path="/games" element={<Games games={games} />} /> |
| 60 | <Route path='/games/:id' element={<Maplist />}></Route> | 61 | <Route path='/games/:id' element={<Maplist />}></Route> |
| 61 | <Route path="/maps/*" element={<Maps profile={profile} isModerator={isModerator} onUploadRun={(mapID) => {setUploadRunDialog(true);setUploadRunDialogMapID(mapID)}} />}/> | 62 | <Route path="/maps/*" element={<Maps profile={profile} isModerator={isModerator} onUploadRun={(mapID) => {setUploadRunDialog(true);setUploadRunDialogMapID(mapID)}} />}/> |
| 63 | <Route path="/rules" element={<Rules />} /> | ||
| 62 | <Route path="/about" element={<About />} /> | 64 | <Route path="/about" element={<About />} /> |
| 63 | <Route path='/rankings' element={<Rankings></Rankings>}></Route> | 65 | <Route path='/rankings' element={<Rankings></Rankings>}></Route> |
| 64 | <Route path="*" element={"404"} /> | 66 | <Route path="*" element={"404"} /> |
diff --git a/frontend/src/css/Rules.css b/frontend/src/css/Rules.css new file mode 100644 index 0000000..bbc84c0 --- /dev/null +++ b/frontend/src/css/Rules.css | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | main { | ||
| 2 | font-size: 24px; | ||
| 3 | } \ No newline at end of file | ||
diff --git a/frontend/src/pages/Rules.tsx b/frontend/src/pages/Rules.tsx new file mode 100644 index 0000000..516b73c --- /dev/null +++ b/frontend/src/pages/Rules.tsx | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | import React from 'react'; | ||
| 2 | import ReactMarkdown from 'react-markdown'; | ||
| 3 | |||
| 4 | import '../css/Rules.css'; | ||
| 5 | |||
| 6 | const Rules: React.FC = () => { | ||
| 7 | |||
| 8 | const [rulesText, setRulesText] = React.useState<string>(""); | ||
| 9 | |||
| 10 | React.useEffect(() => { | ||
| 11 | const fetchRules = async () => { | ||
| 12 | try { | ||
| 13 | const response = await fetch( | ||
| 14 | 'https://raw.githubusercontent.com/pektezol/leastportalshub/main/README.md' | ||
| 15 | ); | ||
| 16 | if (!response.ok) { | ||
| 17 | throw new Error('Failed to fetch README'); | ||
| 18 | } | ||
| 19 | const rulesText = await response.text(); | ||
| 20 | setRulesText(rulesText); | ||
| 21 | } catch (error) { | ||
| 22 | console.error('Error fetching Rules:', error); | ||
| 23 | } | ||
| 24 | setRulesText(rulesText) | ||
| 25 | }; | ||
| 26 | fetchRules(); | ||
| 27 | }, []); | ||
| 28 | |||
| 29 | |||
| 30 | return ( | ||
| 31 | <main> | ||
| 32 | <ReactMarkdown>{rulesText}</ReactMarkdown> | ||
| 33 | </main> | ||
| 34 | ); | ||
| 35 | }; | ||
| 36 | |||
| 37 | export default Rules; | ||