Fix logout in nav

This commit is contained in:
Alex Thomassen 2024-02-10 16:50:03 +00:00
parent ce2024b943
commit cb8925463f
Signed by: Alex
GPG Key ID: 10BD786B5F6FF5DE

View File

@ -17,15 +17,15 @@ public function logout(Logout $logout): void
} }
}; ?> }; ?>
<nav x-data="{ open: false }" class="bg-white dark:bg-gray-800 border-b border-gray-100 dark:border-gray-700"> <nav x-data="{ open: false }" class="bg-white border-b border-gray-100 dark:bg-gray-800 dark:border-gray-700">
<!-- Primary Navigation Menu --> <!-- Primary Navigation Menu -->
<div class="max-w-full mx-auto px-4 sm:px-6 lg:px-8"> <div class="max-w-full px-4 mx-auto sm:px-6 lg:px-8">
<div class="flex justify-between h-16"> <div class="flex justify-between h-16">
<div class="flex"> <div class="flex">
<!-- Logo --> <!-- Logo -->
<div class="shrink-0 flex items-center"> <div class="flex items-center shrink-0">
<a href="{{ route('dashboard') }}" wire:navigate> <a href="{{ route('dashboard') }}" wire:navigate>
<x-application-logo class="block h-9 w-auto fill-current text-gray-800 dark:text-gray-200" /> <x-application-logo class="block w-auto text-gray-800 fill-current h-9 dark:text-gray-200" />
</a> </a>
</div> </div>
@ -42,12 +42,12 @@ public function logout(Logout $logout): void
<div class="hidden sm:flex sm:items-center sm:ms-6"> <div class="hidden sm:flex sm:items-center sm:ms-6">
<x-dropdown align="right" width="48"> <x-dropdown align="right" width="48">
<x-slot name="trigger"> <x-slot name="trigger">
<button class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300 focus:outline-none transition ease-in-out duration-150"> <button class="inline-flex items-center px-3 py-2 text-sm font-medium leading-4 text-gray-500 transition duration-150 ease-in-out bg-white border border-transparent rounded-md dark:text-gray-400 dark:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300 focus:outline-none">
<img src="{{ Auth::user()->avatar }}" class="h-6 w-6 rounded-full" alt="{{ Auth::user()->display_name }}" /> <img src="{{ Auth::user()->avatar }}" class="w-6 h-6 rounded-full" alt="{{ Auth::user()->display_name }}" />
<div class="ml-2">{{ Auth::user()->display_name }}</div> <div class="ml-2">{{ Auth::user()->display_name }}</div>
<div class="ms-1"> <div class="ms-1">
<svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"> <svg class="w-4 h-4 fill-current" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" /> <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg> </svg>
</div> </div>
@ -56,20 +56,24 @@ public function logout(Logout $logout): void
<x-slot name="content"> <x-slot name="content">
<!-- Authentication --> <!-- Authentication -->
<button wire:click="logout" class="w-full text-start"> <form method="POST" action="{{ route('logout') }}">
<x-dropdown-link> @csrf
<x-dropdown-link :href="route('logout')"
onclick="event.preventDefault();
this.closest('form').submit();">
{{ __('Log Out') }} {{ __('Log Out') }}
</x-dropdown-link> </x-dropdown-link>
</button> </form>
</x-slot> </x-slot>
</x-dropdown> </x-dropdown>
</div> </div>
@endif @endif
<!-- Hamburger --> <!-- Hamburger -->
<div class="-me-2 flex items-center sm:hidden"> <div class="flex items-center -me-2 sm:hidden">
<button @click="open = ! open" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-900 focus:outline-none focus:bg-gray-100 dark:focus:bg-gray-900 focus:text-gray-500 dark:focus:text-gray-400 transition duration-150 ease-in-out"> <button @click="open = ! open" class="inline-flex items-center justify-center p-2 text-gray-400 transition duration-150 ease-in-out rounded-md dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-900 focus:outline-none focus:bg-gray-100 dark:focus:bg-gray-900 focus:text-gray-500 dark:focus:text-gray-400">
<svg class="h-6 w-6" stroke="currentColor" fill="none" viewBox="0 0 24 24"> <svg class="w-6 h-6" stroke="currentColor" fill="none" viewBox="0 0 24 24">
<path :class="{'hidden': open, 'inline-flex': ! open }" class="inline-flex" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" /> <path :class="{'hidden': open, 'inline-flex': ! open }" class="inline-flex" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
<path :class="{'hidden': ! open, 'inline-flex': open }" class="hidden" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /> <path :class="{'hidden': ! open, 'inline-flex': open }" class="hidden" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg> </svg>
@ -90,17 +94,20 @@ public function logout(Logout $logout): void
<!-- Responsive Settings Options --> <!-- Responsive Settings Options -->
<div class="pt-4 pb-1 border-t border-gray-200 dark:border-gray-600"> <div class="pt-4 pb-1 border-t border-gray-200 dark:border-gray-600">
<div class="px-4"> <div class="px-4">
<div class="font-medium text-base text-gray-800 dark:text-gray-200" x-data="{ name: '{{ auth()->user()->display_name }}' }" x-text="name" x-on:profile-updated.window="name = $event.detail.name"></div> <div class="text-base font-medium text-gray-800 dark:text-gray-200" x-data="{ name: '{{ auth()->user()->display_name }}' }" x-text="name" x-on:profile-updated.window="name = $event.detail.name"></div>
<div class="font-medium text-sm text-gray-500">{{ auth()->user()->display_name }}</div> <div class="text-sm font-medium text-gray-500">{{ auth()->user()->display_name }}</div>
</div> </div>
<div class="mt-3 space-y-1"> <div class="mt-3 space-y-1">
<!-- Authentication --> <form method="POST" action="{{ route('logout') }}">
<button wire:click="logout" class="w-full text-start"> @csrf
<x-responsive-nav-link>
<x-responsive-nav-link :href="route('logout')"
onclick="event.preventDefault();
this.closest('form').submit();">
{{ __('Log Out') }} {{ __('Log Out') }}
</x-responsive-nav-link> </x-responsive-nav-link>
</button> </form>
</div> </div>
</div> </div>
</div> </div>