@finema/finework-layer 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +1 -0
- package/.playground/app/assets/css/main.css +6 -0
- package/.playground/app/pages/layout-admin.vue +104 -0
- package/.playground/app.config.ts +2 -2
- package/.playground/nuxt.config.ts +1 -9
- package/CHANGELOG.md +34 -28
- package/app/app.config.ts +297 -298
- package/app/app.vue +10 -10
- package/app/assets/css/main.css +2 -3
- package/app/components/Button/ActionIcon.vue +29 -29
- package/app/components/Button/Back.vue +22 -22
- package/app/components/InfoItemList.vue +202 -202
- package/app/components/Layout/Admin/Apps.vue +45 -0
- package/app/components/Layout/Admin/Sidebar.vue +233 -0
- package/app/components/Layout/Admin/index.vue +220 -0
- package/app/components/StatusBox.vue +56 -56
- package/app/composables/useAuth.ts +189 -0
- package/app/composables/useRequestOptions.ts +50 -0
- package/app/constants/routes.ts +86 -0
- package/app/error.vue +218 -218
- package/app.config.ts +2 -2
- package/bun.lock +151 -111
- package/eslint.config.js +3 -1
- package/index.d.ts +16 -16
- package/nuxt.config.ts +6 -10
- package/package.json +15 -8
- package/tsconfig.json +20 -2
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<aside
|
|
3
|
+
:class="[`
|
|
4
|
+
flex h-full flex-col overflow-y-auto bg-white
|
|
5
|
+
transition-all duration-300
|
|
6
|
+
`]"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
:class="['flex h-[72px] w-[260px] items-center pl-5 max-sm:pr-5', {
|
|
10
|
+
'justify-center': isCollapsed,
|
|
11
|
+
'justify-between': !isCollapsed,
|
|
12
|
+
}]"
|
|
13
|
+
>
|
|
14
|
+
<NuxtLink :to="routes.home.to">
|
|
15
|
+
<img
|
|
16
|
+
v-if="!isCollapsed"
|
|
17
|
+
src="/logo-mini.png"
|
|
18
|
+
alt="logo_mini_color"
|
|
19
|
+
class="h-[27px]"
|
|
20
|
+
/>
|
|
21
|
+
</NuxtLink>
|
|
22
|
+
|
|
23
|
+
<Navbar />
|
|
24
|
+
</div>
|
|
25
|
+
<div class="bg-primary flex items-center justify-between px-7 py-4 font-bold text-white">
|
|
26
|
+
{{ isCollapsed ? '' : label }}
|
|
27
|
+
|
|
28
|
+
<Icon
|
|
29
|
+
v-if="!isCollapsed"
|
|
30
|
+
name="fluent:arrow-circle-left-24-regular"
|
|
31
|
+
class="size-[24px] cursor-pointer"
|
|
32
|
+
@click="$emit('toggle-collapsed')"
|
|
33
|
+
/>
|
|
34
|
+
<Icon
|
|
35
|
+
v-else
|
|
36
|
+
name="fluent:arrow-circle-right-24-regular"
|
|
37
|
+
class="size-[24px] cursor-pointer"
|
|
38
|
+
@click="$emit('toggle-collapsed')"
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div class="flex-1 overflow-y-auto border-r border-gray-200 p-4">
|
|
43
|
+
<div
|
|
44
|
+
v-if="isGroup"
|
|
45
|
+
class="space-y-4 divide-y-1 divide-[#d9d9d9]"
|
|
46
|
+
>
|
|
47
|
+
<div
|
|
48
|
+
v-for="group in navigationItems"
|
|
49
|
+
:key="group.label"
|
|
50
|
+
class="pb-4"
|
|
51
|
+
>
|
|
52
|
+
<div class="mt-2 mb-2 text-[10px] font-semibold text-gray-400">
|
|
53
|
+
{{ group.label }}
|
|
54
|
+
</div>
|
|
55
|
+
<NavigationMenu
|
|
56
|
+
orientation="vertical"
|
|
57
|
+
:items="group.children"
|
|
58
|
+
:collapsed="isCollapsed"
|
|
59
|
+
:popover="isCollapsed"
|
|
60
|
+
:tooltip="isCollapsed"
|
|
61
|
+
:ui="{
|
|
62
|
+
list: 'space-y-2 ',
|
|
63
|
+
label: [
|
|
64
|
+
'text-sm font-bold text-gray-500 py-[12px] px-[10px] rounded-lg',
|
|
65
|
+
'hover:text-primary',
|
|
66
|
+
],
|
|
67
|
+
link: [
|
|
68
|
+
'cursor-pointer text-sm font-bold text-gray-500 px-[10px] rounded-lg gap-3',
|
|
69
|
+
'hover:text-primary',
|
|
70
|
+
'data-active:before:bg-white data-active:before:rounded-lg data-active:text-primary font-semibold',
|
|
71
|
+
],
|
|
72
|
+
linkLeadingIcon: 'group-data-[state=open]:text-current text-current size-[24px] group-hover:text-primary',
|
|
73
|
+
childList: 'border-none ms-0 pl-8 bg-gray-100 mt-2 py-1 rounded-lg',
|
|
74
|
+
childLink: 'ps-0',
|
|
75
|
+
childItem: 'ps-0',
|
|
76
|
+
}"
|
|
77
|
+
class="w-full justify-center"
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
<NavigationMenu
|
|
82
|
+
v-else
|
|
83
|
+
orientation="vertical"
|
|
84
|
+
:items="navigationItems"
|
|
85
|
+
:collapsed="isCollapsed"
|
|
86
|
+
:popover="isCollapsed"
|
|
87
|
+
:tooltip="isCollapsed"
|
|
88
|
+
:ui="{
|
|
89
|
+
list: 'space-y-2 ',
|
|
90
|
+
label: [
|
|
91
|
+
'text-sm font-bold text-gray-500 py-[12px] px-[10px] rounded-lg',
|
|
92
|
+
'hover:text-primary',
|
|
93
|
+
],
|
|
94
|
+
link: [
|
|
95
|
+
'cursor-pointer text-sm font-bold text-gray-500 px-[10px] rounded-lg gap-3',
|
|
96
|
+
'hover:text-primary',
|
|
97
|
+
'data-active:before:bg-white data-active:before:rounded-lg data-active:text-primary font-semibold',
|
|
98
|
+
],
|
|
99
|
+
linkLeadingIcon: 'group-data-[state=open]:text-current text-current size-[24px] group-hover:text-primary ',
|
|
100
|
+
childList: 'border-none ms-0 pl-8 bg-gray-100 mt-2 py-1 rounded-lg',
|
|
101
|
+
childLink: 'ps-0',
|
|
102
|
+
childItem: 'ps-0',
|
|
103
|
+
}"
|
|
104
|
+
class="w-full justify-center"
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
<div
|
|
108
|
+
v-if="isMobile"
|
|
109
|
+
class="border-t border-gray-100 p-3"
|
|
110
|
+
>
|
|
111
|
+
<div class="flex items-center justify-between gap-2">
|
|
112
|
+
<div class="flex min-w-0 flex-1 items-center gap-3">
|
|
113
|
+
<Avatar
|
|
114
|
+
class="border-muted size-[32px] flex-shrink-0 border text-lg"
|
|
115
|
+
icon="ri:user-line"
|
|
116
|
+
:src="auth.me.value?.avatar_url || ''"
|
|
117
|
+
/>
|
|
118
|
+
<div class="flex min-w-0 flex-1 flex-col">
|
|
119
|
+
<p class="truncate text-sm font-bold">
|
|
120
|
+
{{ auth.me.value?.display_name || auth.me.value?.full_name }}
|
|
121
|
+
</p>
|
|
122
|
+
<p class="text-muted truncate text-xs">
|
|
123
|
+
{{ auth.me.value?.email || '' }}
|
|
124
|
+
</p>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
<DropdownMenu
|
|
128
|
+
arrow
|
|
129
|
+
size="xl"
|
|
130
|
+
:items="userMenuItems"
|
|
131
|
+
:ui="{
|
|
132
|
+
content: 'w-48',
|
|
133
|
+
}"
|
|
134
|
+
>
|
|
135
|
+
<Button
|
|
136
|
+
icon="ph:dots-three-outline-vertical-bold"
|
|
137
|
+
variant="ghost"
|
|
138
|
+
color="neutral"
|
|
139
|
+
size="xs"
|
|
140
|
+
/>
|
|
141
|
+
</DropdownMenu>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
</aside>
|
|
145
|
+
</template>
|
|
146
|
+
|
|
147
|
+
<script lang="ts" setup>
|
|
148
|
+
import type { NavigationMenuItem } from '@nuxt/ui'
|
|
149
|
+
import { computed } from 'vue'
|
|
150
|
+
import { useRoute } from 'vue-router'
|
|
151
|
+
import Navbar from './Apps.vue'
|
|
152
|
+
|
|
153
|
+
defineEmits<{
|
|
154
|
+
'toggle-collapsed': []
|
|
155
|
+
}>()
|
|
156
|
+
|
|
157
|
+
const props = defineProps<{
|
|
158
|
+
label: string
|
|
159
|
+
isCollapsed: boolean
|
|
160
|
+
isMobile?: boolean
|
|
161
|
+
items: NavigationMenuItem[]
|
|
162
|
+
isGroup?: boolean
|
|
163
|
+
}>()
|
|
164
|
+
|
|
165
|
+
const route = useRoute()
|
|
166
|
+
const auth = useAuth()
|
|
167
|
+
const userMenuItems = [
|
|
168
|
+
|
|
169
|
+
{
|
|
170
|
+
label: 'View profile',
|
|
171
|
+
icon: 'i-lucide-user',
|
|
172
|
+
to: routes.account.profile.to,
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
{
|
|
176
|
+
label: routes.logout.label,
|
|
177
|
+
icon: 'i-lucide-log-out',
|
|
178
|
+
to: routes.logout.to,
|
|
179
|
+
external: true,
|
|
180
|
+
},
|
|
181
|
+
]
|
|
182
|
+
|
|
183
|
+
const mappedItems = (items: NavigationMenuItem[]): NavigationMenuItem[] => {
|
|
184
|
+
return items.map((item) => {
|
|
185
|
+
let isAnyChildActive = false
|
|
186
|
+
const mappedChildren = item.children?.map((child) => {
|
|
187
|
+
const isChildCurrentlyActive = route.path === child.to
|
|
188
|
+
|
|
189
|
+
if (isChildCurrentlyActive) {
|
|
190
|
+
isAnyChildActive = true
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
active: isChildCurrentlyActive,
|
|
195
|
+
class: 'hover:bg-transparent hover:text-gray-700 hover:font-bold py-2 data-active:before:bg-transparent data-active:text-gray-700 data-active:font-bold',
|
|
196
|
+
icon: '',
|
|
197
|
+
...child,
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
const selfIsActive = item.to ? route.path.startsWith(String(item.to)) : false
|
|
202
|
+
|
|
203
|
+
const itemIsActive = selfIsActive || isAnyChildActive // A root item is active if its own link matches OR if any child is active
|
|
204
|
+
|
|
205
|
+
const itemDefaultOpen = item.children ? isAnyChildActive : false
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
...item,
|
|
209
|
+
active: itemIsActive,
|
|
210
|
+
class: itemIsActive
|
|
211
|
+
? 'before:bg-primary before:rounded-lg text-white'
|
|
212
|
+
: '',
|
|
213
|
+
defaultOpen: itemDefaultOpen || selfIsActive,
|
|
214
|
+
open: itemDefaultOpen || selfIsActive,
|
|
215
|
+
children: mappedChildren,
|
|
216
|
+
to: mappedChildren ? undefined : item.to,
|
|
217
|
+
}
|
|
218
|
+
})
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const navigationItems = computed<NavigationMenuItem[]>(() => {
|
|
222
|
+
if (props.isGroup) {
|
|
223
|
+
return props.items.map((group) => {
|
|
224
|
+
return {
|
|
225
|
+
...group,
|
|
226
|
+
children: mappedItems(group.children as NavigationMenuItem[]),
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return mappedItems(props.items)
|
|
232
|
+
})
|
|
233
|
+
</script>
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="relative flex min-h-screen flex-1">
|
|
3
|
+
<div
|
|
4
|
+
:class="[`
|
|
5
|
+
fixed inset-0 z-30 hidden w-auto
|
|
6
|
+
lg:block
|
|
7
|
+
`, {
|
|
8
|
+
'max-w-[88px]': isCollapsed,
|
|
9
|
+
'max-w-[260px]': !isCollapsed,
|
|
10
|
+
}]"
|
|
11
|
+
>
|
|
12
|
+
<Sidebar
|
|
13
|
+
:label="label"
|
|
14
|
+
:is-collapsed="isCollapsed"
|
|
15
|
+
:items="sidebarItems"
|
|
16
|
+
:is-group="isSidebarGroup"
|
|
17
|
+
@toggle-collapsed="isCollapsed = !isCollapsed"
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
20
|
+
<div
|
|
21
|
+
:class="['w-full bg-gray-50', {
|
|
22
|
+
'lg:pl-[88px]': isCollapsed,
|
|
23
|
+
'lg:pl-[260px]': !isCollapsed,
|
|
24
|
+
}]"
|
|
25
|
+
>
|
|
26
|
+
<nav
|
|
27
|
+
class="
|
|
28
|
+
fixed top-0 left-0 z-20 flex min-h-[72px] w-screen items-center
|
|
29
|
+
justify-between gap-4 bg-white px-5
|
|
30
|
+
lg:justify-end
|
|
31
|
+
"
|
|
32
|
+
style="box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.04);"
|
|
33
|
+
>
|
|
34
|
+
<div class="flex items-center gap-4">
|
|
35
|
+
<Slideover
|
|
36
|
+
v-model:open="isShowSidebarMobile"
|
|
37
|
+
:ui="{
|
|
38
|
+
content: 'w-[80%] max-w-[260px] lg:hidden',
|
|
39
|
+
overlay: 'lg:hidden',
|
|
40
|
+
}"
|
|
41
|
+
side="left"
|
|
42
|
+
>
|
|
43
|
+
<svg
|
|
44
|
+
class="
|
|
45
|
+
cursor-pointer
|
|
46
|
+
lg:hidden
|
|
47
|
+
"
|
|
48
|
+
width="19"
|
|
49
|
+
height="18"
|
|
50
|
+
viewBox="0 0 19 18"
|
|
51
|
+
fill="none"
|
|
52
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
53
|
+
transform="scale(-1, 1)"
|
|
54
|
+
@click="isShowSidebarMobile = true"
|
|
55
|
+
>
|
|
56
|
+
<path
|
|
57
|
+
d="M10 18L10 16L19 16L19 18L10 18ZM6 2L6 -2.62268e-07L19 -8.30516e-07L19 2L6 2ZM-3.49691e-07 10L-4.37114e-07 8L19 8L19 10L-3.49691e-07 10Z"
|
|
58
|
+
fill="#4B5563"
|
|
59
|
+
/>
|
|
60
|
+
</svg>
|
|
61
|
+
|
|
62
|
+
<template #content>
|
|
63
|
+
<Sidebar
|
|
64
|
+
:label="label"
|
|
65
|
+
:is-collapsed="false"
|
|
66
|
+
:is-mobile="true"
|
|
67
|
+
:items="sidebarItems"
|
|
68
|
+
:is-group="isSidebarGroup"
|
|
69
|
+
@toggle-collapsed="isShowSidebarMobile = false"
|
|
70
|
+
/>
|
|
71
|
+
</template>
|
|
72
|
+
</Slideover>
|
|
73
|
+
<NuxtLink :to="routes.home.to">
|
|
74
|
+
<img
|
|
75
|
+
src="/logo-mini.png"
|
|
76
|
+
alt="logo_mini_color"
|
|
77
|
+
class="
|
|
78
|
+
h-[20px]
|
|
79
|
+
lg:hidden
|
|
80
|
+
"
|
|
81
|
+
/>
|
|
82
|
+
</NuxtLink>
|
|
83
|
+
<Apps class="lg:hidden" />
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<div class="flex items-center justify-center gap-4">
|
|
87
|
+
<DropdownMenu
|
|
88
|
+
size="xl"
|
|
89
|
+
:items="userMenuItems"
|
|
90
|
+
:content="{
|
|
91
|
+
align: 'end',
|
|
92
|
+
side: 'bottom',
|
|
93
|
+
}"
|
|
94
|
+
:ui="{
|
|
95
|
+
content: 'w-48',
|
|
96
|
+
}"
|
|
97
|
+
>
|
|
98
|
+
<div class="relative flex cursor-pointer items-center gap-2">
|
|
99
|
+
<div
|
|
100
|
+
class="flex flex-col justify-end text-right max-sm:hidden"
|
|
101
|
+
>
|
|
102
|
+
<p class="font-bold">
|
|
103
|
+
{{ auth.me.value?.display_name || auth.me.value?.full_name }}
|
|
104
|
+
</p>
|
|
105
|
+
<p class="text-muted text-sm">
|
|
106
|
+
{{ auth.me.value?.email || '' }}
|
|
107
|
+
</p>
|
|
108
|
+
</div>
|
|
109
|
+
<Avatar
|
|
110
|
+
class="border-muted size-[40px] border text-2xl"
|
|
111
|
+
icon="ri:user-line"
|
|
112
|
+
:src="auth.me.value?.avatar_url || ''"
|
|
113
|
+
/>
|
|
114
|
+
<Icon
|
|
115
|
+
name="i-ph:caret-down-light"
|
|
116
|
+
class="size-5"
|
|
117
|
+
/>
|
|
118
|
+
</div>
|
|
119
|
+
</DropdownMenu>
|
|
120
|
+
</div>
|
|
121
|
+
</nav>
|
|
122
|
+
<div class="w-full bg-gray-50 pt-[72px]">
|
|
123
|
+
<main
|
|
124
|
+
class="
|
|
125
|
+
mx-auto min-h-full w-full flex-1 px-6 py-10 lg:px-8
|
|
126
|
+
"
|
|
127
|
+
>
|
|
128
|
+
<Breadcrumb
|
|
129
|
+
v-if="!app.pageMeta.isHideBreadcrumbs && breadcrumbsItems.length > 1"
|
|
130
|
+
:items="breadcrumbsItems"
|
|
131
|
+
class="mb-6"
|
|
132
|
+
:ui="{
|
|
133
|
+
item: 'max-w-2/3',
|
|
134
|
+
list: 'w-full',
|
|
135
|
+
}"
|
|
136
|
+
/>
|
|
137
|
+
<div
|
|
138
|
+
v-if="app.pageMeta.title"
|
|
139
|
+
class="
|
|
140
|
+
mb-4 flex flex-col justify-between gap-1 md:mb-6 md:gap-4
|
|
141
|
+
lg:flex-row lg:items-start
|
|
142
|
+
"
|
|
143
|
+
>
|
|
144
|
+
<div class="flex flex-1 flex-col">
|
|
145
|
+
<h1
|
|
146
|
+
class="
|
|
147
|
+
text-3xl font-bold wrap-break-word
|
|
148
|
+
lg:max-w-2/3
|
|
149
|
+
"
|
|
150
|
+
:title="app.pageMeta.title"
|
|
151
|
+
>
|
|
152
|
+
{{ app.pageMeta.title }}
|
|
153
|
+
<span id="page-title-extra" />
|
|
154
|
+
</h1>
|
|
155
|
+
|
|
156
|
+
<div id="page-subtitle" />
|
|
157
|
+
<p
|
|
158
|
+
v-if="app.pageMeta.sub_title"
|
|
159
|
+
class="text-[#475467]"
|
|
160
|
+
>
|
|
161
|
+
{{ app.pageMeta.sub_title }}
|
|
162
|
+
</p>
|
|
163
|
+
</div>
|
|
164
|
+
<div id="page-header" />
|
|
165
|
+
</div>
|
|
166
|
+
<slot />
|
|
167
|
+
</main>
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
</template>
|
|
172
|
+
|
|
173
|
+
<script lang="ts" setup>
|
|
174
|
+
import type { DropdownMenuItem, NavigationMenuItem } from '@nuxt/ui'
|
|
175
|
+
import { computed } from 'vue'
|
|
176
|
+
import Sidebar from './Sidebar.vue'
|
|
177
|
+
import Apps from './Apps.vue'
|
|
178
|
+
|
|
179
|
+
defineProps<{
|
|
180
|
+
label: string
|
|
181
|
+
sidebarItems: NavigationMenuItem[]
|
|
182
|
+
isSidebarGroup?: boolean
|
|
183
|
+
}>()
|
|
184
|
+
|
|
185
|
+
const app = useApp()
|
|
186
|
+
const isShowSidebarMobile = ref(false)
|
|
187
|
+
const auth = useAuth()
|
|
188
|
+
// Cookie to store user preference for desktop
|
|
189
|
+
const isCollapsed = useCookie<boolean>('app.admin.sidebar.isCollapsed', {
|
|
190
|
+
default: () => false,
|
|
191
|
+
path: '/',
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
const userMenuItems: DropdownMenuItem[] = [
|
|
195
|
+
{
|
|
196
|
+
label: 'View profile',
|
|
197
|
+
icon: 'i-lucide-user',
|
|
198
|
+
to: routes.account.profile.to,
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
{
|
|
202
|
+
label: routes.logout.label,
|
|
203
|
+
icon: 'i-lucide-log-out',
|
|
204
|
+
to: routes.logout.to,
|
|
205
|
+
external: true,
|
|
206
|
+
},
|
|
207
|
+
]
|
|
208
|
+
|
|
209
|
+
const breadcrumbsItems = computed(() => [
|
|
210
|
+
// {
|
|
211
|
+
// label: '',
|
|
212
|
+
// icon: 'ph:house',
|
|
213
|
+
// to: '/',
|
|
214
|
+
// },
|
|
215
|
+
...(app.pageMeta.breadcrumbs || []).map((item: any) => ({
|
|
216
|
+
...item,
|
|
217
|
+
icon: '',
|
|
218
|
+
})),
|
|
219
|
+
])
|
|
220
|
+
</script>
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<slot v-if="skip" />
|
|
3
|
-
<template v-else>
|
|
4
|
-
<Card v-if="status.isLoading">
|
|
5
|
-
<div class="flex items-center justify-center py-12">
|
|
6
|
-
<Loader />
|
|
7
|
-
</div>
|
|
8
|
-
</Card>
|
|
9
|
-
|
|
10
|
-
<!-- Not Found State -->
|
|
11
|
-
<Card v-else-if="status.isSuccess && !data || status.isError && status.errorData?.code === 'NOT_FOUND'">
|
|
12
|
-
<div class="py-12 text-center">
|
|
13
|
-
<Icon
|
|
14
|
-
name="lucide:search-x"
|
|
15
|
-
class="mx-auto mb-4 text-gray-400"
|
|
16
|
-
size="48"
|
|
17
|
-
/>
|
|
18
|
-
<h3 class="mb-2 text-lg font-medium text-gray-900">
|
|
19
|
-
ไม่พบข้อมูล
|
|
20
|
-
</h3>
|
|
21
|
-
<p class="text-gray-600">
|
|
22
|
-
ไม่พบข้อมูลที่คุณค้นหา กรุณาลองใหม่อีกครั้ง
|
|
23
|
-
</p>
|
|
24
|
-
</div>
|
|
25
|
-
</Card>
|
|
26
|
-
<Card v-else-if="status.isError">
|
|
27
|
-
<div class="py-12 text-center">
|
|
28
|
-
<Icon
|
|
29
|
-
name="lucide:alert-circle"
|
|
30
|
-
class="mx-auto mb-4 text-red-500"
|
|
31
|
-
size="48"
|
|
32
|
-
/>
|
|
33
|
-
<h3 class="mb-2 text-lg font-medium text-gray-900">
|
|
34
|
-
เกิดข้อผิดพลาด
|
|
35
|
-
</h3>
|
|
36
|
-
<p class="text-gray-600">
|
|
37
|
-
ไม่สามารถโหลดข้อมูลได้ กรุณาลองใหม่อีกครั้ง
|
|
38
|
-
</p>
|
|
39
|
-
</div>
|
|
40
|
-
</Card>
|
|
41
|
-
<slot
|
|
42
|
-
v-else-if="data"
|
|
43
|
-
:data="data"
|
|
44
|
-
/>
|
|
45
|
-
</template>
|
|
46
|
-
</template>
|
|
47
|
-
|
|
48
|
-
<script lang="ts" setup generic="T">
|
|
49
|
-
import type { IStatus } from '#core/types/lib'
|
|
50
|
-
|
|
51
|
-
defineProps<{
|
|
52
|
-
status: IStatus
|
|
53
|
-
data: T
|
|
54
|
-
skip?: boolean
|
|
55
|
-
}>()
|
|
56
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<slot v-if="skip" />
|
|
3
|
+
<template v-else>
|
|
4
|
+
<Card v-if="status.isLoading">
|
|
5
|
+
<div class="flex items-center justify-center py-12">
|
|
6
|
+
<Loader />
|
|
7
|
+
</div>
|
|
8
|
+
</Card>
|
|
9
|
+
|
|
10
|
+
<!-- Not Found State -->
|
|
11
|
+
<Card v-else-if="status.isSuccess && !data || status.isError && status.errorData?.code === 'NOT_FOUND'">
|
|
12
|
+
<div class="py-12 text-center">
|
|
13
|
+
<Icon
|
|
14
|
+
name="lucide:search-x"
|
|
15
|
+
class="mx-auto mb-4 text-gray-400"
|
|
16
|
+
size="48"
|
|
17
|
+
/>
|
|
18
|
+
<h3 class="mb-2 text-lg font-medium text-gray-900">
|
|
19
|
+
ไม่พบข้อมูล
|
|
20
|
+
</h3>
|
|
21
|
+
<p class="text-gray-600">
|
|
22
|
+
ไม่พบข้อมูลที่คุณค้นหา กรุณาลองใหม่อีกครั้ง
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|
|
25
|
+
</Card>
|
|
26
|
+
<Card v-else-if="status.isError">
|
|
27
|
+
<div class="py-12 text-center">
|
|
28
|
+
<Icon
|
|
29
|
+
name="lucide:alert-circle"
|
|
30
|
+
class="mx-auto mb-4 text-red-500"
|
|
31
|
+
size="48"
|
|
32
|
+
/>
|
|
33
|
+
<h3 class="mb-2 text-lg font-medium text-gray-900">
|
|
34
|
+
เกิดข้อผิดพลาด
|
|
35
|
+
</h3>
|
|
36
|
+
<p class="text-gray-600">
|
|
37
|
+
ไม่สามารถโหลดข้อมูลได้ กรุณาลองใหม่อีกครั้ง
|
|
38
|
+
</p>
|
|
39
|
+
</div>
|
|
40
|
+
</Card>
|
|
41
|
+
<slot
|
|
42
|
+
v-else-if="data"
|
|
43
|
+
:data="data"
|
|
44
|
+
/>
|
|
45
|
+
</template>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script lang="ts" setup generic="T">
|
|
49
|
+
import type { IStatus } from '#core/types/lib'
|
|
50
|
+
|
|
51
|
+
defineProps<{
|
|
52
|
+
status: IStatus
|
|
53
|
+
data: T
|
|
54
|
+
skip?: boolean
|
|
55
|
+
}>()
|
|
56
|
+
</script>
|