18
18
19
19
<div class =" mx-auto max-w-7xl sm:px-6 lg:px-8" >
20
20
<div class =" overflow-hidden bg-white shadow-xl sm:rounded-lg" >
21
+
22
+ <a href =" #" @click =" deleteSelectedUsers"
23
+ class =" float-left px-4 mt-3 py-2 text-red-400 duration-100 rounded hover:text-red-600" >
24
+ <svg xmlns =" http://www.w3.org/2000/svg" viewBox =" 0 0 24 24" class =" h-6 w-6" >
25
+ <path stroke-linecap =" round" stroke-linejoin =" round" stroke-width =" 2" stroke =" currentColor"
26
+ fill =" none"
27
+ d =" M3 6h18M6 6l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12M9 4v-1a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1" />
28
+ </svg >
29
+ </a >
30
+
21
31
<div class =" flex justify-end mt-3" >
22
32
<div class =" mb-3 xl:w-96" >
23
33
<div class =" relative flex items-stretch w-4/5 mb-3 input-group" >
39
49
</div >
40
50
</div >
41
51
</div >
52
+
42
53
<table class =" min-w-full divide-y divide-gray-200" >
43
54
<thead class =" bg-gray-50" >
44
55
<tr >
56
+ <th scope =" col" ></th >
57
+ <th scope =" col"
58
+ class =" px-6 py-3 text-xs font-medium tracking-wider text-center text-gray-500 uppercase" >
59
+ ID
60
+ </th >
45
61
<th scope =" col"
46
62
class =" px-6 py-3 text-xs font-medium tracking-wider text-center text-gray-500 uppercase" >
47
63
Name
65
81
</thead >
66
82
<tbody class =" bg-white divide-y divide-gray-200" >
67
83
<tr v-for =" user in users.data" :key =" user.id" >
84
+ <td >
85
+ <input type =" checkbox" v-model =" selectedUsers" :value =" user.id"
86
+ class =" ml-5 outline-none" />
87
+ </td >
88
+ <td class =" px-6 py-4 whitespace-nowrap" >
89
+ <div class =" text-sm text-center text-gray-900" >
90
+ {{ user.id }}
91
+ </div >
92
+ </td >
68
93
<td class =" px-6 py-4 whitespace-nowrap" >
69
94
<div class =" flex items-center justify-center" >
95
+
70
96
<div class =" ml-4" >
71
97
<div class =" text-sm font-medium text-gray-900" >
72
98
<inertia-link class =" transition hover:text-blue-500"
109
135
d =" M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
110
136
</svg >
111
137
</a >
138
+
112
139
</td >
113
140
</tr >
114
141
</tbody >
@@ -133,6 +160,7 @@ export default {
133
160
},
134
161
data () {
135
162
return {
163
+ selectedUsers: [],
136
164
term: this .$page .term || ' ' ,
137
165
}
138
166
},
@@ -150,6 +178,24 @@ export default {
150
178
search () {
151
179
this .$inertia .replace (this .route (' users.index' , { term: this .term }))
152
180
},
181
+ async deleteSelectedUsers () {
182
+ if (this .selectedUsers .length === 0 ) {
183
+ return ;
184
+ }
185
+
186
+ const confirmed = confirm (` Are you sure you want to delete ${ this .selectedUsers .length } user(s)?` );
187
+ if (! confirmed) {
188
+ return ;
189
+ }
190
+
191
+ try {
192
+ await this .$inertia .post (' /users/delete' , { ids: this .selectedUsers });
193
+ this .selectedUsers = [];
194
+ } catch (error) {
195
+ console .error (error);
196
+ alert (' An error occurred while deleting the selected users.' );
197
+ }
198
+ },
153
199
}
154
200
}
155
201
</script >
0 commit comments