diff --git a/docs/stories/bExternalFilters.stories.tsx b/docs/stories/bExternalFilters.stories.tsx index 1203f81..43d60da 100644 --- a/docs/stories/bExternalFilters.stories.tsx +++ b/docs/stories/bExternalFilters.stories.tsx @@ -20,6 +20,24 @@ export const Primary = () => { const [jobTitle, setJobTitle] = useState(new Set()); const [birthday, setBirthday] = useState(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 ( @@ -32,7 +50,7 @@ export const Primary = () => {