Skip to content

Commit

Permalink
Update UserNav for guest users
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenWeathers committed Apr 7, 2024
1 parent 044f789 commit 803a324
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 22 deletions.
64 changes: 42 additions & 22 deletions ui/src/components/global/NavUserMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { user } from '../../stores';
import UserAvatar from '../user/UserAvatar.svelte';
import { onMount } from 'svelte';
import VoteIcon from '../icons/VoteIcon.svelte';
export let currentPage;
export let eventTag;
Expand All @@ -30,6 +31,11 @@
router.route(appRoutes.profile, true);
}
function goToRegister() {
toggleMenu();
router.route(appRoutes.register, true);
}
function getProfile() {
xfetch(`/api/users/${$user.id}`)
.then(res => res.json())
Expand Down Expand Up @@ -101,30 +107,44 @@
on:click="{goToProfile}"
>
<UserIcon class="h-4 w-4 me-3" />
<span>Profile</span>
<span>{$LL.profile()}</span>
</button>
</li>
<li class="flex">
<button
class="inline-flex items-center w-full px-2 py-1 font-semibold transition-colors duration-150 rounded-md hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-gray-800 dark:hover:text-gray-200"
on:click="{logoutUser}"
>
<svg
class="w-4 h-4 me-3"
aria-hidden="true"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
viewBox="0 0 24 24"
stroke="currentColor"
{#if $user.rank === 'GUEST'}
<li class="flex">
<button
class="inline-flex items-center w-full px-2 py-1 font-semibold transition-colors duration-150 rounded-md hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-gray-800 dark:hover:text-gray-200"
data-testid="create-account-link"
on:click="{goToRegister}"
>
<path
d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1"
></path>
</svg>
<span>{$LL.logout()}</span>
</button>
</li>
<VoteIcon class="w-4 h-4 me-3 " />
<span>{$LL.createAccount()}</span>
</button>
</li>
{:else}
<li class="flex">
<button
class="inline-flex items-center w-full px-2 py-1 font-semibold transition-colors duration-150 rounded-md hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-gray-800 dark:hover:text-gray-200"
data-testid="logout-link"
on:click="{logoutUser}"
>
<svg
class="w-4 h-4 me-3"
aria-hidden="true"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1"
></path>
</svg>
<span>{$LL.logout()}</span>
</button>
</li>
{/if}
</ul>
{/if}
1 change: 1 addition & 0 deletions ui/src/i18n/de/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ const de: Translation = {
profileDeleteError:
'Es ist ein Fehler beim L\u00F6schen des Kontos aufgetreten.',
profileTitle: 'Profil',
profile: 'Profil',
updatePassword: 'Passwort \u00E4ndern',
deleteAccount: 'Konto l\u00F6schen',
deleteAccountWarningStatement:
Expand Down
1 change: 1 addition & 0 deletions ui/src/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ const en: BaseTranslation = {
passwordUpdateError: 'Error encountered attempting to update password',
profileDeleteError: 'Error encountered attempting to delete your account.',
profileTitle: 'Your Profile',
profile: 'Profile',
updatePassword: 'Update Password',
deleteAccount: 'Delete Account',
deleteAccountWarningStatement:
Expand Down
1 change: 1 addition & 0 deletions ui/src/i18n/es/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ const es: Translation = {
passwordUpdateError: 'Error encountered attempting to update password',
profileDeleteError: 'Error encountered attempting to delete your account.',
profileTitle: 'Your Profile',
profile: 'Profile',
updatePassword: 'Update Password',
deleteAccount: 'Delete Account',
deleteAccountWarningStatement:
Expand Down
1 change: 1 addition & 0 deletions ui/src/i18n/fa/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ const fa: Translation = {
passwordUpdateError: 'Error encountered attempting to update password',
profileDeleteError: 'Error encountered attempting to delete your account.',
profileTitle: 'Your Profile',
profile: 'Profile',
updatePassword: 'Update Password',
deleteAccount: 'Delete Account',
deleteAccountWarningStatement:
Expand Down
1 change: 1 addition & 0 deletions ui/src/i18n/fr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ const fr: Translation = {
passwordUpdateError: 'Erreur lors de la mise à jour du mot de passe',
profileDeleteError: 'Erreur lors de la suppression de votre compte.',
profileTitle: 'Votre Profil',
profile: 'Profile',
updatePassword: 'Mettre à jour le mot de passe',
deleteAccount: 'Supprimer le compte',
deleteAccountWarningStatement:
Expand Down
1 change: 1 addition & 0 deletions ui/src/i18n/it/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ const it: Translation = {
profileDeleteError:
'Errore riscontrato tentativo di eliminare il tuo account.',
profileTitle: 'Il tuo profilo',
profile: 'Profile',
updatePassword: 'Aggiorna la password',
deleteAccount: "Eliminare l'account",
deleteAccountWarningStatement:
Expand Down
1 change: 1 addition & 0 deletions ui/src/i18n/pt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ const pt: Translation = {
passwordUpdateError: 'Erro ao tentar atualizar a senha',
profileDeleteError: 'Erro encontrado ao tentar excluir sua conta.',
profileTitle: 'Seu perfil',
profile: 'Profile',
updatePassword: 'Atualizar senha',
deleteAccount: 'Excluir conta',
deleteAccountWarningStatement: 'Tem certeza de que deseja excluir sua conta?',
Expand Down
1 change: 1 addition & 0 deletions ui/src/i18n/ru/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ const ru: Translation = {
passwordUpdateError: 'Error encountered attempting to update password',
profileDeleteError: 'Error encountered attempting to delete your account.',
profileTitle: 'Your Profile',
profile: 'Profile',
updatePassword: 'Update Password',
deleteAccount: 'Delete Account',
deleteAccountWarningStatement:
Expand Down

0 comments on commit 803a324

Please sign in to comment.