From: Daniel Karbach Date: Thu, 5 Jan 2023 22:27:54 +0000 (+0100) Subject: more content variety X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=5b21bf8a7e7efed35389c693fcf3775d6ee3f0ec;p=alttp.git more content variety --- diff --git a/resources/js/components/App.js b/resources/js/components/App.js index bea5c34..fe8ff25 100644 --- a/resources/js/components/App.js +++ b/resources/js/components/App.js @@ -59,8 +59,30 @@ const App = () => {
} /> - } /> - } /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> } /> } /> } /> diff --git a/resources/js/components/pages/Techniques.js b/resources/js/components/pages/Techniques.js index c206a31..4bc0066 100644 --- a/resources/js/components/pages/Techniques.js +++ b/resources/js/components/pages/Techniques.js @@ -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 ; @@ -59,8 +60,13 @@ const Techniques = () => { } return - + ; }; +Techniques.propTypes = { + namespace: PropTypes.string, + type: PropTypes.string, +}; + export default withTranslation()(Techniques); diff --git a/resources/js/components/techniques/List.js b/resources/js/components/techniques/List.js index 0549cd3..58f0eae 100644 --- a/resources/js/components/techniques/List.js +++ b/resources/js/components/techniques/List.js @@ -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 }) =>
    {techniques.map(tech =>
  • - + {getTranslation(tech, 'title', i18n.language)}

    diff --git a/resources/js/components/techniques/Overview.js b/resources/js/components/techniques/Overview.js index 8c7cd4d..1686865 100644 --- a/resources/js/components/techniques/Overview.js +++ b/resources/js/components/techniques/Overview.js @@ -6,12 +6,16 @@ import { withTranslation } from 'react-i18next'; import List from './List'; import i18n from '../../i18n'; -const Overview = ({ techniques }) => -

    {i18n.t('techniques.heading')}

    +const Overview = ({ + namespace, + techniques, +}) => +

    {i18n.t(`${namespace}.heading`)}

    ; Overview.propTypes = { + namespace: PropTypes.string, techniques: PropTypes.arrayOf(PropTypes.shape({ })), }; diff --git a/resources/js/helpers/Technique.js b/resources/js/helpers/Technique.js index 410f015..1a8f4fc 100644 --- a/resources/js/helpers/Technique.js +++ b/resources/js/helpers/Technique.js @@ -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; diff --git a/resources/js/i18n/de.js b/resources/js/i18n/de.js index f3fbe96..e77d1de 100644 --- a/resources/js/i18n/de.js +++ b/resources/js/i18n/de.js @@ -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', diff --git a/resources/js/i18n/en.js b/resources/js/i18n/en.js index 7088dd4..5a6695a 100644 --- a/resources/js/i18n/en.js +++ b/resources/js/i18n/en.js @@ -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', diff --git a/routes/api.php b/routes/api.php index 0f7aa3e..4ec1bb1 100644 --- a/routes/api.php +++ b/routes/api.php @@ -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');