penambahan search by entered name
This commit is contained in:
@@ -377,8 +377,8 @@
|
||||
<button
|
||||
on:click={() => changePage(page as number)}
|
||||
class="px-2 py-1 border rounded {page === currentPage
|
||||
? 'bg-blue-600 text-white'
|
||||
: ''}"
|
||||
? 'bg-blue-600 text-white border-blue-600'
|
||||
: 'bg-white border-gray-300 hover:bg-gray-100'}"
|
||||
>
|
||||
{page}
|
||||
</button>
|
||||
|
||||
@@ -334,8 +334,11 @@
|
||||
ascending: sortOrder === "asc",
|
||||
}).range(fromIndex, toIndex);
|
||||
|
||||
if (searchTerm) {
|
||||
query = query.ilike("work_description", `%${searchTerm}%`)
|
||||
if (typeof searchTerm === "string" && searchTerm.length > 4) {
|
||||
// Supabase ilike only supports one column at a time, so use or for multiple columns
|
||||
query = query.or(
|
||||
`work_description.ilike.%${searchTerm}%,entered_name.ilike.%${searchTerm}%`
|
||||
);
|
||||
}
|
||||
|
||||
if (villaIdFilter) {
|
||||
@@ -688,7 +691,7 @@
|
||||
<input
|
||||
type="text"
|
||||
id="search-input"
|
||||
placeholder="🔍 Search by name..."
|
||||
placeholder="🔍 Search by work description..."
|
||||
class="border border-gray-300 focus:ring-2 focus:ring-blue-500 focus:outline-none px-4 py-2 rounded-xl text-sm w-64 transition"
|
||||
on:input={(e) => {
|
||||
currentSearchTerm = (e.target as HTMLInputElement).value.toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user