-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add the ability to save filter params as views
- Loading branch information
1 parent
f1e5438
commit 6235588
Showing
13 changed files
with
315 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/components/data-table/advanced/views/create-view-popover.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useState } from "react" | ||
import { useSearchParams } from "next/navigation" | ||
import type { DataTableFilterOption } from "@/types" | ||
|
||
import { Button } from "@/components/ui/button" | ||
import { | ||
Popover, | ||
PopoverContent, | ||
PopoverTrigger, | ||
} from "@/components/ui/popover" | ||
|
||
import { CreateViewForm } from "./create-view-form" | ||
import { calcFilterParams } from "./utils" | ||
|
||
interface CreateViewPopoverProps<T> { | ||
selectedOptions: DataTableFilterOption<T>[] | ||
} | ||
|
||
export function CreateViewPopover<T>({ | ||
selectedOptions, | ||
}: CreateViewPopoverProps<T>) { | ||
const searchParams = useSearchParams() | ||
|
||
const [open, setOpen] = useState(false) | ||
|
||
const filterParams = calcFilterParams(selectedOptions, searchParams) | ||
|
||
return ( | ||
<Popover open={open} onOpenChange={setOpen}> | ||
<PopoverTrigger asChild> | ||
<Button variant="outline" size="sm"> | ||
Save as new view | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverContent className="w-[12.5rem] p-0" align="end"> | ||
<CreateViewForm | ||
filterParams={filterParams} | ||
onSuccess={() => setOpen(false)} | ||
/> | ||
</PopoverContent> | ||
</Popover> | ||
) | ||
} |
Oops, something went wrong.