Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
Fix locale routing (#247)
Luke Vella0f35bd051837
diff --git a/src/components/create-poll.tsx b/src/components/create-poll.tsxindex 6517dfcde..84a23d04c 100644--- a/src/components/create-poll.tsx+++ b/src/components/create-poll.tsx@@ -152,6 +152,7 @@ const Page: NextPage<CreatePollPageProps> = ({<StandardLayout><Head><title>{formData?.eventDetails?.title ?? t("newPoll")}</title>+ <meta name="robots" content="noindex,nofollow" /></Head><div className="max-w-full py-4 md:px-3 lg:px-6"><div className="mx-auto w-fit max-w-full lg:mx-0">diff --git a/src/components/forms/poll-options-form/date-navigation-toolbar.tsx b/src/components/forms/poll-options-form/date-navigation-toolbar.tsxindex 785f4b5dd..4a7cbab11 100644--- a/src/components/forms/poll-options-form/date-navigation-toolbar.tsx+++ b/src/components/forms/poll-options-form/date-navigation-toolbar.tsx@@ -1,3 +1,4 @@+import { useTranslation } from "next-i18next";import * as React from "react";import ChevronLeft from "../../icons/chevron-left.svg";@@ -13,6 +14,7 @@ export interface DateNavigationToolbarProps {const DateNavigationToolbar: React.VoidFunctionComponent<DateNavigationToolbarProps> =({ year, label, onPrevious, onToday, onNext }) => {+ const { t } = useTranslation("app");return (<div className="flex h-14 w-full shrink-0 items-center border-b px-4"><div className="grow">@@ -25,7 +27,7 @@ const DateNavigationToolbar: React.VoidFunctionComponent<DateNavigationToolbarPr<ChevronLeft className="h-5" /></button><button type="button" onClick={onToday}>- Today+ {t("today")}</button><button type="button" onClick={onNext}><ChevronRight className="h-5" />diff --git a/src/components/page-layout/footer.tsx b/src/components/page-layout/footer.tsxindex b2398606f..b88ce38fc 100644--- a/src/components/page-layout/footer.tsx+++ b/src/components/page-layout/footer.tsx@@ -1,4 +1,5 @@import Link from "next/link";+import { useRouter } from "next/router";import { Trans, useTranslation } from "next-i18next";import * as React from "react";@@ -15,6 +16,7 @@ import { LanguageSelect } from "../poll/language-selector";const Footer: React.VoidFunctionComponent = () => {const { t } = useTranslation("common");+ const router = useRouter();return (<div className="mt-16 bg-slate-50/70"><div className="mx-auto max-w-7xl space-y-8 p-8 lg:flex lg:space-x-16 lg:space-y-0">@@ -132,7 +134,12 @@ const Footer: React.VoidFunctionComponent = () => {</div><div className="lg:w-2/6"><div className="mb-4 font-medium">{t("language")}</div>- <LanguageSelect className="mb-4 w-full" />+ <LanguageSelect+ className="mb-4 w-full"+ onChange={(locale) => {+ router.push(router.asPath, router.asPath, { locale });+ }}+ /><ahref="https://github.com/lukevella/rallly/wiki/Guide-for-translators"className="inline-flex items-center rounded-md border px-3 py-2 text-xs text-slate-500"diff --git a/src/components/poll/language-selector.tsx b/src/components/poll/language-selector.tsxindex 86fd01b09..4256fb0bb 100644--- a/src/components/poll/language-selector.tsx+++ b/src/components/poll/language-selector.tsx@@ -17,7 +17,6 @@ export const LanguageSelect: React.VoidFunctionComponent<{Cookies.set("NEXT_LOCALE", e.target.value, {expires: 365,});- router.push(router.asPath, router.asPath, { locale: e.target.value });onChange?.(e.target.value);}}>diff --git a/src/components/preferences.tsx b/src/components/preferences.tsxindex e9dafc48d..7238b447f 100644--- a/src/components/preferences.tsx+++ b/src/components/preferences.tsx@@ -1,4 +1,5 @@import clsx from "clsx";+import { useRouter } from "next/router";import { useTranslation } from "next-i18next";import { usePlausible } from "next-plausible";import React from "react";@@ -12,6 +13,8 @@ const Preferences: React.VoidFunctionComponent = () => {const { weekStartsOn, setWeekStartsOn, timeFormat, setTimeFormat } =usePreferences();+ const router = useRouter();+const plausible = usePlausible();return (<div>@@ -19,7 +22,7 @@ const Preferences: React.VoidFunctionComponent = () => {<div className="grow text-sm text-slate-500">{t("common:language")}</div>- <LanguageSelect className="w-full" />+ <LanguageSelect className="w-full" onChange={() => router.reload()} /></div><div className="grow space-y-2"><div>