Skip to content

Commit 6fcb278

Browse files
committed
Logout button
1 parent 6efdda9 commit 6fcb278

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

assets/vue/layouts/AdminLayout.vue

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
>
1111
<BaseIcon name="menu" />
1212
</button>
13-
<div class="relative max-w-md w-full transition-all ">
13+
<div class="relative max-w-md w-full transition-all">
1414
<BaseIcon name="search" />
1515
<input
1616
placeholder="Search subscribers, campaigns..."
@@ -22,18 +22,44 @@
2222

2323
<div class="flex items-center gap-4">
2424
<button class="hidden sm:flex items-center gap-2 px-4 py-2 bg-ext-wf1 text-white text-xs font-bold rounded-lg hover:bg-ext-wf3 transition-shadow shadow-sm shadow-indigo-500/20">
25-
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-plus" aria-hidden="true"><path d="M5 12h14"></path><path d="M12 5v14"></path></svg>
25+
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none"
26+
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
27+
<path d="M5 12h14"></path>
28+
<path d="M12 5v14"></path>
29+
</svg>
2630
Create Campaign
2731
</button>
2832

2933
<!-- User dropdown -->
30-
<div class="flex items-center gap-3 pl-2 group cursor-pointer">
31-
<div class="flex flex-col items-end hidden sm:flex">
32-
<span class="text-sm font-bold text-slate-800 leading-none">{{ adminData.login_name || 'Admin User' }}</span>
33-
<span class="text-[10px] text-slate-500 mt-0.5">{{ adminData.super_user ? 'Super Admin' : 'Administrator' }}</span>
34+
<div class="relative">
35+
<div
36+
class="flex items-center gap-3 pl-2 cursor-pointer"
37+
@click="toggleDropdown"
38+
>
39+
<div class="flex flex-col items-end hidden sm:flex">
40+
<span class="text-sm font-bold text-slate-800 leading-none">
41+
{{ adminData.login_name || 'Admin User' }}
42+
</span>
43+
<span class="text-[10px] text-slate-500 mt-0.5">
44+
{{ adminData.super_user ? 'Super Admin' : 'Administrator' }}
45+
</span>
46+
</div>
47+
48+
<BaseIcon name="chevronDown" />
3449
</div>
3550

36-
<BaseIcon name="chevronDown" />
51+
<!-- Dropdown -->
52+
<div
53+
v-if="dropdownOpen"
54+
class="absolute right-0 mt-2 w-40 bg-white border border-slate-200 rounded-lg shadow-lg py-1 z-50"
55+
>
56+
<a
57+
href="/logout"
58+
class="block px-4 py-2 text-sm text-slate-700 hover:bg-slate-100"
59+
>
60+
Logout
61+
</a>
62+
</div>
3763
</div>
3864
</div>
3965
</header>
@@ -46,22 +72,28 @@
4672
</template>
4773

4874
<script setup>
49-
/* No imports required */
5075
import BaseIcon from "../components/base/BaseIcon.vue";
5176
import { useSidebar } from "../composables/useSidebar";
5277
import { onMounted, ref } from "vue";
5378
5479
const { openSidebar } = useSidebar();
80+
5581
const adminData = ref({});
82+
const dropdownOpen = ref(false);
83+
84+
const toggleDropdown = () => {
85+
dropdownOpen.value = !dropdownOpen.value;
86+
};
5687
5788
onMounted(async () => {
5889
try {
5990
const response = await fetch('/admin-about', {
6091
headers: {
61-
'Accept': 'application/json',
92+
Accept: 'application/json',
6293
'X-Requested-With': 'XMLHttpRequest'
6394
}
6495
});
96+
6597
if (response.ok) {
6698
adminData.value = await response.json();
6799
}

0 commit comments

Comments
 (0)