import dynamic from "dva/dynamic";
import orderSignList from "../models/orderSignList";
import noticeDetail from "../models/noticeDetail";
import credit from "../models/credit";
// import BasicModules from "@/pages/BasicModules";

// wrapper of dynamic
const dynamicWrapper = (app, models, component) =>
  dynamic({
    app,
    // models: () => models.map(function(m) {
    //   const model = import(`../models/${m}.js`);
    //   console.log(m);
    //   return model;
    // }),
    models: () => models.map(m => import(`../models/${m}.js`)),
    // component:
    // models.length > 0 ? () => new BasicModules(component(), app) : component
    component
  });

// nav data
export const getNavData = app => [
  {
    name: "要货",
    path: "buyer",
    layout: "BuyerHomeLayout",
    icon: "shopping-cart",
    component: dynamicWrapper(
      app,
      [
        "homeLayout",
        "home",
        "goodsLevel",
        "goodsCommon",
        "goodsHot",
        "orderEdit",
        "goodsPurchase",
        "orderList",
        "cartList",
        "commodityDetails",
        "orderListDetail",
        "orderSignList",
        "announcement",
        "orderSignListDetail",
        "goodsSupplyList",
        "goodsSupplyDetail",
        "noticeDetail",
        "credit",
        "replenishmentParameter",
        "returnOrderList",
        "returnOrderListDetail",
        "returnOrderEdit",
        "myAccount",
        "public",
        "paymentNotice",
        "goodsOpts"
      ],
      () => import("../layouts/buyer/HomeLayout")
    ),
    children: []
  }
];
