Skip to content

Commit

Permalink
seo configs update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahsan-Ullah1871 committed Oct 20, 2021
1 parent f5be8db commit 2e4a15d
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 64 deletions.
10 changes: 7 additions & 3 deletions src/containers/Listings/Listings.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ class Listings extends Component {
return (
<>
<Helmet>
<title>{seoConfigs.meta_listing_title}</title>
<meta name="description" content={seoConfigs.meta_listing_description} />
<title>{seoConfigs.meta_title}</title>
<meta name="description" content={seoConfigs.meta_description} />
<link rel="canonical" href={location.pathname} />
</Helmet>
<Aux>
Expand Down Expand Up @@ -335,7 +335,11 @@ class Listings extends Component {
<p className={classes.storeTitle}>{list.get('title', '')}</p>
<div className={classes.bottomDesc}>
<img
src={list.getIn(['account', 'images', 0])? getThumbnailImage(list.getIn(['account', 'images', 0])) : NoIamgeLogo}
src={
list.getIn(['account', 'images', 0])
? getThumbnailImage(list.getIn(['account', 'images', 0]))
: NoIamgeLogo
}
alt={list.get('title', '')}
title={list.getIn(['account', 'name'])}
/>{' '}
Expand Down
125 changes: 77 additions & 48 deletions src/containers/ListingsByCategory/ListingsByCategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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 = (
<div className="col-sm-12">
<button
className="btnGreenStyle pull-right mt-4"
onClick={ loadMore}
>
<button className="btnGreenStyle pull-right mt-4" onClick={loadMore}>
Load More
</button>
</div>
);
}

// 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 (
<>
<Helmet>
<title>Best {categoryName.split('-')[1]} products near me</title>
<meta
name="description"
content={`Buy and sell products online - ${categoryName.split('-')[1]} `}
/>
<link rel="canonical" href={location.pathname} />
</Helmet>
{!loading && (
<Helmet>
<title> {`${seoTitle(seo_configs.meta_listing_category_title)}`}</title>
<meta
name="description"
content={`${seoDescription(seo_configs.meta_listing_category_description)}`}
/>
<link rel="canonical" href={location.pathname} />
</Helmet>
)}
<Aux>
{loading && (
<>
<div className={classes.Backdrop}><Loader
type="ThreeDots"
color="var(--primary_color)"
height={100}
width={100}
style={{
position: 'absolute',
right: 0,
height: '100vh',
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
zIndex: '50000',
}}
/></div>

<div className={classes.Backdrop}>
<Loader
type="ThreeDots"
color="var(--primary_color)"
height={100}
width={100}
style={{
position: 'absolute',
right: 0,
height: '100vh',
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
zIndex: '50000',
}}
/>
</div>
</>
)}
{listings &&
Expand All @@ -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 (
<Link
Expand Down
40 changes: 35 additions & 5 deletions src/containers/ProductDetails/ProductDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const ProductDetail = () => {
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(() => {
Expand Down Expand Up @@ -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 (
<>
<Helmet>
<title> {listing?.title || 'N/A'}- Buy Online </title>
<meta name="description" content={`${listing?.description}`} />
<link rel="canonical" href={location.pathname} />
</Helmet>
{!loading && (
<Helmet>
<title> {seoTitle(seo_configs.meta_listing_title)} </title>
<meta
name="description"
content={`${seoDescription(seo_configs.meta_listing_description)}`}
/>
<link rel="canonical" href={location.pathname} />
</Helmet>
)}
<Aux>
{/* <Backdrop show={loading} />
<Spinner show={loading} /> */}
Expand Down
7 changes: 4 additions & 3 deletions src/containers/Store/AllStores.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -95,8 +96,8 @@ const AllStores = () => {
return (
<Aux>
<Helmet>
<title>Tradly Web - Stores </title>
<meta name="description" content=" All stores list . You can select a store" />
<title>{`${seo_configs.meta_title}`}</title>
<meta name="description" content={`${seo_configs.meta_description}`} />
<link rel="canonical" href={location.pathname} />
</Helmet>
{followLoading && (
Expand Down Expand Up @@ -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;
Expand Down
45 changes: 40 additions & 5 deletions src/containers/Store/StoreDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 (
<>
<Helmet>
<title>Find items sold by {storeName}. Buy online</title>
<title>{`${seoTitle(seoConfigs.meta_account_title)}`}</title>
<meta
name="description"
content={`Products sold by ${storeName}. Chat and buy from mobile app. `}
content={`${seoDescription(seoConfigs.meta_account_description)} `}
/>
<link rel="canonical" href={location.pathname} />
</Helmet>
Expand Down Expand Up @@ -334,6 +368,7 @@ const mapStateToProps = (state) => {
listings: selectListings(state),
allListings: state.product.listings,
page: state.product.page,
seoConfigs: state.auth.seo_configs,
};
};

Expand Down

4 comments on commit 2e4a15d

@vercel
Copy link

@vercel vercel bot commented on 2e4a15d Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 2e4a15d Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 2e4a15d Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 2e4a15d Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.