Skip to content

Commit

Permalink
fix: update calcViewSearchParamsURL to support multi filters
Browse files Browse the repository at this point in the history
  • Loading branch information
nainglinnkhant committed Jul 8, 2024
1 parent c0ab48d commit 5f1f5e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ export function DataTableMultiFilter<TData>({
onClick={() => {
setSelectedOptions((prev) => prev.filter((item) => !item.isMulti))

const paramsObj: Record<string, null> = {}
const paramsObj: Record<string, null | string> = {}
for (const option of options) {
paramsObj[option.value as string] = null
}
paramsObj.operator = "and"

const newSearchParams = createQueryString(paramsObj, searchParams)
router.push(`${pathname}?${newSearchParams}`, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export function DataTableViewsDropdown({
<Button
variant="outline"
size="sm"
className="flex w-36 justify-between truncate"
className="flex w-36 justify-between"
>
{currentView?.name || "All tasks"}
<span className="truncate">{currentView?.name || "All tasks"}</span>
<CaretDownIcon aria-hidden="true" className="size-4 shrink-0" />
</Button>
</PopoverTrigger>
Expand Down
3 changes: 2 additions & 1 deletion src/components/data-table/advanced/views/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export function calcViewSearchParamsURL(view: ViewItem) {

for (const item of filterParams.filters ?? []) {
if (FILTERABLE_FIELDS.includes(item.field)) {
searchParamsObj[item.field] = item.value
const value = item.isMulti ? `${item.value}~multi` : item.value
searchParamsObj[item.field] = value
}
}
if (filterParams.operator) {
Expand Down

0 comments on commit 5f1f5e9

Please sign in to comment.