This commit is contained in:
Timothy J. Baek 2024-10-21 02:00:22 -07:00
parent ec17bbc867
commit e1baa9cc3f

View File

@ -90,6 +90,25 @@
sortOrder = 'asc'; sortOrder = 'asc';
} }
} }
let filteredUsers;
$: filteredUsers = users
.filter((user) => {
if (search === '') {
return true;
} else {
let name = user.name.toLowerCase();
const query = search.toLowerCase();
return name.includes(query);
}
})
.sort((a, b) => {
if (a[sortKey] < b[sortKey]) return sortOrder === 'asc' ? -1 : 1;
if (a[sortKey] > b[sortKey]) return sortOrder === 'asc' ? 1 : -1;
return 0;
})
.slice((page - 1) * 20, page * 20);
</script> </script>
<ConfirmDialog <ConfirmDialog
@ -255,22 +274,7 @@
</tr> </tr>
</thead> </thead>
<tbody class=""> <tbody class="">
{#each users {#each filteredUsers as user, userIdx}
.filter((user) => {
if (search === '') {
return true;
} else {
let name = user.name.toLowerCase();
const query = search.toLowerCase();
return name.includes(query);
}
})
.sort((a, b) => {
if (a[sortKey] < b[sortKey]) return sortOrder === 'asc' ? -1 : 1;
if (a[sortKey] > b[sortKey]) return sortOrder === 'asc' ? 1 : -1;
return 0;
})
.slice((page - 1) * 20, page * 20) as user, userIdx}
<tr class="bg-white dark:bg-gray-900 dark:border-gray-850 text-xs"> <tr class="bg-white dark:bg-gray-900 dark:border-gray-850 text-xs">
<td class="px-3 py-1 min-w-[7rem] w-28"> <td class="px-3 py-1 min-w-[7rem] w-28">
<button <button