diff --git a/src/containers/Listings/Listings.js b/src/containers/Listings/Listings.js index 7dfcd85..07143e5 100644 --- a/src/containers/Listings/Listings.js +++ b/src/containers/Listings/Listings.js @@ -272,8 +272,8 @@ class Listings extends Component { return ( <> - {seoConfigs.meta_listing_title} - + {seoConfigs.meta_title} + @@ -335,7 +335,11 @@ class Listings extends Component { {list.get('title', '')} {' '} diff --git a/src/containers/ListingsByCategory/ListingsByCategory.js b/src/containers/ListingsByCategory/ListingsByCategory.js index 4fedd82..655ffad 100644 --- a/src/containers/ListingsByCategory/ListingsByCategory.js +++ b/src/containers/ListingsByCategory/ListingsByCategory.js @@ -3,13 +3,12 @@ import classes from './ListingByCategory.module.css'; import { useDispatch, useSelector } from 'react-redux'; import { Link, useLocation, useParams } from 'react-router-dom'; import * as actions from '../../store/actions/index'; -import { getThumbnailImage, totalCountOfProducts } from '../../shared/constants'; - import NoProductImage from '../../assets/images/rsz_noimage.png'; +import { getThumbnailImage, totalCountOfProducts } from '../../shared/constants'; +import NoProductImage from '../../assets/images/rsz_noimage.png'; import NoIamgeLogo from '../../assets/images/home/store/noImage.svg'; import Aux from '../../hoc/Auxiliary/Auxiliary'; import Loader from 'react-loader-spinner'; - import { Helmet } from 'react-helmet'; const ListingsByCategory = () => { @@ -19,83 +18,113 @@ const ListingsByCategory = () => { const dispatch = useDispatch(); useEffect(() => { dispatch( - actions.initListings(0, '&category_id=' + categoryName.split('-')[0], totalCountOfProducts,true) + actions.initListings( + 0, + '&category_id=' + categoryName.split('-')[0], + totalCountOfProducts, + true + ) ); }, [categoryName, dispatch]); let listings = useSelector((state) => state.product.listings); let page = useSelector((state) => state.product.page); let total_records = useSelector((state) => state.product.total_records); let loading = useSelector((state) => state.product.loading); + const seo_configs = useSelector((state) => state.auth.seo_configs); // function const loadMore = () => { - const count = listings.length; - + const count = listings.length; + if (listings.length === 100) { dispatch( actions.initListings( 0, '&category_id=' + categoryName.split('-')[0], - totalCountOfProducts,false, - parseInt(page)+1 + totalCountOfProducts, + false, + parseInt(page) + 1 ) ); } else { - dispatch( - actions.initListings( - count, - '&category_id=' + categoryName.split('-')[0], - totalCountOfProducts,false, - parseInt(page) - ) - ); + dispatch( + actions.initListings( + count, + '&category_id=' + categoryName.split('-')[0], + totalCountOfProducts, + false, + parseInt(page) + ) + ); } }; let showLoadButton; - if ( total_records > totalCountOfProducts && - listings?.length !== total_records) { + if (total_records > totalCountOfProducts && listings?.length !== total_records) { showLoadButton = ( - + Load More ); } + + // seo title + const seoTitle = (text) => { + if (text) { + const check = text.includes('{listing_category}'); + if (check) { + return text.replace('{listing_category}', categoryName.split('-')[1]); + } + return text; + } + }; + + // Seo description + const seoDescription = (text) => { + if (text) { + const check = text.includes('{listing_category_description}'); + if (check) { + return text.replace('{listing_category_description}', categoryName.split('-')[1]); + } + return text; + } + }; + return ( <> - - Best {categoryName.split('-')[1]} products near me - - - + {!loading && ( + + {`${seoTitle(seo_configs.meta_listing_category_title)}`} + + + + )} {loading && ( <> - - + + + > )} {listings && @@ -104,7 +133,7 @@ const ListingsByCategory = () => { {listings?.map((list, i) => { let imagePath = NoProductImage; if (list.images[0] !== undefined) { - imagePath =getThumbnailImage(list.images[0]) ; + imagePath = getThumbnailImage(list.images[0]); } return ( { const cartError = useSelector((state) => state.cart.error); const cartErrorMessage = useSelector((state) => state.cart.message); const listingsConfigs = useSelector((state) => state.auth.listings_configs); + const seo_configs = useSelector((state) => state.auth.seo_configs); + const dispatch = useDispatch(); useEffect(() => { @@ -211,13 +213,41 @@ const ProductDetail = () => { // // } + // seo title + const seoTitle = (text) => { + if(text){ + const check = text.includes('{listing_title}'); + if (check) { + return text.replace('{listing_title}', listing?.title); + } + return text; + } + } + + // Seo description + const seoDescription = (text) => { + if (text) { + const check = text.includes('{listing_description}'); + if (check) { + return text.replace('{listing_description}', listing?.description); + } + return text; + } + }; + + return ( <> - - {listing?.title || 'N/A'}- Buy Online - - - + {!loading && ( + + {seoTitle(seo_configs.meta_listing_title)} + + + + )} {/* */} diff --git a/src/containers/Store/AllStores.js b/src/containers/Store/AllStores.js index 20432e9..b352e79 100644 --- a/src/containers/Store/AllStores.js +++ b/src/containers/Store/AllStores.js @@ -41,6 +41,7 @@ const AllStores = () => { const stores = useSelector((state) => state.store.storesLists); const accountCategory = useSelector((state) => state.store.categories); + const seo_configs = useSelector((state) => state.auth.seo_configs); const postStoreFollow = (id, following) => { @@ -95,8 +96,8 @@ const AllStores = () => { return ( - Tradly Web - Stores - + {`${seo_configs.meta_title}`} + {followLoading && ( @@ -129,7 +130,7 @@ const AllStores = () => { {stores?.accounts?.map((store, i) => { let imagePath = AllenSollyLogo; if (store.images.length > 0) { - imagePath = getThumbnailImage(store.images[0]) ; + imagePath = getThumbnailImage(store.images[0]); } let description = store.description; diff --git a/src/containers/Store/StoreDetails.js b/src/containers/Store/StoreDetails.js index 2ab43c0..1472009 100644 --- a/src/containers/Store/StoreDetails.js +++ b/src/containers/Store/StoreDetails.js @@ -8,7 +8,7 @@ import ReactMarkdown from 'react-markdown'; import classes from './Store.module.css'; import AllenSollyLogo from '../../assets/images/home/store/allenSolly.svg'; - import * as actions from '../../store/actions/index'; +import * as actions from '../../store/actions/index'; import Maps from '../../components/UI/Maps/Maps'; import Modal from '../../components/UI/Modal/Modal'; @@ -23,7 +23,6 @@ import { Helmet } from 'react-helmet'; import PropTypes from 'prop-types'; import Loader from 'react-loader-spinner'; - class StoreDetails extends Component { constructor(props) { super(props); @@ -127,7 +126,7 @@ class StoreDetails extends Component { }; render() { - const { storeDetails, listings, total_records, loading, allListings } = this.props; + const { storeDetails, listings, total_records, loading, allListings, seoConfigs } = this.props; let listing = ''; let showLoadButton = null; let storeContent = null; @@ -276,13 +275,48 @@ class StoreDetails extends Component { ); const { location } = this.props; + // seo title + const seoTitle = (text) => { + if (text) { + const check = text.includes('{account_title}'); + if (check) { + return text.replace('{account_title}', storeName); + } + return text; + } + }; + + // Seo description + const seoDescription = (text) => { + if (text) { + const check = text.includes('{account_title}'); + const check2 = text.includes('{account_description}'); + if (check && check2) { + const first = text.replace('{account_title}', storeName); + return first.replace( + '{account_description}', + storeDetails.get('description', '') || 'N/A' + ); + } else if (check) { + return text.replace('{account_title}', storeName); + } else if (check2) { + return text.replace( + '{account_description}', + storeDetails.get('description', '') || 'N/A' + ); + } + + return text; + } + }; + return ( <> - Find items sold by {storeName}. Buy online + {`${seoTitle(seoConfigs.meta_account_title)}`} @@ -334,6 +368,7 @@ const mapStateToProps = (state) => { listings: selectListings(state), allListings: state.product.listings, page: state.product.page, + seoConfigs: state.auth.seo_configs, }; };
{list.get('title', '')}