-
Notifications
You must be signed in to change notification settings - Fork 0
Fix auth & made lang switch available when logged out #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b75859b
fix: auth returning wrong account
Woofer21 de1e177
fix: update lang on log out & in
Woofer21 caa2be4
fix: improve how the lang set works
Woofer21 aca5772
feat: restructure lang selector into own comp & availbe when logged out
Woofer21 d54e876
fix: add deps array to useEffect
Woofer21 d954143
chore: improve nav menu padding
dpaulos6 73dd827
fix: merge theme into user bar when logged in
Woofer21 73f0cb0
refactor: change location of nav comps
Woofer21 e2f7484
chore: better user button and added system theme option
dpaulos6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,5 +55,5 @@ | |
| "typescript": "^5", | ||
| "ultracite": "4.2.0" | ||
| }, | ||
| "packageManager": "pnpm@10.6.5" | ||
| "packageManager": "pnpm@10.7.1" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| "use client"; | ||
|
|
||
| import type { Locale } from "@/i18n/config"; | ||
| import { getUserLocale, setUserLocale } from "@/i18n/services/locale"; | ||
| import { authClient } from "@/lib/auth-client"; | ||
| import { Languages } from "lucide-react"; | ||
| import { useTranslations } from "next-intl"; | ||
| import { useEffect, useState } from "react"; | ||
| import Flag from "react-world-flags"; | ||
| import { | ||
| DropdownMenuRadioGroup, | ||
| DropdownMenuRadioItem, | ||
| DropdownMenuSub, | ||
| DropdownMenuSubContent, | ||
| DropdownMenuSubTrigger | ||
| } from "../ui/dropdown-menu"; | ||
|
|
||
| export default function LanguageSwitcher() { | ||
| const t = useTranslations(); | ||
| const { data: session } = authClient.useSession(); | ||
| const [lang, setLang] = useState("en"); | ||
|
|
||
| useEffect(() => { | ||
| async function getLang() { | ||
| setLang(await getUserLocale()); | ||
| } | ||
|
|
||
| getLang(); | ||
| }, []); | ||
|
|
||
| const handleLocaleChange = (value: string) => { | ||
| setUserLocale(value as Locale); | ||
| setLang(value); | ||
|
|
||
| if (session) { | ||
| authClient.updateUser({ | ||
| locale: value | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <DropdownMenuSub> | ||
| <DropdownMenuSubTrigger> | ||
| <Languages className="size-4 text-muted-foreground" /> | ||
| {t("nav.dropdown.language")} | ||
| </DropdownMenuSubTrigger> | ||
| <DropdownMenuSubContent> | ||
| <DropdownMenuRadioGroup | ||
| value={lang} | ||
| onValueChange={(value) => handleLocaleChange(value)} | ||
| > | ||
| <DropdownMenuRadioItem value="en"> | ||
| <Flag | ||
| code="us" | ||
| className="size-4" | ||
| /> | ||
| English | ||
| </DropdownMenuRadioItem> | ||
| <DropdownMenuRadioItem value="de"> | ||
| <Flag | ||
| code="de" | ||
| className="size-4" | ||
| /> | ||
| Deutsch | ||
| </DropdownMenuRadioItem> | ||
| <DropdownMenuRadioItem value="fr"> | ||
| <Flag | ||
| code="fr" | ||
| className="size-4" | ||
| /> | ||
| Français | ||
| </DropdownMenuRadioItem> | ||
| <DropdownMenuRadioItem value="es"> | ||
| <Flag | ||
| code="es" | ||
| className="size-4" | ||
| /> | ||
| Española | ||
| </DropdownMenuRadioItem> | ||
| <DropdownMenuRadioItem value="it"> | ||
| <Flag | ||
| code="it" | ||
| className="size-4" | ||
| /> | ||
| Italiana | ||
| </DropdownMenuRadioItem> | ||
| </DropdownMenuRadioGroup> | ||
| </DropdownMenuSubContent> | ||
| </DropdownMenuSub> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.