+ );
+}
diff --git a/src/app/[locale]/(main)/zones/page.tsx b/src/app/[locale]/(main)/zones/page.tsx
index 8aab6e4..cc1e646 100644
--- a/src/app/[locale]/(main)/zones/page.tsx
+++ b/src/app/[locale]/(main)/zones/page.tsx
@@ -34,7 +34,7 @@ const Zones = () => {
const zones = data?.data ?? [];
return (
-
+
;
+
+type SignInFormProps = {
+ callbackPath?: string;
+};
+
+export const SignInForm = ({ callbackPath }: SignInFormProps) => {
+ const t = useTranslations("SignIn");
+ const locale = useLocale();
+ const path = usePathname();
+
+ const [responseMessage, setResponseMessage] = useState({
+ isSuccessful: false,
+ message: "",
+ });
+
+ const form = useForm({
+ resolver: zodResolver(signInSchema),
+ });
+
+ const onSubmit = async ({ email }: SignInFormValues) => {
+ try {
+ const result = await signIn("nodemailer", {
+ email,
+ redirect: false,
+ callbackUrl: callbackPath ?? `/${locale}/${path}`,
+ });
+
+ if (result?.error) {
+ throw new Error(result.error);
+ } else if (result?.ok) {
+ setResponseMessage({
+ isSuccessful: true,
+ message: t("checkEmail"),
+ });
+
+ form.reset();
+ }
+ } catch (err: unknown) {
+ console.log(err);
+
+ setResponseMessage({
+ isSuccessful: false,
+ message: t("failure"),
+ });
+
+ clearMessage(setResponseMessage);
+ }
+ };
+
+ return (
+
+
+
+ );
+};
diff --git a/src/messages/en.json b/src/messages/en.json
index e271dfe..1d5115a 100644
--- a/src/messages/en.json
+++ b/src/messages/en.json
@@ -219,6 +219,7 @@
"SignIn": {
"title": "Sign In",
"info": "Sign in to access additional features, such as receiving email notifications for tournaments in your area. There's no need to create an account, just sign in with your email address and we'll send you a link.",
+
"emailLabel": "Email",
"emailPlaceholder": "Your email",
"signInButton": "Sign In",
@@ -236,6 +237,8 @@
"Zones": {
"title": "Your Zones",
"info": "You can set up zones to receive email notifications for tournaments in these areas. These zones can also be used to filter tournaments on the main map.",
+ "logonRequired": "You must be signed in to access this feature so that we can store your personalized Zones. There's no need to create an account, just sign in with your email address and we'll send you a link.",
+
"noNotifications": "You have not enabled email notifications for this zone.",
"withNotifications": "You will receive email notifications for new tournaments with {list} time control in this region.",
"editButton": "Edit",
diff --git a/src/messages/fr.json b/src/messages/fr.json
index 30765c0..933fb70 100644
--- a/src/messages/fr.json
+++ b/src/messages/fr.json
@@ -237,6 +237,8 @@
"Zones": {
"title": "Vos régions",
"info": "Vous pouvez définir des zones personnalisées pour recevoir des notifications par e-mail pour les tournois dans ces zones. Ces zones peuvent aussi être utiliser pour filtrer les tournois sur la carte.",
+ "logonRequired": "Vous devez être connecté pour accéder à cette fonctionnalité afin que nous puissions stocker vos régions personnalisées. Vous n'avez pas besoin de créer un compte, connectez-vous simplement avec votre adresse e-mail et nous vous enverrons un lien.",
+
"noNotifications": "Vous n'avez pas activé les notifications par email pour cette région.",
"withNotifications": "Vous allez recevoir des notifications par e-mail pour les nouveaux tournois de cadences {list} dans cette région.",
"editButton": "Modifier",
diff --git a/src/utils/navigation.ts b/src/utils/navigation.ts
index 4ffb2c0..92adadd 100644
--- a/src/utils/navigation.ts
+++ b/src/utils/navigation.ts
@@ -41,8 +41,6 @@ export const pathnames = {
fr: "/contactez-nous",
en: "/contact-us",
},
-
- "[...rest]": "[...rest]",
} satisfies Pathnames;
export const { Link, redirect, usePathname, useRouter, getPathname } =
diff --git a/src/utils/nodemailerProvider.ts b/src/utils/nodemailerProvider.ts
index 488b7a2..317e496 100644
--- a/src/utils/nodemailerProvider.ts
+++ b/src/utils/nodemailerProvider.ts
@@ -133,16 +133,20 @@ export default function Nodemailer(
maxAge: 24 * 60 * 60,
async sendVerificationRequest(params) {
+ const { identifier, url, provider } = params;
+
let locale = "fr";
- const { searchParams } = new URL(params.url);
+ const { searchParams } = new URL(url);
if (searchParams.has("callbackUrl")) {
const { pathname } = new URL(searchParams.get("callbackUrl")!);
- locale = pathname.split("/")[1];
+ const maybeLocale = pathname.split("/")[1];
+ if (["en", "fr"].includes(maybeLocale)) {
+ locale = maybeLocale;
+ }
}
const t = await getTranslations({ locale, namespace: "SignIn" });
- const { identifier, url, provider } = params;
const { host } = new URL(url);
const transport = createTransport(provider.server);
const result = await transport.sendMail({