@@ -4,8 +4,7 @@ import type { UserWithRoles } from '@base/stores/admin/user'
4
4
import { avatarText } from ' #imports'
5
5
import { useRoleStore } from ' @base/stores/admin/role'
6
6
import { useUserStore } from ' @base/stores/admin/user'
7
- import { sortBy } from ' lodash-es'
8
- // import UserList from '@base/components/roles/UserList.vue'
7
+ import { match } from ' ts-pattern'
9
8
10
9
definePageMeta ({
11
10
sidebar: {
@@ -46,8 +45,10 @@ const headers = [
46
45
{ title: ' User' , key: ' name' },
47
46
{ title: ' Email' , key: ' email' },
48
47
{ title: ' Role' , key: ' role' },
49
- // { title: 'Plan', key: 'plan' },
50
48
{ title: ' Status' , key: ' status' },
49
+ // TODO: user credits / subscriptions
50
+ // { title: 'Plan', key: 'plan' },
51
+ { title: ' Verified' , key: ' email_verified' },
51
52
{ title: ' Actions' , key: ' actions' , sortable: false },
52
53
]
53
54
@@ -59,30 +60,10 @@ function handleUpdateOptions(options: any) {
59
60
function resolveUserRoleVariant(role : string ) {
60
61
const roleLowerCase = role .toLowerCase ()
61
62
62
- if (roleLowerCase === ' subscriber' )
63
- return { color: ' success' , icon: ' ri-user-line' }
64
- if (roleLowerCase === ' author' )
65
- return { color: ' error' , icon: ' ri-computer-line' }
66
- if (roleLowerCase === ' maintainer' )
67
- return { color: ' info' , icon: ' ri-pie-chart-line' }
68
- if (roleLowerCase === ' editor' )
69
- return { color: ' warning' , icon: ' ri-edit-box-line' }
70
- if (roleLowerCase === ' admin' )
71
- return { color: ' primary' , icon: ' ri-vip-crown-line' }
72
-
73
- return { color: ' success' , icon: ' ri-user-line' }
74
- }
75
-
76
- function resolveUserStatusVariant(stat : string ) {
77
- const statLowerCase = stat .toLowerCase ()
78
- if (statLowerCase === ' pending' )
79
- return ' warning'
80
- if (statLowerCase === ' active' )
81
- return ' success'
82
- if (statLowerCase === ' inactive' )
83
- return ' secondary'
84
-
85
- return ' primary'
63
+ return match (roleLowerCase )
64
+ .with (' admin' , () => ({ color: ' primary' , icon: ' ri-vip-crown-line' }))
65
+ .with (' editor' , () => ({ color: ' warning' , icon: ' ri-edit-box-line' }))
66
+ .otherwise (() => ({ color: ' success' , icon: ' ri-user-line' }))
86
67
}
87
68
88
69
async function handleDeleteUser(user : UserWithRoles ) {
@@ -104,77 +85,25 @@ async function handleDeleteUser(user: UserWithRoles) {
104
85
<VRow >
105
86
<VCol cols =" 12" >
106
87
<VCard class =" mb-6" >
107
- <VCardItem class =" pb-4" >
108
- <VCardTitle >Filters</VCardTitle >
109
- </VCardItem >
110
- <VCardText >
111
- <VRow >
112
- <!-- 👉 Select Role -->
113
- <VCol
114
- cols =" 12"
115
- sm =" 4"
116
- >
117
- <VSelect
118
- v-model =" selectedRole"
119
- label =" Select Role"
120
- placeholder =" Select Role"
121
- :items =" roleData?.data || []"
122
- clearable
123
- clear-icon =" ri-close-line"
124
- />
125
- </VCol >
126
- <!-- 👉 Select Plan -->
127
- <!-- <VCol
128
- cols="12"
129
- sm="4"
130
- >
131
- <VSelect
132
- v-model="selectedPlan"
133
- label="Select Plan"
134
- placeholder="Select Plan"
135
- :items="plans"
136
- clearable
137
- clear-icon="ri-close-line"
138
- />
139
- </VCol> -->
140
- <!-- 👉 Select Status -->
141
- <!-- <VCol
142
- cols="12"
143
- sm="4"
144
- >
145
- <VSelect
146
- v-model="selectedStatus"
147
- label="Select Status"
148
- placeholder="Select Status"
149
- :items="status"
150
- clearable
151
- clear-icon="ri-close-line"
152
- />
153
- </VCol> -->
154
- </VRow >
155
- </VCardText >
156
-
157
- <VDivider />
158
-
159
88
<VCardText class =" d-flex flex-wrap gap-4 align-center" >
160
89
<!-- 👉 Export button -->
161
- <VBtn
162
- variant =" outlined"
163
- color =" secondary"
164
- prepend-icon =" ri-upload-2-line"
165
- >
166
- Export
167
- </VBtn >
90
+ <VSelect
91
+ v-model =" selectedRole"
92
+ label =" Select Role"
93
+ placeholder =" Select Role"
94
+ :items =" roleData?.data || []"
95
+ clearable
96
+ clear-icon =" ri-close-line"
97
+ />
168
98
<VSpacer />
169
99
<div class =" d-flex align-center gap-4 flex-wrap" >
170
100
<!-- 👉 Search -->
171
- <div class =" app-user-search-filter" >
172
- <VTextField
173
- v-model =" userQuery.keyword"
174
- placeholder =" Search User"
175
- density =" compact"
176
- />
177
- </div >
101
+ <VTextField
102
+ v-model =" userQuery.keyword"
103
+ placeholder =" Search User"
104
+ density =" compact"
105
+ style =" min-width : 200px ;"
106
+ />
178
107
<!-- 👉 Add user button -->
179
108
<VBtn >
180
109
Add New User
@@ -228,21 +157,23 @@ async function handleDeleteUser(user: UserWithRoles) {
228
157
:color =" resolveUserRoleVariant(item.roles[0]?.role.name || '').color"
229
158
size =" 22"
230
159
/>
231
- <span class =" text-capitalize text-high-emphasis" >{{ item.roles[0]?.role.name || '' }}</span >
160
+ <span class =" text-capitalize text-high-emphasis" >
161
+ {{ item.roles[0]?.role.name || $t('No role') }}
162
+ </span >
232
163
</div >
233
164
</template >
234
- <!-- TODO: user subscription -->
165
+ <!-- TODO: user credits / subscriptions -->
235
166
<!-- <template #item.plan="{ item }">
236
167
<span class="text-capitalize text-high-emphasis">{{ item.currentPlan }}</span>
237
168
</template> -->
238
169
<!-- Status -->
239
- <template #item .status =" { item } " >
170
+ <template #item .email_verified =" { item } " >
240
171
<VChip
241
- :color =" resolveUserStatusVariant( item.status || '') "
172
+ :color =" item.email_verified ? 'success' : 'secondary' "
242
173
size =" small"
243
174
class =" text-capitalize"
244
175
>
245
- {{ item.status }}
176
+ {{ item.email_verified ? $t('Verified') : $t('Pending') }}
246
177
</VChip >
247
178
</template >
248
179
0 commit comments