@@ -3,11 +3,9 @@ const { client } = useUserSession()
33const toast = useToast ()
44
55// Type assertion for admin plugin methods
6+ type AsyncFn = (... args : unknown []) => Promise <unknown >
67const adminClient = client as typeof client & {
7- admin: {
8- listUsers: Function , createUser: Function , banUser: Function
9- unbanUser: Function , impersonateUser: Function , removeUser: Function
10- }
8+ admin: { listUsers: AsyncFn , createUser: AsyncFn , banUser: AsyncFn , unbanUser: AsyncFn , impersonateUser: AsyncFn , removeUser: AsyncFn }
119}
1210
1311// Users
@@ -28,7 +26,8 @@ async function loadUsers() {
2826}
2927
3028const filteredUsers = computed (() => {
31- if (! search .value ) return users .value
29+ if (! search .value )
30+ return users .value
3231 const s = search .value .toLowerCase ()
3332 return users .value .filter (u => u .email ?.toLowerCase ().includes (s ) || u .name ?.toLowerCase ().includes (s ))
3433})
@@ -125,7 +124,9 @@ async function impersonate(userId: string) {
125124
126125// Delete user
127126async function deleteUser(userId : string ) {
128- if (! confirm (' Are you sure you want to delete this user?' )) return
127+ // eslint-disable-next-line no-alert
128+ if (! confirm (' Are you sure you want to delete this user?' ))
129+ return
129130 try {
130131 await adminClient ?.admin .removeUser ({ userId })
131132 toast .add ({ title: ' User deleted' , color: ' success' })
@@ -144,7 +145,9 @@ onMounted(loadUsers)
144145 <UCard >
145146 <template #header >
146147 <div class =" flex justify-between items-center gap-4" >
147- <h1 class =" text-xl font-semibold" >Admin Dashboard</h1 >
148+ <h1 class =" text-xl font-semibold" >
149+ Admin Dashboard
150+ </h1 >
148151 <div class =" flex gap-2" >
149152 <UInput v-model =" search" placeholder =" Search users..." class =" w-48" />
150153 <UButton @click =" createOpen = true" >
@@ -193,7 +196,9 @@ onMounted(loadUsers)
193196
194197 <!-- Create User Modal -->
195198 <UModal v-model:open =" createOpen" >
196- <template #header >Create New User</template >
199+ <template #header >
200+ Create New User
201+ </template >
197202 <template #body >
198203 <div class =" space-y-4 p-4" >
199204 <UFormField label =" Email" >
@@ -208,14 +213,18 @@ onMounted(loadUsers)
208213 <UFormField label =" Role" >
209214 <USelect v-model =" createForm.role" :options =" ['user', 'admin']" />
210215 </UFormField >
211- <UButton block :loading =" createLoading" @click =" createUser" >Create User</UButton >
216+ <UButton block :loading =" createLoading" @click =" createUser" >
217+ Create User
218+ </UButton >
212219 </div >
213220 </template >
214221 </UModal >
215222
216223 <!-- Ban User Modal -->
217224 <UModal v-model:open =" banOpen" >
218- <template #header >Ban User</template >
225+ <template #header >
226+ Ban User
227+ </template >
219228 <template #body >
220229 <div class =" space-y-4 p-4" >
221230 <UFormField label =" Reason (optional)" >
@@ -224,7 +233,9 @@ onMounted(loadUsers)
224233 <UFormField label =" Duration (hours, leave empty for permanent)" >
225234 <UInput v-model =" banForm.expiresIn" type =" number" placeholder =" e.g. 24" />
226235 </UFormField >
227- <UButton block color =" error" :loading =" banLoading" @click =" banUser" >Ban User</UButton >
236+ <UButton block color =" error" :loading =" banLoading" @click =" banUser" >
237+ Ban User
238+ </UButton >
228239 </div >
229240 </template >
230241 </UModal >
0 commit comments