import { __ } from "@wordpress/i18n"; import { BlockTypeIcon } from "../../icons/icons"; const FilterSidebar = ( props ) => { const { changeStates, fieldValue, fieldOptions, allData, tabName, } = props; const filterCount = allData?.reduce( (acc, item) => { if ( tabName === "ready-pages" ) { item.pages?.forEach((page) => { const type = page.type; if (type) { acc[type] = (acc[type] || 0) + 1; } }); } else { const category = item.category; acc[category] = (acc[category] || 0) + 1; } return acc; }, {}); // Calculate Free/Pro counts for Pattern Types const freeProCount = allData?.reduce( (acc, item) => { acc.all = (acc.all || 0) + 1; if (item.pro) { acc.pro = (acc.pro || 0) + 1; } else { acc.free = (acc.free || 0) + 1; } return acc; }, { all: 0, free: 0, pro: 0 } ); const blockTypeObject = { "ready-patterns": __("Block Types", "post-carousel"), "starter-sites": __("Category Types", "post-carousel"), "ready-pages": __("Pages Types", "post-carousel"), } return (

Pattern Types

{["all", "free", "pro"].map((option, index) => ( ))}

{ blockTypeObject[tabName] }

{ fieldOptions?.filterArr?.length > 0 && ( <>
{ fieldOptions?.filterArr?.map( (option, index) => { const allOptionCount = tabName === "ready-pages" ? fieldOptions?.filterArr?.length : allData?.length; const optionCount = filterCount[ option?.value ] return ( ); })}
) }
); } export default FilterSidebar;