Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: storybook external filters #99

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion docs/stories/bExternalFilters.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ export const Primary = () => {
const [jobTitle, setJobTitle] = useState(new Set<string>());
const [birthday, setBirthday] = useState<Date | DateRange | null>(null);

const filteredData = data.filter((x) => {
if (firstName && !x.first_name.includes(firstName)) return false;
if (lastName && !x.last_name.includes(lastName)) return false;
if (jobTitle.size > 0 && !jobTitle.has(x.job_title)) return false;

const birthdayDate = new Date(x.birthday);
if (birthday instanceof Date) {
if (birthdayDate && birthdayDate !== birthday) return false;
} else if (
birthday?.min &&
birthday?.max &&
(birthdayDate < birthday.min || birthdayDate > birthday.max)
) {
return false;
}
return true;
});

return (
<Box>
<Box>
Expand All @@ -32,7 +50,7 @@ export const Primary = () => {
</Box>

<Table
items={data}
items={filteredData}
id="id"
virtual
stickyHeader
Expand Down