Sanity filter on change

This commit is contained in:
Adria Navarro 2023-10-03 13:10:53 +02:00
parent 9b14f50e8f
commit 0702bc6c33
1 changed files with 12 additions and 1 deletions

View File

@ -5,6 +5,7 @@
import { API } from "api"
export let value = null
export let multiple = false
$: fetch = fetchData({
API,
@ -17,11 +18,21 @@
})
$: options = $fetch.rows
function onChange(e) {
const val = e.detail
if (!val) {
value = val
} else {
value = Array.isArray(val) ? val : [val]
}
}
</script>
<Select
value={multiple ? value : value[0]}
autocomplete
bind:value
on:change={onChange}
{options}
getOptionLabel={option => option.email}
getOptionValue={option => option._id}