1
1
<script setup lang="ts">
2
- import type { User } from ' ~~/server/db/schema' ;
2
+ import type { Admin } from ' ~~/server/db/schema' ;
3
3
import { watchDebounced } from ' @vueuse/core' ;
4
4
5
5
const { postData, changing } = await useMembersRepository ();
6
6
7
- const suggestedUsers = ref <User []>();
7
+ const suggestedAdmins = ref <Admin []>();
8
8
9
9
const submit = async (id : string , closeFn : () => void ) => {
10
10
let success = false ;
@@ -16,23 +16,23 @@ const submit = async (id: string, closeFn: () => void) => {
16
16
}
17
17
};
18
18
19
- const userSearchQuery = ref <string >(' ' );
20
- const fetchingUserSuggestions = ref (false );
19
+ const adminSearchQuery = ref <string >(' ' );
20
+ const fetchingAdminSuggestions = ref (false );
21
21
22
22
watchDebounced (
23
- userSearchQuery ,
23
+ adminSearchQuery ,
24
24
async (q ) => {
25
25
try {
26
- fetchingUserSuggestions .value = true ;
27
- suggestedUsers .value = await $fetch <User []>(' /api/user /lookup' , {
26
+ fetchingAdminSuggestions .value = true ;
27
+ suggestedAdmins .value = await $fetch <Admin []>(' /api/admin /lookup' , {
28
28
query: {
29
29
q ,
30
30
},
31
31
});
32
32
} catch (error ) {
33
- console .error (' error fetching user suggestions' , error );
33
+ console .error (' error fetching admin suggestions' , error );
34
34
} finally {
35
- fetchingUserSuggestions .value = false ;
35
+ fetchingAdminSuggestions .value = false ;
36
36
}
37
37
},
38
38
{ debounce: 500 , maxWait: 1000 }
@@ -52,35 +52,39 @@ watchDebounced(
52
52
type =" text"
53
53
class =" input-custom"
54
54
placeholder =" Start searching to add members"
55
- v-model =" userSearchQuery "
55
+ v-model =" adminSearchQuery "
56
56
:disabled =" changing"
57
57
/>
58
58
<div
59
59
class =" flex flex-col space-y-3 overflow-y-scroll no-scrollbar h-64 mt-3"
60
- v-if =" suggestedUsers && suggestedUsers .length > 0"
60
+ v-if =" suggestedAdmins && suggestedAdmins .length > 0"
61
61
>
62
- <div class =" flex w-full justify-between p-2 border rounded-lg" v-for =" user in suggestedUsers" :key =" user.id" >
62
+ <div
63
+ class =" flex w-full justify-between p-2 border rounded-lg"
64
+ v-for =" admin in suggestedAdmins"
65
+ :key =" admin.id"
66
+ >
63
67
<div class =" flex space-x-1 items-center" >
64
- <img :src =" user .picture" v-if =" user .picture" class =" w-10 h-10 rounded-full" />
68
+ <img :src =" admin .picture" v-if =" admin .picture" class =" w-10 h-10 rounded-full" />
65
69
<div class =" flex flex-col text-sm" >
66
- <span class =" font-bold" >{{ user .firstName }} {{ user .lastName }}</span >
67
- <span >{{ user .email }}</span >
70
+ <span class =" font-bold" >{{ admin .firstName }} {{ admin .lastName }}</span >
71
+ <span >{{ admin .email }}</span >
68
72
</div >
69
73
</div >
70
- <InputButton size =" sm" variant =" outline" @click =" submit(user .id, close)" :loading =" changing"
74
+ <InputButton size =" sm" variant =" outline" @click =" submit(admin .id, close)" :loading =" changing"
71
75
>Add</InputButton
72
76
>
73
77
</div >
74
78
</div >
75
79
<div class =" h-64 flex w-full justify-center items-center" v-else >
76
- <span class =" text-center" v-if =" userSearchQuery && !fetchingUserSuggestions " >
77
- <span class =" font-bold" >No User Found</span ><br />
78
- <span class =" text-xs" >User has to login atleast once to be added.</span >
80
+ <span class =" text-center" v-if =" adminSearchQuery && !fetchingAdminSuggestions " >
81
+ <span class =" font-bold" >No Admin Found</span ><br />
82
+ <span class =" text-xs" >Admin has to login atleast once to be added.</span >
79
83
</span >
80
- <span class =" text-center" v-else-if =" !userSearchQuery " >
84
+ <span class =" text-center" v-else-if =" !adminSearchQuery " >
81
85
<span class =" font-bold" >Start typing to see suggestions.</span ><br />
82
86
<span class =" text-xs" >
83
- Any user added will be able to see / create job postings and see / manage all the applicants.
87
+ Any admin added will be able to see / create job postings and see / manage all the applicants.
84
88
</span >
85
89
</span >
86
90
</div >
0 commit comments