mirror of
https://github.com/vercel/commerce.git
synced 2025-07-27 04:01:23 +00:00
conversions
This commit is contained in:
38
framework/module-data/HomeAllProductsGridData.ts
Normal file
38
framework/module-data/HomeAllProductsGridData.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { getConfig } from '@framework/api'
|
||||
import getSiteInfo from '@framework/api/operations/get-site-info'
|
||||
import getAllProducts from '@framework/api/operations/get-all-products'
|
||||
|
||||
|
||||
|
||||
import rangeMap from '@lib/range-map'
|
||||
|
||||
const nonNullable = (v: any) => v
|
||||
|
||||
const HomeAllProductsGridData = 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 = getConfig({ locale })
|
||||
const { categories, brands } = await getSiteInfo({ config, preview })
|
||||
|
||||
// Get Best Newest Products
|
||||
const { products: newestProducts } = await getAllProducts({
|
||||
variables: { field: 'newestProducts', first: 12 },
|
||||
config,
|
||||
preview,
|
||||
})
|
||||
|
||||
|
||||
return {
|
||||
newestProducts: newestProducts,
|
||||
categories,
|
||||
brands
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default HomeAllProductsGridData
|
21
framework/module-data/ProductSearchData.ts
Normal file
21
framework/module-data/ProductSearchData.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { getConfig } from '@framework/api'
|
||||
import getSiteInfo from '@framework/api/operations/get-site-info'
|
||||
|
||||
const ProductSearchData = 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 = getConfig({ locale })
|
||||
const { categories, brands } = await getSiteInfo({ config, preview })
|
||||
|
||||
return {
|
||||
categories,
|
||||
brands
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default ProductSearchData
|
@@ -1,16 +1,17 @@
|
||||
import {FC} from "react"
|
||||
import * as AgilityTypes from "@agility/types"
|
||||
|
||||
import BestsellingProductsData from "./BestsellingProductsData"
|
||||
import FeaturedProductsData from "./FeaturedProductsData"
|
||||
import HomeAllProductsGridData from "./HomeAllProductsGridData"
|
||||
import ProductSearchData from "./ProductSearchData"
|
||||
|
||||
const allModules:any =[
|
||||
{ name: "BestsellingProducts", init: BestsellingProductsData },
|
||||
{ name: "FeaturedProducts", init: FeaturedProductsData}
|
||||
{ name: "FeaturedProducts", init: FeaturedProductsData},
|
||||
{ name: "HomeAllProductsGrid", init: HomeAllProductsGridData},
|
||||
{ name: "ProductSearch", init: ProductSearchData}
|
||||
]
|
||||
|
||||
/**
|
||||
* Find the data method for a module.
|
||||
* Find the data method for a module by module reference name.
|
||||
* @param moduleName
|
||||
*/
|
||||
const getInitMethod = (moduleName:string):any => {
|
||||
|
Reference in New Issue
Block a user