penambahan search by entered name
This commit is contained in:
@@ -377,8 +377,8 @@
|
|||||||
<button
|
<button
|
||||||
on:click={() => changePage(page as number)}
|
on:click={() => changePage(page as number)}
|
||||||
class="px-2 py-1 border rounded {page === currentPage
|
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}
|
{page}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -334,8 +334,11 @@
|
|||||||
ascending: sortOrder === "asc",
|
ascending: sortOrder === "asc",
|
||||||
}).range(fromIndex, toIndex);
|
}).range(fromIndex, toIndex);
|
||||||
|
|
||||||
if (searchTerm) {
|
if (typeof searchTerm === "string" && searchTerm.length > 4) {
|
||||||
query = query.ilike("work_description", `%${searchTerm}%`)
|
// 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) {
|
if (villaIdFilter) {
|
||||||
@@ -688,7 +691,7 @@
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="search-input"
|
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"
|
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) => {
|
on:input={(e) => {
|
||||||
currentSearchTerm = (e.target as HTMLInputElement).value.toLowerCase();
|
currentSearchTerm = (e.target as HTMLInputElement).value.toLowerCase();
|
||||||
|
|||||||
Reference in New Issue
Block a user