i18n
This commit is contained in:
+79
-68
@@ -18,6 +18,8 @@ import { ColorSchemeScript, mantineHtmlProps } from "@mantine/core";
|
||||
import { HeaderConfig } from "@/features/core/types/header-config";
|
||||
import { playerQueries } from "@/features/players/queries";
|
||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||
import { DEFAULT_LOCALE, ensureMessages, resolveLocale } from "@/lib/i18n";
|
||||
import { getRootMeta } from "@/lib/i18n/meta";
|
||||
import FullScreenLoader from "@/components/full-screen-loader";
|
||||
import { CHROME_COLORS } from "@/lib/mantine/theme-colors";
|
||||
import mantineCssUrl from '@mantine/core/styles.css?url'
|
||||
@@ -33,74 +35,81 @@ export const Route = createRootRouteWithContext<{
|
||||
withPadding: boolean;
|
||||
fullWidth: boolean;
|
||||
}>()({
|
||||
head: () => ({
|
||||
title: "FLXN IX",
|
||||
meta: [
|
||||
{
|
||||
charSet: "utf-8",
|
||||
},
|
||||
{
|
||||
name: "viewport",
|
||||
content:
|
||||
"width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, interactive-widget=resizes-content, viewport-fit=cover",
|
||||
},
|
||||
{ name: 'description', content: 'FLXN — beer pong tournaments, brackets, and stats.' },
|
||||
{ name: 'keywords', content: 'FLXN, beer pong, tournament, sports, statistics, pong' },
|
||||
{ property: 'og:title', content: 'FLXN' },
|
||||
{ property: 'og:description', content: 'FLXN — beer pong tournaments, brackets, and stats.' },
|
||||
{ property: 'og:url', content: 'https://flexxon.app' },
|
||||
{ property: 'og:type', content: 'website' },
|
||||
{ property: 'og:site_name', content: 'FLXN' },
|
||||
{ property: 'og:image', content: 'https://flexxon.app/favicon.png' },
|
||||
{ property: 'og:image:width', content: '512' },
|
||||
{ property: 'og:image:height', content: '512' },
|
||||
{ property: 'og:image:alt', content: 'FLXN logo' },
|
||||
{ property: 'og:locale', content: 'en_US' },
|
||||
{ name: 'twitter:card', content: 'summary' },
|
||||
{ name: 'twitter:title', content: 'FLXN' },
|
||||
{ name: 'twitter:description', content: 'FLXN — beer pong tournaments, brackets, and stats.' },
|
||||
{ name: 'twitter:image', content: 'https://flexxon.app/favicon.png' },
|
||||
{ name: 'mobile-web-app-capable', content: 'yes' },
|
||||
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
|
||||
{ name: 'apple-mobile-web-app-status-bar-style', content: 'default' },
|
||||
{ name: 'apple-mobile-web-app-title', content: 'FLXN' },
|
||||
],
|
||||
links: [
|
||||
{
|
||||
rel: "apple-touch-icon",
|
||||
sizes: "180x180",
|
||||
href: "/apple-touch-icon.png",
|
||||
},
|
||||
{
|
||||
rel: "icon",
|
||||
type: "image/png",
|
||||
sizes: "32x32",
|
||||
href: "/favicon-32x32.png",
|
||||
},
|
||||
{
|
||||
rel: "icon",
|
||||
type: "image/png",
|
||||
sizes: "16x16",
|
||||
href: "/favicon-16x16.png",
|
||||
},
|
||||
{ rel: "manifest", href: "/site.webmanifest" },
|
||||
{ rel: "icon", href: "/favicon.ico" },
|
||||
{ rel: 'stylesheet', href: mantineCssUrl },
|
||||
{ rel: 'stylesheet', href: mantineCarouselCssUrl },
|
||||
{ rel: 'stylesheet', href: mantineDatesCssUrl },
|
||||
{ rel: 'stylesheet', href: mantineTiptapCssUrl },
|
||||
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
|
||||
{
|
||||
rel: "preconnect",
|
||||
href: "https://fonts.gstatic.com",
|
||||
crossOrigin: "anonymous",
|
||||
},
|
||||
{
|
||||
rel: "stylesheet",
|
||||
href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=League+Spartan:wght@100..900&display=swap",
|
||||
}
|
||||
],
|
||||
}),
|
||||
head: () => {
|
||||
// Meta stays DEFAULT_LOCALE: crawlers/unfurlers have no session, and
|
||||
// reading match.context here creates circular route-type inference that
|
||||
// breaks beforeLoad typing in child routes.
|
||||
const rootMeta = getRootMeta(DEFAULT_LOCALE);
|
||||
|
||||
return {
|
||||
title: "FLXN IX",
|
||||
meta: [
|
||||
{
|
||||
charSet: "utf-8",
|
||||
},
|
||||
{
|
||||
name: "viewport",
|
||||
content:
|
||||
"width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, interactive-widget=resizes-content, viewport-fit=cover",
|
||||
},
|
||||
{ name: 'description', content: rootMeta.description },
|
||||
{ name: 'keywords', content: 'FLXN, beer pong, tournament, sports, statistics, pong' },
|
||||
{ property: 'og:title', content: 'FLXN' },
|
||||
{ property: 'og:description', content: rootMeta.description },
|
||||
{ property: 'og:url', content: 'https://flexxon.app' },
|
||||
{ property: 'og:type', content: 'website' },
|
||||
{ property: 'og:site_name', content: 'FLXN' },
|
||||
{ property: 'og:image', content: 'https://flexxon.app/favicon.png' },
|
||||
{ property: 'og:image:width', content: '512' },
|
||||
{ property: 'og:image:height', content: '512' },
|
||||
{ property: 'og:image:alt', content: rootMeta.ogImageAlt },
|
||||
{ property: 'og:locale', content: rootMeta.ogLocale },
|
||||
{ name: 'twitter:card', content: 'summary' },
|
||||
{ name: 'twitter:title', content: 'FLXN' },
|
||||
{ name: 'twitter:description', content: rootMeta.description },
|
||||
{ name: 'twitter:image', content: 'https://flexxon.app/favicon.png' },
|
||||
{ name: 'mobile-web-app-capable', content: 'yes' },
|
||||
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
|
||||
{ name: 'apple-mobile-web-app-status-bar-style', content: 'default' },
|
||||
{ name: 'apple-mobile-web-app-title', content: 'FLXN' },
|
||||
],
|
||||
links: [
|
||||
{
|
||||
rel: "apple-touch-icon",
|
||||
sizes: "180x180",
|
||||
href: "/apple-touch-icon.png",
|
||||
},
|
||||
{
|
||||
rel: "icon",
|
||||
type: "image/png",
|
||||
sizes: "32x32",
|
||||
href: "/favicon-32x32.png",
|
||||
},
|
||||
{
|
||||
rel: "icon",
|
||||
type: "image/png",
|
||||
sizes: "16x16",
|
||||
href: "/favicon-16x16.png",
|
||||
},
|
||||
{ rel: "manifest", href: "/site.webmanifest" },
|
||||
{ rel: "icon", href: "/favicon.ico" },
|
||||
{ rel: 'stylesheet', href: mantineCssUrl },
|
||||
{ rel: 'stylesheet', href: mantineCarouselCssUrl },
|
||||
{ rel: 'stylesheet', href: mantineDatesCssUrl },
|
||||
{ rel: 'stylesheet', href: mantineTiptapCssUrl },
|
||||
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
|
||||
{
|
||||
rel: "preconnect",
|
||||
href: "https://fonts.gstatic.com",
|
||||
crossOrigin: "anonymous",
|
||||
},
|
||||
{
|
||||
rel: "stylesheet",
|
||||
href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=League+Spartan:wght@100..900&display=swap",
|
||||
}
|
||||
],
|
||||
};
|
||||
},
|
||||
errorComponent: (props) => {
|
||||
return (
|
||||
<RootDocument>
|
||||
@@ -123,6 +132,7 @@ export const Route = createRootRouteWithContext<{
|
||||
context.queryClient,
|
||||
playerQueries.auth()
|
||||
);
|
||||
await ensureMessages(resolveLocale(auth?.metadata?.locale));
|
||||
return { auth };
|
||||
} catch (error: any) {
|
||||
if (isRedirect(error) || error instanceof Response) throw error;
|
||||
@@ -138,6 +148,7 @@ export const Route = createRootRouteWithContext<{
|
||||
context.queryClient,
|
||||
playerQueries.auth()
|
||||
);
|
||||
await ensureMessages(resolveLocale(auth?.metadata?.locale));
|
||||
return { auth };
|
||||
} catch {
|
||||
return {};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { Outlet, redirect, createFileRoute } from "@tanstack/react-router";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import type { HeaderConfig } from "@/features/core/types/header-config";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin")({
|
||||
component: Outlet,
|
||||
@@ -7,12 +9,12 @@ export const Route = createFileRoute("/_authed/admin")({
|
||||
throw redirect({ to: "/" });
|
||||
}
|
||||
|
||||
return {
|
||||
header: {
|
||||
...context.header,
|
||||
title: "Admin",
|
||||
withBackButton: true,
|
||||
},
|
||||
const header: HeaderConfig = {
|
||||
...context.header,
|
||||
title: msg`Admin`,
|
||||
withBackButton: true,
|
||||
};
|
||||
|
||||
return { header };
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,6 +4,8 @@ import { ActivitiesTable, activityQueries } from "@/features/activities";
|
||||
import { PlayersActivityTable, playerQueries } from "@/features/players";
|
||||
import { Box, Divider, Group, Skeleton, Stack, Tabs } from "@mantine/core";
|
||||
import { Suspense, useState } from "react";
|
||||
import { Trans } from "@lingui/react/macro";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/activities")({
|
||||
component: Stats,
|
||||
@@ -16,7 +18,7 @@ export const Route = createFileRoute("/_authed/admin/activities")({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
header: {
|
||||
title: "Activities",
|
||||
title: msg`Activities`,
|
||||
withBackButton: true,
|
||||
},
|
||||
refresh: [activityQueries.search().queryKey, playerQueries.activity().queryKey],
|
||||
@@ -53,8 +55,8 @@ function Stats() {
|
||||
return (
|
||||
<Tabs value={activeTab} onChange={setActiveTab}>
|
||||
<Tabs.List mb='md'>
|
||||
<Tabs.Tab value="server-functions">Server Functions</Tabs.Tab>
|
||||
<Tabs.Tab value="player-activity">Player Activity</Tabs.Tab>
|
||||
<Tabs.Tab value="server-functions"><Trans>Server Functions</Trans></Tabs.Tab>
|
||||
<Tabs.Tab value="player-activity"><Trans>Player Activity</Trans></Tabs.Tab>
|
||||
</Tabs.List>
|
||||
|
||||
<Tabs.Panel value="server-functions">
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { AdminPage } from "@/features/admin";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/")({
|
||||
loader: () => ({
|
||||
header: {
|
||||
withBackButton: true,
|
||||
title: "Admin",
|
||||
title: msg`Admin`,
|
||||
},
|
||||
withPadding: false,
|
||||
}),
|
||||
|
||||
@@ -2,13 +2,15 @@ import BracketPreview from "@/features/admin/components/preview";
|
||||
import { NumberInput } from "@mantine/core";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { useState } from "react";
|
||||
import { useLingui } from "@lingui/react/macro";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/preview")({
|
||||
component: RouteComponent,
|
||||
loader: () => ({
|
||||
header: {
|
||||
withBackButton: true,
|
||||
title: "Bracket Preview",
|
||||
title: msg`Bracket Preview`,
|
||||
},
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
@@ -16,13 +18,14 @@ export const Route = createFileRoute("/_authed/admin/preview")({
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
const { t } = useLingui();
|
||||
const [n, setN] = useState(16);
|
||||
return (
|
||||
<>
|
||||
<NumberInput
|
||||
min={9}
|
||||
max={27}
|
||||
label="Number of teams"
|
||||
label={t`Number of teams`}
|
||||
value={n}
|
||||
onChange={(value) => setN(value as number)}
|
||||
w={150}
|
||||
|
||||
@@ -9,6 +9,8 @@ import TeamAssignmentPreview from "@/features/tournaments/components/team-assign
|
||||
import { WarningCircleIcon, ShuffleIcon, CheckCircleIcon } from "@phosphor-icons/react";
|
||||
import { PlayerInfo } from "@/features/players/types";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { Trans, Plural } from "@lingui/react/macro";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/tournaments/$id/assign-partners")({
|
||||
beforeLoad: async ({ context, params }) => {
|
||||
@@ -23,7 +25,8 @@ export const Route = createFileRoute("/_authed/admin/tournaments/$id/assign-part
|
||||
loader: ({ context }) => ({
|
||||
header: {
|
||||
withBackButton: true,
|
||||
title: `Manage ${context.tournament.name}`,
|
||||
title: msg`Manage {name}`,
|
||||
titleValues: { name: context.tournament.name },
|
||||
},
|
||||
}),
|
||||
component: RouteComponent,
|
||||
@@ -120,19 +123,19 @@ function RouteComponent() {
|
||||
{freeAgents.length}
|
||||
</Text>
|
||||
<Text size="sm" c="dimmed">
|
||||
{freeAgents.length === 1 ? "player enrolled" : "players enrolled"}
|
||||
<Plural value={freeAgents.length} one="player enrolled" other="players enrolled" />
|
||||
</Text>
|
||||
</Group>
|
||||
|
||||
{!hasEnoughPlayers && (
|
||||
<Alert color="yellow" icon={<WarningCircleIcon size={16} />}>
|
||||
Need at least 2 players to create teams
|
||||
<Trans>Need at least 2 players to create teams</Trans>
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{hasOddPlayers && (
|
||||
<Alert color="red" icon={<WarningCircleIcon size={16} />}>
|
||||
Cannot create teams with an odd number of players. Please have one player unenroll.
|
||||
<Trans>Cannot create teams with an odd number of players. Please have one player unenroll.</Trans>
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
@@ -142,7 +145,7 @@ function RouteComponent() {
|
||||
onClick={handleGenerate}
|
||||
loading={generateMutation.isPending}
|
||||
>
|
||||
Generate Random Pairings
|
||||
<Trans>Generate Random Pairings</Trans>
|
||||
</Button>
|
||||
)}
|
||||
</Stack>
|
||||
@@ -151,7 +154,7 @@ function RouteComponent() {
|
||||
<Stack gap="md">
|
||||
<Group justify="space-between" align="center">
|
||||
<Text size="lg" fw={600}>
|
||||
Partner Assignments
|
||||
<Trans>Partner Assignments</Trans>
|
||||
</Text>
|
||||
<Group gap="sm">
|
||||
<Button
|
||||
@@ -161,7 +164,7 @@ function RouteComponent() {
|
||||
loading={generateMutation.isPending}
|
||||
size="sm"
|
||||
>
|
||||
Re-roll
|
||||
<Trans>Re-roll</Trans>
|
||||
</Button>
|
||||
<Button
|
||||
leftSection={<CheckCircleIcon size={18} />}
|
||||
@@ -169,7 +172,7 @@ function RouteComponent() {
|
||||
loading={confirmMutation.isPending}
|
||||
size="sm"
|
||||
>
|
||||
Confirm & Create Teams
|
||||
<Trans>Confirm & Create Teams</Trans>
|
||||
</Button>
|
||||
</Group>
|
||||
</Group>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { tournamentQueries } from "@/features/tournaments/queries";
|
||||
import ManageTournament from "@/features/tournaments/components/manage-tournament";
|
||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||
import { Divider, Group, Skeleton, Stack } from "@mantine/core";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/tournaments/$id/")({
|
||||
beforeLoad: async ({ context, params }) => {
|
||||
@@ -19,7 +20,8 @@ export const Route = createFileRoute("/_authed/admin/tournaments/$id/")({
|
||||
loader: ({ context }) => ({
|
||||
header: {
|
||||
withBackButton: true,
|
||||
title: `Manage ${context.tournament.name}`,
|
||||
title: msg`Manage {name}`,
|
||||
titleValues: { name: context.tournament.name },
|
||||
},
|
||||
withPadding: false,
|
||||
}),
|
||||
|
||||
@@ -3,6 +3,7 @@ import { tournamentQueries } from "@/features/tournaments/queries";
|
||||
import ManageTeams from "@/features/teams/components/manage-teams";
|
||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||
import { Box, Divider, Group, Skeleton, Stack } from "@mantine/core";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/tournaments/$id/teams")({
|
||||
beforeLoad: async ({ context, params }) => {
|
||||
@@ -19,7 +20,8 @@ export const Route = createFileRoute("/_authed/admin/tournaments/$id/teams")({
|
||||
loader: ({ context }) => ({
|
||||
header: {
|
||||
withBackButton: true,
|
||||
title: `${context.tournament.name} Teams`,
|
||||
title: msg`{name} Teams`,
|
||||
titleValues: { name: context.tournament.name },
|
||||
},
|
||||
withPadding: false,
|
||||
}),
|
||||
|
||||
@@ -4,6 +4,7 @@ import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { Divider, Group, Skeleton, Stack } from "@mantine/core";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { Suspense } from "react";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/tournaments/")({
|
||||
beforeLoad: ({ context }) => {
|
||||
@@ -13,7 +14,7 @@ export const Route = createFileRoute("/_authed/admin/tournaments/")({
|
||||
loader: () => ({
|
||||
header: {
|
||||
withBackButton: true,
|
||||
title: "Manage Tournaments",
|
||||
title: msg`Manage Tournaments`,
|
||||
},
|
||||
refresh: tournamentQueries.list().queryKey,
|
||||
withPadding: false,
|
||||
|
||||
@@ -14,6 +14,8 @@ import { Match } from "@/features/matches/types";
|
||||
import BracketView from "@/features/bracket/components/bracket-view";
|
||||
import { SpotifyControlsBar } from "@/features/spotify/components";
|
||||
import { useAuth } from "@/contexts/auth-context";
|
||||
import { Trans } from "@lingui/react/macro";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/tournaments/run/$id")({
|
||||
beforeLoad: async ({ context, params }) => {
|
||||
@@ -33,7 +35,8 @@ export const Route = createFileRoute("/_authed/admin/tournaments/run/$id")({
|
||||
showSpotifyPanel: true,
|
||||
header: {
|
||||
withBackButton: true,
|
||||
title: `Run ${context.tournament.name}`,
|
||||
title: msg`Run {name}`,
|
||||
titleValues: { name: context.tournament.name },
|
||||
},
|
||||
}),
|
||||
component: RouteComponent,
|
||||
@@ -160,7 +163,7 @@ function RouteComponent() {
|
||||
/>
|
||||
<Divider />
|
||||
<div>
|
||||
<Title order={3} ta="center" mb="md">Knockout Bracket</Title>
|
||||
<Title order={3} ta="center" mb="md"><Trans>Knockout Bracket</Trans></Title>
|
||||
<BracketView bracket={bracket} showControls groupConfig={tournament.group_config} nextUpMatchId={nextUpMatchId} />
|
||||
</div>
|
||||
</Stack>
|
||||
|
||||
@@ -5,6 +5,7 @@ import PlayerStatsTableSkeleton from '@/features/players/components/player-stats
|
||||
import { prefetchServerQuery } from '@/lib/tanstack-query/utils/prefetch';
|
||||
import { createFileRoute } from '@tanstack/react-router';
|
||||
import { Suspense } from 'react';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
export const Route = createFileRoute('/_authed/badges')({
|
||||
component: Badges,
|
||||
@@ -16,7 +17,7 @@ export const Route = createFileRoute('/_authed/badges')({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
header: {
|
||||
title: 'All Badges',
|
||||
title: msg`All Badges`,
|
||||
withBackButton: true,
|
||||
},
|
||||
refresh: [badgeQueries.allBadges().queryKey],
|
||||
|
||||
@@ -2,14 +2,17 @@ import { createFileRoute } from "@tanstack/react-router";
|
||||
import { Box, Title, Stack } from "@mantine/core";
|
||||
import { ColorSchemePicker } from "@/features/settings/components/color-scheme-picker";
|
||||
import AccentColorPicker from "@/features/settings/components/accent-color-picker";
|
||||
import LocalePicker from "@/features/settings/components/locale-picker";
|
||||
import { NotificationsSection } from "@/features/settings/components/notifications-section";
|
||||
import { SignOutIcon } from "@phosphor-icons/react";
|
||||
import ListLink from "@/components/list-link";
|
||||
import { Trans, useLingui } from "@lingui/react/macro";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/settings")({
|
||||
loader: () => ({
|
||||
header: {
|
||||
title: "Settings",
|
||||
title: msg`Settings`,
|
||||
withBackButton: true,
|
||||
},
|
||||
withPadding: false,
|
||||
@@ -18,6 +21,7 @@ export const Route = createFileRoute("/_authed/settings")({
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
const { t } = useLingui();
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
@@ -27,14 +31,15 @@ function RouteComponent() {
|
||||
borderBottom: "1px solid var(--mantine-color-default-border)",
|
||||
}}
|
||||
>
|
||||
<Title order={3}>Appearance</Title>
|
||||
<Title order={3}><Trans>Appearance</Trans></Title>
|
||||
<Stack>
|
||||
<AccentColorPicker />
|
||||
<ColorSchemePicker />
|
||||
<LocalePicker />
|
||||
</Stack>
|
||||
</Box>
|
||||
<NotificationsSection />
|
||||
<ListLink label="Sign Out" to="/logout" Icon={SignOutIcon} />
|
||||
<ListLink label={t`Sign Out`} to="/logout" Icon={SignOutIcon} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import LeagueHeadToHead from "@/features/players/components/league-head-to-head";
|
||||
import { Box, Loader, Tabs, Button, Group, Container, Stack } from "@mantine/core";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { Trans } from "@lingui/react/macro";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/stats")({
|
||||
component: Stats,
|
||||
@@ -18,7 +20,7 @@ export const Route = createFileRoute("/_authed/stats")({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
header: {
|
||||
title: "Player Stats"
|
||||
title: msg`Player Stats`
|
||||
},
|
||||
refresh: [playerQueries.allStats().queryKey],
|
||||
}),
|
||||
@@ -41,8 +43,8 @@ function Stats() {
|
||||
return (
|
||||
<Tabs defaultValue="stats">
|
||||
<Tabs.List grow>
|
||||
<Tabs.Tab value="stats">Stats</Tabs.Tab>
|
||||
<Tabs.Tab value="h2h">Head to Head</Tabs.Tab>
|
||||
<Tabs.Tab value="stats"><Trans>Stats</Trans></Tabs.Tab>
|
||||
<Tabs.Tab value="h2h"><Trans>Head to Head</Trans></Tabs.Tab>
|
||||
</Tabs.List>
|
||||
|
||||
<Tabs.Panel value="stats">
|
||||
@@ -54,21 +56,21 @@ function Stats() {
|
||||
size="compact-xs"
|
||||
onClick={() => setViewType('all')}
|
||||
>
|
||||
All
|
||||
<Trans>All</Trans>
|
||||
</Button>
|
||||
<Button
|
||||
variant={viewType === 'mainline' ? 'filled' : 'light'}
|
||||
size="compact-xs"
|
||||
onClick={() => setViewType('mainline')}
|
||||
>
|
||||
Mainline
|
||||
<Trans>Mainline</Trans>
|
||||
</Button>
|
||||
<Button
|
||||
variant={viewType === 'regional' ? 'filled' : 'light'}
|
||||
size="compact-xs"
|
||||
onClick={() => setViewType('regional')}
|
||||
>
|
||||
Regional
|
||||
<Trans>Regional</Trans>
|
||||
</Button>
|
||||
</Group>
|
||||
<Box style={{ opacity: isStale ? 0.6 : 1, transition: 'opacity 150ms' }}>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { tournamentQueries, useTournament } from "@/features/tournaments/queries
|
||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||
import { Container } from "@mantine/core";
|
||||
import { PredictionLeaderboard } from "@/features/predictions/components/prediction-leaderboard";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/tournaments/$id/predictions")({
|
||||
beforeLoad: async ({ context, params }) => {
|
||||
@@ -19,7 +20,7 @@ export const Route = createFileRoute("/_authed/tournaments/$id/predictions")({
|
||||
loader: () => ({
|
||||
header: {
|
||||
withBackButton: true,
|
||||
title: "Predictions",
|
||||
title: msg`Predictions`,
|
||||
},
|
||||
}),
|
||||
component: RouteComponent,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
import { Trans } from "@lingui/react/macro";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { useMemo } from "react";
|
||||
import { Box, Container, Group, Paper, Stack, Text } from "@mantine/core";
|
||||
import { tournamentQueries, useTournament } from "@/features/tournaments/queries";
|
||||
@@ -41,7 +43,8 @@ export const Route = createFileRoute(
|
||||
withPadding: false,
|
||||
header: {
|
||||
withBackButton: true,
|
||||
title: `${context.prediction.player.first_name}'s Bracket`,
|
||||
title: msg`{name}'s Bracket`,
|
||||
titleValues: { name: context.prediction.player.first_name },
|
||||
},
|
||||
}),
|
||||
component: RouteComponent,
|
||||
@@ -100,7 +103,7 @@ function RouteComponent() {
|
||||
<Group gap="md" wrap="nowrap">
|
||||
<Stack gap={0} ta="center">
|
||||
<Text size="xs" c="dimmed" fw={700}>
|
||||
PTS
|
||||
<Trans>PTS</Trans>
|
||||
</Text>
|
||||
<Text size="sm" fw={700}>
|
||||
{score.points}
|
||||
@@ -108,7 +111,7 @@ function RouteComponent() {
|
||||
</Stack>
|
||||
<Stack gap={0} ta="center">
|
||||
<Text size="xs" c="dimmed" fw={700}>
|
||||
PICKS
|
||||
<Trans>PICKS</Trans>
|
||||
</Text>
|
||||
<Text size="xs" c="dimmed">
|
||||
{score.correct}/{score.total}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { prefetchServerQuery } from '@/lib/tanstack-query/utils/prefetch'
|
||||
import { Suspense } from 'react'
|
||||
import TournamentCardList from '@/features/tournaments/components/tournament-card-list'
|
||||
import { Skeleton, Stack } from '@mantine/core'
|
||||
import { msg } from '@lingui/core/macro'
|
||||
|
||||
export const Route = createFileRoute('/_authed/tournaments/')({
|
||||
beforeLoad: async ({ context }) => {
|
||||
@@ -13,7 +14,7 @@ export const Route = createFileRoute('/_authed/tournaments/')({
|
||||
loader: () => ({
|
||||
header: {
|
||||
withBackButton: true,
|
||||
title: 'Tournaments',
|
||||
title: msg`Tournaments`,
|
||||
},
|
||||
refresh: tournamentQueries.list().queryKey
|
||||
}),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { superTokensRequestMiddleware } from "@/utils/supertokens";
|
||||
import { sendPushToPlayer } from "@/lib/push";
|
||||
import { isPushConfigured } from "@/lib/config";
|
||||
@@ -25,7 +26,7 @@ export const Route = createFileRoute("/api/push/test")({
|
||||
try {
|
||||
const result = await sendPushToPlayer(player.id, {
|
||||
title: "Flexxon",
|
||||
body: "Test notification — push is working on this device.",
|
||||
body: msg`Test notification — push is working on this device.`,
|
||||
url: "/settings",
|
||||
tag: "flexxon-test",
|
||||
});
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { SpotifyWebApiClient } from "@/lib/spotify/client";
|
||||
import type { SpotifyPlaybackSnapshot } from "@/lib/spotify/types";
|
||||
import { localizedFor } from "@/lib/i18n/server-messages";
|
||||
|
||||
export const Route = createFileRoute("/api/spotify/capture")({
|
||||
server: {
|
||||
handlers: {
|
||||
POST: async ({ request }: { request: Request }) => {
|
||||
// No session middleware on this route; localize with DEFAULT_LOCALE.
|
||||
const i18n = localizedFor(null);
|
||||
try {
|
||||
const cookies = request.headers.get("Cookie") || "";
|
||||
const accessTokenMatch = cookies.match(
|
||||
@@ -14,7 +18,7 @@ export const Route = createFileRoute("/api/spotify/capture")({
|
||||
|
||||
if (!accessTokenMatch) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: "No access token found" }),
|
||||
JSON.stringify({ error: i18n._(msg`No access token found`) }),
|
||||
{
|
||||
status: 401,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -29,7 +33,7 @@ export const Route = createFileRoute("/api/spotify/capture")({
|
||||
|
||||
if (!snapshot) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: "No active playback to capture" }),
|
||||
JSON.stringify({ error: i18n._(msg`No active playback to capture`) }),
|
||||
{
|
||||
status: 400,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -47,7 +51,7 @@ export const Route = createFileRoute("/api/spotify/capture")({
|
||||
const errorMessage =
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "Failed to capture playback state";
|
||||
: i18n._(msg`Failed to capture playback state`);
|
||||
|
||||
return new Response(JSON.stringify({ error: errorMessage }), {
|
||||
status: 500,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { SpotifyWebApiClient } from "@/lib/spotify/client";
|
||||
import { localizedFor } from "@/lib/i18n/server-messages";
|
||||
|
||||
function getAccessTokenFromCookies(request: Request): string | null {
|
||||
const cookieHeader = request.headers.get("cookie");
|
||||
@@ -16,11 +18,13 @@ export const Route = createFileRoute("/api/spotify/playback")({
|
||||
server: {
|
||||
handlers: {
|
||||
POST: async ({ request }: { request: Request }) => {
|
||||
// No session middleware on this route; localize with DEFAULT_LOCALE.
|
||||
const i18n = localizedFor(null);
|
||||
try {
|
||||
const accessToken = getAccessTokenFromCookies(request);
|
||||
if (!accessToken) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: "No access token found" }),
|
||||
JSON.stringify({ error: i18n._(msg`No access token found`) }),
|
||||
{
|
||||
status: 401,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -41,7 +45,7 @@ export const Route = createFileRoute("/api/spotify/playback")({
|
||||
if (!trackId) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "trackId is required for playTrack action",
|
||||
error: i18n._(msg`trackId is required for playTrack action`),
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
@@ -63,7 +67,7 @@ export const Route = createFileRoute("/api/spotify/playback")({
|
||||
case "volume":
|
||||
if (typeof volumePercent !== "number") {
|
||||
return new Response(
|
||||
JSON.stringify({ error: "volumePercent must be a number" }),
|
||||
JSON.stringify({ error: i18n._(msg`volumePercent must be a number`) }),
|
||||
{
|
||||
status: 400,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -76,7 +80,7 @@ export const Route = createFileRoute("/api/spotify/playback")({
|
||||
if (!deviceId) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "deviceId is required for transfer action",
|
||||
error: i18n._(msg`deviceId is required for transfer action`),
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
@@ -87,10 +91,13 @@ export const Route = createFileRoute("/api/spotify/playback")({
|
||||
await spotifyClient.transferPlayback(deviceId);
|
||||
break;
|
||||
default:
|
||||
return new Response(JSON.stringify({ error: "Invalid action" }), {
|
||||
status: 400,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
return new Response(
|
||||
JSON.stringify({ error: i18n._(msg`Invalid action`) }),
|
||||
{
|
||||
status: 400,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return new Response(JSON.stringify({ success: true }), {
|
||||
@@ -104,8 +111,9 @@ export const Route = createFileRoute("/api/spotify/playback")({
|
||||
if (error.message.includes("NO_ACTIVE_DEVICE")) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error:
|
||||
"No active device found. Please select a device first.",
|
||||
error: i18n._(
|
||||
msg`No active device found. Please select a device first.`
|
||||
),
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
@@ -117,7 +125,9 @@ export const Route = createFileRoute("/api/spotify/playback")({
|
||||
if (error.message.includes("PREMIUM_REQUIRED")) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "Spotify Premium is required for playback control.",
|
||||
error: i18n._(
|
||||
msg`Spotify Premium is required for playback control.`
|
||||
),
|
||||
}),
|
||||
{
|
||||
status: 403,
|
||||
@@ -135,7 +145,7 @@ export const Route = createFileRoute("/api/spotify/playback")({
|
||||
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "Playback control failed",
|
||||
error: i18n._(msg`Playback control failed`),
|
||||
details: error instanceof Error ? error.message : "Unknown error",
|
||||
}),
|
||||
{
|
||||
@@ -147,11 +157,13 @@ export const Route = createFileRoute("/api/spotify/playback")({
|
||||
},
|
||||
|
||||
GET: async ({ request }: { request: Request }) => {
|
||||
// No session middleware on this route; localize with DEFAULT_LOCALE.
|
||||
const i18n = localizedFor(null);
|
||||
try {
|
||||
const accessToken = getAccessTokenFromCookies(request);
|
||||
if (!accessToken) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: "No access token found" }),
|
||||
JSON.stringify({ error: i18n._(msg`No access token found`) }),
|
||||
{
|
||||
status: 401,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -190,7 +202,7 @@ export const Route = createFileRoute("/api/spotify/playback")({
|
||||
} catch (error) {
|
||||
console.error("Get playback data error:", error);
|
||||
return new Response(
|
||||
JSON.stringify({ error: "Failed to get playback data" }),
|
||||
JSON.stringify({ error: i18n._(msg`Failed to get playback data`) }),
|
||||
{
|
||||
status: 500,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { SpotifyWebApiClient } from "@/lib/spotify/client";
|
||||
import type { SpotifyPlaybackSnapshot } from "@/lib/spotify/types";
|
||||
import { localizedFor } from "@/lib/i18n/server-messages";
|
||||
|
||||
export const Route = createFileRoute("/api/spotify/resume")({
|
||||
server: {
|
||||
handlers: {
|
||||
POST: async ({ request }: { request: Request }) => {
|
||||
// No session middleware on this route; localize with DEFAULT_LOCALE.
|
||||
const i18n = localizedFor(null);
|
||||
try {
|
||||
const cookies = request.headers.get("Cookie") || "";
|
||||
const accessTokenMatch = cookies.match(
|
||||
@@ -14,7 +18,7 @@ export const Route = createFileRoute("/api/spotify/resume")({
|
||||
|
||||
if (!accessTokenMatch) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: "No access token found" }),
|
||||
JSON.stringify({ error: i18n._(msg`No access token found`) }),
|
||||
{
|
||||
status: 401,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -30,7 +34,7 @@ export const Route = createFileRoute("/api/spotify/resume")({
|
||||
|
||||
if (!snapshot) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: "No snapshot provided" }),
|
||||
JSON.stringify({ error: i18n._(msg`No snapshot provided`) }),
|
||||
{
|
||||
status: 400,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -47,14 +51,14 @@ export const Route = createFileRoute("/api/spotify/resume")({
|
||||
} catch (error) {
|
||||
console.error("Spotify resume error:", error);
|
||||
|
||||
let errorMessage = "Failed to resume playback state";
|
||||
let errorMessage = i18n._(msg`Failed to resume playback state`);
|
||||
|
||||
if (error instanceof Error) {
|
||||
if (
|
||||
error.message.includes("Premium") ||
|
||||
error.message.includes("403")
|
||||
) {
|
||||
errorMessage = "Spotify premium required";
|
||||
errorMessage = i18n._(msg`Spotify premium required`);
|
||||
} else {
|
||||
errorMessage = error.message;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { superTokensRequestMiddleware } from "@/utils/supertokens";
|
||||
import { pbAdmin } from "@/lib/pocketbase/client";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { localizedFor } from "@/lib/i18n/server-messages";
|
||||
import { z } from "zod";
|
||||
|
||||
const uploadSchema = z.object({
|
||||
@@ -13,6 +15,7 @@ export const Route = createFileRoute("/api/teams/upload-logo")({
|
||||
middleware: [superTokensRequestMiddleware],
|
||||
handlers: {
|
||||
POST: async ({ request, context }) => {
|
||||
const i18n = localizedFor(context.metadata);
|
||||
try {
|
||||
const userId = context.userAuthId;
|
||||
const isAdmin = context.roles.includes("Admin");
|
||||
@@ -27,7 +30,7 @@ export const Route = createFileRoute("/api/teams/upload-logo")({
|
||||
if (!validationResult.success) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "Invalid input",
|
||||
error: i18n._(msg`Invalid input`),
|
||||
details: validationResult.error.issues,
|
||||
}),
|
||||
{
|
||||
@@ -40,7 +43,7 @@ export const Route = createFileRoute("/api/teams/upload-logo")({
|
||||
if (!logoFile || logoFile.size === 0) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "Logo file is required",
|
||||
error: i18n._(msg`Logo file is required`),
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
@@ -58,7 +61,9 @@ export const Route = createFileRoute("/api/teams/upload-logo")({
|
||||
if (!allowedTypes.includes(logoFile.type)) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "Invalid file type. Only JPEG, PNG and GIF are allowed.",
|
||||
error: i18n._(
|
||||
msg`Invalid file type. Only JPEG, PNG and GIF are allowed.`
|
||||
),
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
@@ -71,7 +76,7 @@ export const Route = createFileRoute("/api/teams/upload-logo")({
|
||||
if (logoFile.size > maxSize) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "File too large. Maximum size is 10MB.",
|
||||
error: i18n._(msg`File too large. Maximum size is 10MB.`),
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
@@ -84,7 +89,7 @@ export const Route = createFileRoute("/api/teams/upload-logo")({
|
||||
if (!team) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "Team not found",
|
||||
error: i18n._(msg`Team not found`),
|
||||
}),
|
||||
{
|
||||
status: 404,
|
||||
@@ -132,8 +137,8 @@ export const Route = createFileRoute("/api/teams/upload-logo")({
|
||||
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "Failed to upload logo",
|
||||
message: error.message || "Unknown error occurred",
|
||||
error: i18n._(msg`Failed to upload logo`),
|
||||
message: error.message || i18n._(msg`Unknown error occurred`),
|
||||
}),
|
||||
{
|
||||
status: 500,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { superTokensRequestMiddleware } from "@/utils/supertokens";
|
||||
import { pbAdmin } from "@/lib/pocketbase/client";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { localizedFor } from "@/lib/i18n/server-messages";
|
||||
import { z } from "zod";
|
||||
|
||||
const uploadSchema = z.object({
|
||||
@@ -13,6 +15,7 @@ export const Route = createFileRoute("/api/tournaments/upload-logo")({
|
||||
middleware: [superTokensRequestMiddleware],
|
||||
handlers: {
|
||||
POST: async ({ request, context }) => {
|
||||
const i18n = localizedFor(context.metadata);
|
||||
try {
|
||||
const userId = context.userAuthId;
|
||||
const isAdmin = context.roles.includes("Admin");
|
||||
@@ -28,7 +31,7 @@ export const Route = createFileRoute("/api/tournaments/upload-logo")({
|
||||
if (!validationResult.success) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "Invalid input",
|
||||
error: i18n._(msg`Invalid input`),
|
||||
details: validationResult.error.issues,
|
||||
}),
|
||||
{
|
||||
@@ -41,7 +44,7 @@ export const Route = createFileRoute("/api/tournaments/upload-logo")({
|
||||
if (!logoFile || logoFile.size === 0) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "Logo file is required",
|
||||
error: i18n._(msg`Logo file is required`),
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
@@ -59,7 +62,9 @@ export const Route = createFileRoute("/api/tournaments/upload-logo")({
|
||||
if (!allowedTypes.includes(logoFile.type)) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "Invalid file type. Only JPEG, PNG and GIF are allowed.",
|
||||
error: i18n._(
|
||||
msg`Invalid file type. Only JPEG, PNG and GIF are allowed.`
|
||||
),
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
@@ -72,7 +77,7 @@ export const Route = createFileRoute("/api/tournaments/upload-logo")({
|
||||
if (logoFile.size > maxSize) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "File too large. Maximum size is 10MB.",
|
||||
error: i18n._(msg`File too large. Maximum size is 10MB.`),
|
||||
}),
|
||||
{
|
||||
status: 400,
|
||||
@@ -85,7 +90,7 @@ export const Route = createFileRoute("/api/tournaments/upload-logo")({
|
||||
if (!tournament) {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "Tournament not found",
|
||||
error: i18n._(msg`Tournament not found`),
|
||||
}),
|
||||
{
|
||||
status: 404,
|
||||
@@ -130,8 +135,8 @@ export const Route = createFileRoute("/api/tournaments/upload-logo")({
|
||||
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
error: "Failed to upload logo",
|
||||
message: error.message || "Unknown error occurred",
|
||||
error: i18n._(msg`Failed to upload logo`),
|
||||
message: error.message || i18n._(msg`Unknown error occurred`),
|
||||
}),
|
||||
{
|
||||
status: 500,
|
||||
|
||||
Reference in New Issue
Block a user