Skip to content

Commit 67d05ea

Browse files
committed
Moved the features to be environment variable only
1 parent a8607f2 commit 67d05ea

File tree

7 files changed

+4
-35
lines changed

7 files changed

+4
-35
lines changed

components/product/ProductCard/ProductCard.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ interface Props {
1111
product: Product
1212
variant?: 'slim' | 'simple'
1313
imgProps?: Omit<ImageProps, 'src'>
14-
wishlist?: boolean
1514
}
1615

1716
const placeholderImg = '/product-img-placeholder.svg'
@@ -21,7 +20,6 @@ const ProductCard: FC<Props> = ({
2120
product,
2221
variant,
2322
imgProps,
24-
wishlist = false,
2523
...props
2624
}) => (
2725
<Link href={`/product/${product.slug}`} {...props}>

components/product/ProductView/ProductView.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ interface Props {
1919
className?: string
2020
children?: any
2121
product: Product
22-
wishlist?: boolean
2322
}
2423

25-
const ProductView: FC<Props> = ({ product, wishlist = false }) => {
24+
const ProductView: FC<Props> = ({ product }) => {
2625
const addItem = useAddItem()
2726
const { price } = usePrice({
2827
amount: product.price.value,

next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
defaultLocale: 'en-US',
88
},
99
env: {
10-
WISHLIST_ENABLED: false,
10+
WISHLIST_ENABLED: true,
1111
},
1212
rewrites() {
1313
return [

pages/index.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { getConfig } from '@framework/api'
88
import getAllProducts from '@framework/product/get-all-products'
99
import getSiteInfo from '@framework/common/get-site-info'
1010
import getAllPages from '@framework/common/get-all-pages'
11-
import Features from '@commerce/utils/features'
1211

1312
export async function getStaticProps({
1413
preview,
@@ -24,17 +23,13 @@ export async function getStaticProps({
2423

2524
const { categories, brands } = await getSiteInfo({ config, preview })
2625
const { pages } = await getAllPages({ config, preview })
27-
const isWishlistEnabled = Features.isEnabled('wishlist')
2826

2927
return {
3028
props: {
3129
products,
3230
categories,
3331
brands,
3432
pages,
35-
commerceFeatures: {
36-
wishlist: isWishlistEnabled,
37-
},
3833
},
3934
revalidate: 14400,
4035
}
@@ -44,7 +39,6 @@ export default function Home({
4439
products,
4540
brands,
4641
categories,
47-
commerceFeatures,
4842
}: InferGetStaticPropsType<typeof getStaticProps>) {
4943
return (
5044
<>
@@ -57,7 +51,6 @@ export default function Home({
5751
width: i === 0 ? 1080 : 540,
5852
height: i === 0 ? 1080 : 540,
5953
}}
60-
wishlist={!!process.env.WISHLIST_ENABLED}
6154
/>
6255
))}
6356
</Grid>
@@ -71,7 +64,6 @@ export default function Home({
7164
width: 320,
7265
height: 320,
7366
}}
74-
wishlist={!!process.env.WISHLIST_ENABLED}
7567
/>
7668
))}
7769
</Marquee>
@@ -94,7 +86,6 @@ export default function Home({
9486
width: i === 0 ? 1080 : 540,
9587
height: i === 0 ? 1080 : 540,
9688
}}
97-
wishlist={!!process.env.WISHLIST_ENABLED}
9889
/>
9990
))}
10091
</Grid>
@@ -108,7 +99,6 @@ export default function Home({
10899
width: 320,
109100
height: 320,
110101
}}
111-
wishlist={!!process.env.WISHLIST_ENABLED}
112102
/>
113103
))}
114104
</Marquee>

pages/product/[slug].tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ import { getConfig } from '@framework/api'
1111
import getProduct from '@framework/product/get-product'
1212
import getAllPages from '@framework/common/get-all-pages'
1313
import getAllProductPaths from '@framework/product/get-all-product-paths'
14-
import Features from '@commerce/utils/features'
1514

1615
export async function getStaticProps({
1716
params,
1817
locale,
1918
preview,
2019
}: GetStaticPropsContext<{ slug: string }>) {
21-
const isWishlistEnabled = Features.isEnabled('wishlist')
2220
const config = getConfig({ locale })
2321
const { pages } = await getAllPages({ config, preview })
2422
const { product } = await getProduct({
@@ -35,9 +33,6 @@ export async function getStaticProps({
3533
props: {
3634
pages,
3735
product,
38-
commerceFeatures: {
39-
wishlist: isWishlistEnabled,
40-
},
4136
},
4237
revalidate: 200,
4338
}
@@ -62,17 +57,13 @@ export async function getStaticPaths({ locales }: GetStaticPathsContext) {
6257

6358
export default function Slug({
6459
product,
65-
commerceFeatures,
6660
}: InferGetStaticPropsType<typeof getStaticProps>) {
6761
const router = useRouter()
6862

6963
return router.isFallback ? (
7064
<h1>Loading...</h1> // TODO (BC) Add Skeleton Views
7165
) : (
72-
<ProductView
73-
product={product as any}
74-
wishlist={!!process.env.WISHLIST_ENABLED}
75-
/>
66+
<ProductView product={product as any} />
7667
)
7768
}
7869

pages/search.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ const SORT = Object.entries({
2626
'price-desc': 'Price: High to low',
2727
})
2828

29-
import Features from '@commerce/utils/features'
30-
3129
import {
3230
filterQuery,
3331
getCategoryPath,
@@ -43,23 +41,18 @@ export async function getStaticProps({
4341
const config = getConfig({ locale })
4442
const { pages } = await getAllPages({ config, preview })
4543
const { categories, brands } = await getSiteInfo({ config, preview })
46-
const isWishlistEnabled = Features.isEnabled('wishlist')
4744
return {
4845
props: {
4946
pages,
5047
categories,
5148
brands,
52-
commerceFeatures: {
53-
wishlist: isWishlistEnabled,
54-
},
5549
},
5650
}
5751
}
5852

5953
export default function Search({
6054
categories,
6155
brands,
62-
commerceFeatures: { wishlist },
6356
}: InferGetStaticPropsType<typeof getStaticProps>) {
6457
const [activeFilter, setActiveFilter] = useState('')
6558
const [toggleFilter, setToggleFilter] = useState(false)
@@ -359,7 +352,6 @@ export default function Search({
359352
width: 480,
360353
height: 480,
361354
}}
362-
wishlist={wishlist}
363355
/>
364356
))}
365357
</Grid>

pages/wishlist.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ import { useCustomer } from '@framework/customer'
1111
import { WishlistCard } from '@components/wishlist'
1212
import useWishlist from '@framework/wishlist/use-wishlist'
1313
import getAllPages from '@framework/common/get-all-pages'
14-
import Features from '@commerce/utils/features'
1514

1615
export async function getStaticProps({
1716
preview,
1817
locale,
1918
}: GetStaticPropsContext) {
2019
// Disabling page if Feature is not available
21-
if (Features.isEnabled('wishlist')) {
20+
if (!process.env.WISHLIST_ENABLED) {
2221
return {
2322
notFound: true,
2423
}

0 commit comments

Comments
 (0)