mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
Moved the features to be environment variable only
This commit is contained in:
@@ -8,7 +8,6 @@ import { getConfig } from '@framework/api'
|
||||
import getAllProducts from '@framework/product/get-all-products'
|
||||
import getSiteInfo from '@framework/common/get-site-info'
|
||||
import getAllPages from '@framework/common/get-all-pages'
|
||||
import Features from '@commerce/utils/features'
|
||||
|
||||
export async function getStaticProps({
|
||||
preview,
|
||||
@@ -24,7 +23,6 @@ export async function getStaticProps({
|
||||
|
||||
const { categories, brands } = await getSiteInfo({ config, preview })
|
||||
const { pages } = await getAllPages({ config, preview })
|
||||
const isWishlistEnabled = Features.isEnabled('wishlist')
|
||||
|
||||
return {
|
||||
props: {
|
||||
@@ -32,9 +30,6 @@ export async function getStaticProps({
|
||||
categories,
|
||||
brands,
|
||||
pages,
|
||||
commerceFeatures: {
|
||||
wishlist: isWishlistEnabled,
|
||||
},
|
||||
},
|
||||
revalidate: 14400,
|
||||
}
|
||||
@@ -44,7 +39,6 @@ export default function Home({
|
||||
products,
|
||||
brands,
|
||||
categories,
|
||||
commerceFeatures,
|
||||
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
||||
return (
|
||||
<>
|
||||
@@ -57,7 +51,6 @@ export default function Home({
|
||||
width: i === 0 ? 1080 : 540,
|
||||
height: i === 0 ? 1080 : 540,
|
||||
}}
|
||||
wishlist={!!process.env.WISHLIST_ENABLED}
|
||||
/>
|
||||
))}
|
||||
</Grid>
|
||||
@@ -71,7 +64,6 @@ export default function Home({
|
||||
width: 320,
|
||||
height: 320,
|
||||
}}
|
||||
wishlist={!!process.env.WISHLIST_ENABLED}
|
||||
/>
|
||||
))}
|
||||
</Marquee>
|
||||
@@ -94,7 +86,6 @@ export default function Home({
|
||||
width: i === 0 ? 1080 : 540,
|
||||
height: i === 0 ? 1080 : 540,
|
||||
}}
|
||||
wishlist={!!process.env.WISHLIST_ENABLED}
|
||||
/>
|
||||
))}
|
||||
</Grid>
|
||||
@@ -108,7 +99,6 @@ export default function Home({
|
||||
width: 320,
|
||||
height: 320,
|
||||
}}
|
||||
wishlist={!!process.env.WISHLIST_ENABLED}
|
||||
/>
|
||||
))}
|
||||
</Marquee>
|
||||
|
@@ -11,14 +11,12 @@ import { getConfig } from '@framework/api'
|
||||
import getProduct from '@framework/product/get-product'
|
||||
import getAllPages from '@framework/common/get-all-pages'
|
||||
import getAllProductPaths from '@framework/product/get-all-product-paths'
|
||||
import Features from '@commerce/utils/features'
|
||||
|
||||
export async function getStaticProps({
|
||||
params,
|
||||
locale,
|
||||
preview,
|
||||
}: GetStaticPropsContext<{ slug: string }>) {
|
||||
const isWishlistEnabled = Features.isEnabled('wishlist')
|
||||
const config = getConfig({ locale })
|
||||
const { pages } = await getAllPages({ config, preview })
|
||||
const { product } = await getProduct({
|
||||
@@ -35,9 +33,6 @@ export async function getStaticProps({
|
||||
props: {
|
||||
pages,
|
||||
product,
|
||||
commerceFeatures: {
|
||||
wishlist: isWishlistEnabled,
|
||||
},
|
||||
},
|
||||
revalidate: 200,
|
||||
}
|
||||
@@ -62,17 +57,13 @@ export async function getStaticPaths({ locales }: GetStaticPathsContext) {
|
||||
|
||||
export default function Slug({
|
||||
product,
|
||||
commerceFeatures,
|
||||
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
||||
const router = useRouter()
|
||||
|
||||
return router.isFallback ? (
|
||||
<h1>Loading...</h1> // TODO (BC) Add Skeleton Views
|
||||
) : (
|
||||
<ProductView
|
||||
product={product as any}
|
||||
wishlist={!!process.env.WISHLIST_ENABLED}
|
||||
/>
|
||||
<ProductView product={product as any} />
|
||||
)
|
||||
}
|
||||
|
||||
|
@@ -26,8 +26,6 @@ const SORT = Object.entries({
|
||||
'price-desc': 'Price: High to low',
|
||||
})
|
||||
|
||||
import Features from '@commerce/utils/features'
|
||||
|
||||
import {
|
||||
filterQuery,
|
||||
getCategoryPath,
|
||||
@@ -43,15 +41,11 @@ export async function getStaticProps({
|
||||
const config = getConfig({ locale })
|
||||
const { pages } = await getAllPages({ config, preview })
|
||||
const { categories, brands } = await getSiteInfo({ config, preview })
|
||||
const isWishlistEnabled = Features.isEnabled('wishlist')
|
||||
return {
|
||||
props: {
|
||||
pages,
|
||||
categories,
|
||||
brands,
|
||||
commerceFeatures: {
|
||||
wishlist: isWishlistEnabled,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -59,7 +53,6 @@ export async function getStaticProps({
|
||||
export default function Search({
|
||||
categories,
|
||||
brands,
|
||||
commerceFeatures: { wishlist },
|
||||
}: InferGetStaticPropsType<typeof getStaticProps>) {
|
||||
const [activeFilter, setActiveFilter] = useState('')
|
||||
const [toggleFilter, setToggleFilter] = useState(false)
|
||||
@@ -359,7 +352,6 @@ export default function Search({
|
||||
width: 480,
|
||||
height: 480,
|
||||
}}
|
||||
wishlist={wishlist}
|
||||
/>
|
||||
))}
|
||||
</Grid>
|
||||
|
@@ -11,14 +11,13 @@ import { useCustomer } from '@framework/customer'
|
||||
import { WishlistCard } from '@components/wishlist'
|
||||
import useWishlist from '@framework/wishlist/use-wishlist'
|
||||
import getAllPages from '@framework/common/get-all-pages'
|
||||
import Features from '@commerce/utils/features'
|
||||
|
||||
export async function getStaticProps({
|
||||
preview,
|
||||
locale,
|
||||
}: GetStaticPropsContext) {
|
||||
// Disabling page if Feature is not available
|
||||
if (Features.isEnabled('wishlist')) {
|
||||
if (!process.env.WISHLIST_ENABLED) {
|
||||
return {
|
||||
notFound: true,
|
||||
}
|
||||
|
Reference in New Issue
Block a user