Enforce suggest limit in UI
This commit is contained in:
@@ -44,6 +44,7 @@ const translations = {
|
||||
"suggest.title": "Suggest games (up to 5)",
|
||||
"suggest.new": "Add new suggestion",
|
||||
"suggest.addButton": "Suggest a game",
|
||||
"suggest.maxReached": "max limit reached",
|
||||
"suggest.jokerAddButton": "🃏 Joker: add another game",
|
||||
"suggest.hint": "Only you can see your suggestions until voting starts.",
|
||||
"form.gameName": "Game name *",
|
||||
@@ -212,6 +213,7 @@ const translations = {
|
||||
"suggest.title": "Schlage Spiele vor (bis zu 5)",
|
||||
"suggest.new": "Neuen Vorschlag hinzufügen",
|
||||
"suggest.addButton": "Spiel vorschlagen",
|
||||
"suggest.maxReached": "Limit erreicht",
|
||||
"suggest.jokerAddButton": "🃏 Joker: Weiteres Spiel hinzufügen",
|
||||
"suggest.hint": "Nur du siehst deine Vorschläge bis zum Start der Abstimmung.",
|
||||
"form.gameName": "Spielname *",
|
||||
|
||||
@@ -129,6 +129,16 @@ export function renderWelcome() {
|
||||
el.textContent = t("auth.welcome", { name });
|
||||
}
|
||||
|
||||
function updateSuggestButtonState() {
|
||||
const btn = $("open-suggest-modal");
|
||||
if (!btn) return;
|
||||
const limit = 5;
|
||||
const count = state.mySuggestions?.length ?? 0;
|
||||
const blocked = count >= limit;
|
||||
btn.disabled = blocked || state.phase !== "Suggest";
|
||||
btn.textContent = blocked ? t("suggest.maxReached") : t("suggest.addButton");
|
||||
}
|
||||
|
||||
export function renderMySuggestions() {
|
||||
const wrap = $("my-suggestions");
|
||||
if (!wrap) return;
|
||||
@@ -141,6 +151,7 @@ export function renderMySuggestions() {
|
||||
buildCard(s, { showAuthor: false, allowDelete, allowEdit, lockTitle }),
|
||||
),
|
||||
);
|
||||
updateSuggestButtonState();
|
||||
}
|
||||
|
||||
export function renderAllSuggestions() {
|
||||
|
||||
Reference in New Issue
Block a user