-
{t("loading")}
+
+
);
};
diff --git a/src/hooks/useAuthMenuOptions.ts b/src/hooks/useAuthMenuOptions.ts
new file mode 100644
index 0000000..50bad97
--- /dev/null
+++ b/src/hooks/useAuthMenuOptions.ts
@@ -0,0 +1,59 @@
+"use client";
+
+import { useState } from "react";
+
+import { signIn, signOut, useSession } from "next-auth/react";
+import { useTranslations } from "next-intl";
+import { useRouter } from "next/navigation";
+
+import { DropdownMenuItem } from "@/components/DropdownMenu";
+
+export const useAuthMenuOptions = () => {
+ const t = useTranslations("Nav");
+ const router = useRouter();
+ const [signingOut, setSigningOut] = useState(false);
+ const { data: sessionData, status } = useSession();
+
+ const handleSignOut = async () => {
+ setSigningOut(true);
+ try {
+ await signOut({ redirect: false });
+ router.push("/");
+ } finally {
+ setSigningOut(false);
+ }
+ };
+
+ if (status === "loading") {
+ return [];
+ }
+
+ if (!sessionData) {
+ return [
+ {
+ title: t("signIn"),
+ onClick: () => signIn(),
+ },
+ ];
+ }
+
+ const items: DropdownMenuItem[] = [
+ {
+ title: t("myZones"),
+ onClick: () => router.push("/zones"),
+ disabled: signingOut,
+ },
+ // {
+ // title: t("deleteAccount"),
+ // onClick: handleSignOut,
+ // disabled: signingOut,
+ // },
+ {
+ title: t("signOut"),
+ onClick: handleSignOut,
+ disabled: signingOut,
+ },
+ ];
+
+ return items;
+};
diff --git a/src/messages/en.json b/src/messages/en.json
index 91a181b..9e4ab91 100644
--- a/src/messages/en.json
+++ b/src/messages/en.json
@@ -35,7 +35,9 @@
"clubs": "Clubs",
"elo": "Elo Calculator",
"signIn": "Sign In",
- "signOut": "Sign Out"
+ "signOut": "Sign Out",
+ "myZones": "My Zones",
+ "deleteAccount": "Delete my Account"
},
"Footer": {
diff --git a/src/messages/fr.json b/src/messages/fr.json
index dfb25ac..efe78f3 100644
--- a/src/messages/fr.json
+++ b/src/messages/fr.json
@@ -35,7 +35,9 @@
"clubs": "Clubs",
"elo": "Calculette Elo",
"signIn": "Se connecter",
- "signOut": "Se déconnecter"
+ "signOut": "Se déconnecter",
+ "myZones": "Mes Régions",
+ "deleteAccount": "Supprimer le compte"
},
"Footer": {
diff --git a/yarn.lock b/yarn.lock
index 8d559d1..5e5cd6a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1178,14 +1178,14 @@
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.0.tgz#a5417ae8427873f1dd08b70b3574b453e67b5f7f"
integrity sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==
-"@floating-ui/core@^1.0.0":
+"@floating-ui/core@^1.0.0", "@floating-ui/core@^1.5.3":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.6.0.tgz#fa41b87812a16bf123122bf945946bae3fdf7fc1"
integrity sha512-PcF++MykgmTj3CIyOQbKA/hDzOAiqI3mhuoN44WRCopIs1sgoDoU4oty4Jtqaj/y3oDU6fnVSm4QG0a3t5i0+g==
dependencies:
"@floating-ui/utils" "^0.2.1"
-"@floating-ui/dom@^1.0.1", "@floating-ui/dom@^1.6.1":
+"@floating-ui/dom@^1.0.1", "@floating-ui/dom@^1.5.4", "@floating-ui/dom@^1.6.1":
version "1.6.3"
resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.6.3.tgz#954e46c1dd3ad48e49db9ada7218b0985cee75ef"
integrity sha512-RnDthu3mzPlQ31Ss/BTwQ1zjzIhr3lk1gZB1OC56h/1vEtaXkESrOqL5fQVMfXpwGtRwX+YsZBdyHtJMQnkArw==
@@ -1193,6 +1193,22 @@
"@floating-ui/core" "^1.0.0"
"@floating-ui/utils" "^0.2.0"
+"@floating-ui/react-dom@^2.0.0":
+ version "2.0.8"
+ resolved "https://registry.yarnpkg.com/@floating-ui/react-dom/-/react-dom-2.0.8.tgz#afc24f9756d1b433e1fe0d047c24bd4d9cefaa5d"
+ integrity sha512-HOdqOt3R3OGeTKidaLvJKcgg75S6tibQ3Tif4eyd91QnIJWr0NLvoXFpJA/j8HqkFSL68GDca9AuyWEHlhyClw==
+ dependencies:
+ "@floating-ui/dom" "^1.6.1"
+
+"@floating-ui/react@^0.26.5":
+ version "0.26.12"
+ resolved "https://registry.yarnpkg.com/@floating-ui/react/-/react-0.26.12.tgz#6908f774d8e3167d89b37fd83be975c7e5d8be99"
+ integrity sha512-D09o62HrWdIkstF2kGekIKAC0/N/Dl6wo3CQsnLcOmO3LkW6Ik8uIb3kw8JYkwxNCcg+uJ2bpWUiIijTBep05w==
+ dependencies:
+ "@floating-ui/react-dom" "^2.0.0"
+ "@floating-ui/utils" "^0.2.0"
+ tabbable "^6.0.0"
+
"@floating-ui/utils@^0.2.0", "@floating-ui/utils@^0.2.1":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.2.1.tgz#16308cea045f0fc777b6ff20a9f25474dd8293d2"
@@ -1259,6 +1275,15 @@
dependencies:
tslib "^2.4.0"
+"@headlessui-float/react@^0.13.3":
+ version "0.13.3"
+ resolved "https://registry.yarnpkg.com/@headlessui-float/react/-/react-0.13.3.tgz#700ac6cfe56a264dcdc4c6486253dd7573b1b970"
+ integrity sha512-wApuiUu2zcuETftdEJupEUG3XP6AUpwNN+kb6rrBadMf/jpOt1rVBjurgL+peKSW9AfxpNT7uqlL4se6u/epqw==
+ dependencies:
+ "@floating-ui/core" "^1.5.3"
+ "@floating-ui/dom" "^1.5.4"
+ "@floating-ui/react" "^0.26.5"
+
"@headlessui/react@^1.7.18":
version "1.7.18"
resolved "https://registry.yarnpkg.com/@headlessui/react/-/react-1.7.18.tgz#30af4634d2215b2ca1aa29d07f33d02bea82d9d7"
@@ -5516,6 +5541,11 @@ supports-preserve-symlinks-flag@^1.0.0:
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
+tabbable@^6.0.0:
+ version "6.2.0"
+ resolved "https://registry.yarnpkg.com/tabbable/-/tabbable-6.2.0.tgz#732fb62bc0175cfcec257330be187dcfba1f3b97"
+ integrity sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==
+
tailwind-merge@^2.0.0:
version "2.2.2"
resolved "https://registry.yarnpkg.com/tailwind-merge/-/tailwind-merge-2.2.2.tgz#87341e7604f0e20499939e152cd2841f41f7a3df"