Skip to content

Commit 69b5159

Browse files
authored
Merge pull request #7 from iamsharzil/image-https
changed link from http to https
2 parents d277169 + 7d6e3e4 commit 69b5159

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

components/Card.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { IInitialState } from 'interfaces/state';
1313

1414
// import animationData from 'lottie/loader.json';
1515
import successAnimation from 'lottie/success.json';
16+
import { cacheRemove } from 'utils/cacheRemove';
1617

1718
type Inputs = {
1819
quantity: Number;
@@ -67,6 +68,7 @@ const Card: FC<IProduct> = (product) => {
6768
};
6869

6970
const imageUrl = product.image.url;
71+
const httpsImage = cacheRemove(imageUrl);
7072
const price = product.price_range.maximum_price.final_price.value;
7173

7274
if (product.stock_status === 'OUT_OF_STOCK') {
@@ -90,7 +92,7 @@ const Card: FC<IProduct> = (product) => {
9092
<div className='card-body'>
9193
<h5 className='card-title'>{product.name}</h5>
9294
</div>
93-
<img src={imageUrl} className='img-fluid' alt={product.name} />
95+
<img src={httpsImage} className='img-fluid' alt={product.name} />
9496
<div className='card-body text-center'>
9597
<p className='card-text'>
9698
<strong>Rs. {price}</strong>{' '}

components/Cart/CartItems.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { TCart } from 'interfaces/cart';
22
import { useSelector } from 'react-redux';
33
import { IInitialState } from 'interfaces/state';
44
import { motion } from 'framer-motion';
5+
import { cacheRemove } from 'utils/cacheRemove';
56

67
type Inputs = {
78
cart_item_id: string;
@@ -32,7 +33,7 @@ const CartItems = ({
3233
(state: IInitialState) => state
3334
);
3435

35-
let {
36+
const {
3637
product: {
3738
name,
3839
price_range: { maximum_price },
@@ -43,19 +44,17 @@ const CartItems = ({
4344
},
4445
} = cartItem;
4546

46-
let final_price = maximum_price.final_price.value;
47-
let total_price = value;
47+
const final_price = maximum_price.final_price.value;
48+
const total_price = value;
49+
50+
const httpsImage = cacheRemove(cartItem.product.thumbnail.url);
4851

4952
return (
5053
<motion.tr key={cartItem.id} variants={item}>
5154
<td className='col-sm-8 col-md-6'>
5255
<div className='media'>
5356
<a className='thumbnail pull-left' href='#'>
54-
<img
55-
className='media-object'
56-
width={60}
57-
src={cartItem.product.thumbnail.url}
58-
/>
57+
<img className='media-object' width={60} src={httpsImage} />
5958
</a>
6059
<div className='media-body ml-3 pt-4'>
6160
<h6 className='media-heading'>{name}</h6>

utils/cacheRemove.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const regexCacheRemove = /\/cache\/[a-z0-9]*\//g;
2+
3+
export const cacheRemove = (url: string) => {
4+
return url.replace('http:', 'https:').replace(regexCacheRemove, '/');
5+
};

0 commit comments

Comments
 (0)