React - conditional rendering for meta informations

0 votes
27 views
added Nov 15 in React by lcjr First Warrant Officer (9,190 points)
/Component
import { useRouter } from 'next/router';


function ListingComponent(props) {
    const {
    assetID,
    onShowEnquireModal,
    } = props;
    const router = useRouter();
    const { coworking } = router.query;
  

    let headerTitle;	
      let headerTitleProject;	
      let headerTitleDistrict;	
      const propertyTypelabel = getFullPropertyType(propertyType);	
      const propOrCondo =	
        propertyType === 'any' || !propertyType ? 'Properties' : propertyTypelabel;	
      if (coworking == 1) {	
        headerTitle = `All Coworking in`;	
      } else {	
        headerTitle = `${propOrCondo} for ${listingType.charAt(0).toUpperCase() +	
          listingType.slice(1)} in `;	
      }	
      if (project_name == district) {	
        headerTitleDistrict = `${project_name ? `${project_name}, ` : ''} ${	
          selectedState ? `${selectedState}` : ''	
        }`;	
      } else {	
        headerTitleProject = `${project_name ? `${project_name}, ` : ''} `;	
        headerTitleDistrict = `${district ? `${district}, ` : ''} ${	
          selectedState ? `${selectedState}` : ''	
        }`;	
      }
      
return (	
    <div className="listing-col wavy">

 

 

/pages

function Rent(props) {	
  const [isMobile, toggleDevice] = useState();	
  const [isLoadedGPT, setLoadedGPT] = useState(false);	
  const { router, asPath } = props;	
  const {	
    state = 'Wakanda',	
    propertyType,	
    project_name,	
    searchedLabel,	
    asset_id,	
    page,	
    coworking,	
  } = router;	
  let { district } = router;	
  if (district === 'klgc') {	
    district = 'KLGC';	
  }
  
  let titleStart;	
  if (coworking == 1) {	
    titleStart = 'All Coworking in';	
  } else {	
    titleStart = `${propOrCondo} for Rent in`;	
  }	
  if (project_name == district) {	
    title = `${titleStart} ${project_name ? `${project_name}, ` : ''} ${	
      state ? `${state}` : ''	
    } ${page > 1 ? ` | Page ${page}` : ''} | Example.com`;	
  } else {	
    title = `${titleStart} ${project_name ? `${project_name}, ` : ''} ${	
      district ? `${district}, ` : ''	
    } ${state ? `${state}` : ''} ${	
      page > 1 ? ` | Page ${page}` : ''	
    } | Example.com`;	
  }
  
  const keywords = `Real Estate, property, for rent, ${	
    project_name ? `${project_name}, ` : ''	
  } ${district ? `${district}, ` : ''} ${	
    state ? `${state}, ` : ''	
  }, apartment, house, condo`;

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...