perbaikan ui profile dan logout
This commit is contained in:
@@ -68,21 +68,6 @@
|
|||||||
"vm",
|
"vm",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "Profile",
|
|
||||||
icon: "🧑",
|
|
||||||
url: "/backoffice/profile",
|
|
||||||
roles: [
|
|
||||||
"it",
|
|
||||||
"ga",
|
|
||||||
"hr",
|
|
||||||
"s&m",
|
|
||||||
"office",
|
|
||||||
"hm",
|
|
||||||
"vm",
|
|
||||||
"accounting",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "Issues",
|
name: "Issues",
|
||||||
icon: "📂",
|
icon: "📂",
|
||||||
@@ -191,22 +176,6 @@
|
|||||||
url: "/backoffice/feedback",
|
url: "/backoffice/feedback",
|
||||||
roles: ["it", "ga", "s&m", "office", "hm", "vm"],
|
roles: ["it", "ga", "s&m", "office", "hm", "vm"],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "Logout",
|
|
||||||
icon: "🚪",
|
|
||||||
url: "/logout",
|
|
||||||
roles: [
|
|
||||||
"it",
|
|
||||||
"guest",
|
|
||||||
"accounting",
|
|
||||||
"ga",
|
|
||||||
"hr",
|
|
||||||
"s&m",
|
|
||||||
"office",
|
|
||||||
"hm",
|
|
||||||
"vm",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
let activeUrl = "/";
|
let activeUrl = "/";
|
||||||
@@ -222,13 +191,6 @@
|
|||||||
activeUrl = item.url;
|
activeUrl = item.url;
|
||||||
openMenus[item.name] = !openMenus[item.name];
|
openMenus[item.name] = !openMenus[item.name];
|
||||||
} else {
|
} else {
|
||||||
if (item.url === "/logout") {
|
|
||||||
if (confirm("Are you sure you want to logout?")) {
|
|
||||||
logout();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
activeUrl = item.url;
|
activeUrl = item.url;
|
||||||
goto(item.url);
|
goto(item.url);
|
||||||
}
|
}
|
||||||
@@ -250,23 +212,6 @@
|
|||||||
)
|
)
|
||||||
: undefined,
|
: undefined,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// logout
|
|
||||||
async function logout() {
|
|
||||||
const { error } = await supabase.auth.signOut();
|
|
||||||
if (error) {
|
|
||||||
console.error("Logout failed:", error.message);
|
|
||||||
} else {
|
|
||||||
localStorage.removeItem("user");
|
|
||||||
|
|
||||||
goto("/login");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle logout click
|
|
||||||
function handleLogoutClick() {
|
|
||||||
logout();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="w-64 h-screen bg-white border-r shadow-sm">
|
<div class="w-64 h-screen bg-white border-r shadow-sm">
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
avatar: "https://i.pravatar.cc/40",
|
avatar: "https://i.pravatar.cc/40",
|
||||||
};
|
};
|
||||||
let userdata: any = null;
|
let userdata: any = null;
|
||||||
|
let showDropdown = false;
|
||||||
|
|
||||||
const session = writable<Session | null>(null);
|
const session = writable<Session | null>(null);
|
||||||
|
|
||||||
@@ -39,6 +40,19 @@
|
|||||||
user.name = userdata.full_name || "Guest";
|
user.name = userdata.full_name || "Guest";
|
||||||
user.avatar = userdata.profile_picture || "https://i.pravatar.cc/40";
|
user.avatar = userdata.profile_picture || "https://i.pravatar.cc/40";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//alert logout function
|
||||||
|
function handleLogout() {
|
||||||
|
if (confirm("Are you sure you want to logout?")) {
|
||||||
|
logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function logout() {
|
||||||
|
await supabase.auth.signOut();
|
||||||
|
localStorage.clear();
|
||||||
|
goto("/login");
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex h-screen">
|
<div class="flex h-screen">
|
||||||
@@ -55,9 +69,9 @@
|
|||||||
<div class="flex items-center gap-6">
|
<div class="flex items-center gap-6">
|
||||||
<!-- Notifications -->
|
<!-- Notifications -->
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<button class="text-gray-600 hover:text-gray-800 text-xl">
|
<button class="text-gray-600 hover:text-gray-800 text-xl"
|
||||||
🔔
|
>🔔</button
|
||||||
</button>
|
>
|
||||||
{#if notifications > 0}
|
{#if notifications > 0}
|
||||||
<span
|
<span
|
||||||
class="absolute -top-1 -right-1 bg-red-500 text-white text-xs w-5 h-5 flex items-center justify-center rounded-full"
|
class="absolute -top-1 -right-1 bg-red-500 text-white text-xs w-5 h-5 flex items-center justify-center rounded-full"
|
||||||
@@ -66,8 +80,12 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Profile -->
|
<!-- Profile with Dropdown -->
|
||||||
<div class="flex items-center gap-2">
|
<div class="relative">
|
||||||
|
<button
|
||||||
|
class="flex items-center gap-2 focus:outline-none"
|
||||||
|
on:click={() => (showDropdown = !showDropdown)}
|
||||||
|
>
|
||||||
<img
|
<img
|
||||||
src={user.avatar}
|
src={user.avatar}
|
||||||
alt="User Avatar"
|
alt="User Avatar"
|
||||||
@@ -76,6 +94,38 @@
|
|||||||
<span class="text-sm font-medium text-gray-700"
|
<span class="text-sm font-medium text-gray-700"
|
||||||
>{user.name}</span
|
>{user.name}</span
|
||||||
>
|
>
|
||||||
|
<svg
|
||||||
|
class="w-4 h-4 ml-1"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="2"
|
||||||
|
d="M19 9l-7 7-7-7"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{#if showDropdown}
|
||||||
|
<div
|
||||||
|
class="absolute right-0 mt-2 w-40 bg-white border rounded-md shadow-lg z-10"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
href="/backoffice/profile"
|
||||||
|
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100"
|
||||||
|
>Profile</a
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
on:click={handleLogout}
|
||||||
|
class="w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-gray-100"
|
||||||
|
>
|
||||||
|
Logout
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
7
src/routes/backoffice/dining/+page.svelte
Normal file
7
src/routes/backoffice/dining/+page.svelte
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<div
|
||||||
|
style="display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh;"
|
||||||
|
>
|
||||||
|
<div style="font-size: 4rem; margin-bottom: 1rem;">🔒🔨</div>
|
||||||
|
<h2>Halaman sedang dalam tahap development</h2>
|
||||||
|
<p>Mohon maaf, halaman ini belum tersedia.</p>
|
||||||
|
</div>
|
||||||
7
src/routes/backoffice/inventory/+page.svelte
Normal file
7
src/routes/backoffice/inventory/+page.svelte
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<div
|
||||||
|
style="display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh;"
|
||||||
|
>
|
||||||
|
<div style="font-size: 4rem; margin-bottom: 1rem;">🔒🔨</div>
|
||||||
|
<h2>Halaman sedang dalam tahap development</h2>
|
||||||
|
<p>Mohon maaf, halaman ini belum tersedia.</p>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user