i18n
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import type { I18n } from "@lingui/core";
|
||||
import { Match } from "@/features/matches/types";
|
||||
import { Team, TeamInfo } from "@/features/teams/types";
|
||||
import { Tournament } from "@/features/tournaments/types";
|
||||
@@ -150,8 +152,12 @@ export const isPredictionComplete = (
|
||||
);
|
||||
};
|
||||
|
||||
export const getMatchLabel = (matches: Match[], match: Match): string => {
|
||||
if (match.reset) return "Bracket Reset";
|
||||
export const getMatchLabel = (
|
||||
i18n: I18n,
|
||||
matches: Match[],
|
||||
match: Match
|
||||
): string => {
|
||||
if (match.reset) return i18n._(msg`Bracket Reset`);
|
||||
|
||||
const winners = matches.filter(
|
||||
(m) => isBracketMatch(m) && !m.reset && !m.is_losers_bracket
|
||||
@@ -161,24 +167,24 @@ export const getMatchLabel = (matches: Match[], match: Match): string => {
|
||||
!highest || current.lid > highest.lid ? current : highest,
|
||||
undefined
|
||||
);
|
||||
if (!grandFinal) return `Match ${match.order}`;
|
||||
if (!grandFinal) return i18n._({ ...msg`Match {order}`, values: { order: match.order } });
|
||||
|
||||
const hasLosersBracket = matches.some(
|
||||
(m) => isBracketMatch(m) && m.is_losers_bracket
|
||||
);
|
||||
|
||||
if (match.lid === grandFinal.lid) return "Final";
|
||||
if (match.lid === grandFinal.lid) return i18n._(msg`Final`);
|
||||
if (
|
||||
hasLosersBracket &&
|
||||
!match.is_losers_bracket &&
|
||||
grandFinal.home_from_lid === match.lid
|
||||
) {
|
||||
return "Winners Bracket Final";
|
||||
return i18n._(msg`Winners Bracket Final`);
|
||||
}
|
||||
if (match.is_losers_bracket && grandFinal.away_from_lid === match.lid) {
|
||||
return "Losers Bracket Final";
|
||||
return i18n._(msg`Losers Bracket Final`);
|
||||
}
|
||||
return `Match ${match.order}`;
|
||||
return i18n._({ ...msg`Match {order}`, values: { order: match.order } });
|
||||
};
|
||||
|
||||
export type PickResult = "correct" | "incorrect" | "pending";
|
||||
|
||||
Reference in New Issue
Block a user