mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 19:51:23 +00:00
updates
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
import commerce from '@lib/api/commerce'
|
||||
|
||||
const getCustomInitialProps = async function ({ item, agility, languageCode, channelName, pageInSitemap, dynamicPageItem }: any) {
|
||||
//TODO: pass the locale and preview mode as props...
|
||||
|
||||
|
||||
const locale = "en-US"
|
||||
const preview = false
|
||||
|
||||
const config = { locale, locales: [locale] }
|
||||
const productsPromise = commerce.getAllProducts({
|
||||
variables: { first: 6 },
|
||||
config,
|
||||
preview,
|
||||
// Saleor provider only
|
||||
...({ featured: true } as any),
|
||||
})
|
||||
|
||||
const { products } = await productsPromise
|
||||
|
||||
return {
|
||||
products
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default { getCustomInitialProps }
|
@@ -1,17 +0,0 @@
|
||||
import commerce from '@lib/api/commerce'
|
||||
|
||||
const getCustomInitialProps = async function ({ }):Promise<{pages:any, categories: any}> {
|
||||
const languageCode = "en-us"
|
||||
const preview = false
|
||||
const config = { locale: languageCode, locales: [languageCode] }
|
||||
const pagesPromise = commerce.getAllPages({ config, preview })
|
||||
const siteInfoPromise = commerce.getSiteInfo({ config, preview })
|
||||
const { pages } = await pagesPromise
|
||||
const { categories } = await siteInfoPromise
|
||||
return {
|
||||
pages, categories
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default {getCustomInitialProps}
|
@@ -1,27 +0,0 @@
|
||||
import commerce from '@lib/api/commerce'
|
||||
|
||||
const getCustomInitialProps = async function ({ item, agility, languageCode, channelName, pageInSitemap, dynamicPageItem }: any) {
|
||||
//TODO: pass the locale and preview mode as props...
|
||||
|
||||
|
||||
const locale = "en-US"
|
||||
const preview = false
|
||||
|
||||
const config = { locale, locales: [locale] }
|
||||
const productsPromise = commerce.getAllProducts({
|
||||
variables: { first: 6 },
|
||||
config,
|
||||
preview,
|
||||
// Saleor provider only
|
||||
...({ featured: true } as any),
|
||||
})
|
||||
|
||||
const { products } = await productsPromise
|
||||
|
||||
return {
|
||||
products
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default { getCustomInitialProps }
|
@@ -1,27 +0,0 @@
|
||||
import commerce from '@lib/api/commerce'
|
||||
|
||||
const getCustomInitialProps = async function ({ item, agility, languageCode, channelName, pageInSitemap, dynamicPageItem }: any) {
|
||||
//TODO: pass the locale and preview mode as props...
|
||||
|
||||
|
||||
const locale = "en-US"
|
||||
const preview = false
|
||||
|
||||
const config = { locale, locales: [locale] }
|
||||
const productsPromise = commerce.getAllProducts({
|
||||
variables: { first: 6 },
|
||||
config,
|
||||
preview,
|
||||
// Saleor provider only
|
||||
...({ featured: true } as any),
|
||||
})
|
||||
|
||||
const { products } = await productsPromise
|
||||
|
||||
return {
|
||||
products
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default { getCustomInitialProps }
|
@@ -1,26 +0,0 @@
|
||||
import commerce from '@lib/api/commerce'
|
||||
|
||||
const getCustomInitialProps = async function ({ item, agility, languageCode, channelName, pageInSitemap, dynamicPageItem }: any) {
|
||||
//TODO: pass the locale and preview mode as props...
|
||||
|
||||
|
||||
const locale = "en-us"
|
||||
const preview = false
|
||||
|
||||
const config = { locale, locales: [locale] }
|
||||
const productsPromise = commerce.getAllProducts({
|
||||
variables: { first: 4 },
|
||||
config,
|
||||
preview,
|
||||
})
|
||||
|
||||
|
||||
const { products } = await productsPromise
|
||||
|
||||
return {
|
||||
products
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default { getCustomInitialProps }
|
@@ -1,25 +0,0 @@
|
||||
import commerce from '@lib/api/commerce'
|
||||
|
||||
const getCustomInitialProps = async ({ agility, channelName, languageCode }:any) => {
|
||||
|
||||
//TODO: pass the locale and preview mode as props...
|
||||
|
||||
const locale = "en-US"
|
||||
const preview = false
|
||||
const config = { locale, locales: [locale] }
|
||||
const pagesPromise = commerce.getAllPages({ config, preview })
|
||||
const siteInfoPromise = commerce.getSiteInfo({ config, preview })
|
||||
|
||||
const { categories, brands } = await siteInfoPromise
|
||||
return {
|
||||
categories,
|
||||
brands,
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default {
|
||||
getCustomInitialProps
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
import BestsellingProductsData from "./BestsellingProductsData"
|
||||
import CartData from "./CartData"
|
||||
import FeaturedProductsData from "./FeaturedProductsData"
|
||||
import HomeAllProductsGridData from "./HomeAllProductsGridData"
|
||||
import ProductSearchData from "./ProductSearchData"
|
||||
import ProductDetailsData from "./ProductDetailsData"
|
||||
|
||||
const allModules:any =[
|
||||
{ name: "BestsellingProducts", init: BestsellingProductsData },
|
||||
{ name: "FeaturedProducts", init: FeaturedProductsData},
|
||||
{ name: "HomeAllProductsGrid", init: HomeAllProductsGridData},
|
||||
{ name: "ProductSearch", init: ProductSearchData},
|
||||
{ name: "Cart", init: CartData},
|
||||
{ name: "ProductDetails", init: ProductDetailsData}
|
||||
]
|
||||
|
||||
/**
|
||||
* Find the data method for a module by module reference name.
|
||||
* @param moduleName
|
||||
*/
|
||||
export default (moduleName:string):any => {
|
||||
const obj = allModules.find((m: { name: string }) => m.name.toLowerCase() === moduleName.toLowerCase())
|
||||
if (!obj) return null
|
||||
return obj.init
|
||||
}
|
Reference in New Issue
Block a user