]> git.localhorst.tv Git - alttp.git/commitdiff
more content variety
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 5 Jan 2023 22:27:54 +0000 (23:27 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 5 Jan 2023 22:27:54 +0000 (23:27 +0100)
resources/js/components/App.js
resources/js/components/pages/Techniques.js
resources/js/components/techniques/List.js
resources/js/components/techniques/Overview.js
resources/js/helpers/Technique.js
resources/js/i18n/de.js
resources/js/i18n/en.js
routes/api.php

index bea5c34516858a13a2860b7dc81e0a6e236baf0f..fe8ff25c31860b95b202355967852d3f2f352297 100644 (file)
@@ -59,8 +59,30 @@ const App = () => {
                                <Header doLogout={doLogout} />
                                <Routes>
                                        <Route path="h/:hash" element={<AlttpSeed />} />
-                                       <Route path="tech" element={<Techniques />} />
-                                       <Route path="tech/:name" element={<Technique />} />
+                                       <Route
+                                               path="modes"
+                                               element={<Techniques namespace="modes" type="mode" />}
+                                       />
+                                       <Route
+                                               path="modes/:name"
+                                               element={<Technique namespace="modes" type="mode" />}
+                                       />
+                                       <Route
+                                               path="rulesets"
+                                               element={<Techniques namespace="rulesets" type="ruleset" />}
+                                               />
+                                       <Route
+                                               path="rulesets/:name"
+                                               element={<Technique namespace="rulesets" type="ruleset" />}
+                                       />
+                                       <Route
+                                               path="tech"
+                                               element={<Techniques namespace="techniques" type="tech" />}
+                                       />
+                                       <Route
+                                               path="tech/:name"
+                                               element={<Technique namespace="techniques" type="tech" />}
+                                       />
                                        <Route path="tournaments/:id" element={<Tournament />} />
                                        <Route path="users/:id" element={<User />} />
                                        <Route path="/" element={<Front />} />
index c206a31b6fbb9bd33252054e977369b008667a15..4bc0066baefd69654ac06f4ed678fc24230f89f8 100644 (file)
@@ -1,4 +1,5 @@
 import axios from 'axios';
+import PropTypes from 'prop-types';
 import React from 'react';
 import { withTranslation } from 'react-i18next';
 
@@ -10,7 +11,7 @@ import Overview from '../techniques/Overview';
 import { compareTranslation } from '../../helpers/Technique';
 import i18n from '../../i18n';
 
-const Techniques = () => {
+const Techniques = ({ namespace, type }) => {
        const [error, setError] = React.useState(null);
        const [loading, setLoading] = React.useState(true);
        const [techniques, setTechniques] = React.useState([]);
@@ -18,11 +19,11 @@ const Techniques = () => {
        React.useEffect(() => {
                const ctrl = new AbortController();
                setLoading(true);
-               window.document.title = i18n.t('techniques.heading');
+               window.document.title = i18n.t(`${namespace}.heading`);
                axios
-                       .get(`/api/tech`, {
+                       .get(`/api/content`, {
                                params: {
-                                       type: 'tech',
+                                       type,
                                },
                                signal: ctrl.signal
                        })
@@ -39,12 +40,12 @@ const Techniques = () => {
                return () => {
                        ctrl.abort();
                };
-       }, []);
+       }, [namespace, type]);
 
        React.useEffect(() => {
-               window.document.title = i18n.t('techniques.heading');
+               window.document.title = i18n.t(`${namespace}.heading`);
                setTechniques(t => [...t].sort(compareTranslation('title', i18n.language)));
-       }, [i18n.language]);
+       }, [namespace, i18n.language]);
 
        if (loading) {
                return <Loading />;
@@ -59,8 +60,13 @@ const Techniques = () => {
        }
 
        return <ErrorBoundary>
-               <Overview techniques={techniques} />
+               <Overview namespace={namespace} techniques={techniques} />
        </ErrorBoundary>;
 };
 
+Techniques.propTypes = {
+       namespace: PropTypes.string,
+       type: PropTypes.string,
+};
+
 export default withTranslation()(Techniques);
index 0549cd38bc0642d981285388b98cb265129e5e2f..58f0eaef254a5c10ba118b92e5b471f8e5e31389 100644 (file)
@@ -2,14 +2,17 @@ import PropTypes from 'prop-types';
 import React from 'react';
 import { Link } from 'react-router-dom';
 
-import { getTranslation } from '../../helpers/Technique';
+import {
+       getLink,
+       getTranslation,
+} from '../../helpers/Technique';
 import i18n from '../../i18n';
 
 const List = ({ techniques }) => <ul className="tech-list">
        {techniques.map(tech =>
                <li key={tech.id}>
                        <h2>
-                               <Link to={`/tech/${tech.name}`}>
+                               <Link to={getLink(tech)}>
                                        {getTranslation(tech, 'title', i18n.language)}
                                </Link>
                        </h2>
index 8c7cd4db3e8b8725452779105d9454b7f29b537a..16868655b12fe473a2f7425415939504fa914a74 100644 (file)
@@ -6,12 +6,16 @@ import { withTranslation } from 'react-i18next';
 import List from './List';
 import i18n from '../../i18n';
 
-const Overview = ({ techniques }) => <Container>
-       <h1>{i18n.t('techniques.heading')}</h1>
+const Overview = ({
+       namespace,
+       techniques,
+}) => <Container>
+       <h1>{i18n.t(`${namespace}.heading`)}</h1>
        <List techniques={techniques} />
 </Container>;
 
 Overview.propTypes = {
+       namespace: PropTypes.string,
        techniques: PropTypes.arrayOf(PropTypes.shape({
        })),
 };
index 410f01595657de34f339d8c0f88b529bbdab316c..1a8f4fc91f0fe92d3bb874816340eab8d4be9ef6 100644 (file)
@@ -1,5 +1,15 @@
 import i18n from '../i18n';
 
+export const getLink = tech => {
+       if (tech.type === 'mode') {
+               return `/modes/${tech.name}`;
+       }
+       if (tech.type === 'ruleset') {
+               return `/rulesets/${tech.name}`;
+       }
+       return `/tech/${tech.name}`;
+};
+
 export const getRelations = (tech, type) => {
        const rs = (tech && tech.relations) || [];
        return type ? rs.filter(r => r && r.pivot && r.pivot.type === type) : rs;
index f3fbe96d5eeaa6e0133057254ef9d856bf60d546..e77d1de6bc8d03974984bbbebb356f1ddbe8bdd7 100644 (file)
@@ -371,6 +371,9 @@ export default {
                                somaria: 'Cane of Somaria',
                        },
                },
+               modes: {
+                       heading: 'Modi',
+               },
                participants: {
                        empty: 'Noch keine Teilnehmer eingetragen',
                        heading: 'Teilnehmer',
@@ -478,6 +481,9 @@ export default {
                        unlockError: 'Fehler beim Entsperren',
                        unlockSuccess: 'Runde entsperrt',
                },
+               rulesets: {
+                       heading: 'Regelsätze',
+               },
                techniques: {
                        heading: 'Techniken',
                        seeAlso: 'Siehe auch',
index 7088dd4b103dc413f146d2b1ccdfbef84c8efc7e..5a6695afdb6644a26909a2dd7f9f235fd3f6bb01 100644 (file)
@@ -371,6 +371,9 @@ export default {
                                somaria: 'Cane of Somaria',
                        },
                },
+               modes: {
+                       heading: 'Modes',
+               },
                participants: {
                        empty: 'No participants on record',
                        heading: 'Participants',
@@ -478,6 +481,9 @@ export default {
                        unlockError: 'Error unlocking round',
                        unlockSuccess: 'Round unlocked',
                },
+               rulesets: {
+                       heading: 'Rulesets',
+               },
                techniques: {
                        heading: 'Techniques',
                        seeAlso: 'See also',
index 0f7aa3e3febc80d330b6f6c948d0ff35a00e375e..4ec1bb1eab8bbec2e4a108d2235fa7a9e7613d25 100644 (file)
@@ -29,6 +29,9 @@ Route::post('aos-seed/{hash}/retry', 'App\Http\Controllers\AosSeedController@ret
 Route::post('application/{application}/accept', 'App\Http\Controllers\ApplicationController@accept');
 Route::post('application/{application}/reject', 'App\Http\Controllers\ApplicationController@reject');
 
+Route::get('content', 'App\Http\Controllers\TechniqueController@search');
+Route::get('content/{tech:name}', 'App\Http\Controllers\TechniqueController@single');
+
 Route::get('discord-guilds', 'App\Http\Controllers\DiscordGuildController@search');
 Route::get('discord-guilds/{guild_id}', 'App\Http\Controllers\DiscordGuildController@single');
 Route::get('discord-guilds/{guild_id}/channels', 'App\Http\Controllers\DiscordChannelController@search');