conversions

This commit is contained in:
Joel Varty
2021-01-16 14:26:51 -05:00
parent 2dd8d59ae7
commit 914d75dc8d
14 changed files with 854 additions and 27 deletions

View 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

View 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

View File

@@ -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 => {