improve landing page

pull/224/head
Jon Eugster 2 years ago
parent dd7a2d1bc1
commit 39be34e83a

@ -43,7 +43,9 @@ function Tile({gameId, data}: {gameId: string, data: GameTile|undefined}) {
let [loadedTranslation, setLoadedTranslation] = React.useState(false) let [loadedTranslation, setLoadedTranslation] = React.useState(false)
// Load the namespace of the game // Load the namespace of the game
i18next.loadNamespaces(gameId).catch(err => {}).then(() => {setLoadedTranslation(true)}) i18next.loadNamespaces(gameId).catch(err => {
console.warn(`translations for ${gameId} do not exist`)
}).then(() => {setLoadedTranslation(true)})
if (typeof data === 'undefined') { if (typeof data === 'undefined') {
return <></> return <></>
@ -77,10 +79,8 @@ function Tile({gameId, data}: {gameId: string, data: GameTile|undefined}) {
<td> <td>
{data.languages.map((lang) => { {data.languages.map((lang) => {
let langOpt = lean4gameConfig.languages.find((e) => e.iso == lang) let langOpt = lean4gameConfig.languages.find((e) => e.iso == lang)
if (langOpt) { return <ReactCountryFlag key={`flag-${lang}`} title={langOpt?.name} countryCode={langOpt?.flag} className="emojiFlag"/>
return <ReactCountryFlag title={langOpt.name} countryCode={langOpt.flag} className="emojiFlag"/>
} else
return <></>
})} })}
</td> </td>
</tr> </tr>
@ -103,9 +103,26 @@ function LandingPage() {
const closePreferencesPopup = () => setPreferencesPopup(false); const closePreferencesPopup = () => setPreferencesPopup(false);
const togglePreferencesPopup = () => setPreferencesPopup(!preferencesPopup); const togglePreferencesPopup = () => setPreferencesPopup(!preferencesPopup);
let allTiles = lean4gameConfig.allGames.map((gameId) => (useGetGameInfoQuery({game: `g/${gameId}`}).data?.tile))
const { t, i18n } = useTranslation() const { t, i18n } = useTranslation()
let allTiles = lean4gameConfig.allGames.map((gameId) => {
let q = useGetGameInfoQuery({game: `g/${gameId}`})
// if (q.isError) {
// if (q.error?.originalStatus === 404) {
// // Handle 404 error
// console.log('File not found');
// } else {
// // Suppress additional console.error messages
// console.error(q.error);
// }
// }
return q.data?.tile
})
return <div className="landing-page"> return <div className="landing-page">
<header style={{backgroundImage: `url(${bgImage})`}}> <header style={{backgroundImage: `url(${bgImage})`}}>
<nav className="landing-page-nav"> <nav className="landing-page-nav">
@ -128,7 +145,7 @@ function LandingPage() {
</div> </div>
</header> </header>
<div className="game-list"> <div className="game-list">
{allTiles.length == 0 ? {allTiles.filter(x => x != null).length == 0 ?
<p> <p>
<Trans> <Trans>
No Games loaded. Use <a>http://localhost:3000/#/g/local/FOLDER</a> to open a No Games loaded. Use <a>http://localhost:3000/#/g/local/FOLDER</a> to open a

@ -67,7 +67,9 @@ function Level() {
const gameId = React.useContext(GameIdContext) const gameId = React.useContext(GameIdContext)
// Load the namespace of the game // Load the namespace of the game
i18next.loadNamespaces(gameId) i18next.loadNamespaces(gameId).catch(err => {
console.warn(`translations for ${gameId} do not exist.`)
})
const gameInfo = useGetGameInfoQuery({game: gameId}) const gameInfo = useGetGameInfoQuery({game: gameId})

Loading…
Cancel
Save