Skip to content

Commit 180fa1c

Browse files
committed
feat: logout from navbar. fix: Refresh on login to fetch new dashboard layout
1 parent 63d2cae commit 180fa1c

File tree

7 files changed

+21
-25
lines changed

7 files changed

+21
-25
lines changed

resources/ts/Components/AdminSidebar.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
icon: 'user',
4848
},
4949
{
50-
title: 'Go Home',
50+
title: 'Go Frontend',
5151
route: '/',
5252
icon: 'arrow-back',
5353
},

resources/ts/Layouts/AppLayout.svelte

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import MainLayout from './MainLayout.svelte'
44
import { page, inertia, useForm } from '@inertiajs/svelte'
55
import Footer from '@/Components/Footer.svelte'
6+
import { confirmAction } from '@/helpers'
7+
import { toasts } from 'svelte-toasts'
68
79
$: auth = $page.props.auth.user
810
@@ -41,26 +43,13 @@
4143
isNavCollapsed = true
4244
e.preventDefault()
4345
44-
// const confirm: ModalSettings = {
45-
// type: 'confirm',
46-
// title: 'Logout?',
47-
// body: 'Are you sure you want to logout?',
48-
// response: (r: boolean) => {
49-
// if (r) {
50-
// $form.post(route('logout'), {
51-
// onSuccess: () => {
52-
// const t: ToastSettings = {
53-
// message: 'Logged out',
54-
// background: 'variant-filled-success',
55-
// }
56-
// toastStore.trigger(t)
57-
// },
58-
// })
59-
// }
60-
// },
61-
// }
62-
63-
// modalStore.trigger(confirm)
46+
confirmAction('Are you sure you want to logout?', () => {
47+
$form.post(route('logout'), {
48+
onSuccess: () => {
49+
toasts.success('Logged out')
50+
},
51+
})
52+
})
6453
}
6554
</script>
6655

resources/ts/Layouts/DashboardLayout.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@
102102
</div>
103103
</div>
104104

105-
<slot />
105+
<main class="container px-2 md:px-4 lg:px-5">
106+
<slot />
107+
</main>
106108
</div>
107109
</div>
108110
</MainLayout>

resources/ts/Pages/Auth/Login.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
function handleSubmit(e) {
2828
e.preventDefault()
2929
30-
$form.post(route('login'))
30+
$form.post(route('login'), {
31+
onSuccess: resp => {
32+
window.location.reload()
33+
},
34+
})
3135
}
3236
</script>
3337

resources/ts/Pages/User/Dashboard.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
onMount(() => (ready = true))
1010
</script>
1111

12-
<div class="container mt-5">
12+
<div class="mt-5">
1313
{#if ready}
1414
<div in:fly={{ y: -70, duration: 300, easing: quintOut }}>
1515
<Title>User Dashboard</Title>

resources/ts/Pages/User/Profile/MainProfile.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
import { Title } from '@/Components'
33
</script>
44

5-
<div class="container mt-5">
5+
<div class="mt-5">
66
<Title>Profile</Title>
77
</div>

resources/ts/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const appName = window.document.getElementsByTagName('title')[0]?.innerText || '
1313
createInertiaApp({
1414
title: (title: string | null) => `${title || ''} - ${appName}`,
1515
resolve: (name: string) => {
16+
console.log("name", name);
1617
// set eager loading to true to get one js file. NB: Must be Enabled if Svelte
1718
const pages = import.meta.glob('./Pages/**/*.svelte', { eager: true })
1819
let page = pages[`./Pages/${name}.svelte`]

0 commit comments

Comments
 (0)