Get the latest NYC family fun straight to your inbox!
Subscribe
Manage your newsletter subscription preferences.
) } };/** * BusinessList Component * * Outputs List of Businesses **/ class BusinessList extends React.Component { handleShowAllClick = () => { this.props.toggleShortList(this.props.short); } render() { var businesses = this.props.businesses; if (this.props.selected.length > 0 || this.props.selectedLocations.length > 0){ var result = businesses; const filterCategories = (item) => { return !this.props.selected.length || (this.props.selected).some(selectedSubCategory => { // console.log(selectedSubCategory); var formatedSubCat = selectedSubCategory.toLowerCase() .replace(/[^a-z0-9]+/g, " ") .replace(/^-+|-+$/g, " ") .replace(/^-+|-+$/g, '') return typeof item.category !== "undefined" ? (item.category).indexOf(formatedSubCat) >=0 : false; }) } const filterLocations = (item) => { if (this.props.selectedLocations[0] == "all areas") return true; return !this.props.selectedLocations.length || (this.props.selectedLocations).some(selectedLocations => { // console.log(selectedLocations); var formattedLocation = selectedLocations.toLowerCase() // Convert to lower case .replace(/[^a-z0-9]+/g, '-') // Replace one or more non-alphanumeric characters with a hyphen .replace(/^-+|-+$/g, ''); // Remove leading and trailing hyphens return typeof item.dropdown_locations !== "undefined" ? (item.dropdown_locations).indexOf(formattedLocation) >=0 : false; }) } if (this.props.selected.length > 0) { result = result.filter(filterCategories); } console.log(result); if (this.props.selectedLocations.length > 0) { result = result.filter(filterLocations); } console.log(result); } else { var result = businesses.sort(comparePromotions).reverse() } var businessNodes = result.map(function(item) { let imageHolderStyle = { backgroundImage: `url("${item.photo}")` }; let businessServices = ''; var cleanName = clean(item.businessName), removeBreak = breakLine(item.businessName), cleanDescription = item.tagline != null ? cleanText(item.tagline) : "", businesskey = item.key, link = `/${directory_slug}/${slug}/${businesskey}/${cleanName}/`; // Convert schemaData to a JSON string and escape single quotes const schemaData = { "@context": "https://schema.org/", "@type": "LocalBusiness", "telephone": "(831) 292-3471", "name": cleanName, "image": item.photo, "address": { "@type": "PostalAddress", "streetAddress": "1000 South Winchester Blvd. ", "addressLocality": "San Jose", "addressRegion": "CA", "postalCode": "95128", "addressCountry": "US" } }; return (
{removeBreak} {cleanDescription}) }.bind(this)); var listClassName = 'business-list short directory_container'; var seeMoreText = 'See More'; var seeMoreIcon = 'fa fa-chevron-down'; if (this.props.short === false){ listClassName = 'business-list'; seeMoreText = 'Show Less'; seeMoreIcon = 'fa fa-chevron-right'; } if (Array.isArray(result) && result.length) { return (
Search Results: {result.length}
{businessNodes}
{seeMoreText}
) } else { return (
Oh no! No results! Please try another search criteria. We're working on collecting helpful resources for the {parentTitle} section. If you're interested having your business or organization featured, please reach out to advertising@newyorkfamily.com.
) } } };/** * CategoryPage Component * * Container Component for Services + Businesses **/ class CategoryPage extends React.Component { constructor(props) { super(props); // Setting up selected services/categories if ( currentService.length > 0 ) { var $uniqueCategories = this.props.uniqueCategories; for ( var i in $uniqueCategories) { var cleanService = $uniqueCategories[i].toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "-").replace(/^-+|-+$/g, '') if ( cleanService == currentService ) { var selectedSubCategory = JSON.parse( '["' + $uniqueCategories[i] + '"]' ); } } } else { var selectedSubCategory = []; } // Setting up selected locations if ( currentLocation.length > 0 ) { var uniqueLocations = this.props.uniqueLocations; for ( var i in uniqueLocations) { var cleanLocation = uniqueLocations[i].toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "-").replace(/^-+|-+$/g, '') if ( cleanLocation == currentLocation ) { var selectedLocations = JSON.parse( '["' + uniqueLocations[i] + '"]' ); } } } else { var selectedLocations = []; } this.state = { selected: selectedSubCategory, selectedLocations: selectedLocations, shortBusinessList: true, shortServices: true } } // Constuctor pushSelected = (item, filterType) => { switch (filterType) { case "category": if ( (this.state.selected).length > 0 ) { this.setState({ selected: [item] }); } else { this.setState({ selected: this.state.selected.concat(item) }); } break; case "location": if ( (this.state.selectedLocations).length > 0 ) { this.setState({ selectedLocations: [item] }); } else { this.setState({ selectedLocations: this.state.selectedLocations.concat(item) }); } break; } } // pushSelected popSelected = (index, filterType) => { switch (filterType) { case "category": this.setState({ selected: this.state.selected.filter((_, i) => i !== index) }); break; case "location": this.setState({ selectedLocations: this.state.selectedLocations.filter((_, i) => i !== index) }); break; } } // popSelected toggleShortList = (short) => { this.setState({ shortBusinessList: !short }); } // toggleShortList toggleServices = () => { this.setState({ shortServices: !this.state.shortServices }); } render() { // if (Array.isArray(this.props.businesses) && this.props.businesses.length) { return (
) } };/** * Render to DOM **/ReactDOM.render(
,document.getElementById('category-pages-container'));
Looking for a sleep-away camp or day camp for kids in New York City? We've got the best summer and year-round camp options for sports, performing arts, STEM, preschoolers and teens. We also list camps for children in NYC with special needs or who need additional help with academics or tutoring.
Interested having your business or organization featured? Contact Us
More about this Directory
Whether you're in Dumbo, Park Slope, Prospect Heights, Cobble Hill, Williamsburg, Bushwick, Bed-Stuy, Crown Heights, Sheepshead Bay, Red Hook, Brooklyn Heights, Bay Ridge, Greenpoint, Marine Park, or Flatbush, there's a camp in our online directory that is perfect for you.
Subscribe
Get the latest NYC family fun and news straight to your inbox!