mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-07-23 04:26:57 +00:00
Fix translations (#68)
* Feature/clear search (#66) * clear search * clear button placement * smaller button size * multilingual clear button * Fix translation (#65) --------- Co-authored-by: Owen Rees <owenrees82@gmail.com>
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
import { useAtom } from "jotai";
|
import { Dispatch, SetStateAction } from "react";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|
||||||
import { searchStringAtom } from "@/app/atoms";
|
interface SearchBarProps {
|
||||||
|
searchString: string;
|
||||||
|
setSearchString: Dispatch<SetStateAction<string>>;
|
||||||
|
}
|
||||||
|
|
||||||
const SearchBar = () => {
|
const SearchBar = ({ searchString, setSearchString }: SearchBarProps) => {
|
||||||
const t = useTranslations("Tournaments");
|
const t = useTranslations("Tournaments");
|
||||||
const [searchString, setSearchString] = useAtom(searchStringAtom);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white dark:bg-gray-800">
|
<div className="bg-white dark:bg-gray-800">
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
hoveredMapTournamentIdAtom,
|
hoveredMapTournamentIdAtom,
|
||||||
debouncedHoveredMapTournamentIdAtom,
|
debouncedHoveredMapTournamentIdAtom,
|
||||||
debouncedHoveredListTournamentIdAtom,
|
debouncedHoveredListTournamentIdAtom,
|
||||||
|
searchStringAtom,
|
||||||
} from "@/app/atoms";
|
} from "@/app/atoms";
|
||||||
|
|
||||||
import SearchBar from "./SearchBar";
|
import SearchBar from "./SearchBar";
|
||||||
@@ -20,6 +21,7 @@ import ScrollToTopButton from "./ScrollToTopButton";
|
|||||||
export default function TournamentTable() {
|
export default function TournamentTable() {
|
||||||
const t = useTranslations("Tournaments");
|
const t = useTranslations("Tournaments");
|
||||||
|
|
||||||
|
const [searchString, setSearchString] = useAtom(searchStringAtom);
|
||||||
const filteredTournaments = useAtomValue(filteredTournamentsListAtom);
|
const filteredTournaments = useAtomValue(filteredTournamentsListAtom);
|
||||||
const [syncVisible, setSyncVisible] = useAtom(syncVisibleAtom);
|
const [syncVisible, setSyncVisible] = useAtom(syncVisibleAtom);
|
||||||
const hoveredMapTournamentId = useAtomValue(hoveredMapTournamentIdAtom);
|
const hoveredMapTournamentId = useAtomValue(hoveredMapTournamentIdAtom);
|
||||||
@@ -39,6 +41,10 @@ export default function TournamentTable() {
|
|||||||
tournamentRow?.scrollIntoView({ behavior: "smooth" });
|
tournamentRow?.scrollIntoView({ behavior: "smooth" });
|
||||||
}, [debouncedHoveredMapTournamentId]);
|
}, [debouncedHoveredMapTournamentId]);
|
||||||
|
|
||||||
|
const handleClearSearch = () => {
|
||||||
|
setSearchString("");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
className="tournament-table grid w-full auto-rows-max pb-20 lg:col-start-2 lg:col-end-3 lg:h-[calc(100vh-144px)] lg:overflow-y-scroll"
|
className="tournament-table grid w-full auto-rows-max pb-20 lg:col-start-2 lg:col-end-3 lg:h-[calc(100vh-144px)] lg:overflow-y-scroll"
|
||||||
@@ -46,7 +52,16 @@ export default function TournamentTable() {
|
|||||||
data-test="tournament-table-div"
|
data-test="tournament-table-div"
|
||||||
>
|
>
|
||||||
<div className="z-10 flex w-full flex-wrap items-center justify-between gap-3 p-3">
|
<div className="z-10 flex w-full flex-wrap items-center justify-between gap-3 p-3">
|
||||||
<SearchBar />
|
<SearchBar
|
||||||
|
searchString={searchString}
|
||||||
|
setSearchString={setSearchString}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
className="mr-auto rounded-full bg-teal-600 px-3 py-1 text-white hover:bg-teal-700"
|
||||||
|
onClick={() => handleClearSearch()}
|
||||||
|
>
|
||||||
|
{t("clearButton")}
|
||||||
|
</button>
|
||||||
<div className="text-gray-900 dark:text-white">
|
<div className="text-gray-900 dark:text-white">
|
||||||
<label>
|
<label>
|
||||||
<input
|
<input
|
||||||
@@ -86,6 +101,7 @@ export default function TournamentTable() {
|
|||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
{filteredTournaments.length === 0 ? (
|
{filteredTournaments.length === 0 ? (
|
||||||
<tr className="bg-white text-gray-900 dark:bg-gray-800 dark:text-white">
|
<tr className="bg-white text-gray-900 dark:bg-gray-800 dark:text-white">
|
||||||
@@ -123,7 +139,7 @@ export default function TournamentTable() {
|
|||||||
</td>
|
</td>
|
||||||
<td className="p-3">
|
<td className="p-3">
|
||||||
<a href={tournament.url} target="_blank">
|
<a href={tournament.url} target="_blank">
|
||||||
{tournament.timeControl}
|
{t("timeControlEnum", { tc: tournament.timeControl })}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
+2
-1
@@ -35,7 +35,8 @@
|
|||||||
"tournament": "Tournament",
|
"tournament": "Tournament",
|
||||||
"timeControl": "Time Control",
|
"timeControl": "Time Control",
|
||||||
"approx": "Géo-localisation is approximative",
|
"approx": "Géo-localisation is approximative",
|
||||||
"timeControlEnum": "{tc, select, Classic {Classic} Rapid {Rapid} Blitz {Blitz} KO {1h KO} other {{tc}}}"
|
"timeControlEnum": "{tc, select, Classic {Classic} Rapid {Rapid} Blitz {Blitz} KO {1h KO} other {{tc}}}",
|
||||||
|
"clearButton": "Clear"
|
||||||
},
|
},
|
||||||
|
|
||||||
"About": {
|
"About": {
|
||||||
|
|||||||
+2
-1
@@ -35,7 +35,8 @@
|
|||||||
"tournament": "Tournois",
|
"tournament": "Tournois",
|
||||||
"timeControl": "Cadence",
|
"timeControl": "Cadence",
|
||||||
"approx": "Géolocalisation approximative",
|
"approx": "Géolocalisation approximative",
|
||||||
"timeControlEnum": "{tc, select, Classic {Cadence Lente} Rapid {Rapide} Blitz {Blitz} KO {1h KO} other {{tc}}}"
|
"timeControlEnum": "{tc, select, Classic {Cadence Lente} Rapid {Rapide} Blitz {Blitz} KO {1h KO} other {{tc}}}",
|
||||||
|
"clearButton": "Effacer"
|
||||||
},
|
},
|
||||||
|
|
||||||
"About": {
|
"About": {
|
||||||
|
|||||||
Reference in New Issue
Block a user