import validatorRouter from './validator';
import { isPopupEnv } from '@/browser/api';

const isUsePpopup = isPopupEnv;

const shopeeRouter = [
  {
    path: '/shopee/tab/all',
    component: () => import('@/vue/views/Shopee/Tab/All.vue'),
    name: 'ShopeeTabAll',
    meta: {
      layout: isUsePpopup ? 'popup' : 'default',
    },
  },
  // Product
  {
    path: '/shopee/product/clone',
    component: () => import('@/vue/views/Shopee/Product/Clone.vue'),
    name: 'ShopeeProductClone',
    beforeEnter: validatorRouter.shopeeProductShopId,
    meta: {
      layout: isUsePpopup ? 'popup' : 'default',
      requireAuth: true,
    },
  },
  {
    path: '/shopee/product/image/view',
    component: () => import('@/vue/views/Shopee/Product/Image.vue'),
    name: 'ShopeeProductImage',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE',
      showPageHeader: false,
    },
  },
  {
    path: '/shopee/product/review',
    component: () => import('@/vue/views/Shopee/Product/Review/Index.vue'),
    name: 'ShopeeReviewIndex',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_REVIEW',
      pageIcon: 'fa fa-star',
      requireAuth: true,
    },
  },
  {
    path: '/shopee/product/review/get',
    component: () => import('@/vue/views/Shopee/Product/Review/Get.vue'),
    name: 'ShopeeReviewGet',
    beforeEnter: validatorRouter.shopeeProductShopId,
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_REVIEW',
      pageIcon: 'fa fa-star',
      requireAuth: true,
    },
  },
  {
    path: '/shopee/video/compose',
    component: () => import('@/vue/views/Shopee/Video/Compose.vue'),
    name: 'ShopeeVideoCompose',
    meta: {
      layout: isUsePpopup ? 'popup' : 'default',
      requireAuth: true,
    },
  },
  {
    path: '/shopee/video/posts',
    component: () => import('@/vue/views/Shopee/Video/Posts.vue'),
    name: 'ShopeeVideoPosts',
    meta: {
      layout: isUsePpopup ? 'popup' : 'default',
      requireAuth: true,
    },
  },
  {
    path: '/shopee/video/bulk',
    component: () => import('@/vue/views/Shopee/Video/BulkCreate.vue'),
    name: 'ShopeeVideoBulkCreate',
    meta: {
      layout: isUsePpopup ? 'popup' : 'default',
      pageTitleKey: 'GO_SHOPEE_VIDEO',
      pageIcon: 'fa fa-video-camera',
      bareBody: true,
      requireAuth: true,
    },
  },
  {
    path: '/shopee/video/dashboard',
    component: () => import('@/vue/views/Shopee/Video/Dashboard.vue'),
    name: 'ShopeeVideoDashboard',
    meta: {
      layout: isUsePpopup ? 'popup' : 'default',
      pageTitleKey: 'GO_SHOPEE_VIDEO',
      pageIcon: 'fa fa-video-camera',
      bareBody: true,
      requireAuth: true,
    },
  },
];

const spyRouter = [
  {
    path: '/shopee/spy/dashboard',
    component: () => import('@/vue/views/Shopee/Spy/Dashboard.vue'),
    name: 'ShopeeProductList',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_SPY',
      pageIcon: 'fa fa-cubes',
      requireAuth: true,
      requirePlan: 'Vip',
    },
  },
  {
    path: '/shopee/spy/category/:id',
    component: () => import('@/vue/views/Shopee/Spy/Category.vue'),
    name: 'ShopeeSpyCategoryId',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_SPY',
      pageIcon: 'fa fa-home',
      requireAuth: true,
      requirePlan: 'Vip',
    },
    beforeEnter: validatorRouter.paramIdNumber,
  },
  {
    path: '/shopee/spy/shop/by-username',
    component: () => import('@/vue/views/Shopee/Spy/ShopByUsername.vue'),
    name: 'ShopeeSpyShopByUsername',
    meta: {
      layout: isUsePpopup ? 'popup' : 'default',
      pageTitleKey: 'SHOPEE_SPY',
      pageIcon: 'fa fa-home',
      requireAuth: true,
      requirePlan: 'Vip',
    },
  },
  {
    path: '/shopee/spy/shop/:id',
    component: () => import('@/vue/views/Shopee/Spy/Shop.vue'),
    name: 'ShopeeSpyShop',
    meta: {
      layout: isUsePpopup ? 'popup' : 'default',
      pageTitleKey: 'SHOPEE_SPY',
      pageIcon: 'fa fa-home',
      requireAuth: true,
      requirePlan: 'Vip',
    },
    beforeEnter: validatorRouter.paramIdNumber,
  },
  {
    path: '/shopee/spy/product',
    component: () => import('@/vue/views/Shopee/Spy/Product.vue'),
    name: 'ShopeeSpyProduct',
    beforeEnter: validatorRouter.shopeeProductShopId,
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_SPY',
      pageIcon: 'fa fa-cubes',
      requireAuth: true,
      requirePlan: 'Vip',
    },
  },
  {
    path: '/shopee/spy/market',
    component: () => import('@/vue/views/Shopee/Spy/Market.vue'),
    name: 'ShopeeSpyMarket',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_MARKET',
      pageIcon: 'fa fa-home',
    },
  },
  {
    path: '/shopee/spy/search',
    component: () => import('@/vue/views/Shopee/Spy/Search.vue'),
    name: 'ShopeeSpySearch',
    meta: {
      layout: isUsePpopup ? 'popup' : 'default',
      pageTitleKey: 'SHOPEE_SPY',
      pageIcon: 'fa fa-search',
      requireAuth: true,
      requirePlan: 'Vip',
    },
  },
];

const sellerRouter = [
  {
    path: '/shopee/seller/shop/info',
    component: () => import('@/vue/views/Shopee/Seller/Shop/Info.vue'),
    name: 'ShopeeShopIndex',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_MY_SHOP',
      pageIcon: 'fa fa-home',
    },
  },
  // Product
  {
    path: '/shopee/seller/product/manager',
    component: () => import('@/vue/views/Shopee/Seller/Product/Manager.vue'),
    name: 'ShopeeSellerProduct',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_PRODUCT_MANAGER',
      pageIcon: 'fa fa-cubes',
    },
  },
  // Auto
  {
    path: '/shopee/seller/auto/dashboard',
    component: () => import('@/vue/views/Shopee/Seller/Auto/Dashboard.vue'),
    name: 'ShopeeAutoDashboard',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_AUTO',
      pageIcon: 'fa fa-magic',
    },
  },
  {
    path: '/shopee/seller/auto/reply-rating',
    component: () => import('@/vue/views/Shopee/Seller/Auto/ReplyRating.vue'),
    name: 'ShopeeAutoReplyRating',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_AUTO_REPLY_RATING',
      pageIcon: 'fa fa-location-arrow',
      requireAuth: true,
      requirePlan: 'Vip',
    },
  },
  {
    path: '/shopee/seller/auto/push-product',
    component: () => import('@/vue/views/Shopee/Seller/Auto/PushProduct.vue'),
    name: 'ShopeeAutoPushProduct',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_AUTO_PUSH_PRODUCT',
      pageIcon: 'fa fa-location-arrow',
      requireAuth: true,
      requirePlan: 'Vip',
    },
  },
  {
    path: '/shopee/seller/auto/rating-order',
    component: () => import('@/vue/views/Shopee/Seller/Auto/RatingOrder.vue'),
    name: 'ShopeeAutoRatingOrder',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_AUTO_RATING_ORDER',
      pageIcon: 'fa fa-location-arrow',
      requireAuth: true,
      requirePlan: 'Vip',
    },
  },
  {
    path: '/shopee/seller/auto/send-message',
    component: () => import('@/vue/views/Shopee/Seller/Auto/SendMessage/Index.vue'),
    name: 'ShopeeAutoSendMessage',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_MARKETING_SENDER',
      pageIcon: 'fa fa-paper-plane',
      requireAuth: true,
      requirePlan: 'Vip',
    },
  },
  {
    path: '/shopee/seller/auto/send-message/send/:id',
    component: () => import('@/vue/views/Shopee/Seller/Auto/SendMessage/Send.vue'),
    name: 'ShopeeAutoSendMessageSend',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_AUTO_SEND_MESSAGE',
      pageIcon: 'fa fa-location-arrow',
      requireAuth: true,
      requirePlan: 'Vip',
    },
    beforeEnter: validatorRouter.paramUuid,
  },
  {
    path: '/shopee/seller/auto/send-message/collect/:id',
    component: () => import('@/vue/views/Shopee/Seller/Auto/SendMessage/Collect.vue'),
    name: 'ShopeeAutoSendMessageCollect',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_AUTO_SEND_MESSAGE',
      pageIcon: 'fa fa-location-arrow',
      requireAuth: true,
      requirePlan: 'Vip',
    },
    beforeEnter: validatorRouter.paramUuid,
  },
  // FlashSale
  {
    path: '/shopee/seller/flashsale',
    component: () => import('@/vue/views/Shopee/Seller/FlashSale/Index.vue'),
    name: 'ShopeeFlashSaleIndex',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_FLASHSALE',
      pageIcon: 'fa fa-flash',
      requireAuth: true,
    },
  },
  {
    path: '/shopee/seller/flashsale/create',
    component: () => import('@/vue/views/Shopee/Seller/FlashSale/Create.vue'),
    name: 'ShopeeFlashSaleCreate',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_FLASHSALE',
      pageIcon: 'fa fa-flash',
      requireAuth: true,
      requirePlan: 'Vip',
    },
  },
  {
    path: '/shopee/seller/flashsale/clone/:id',
    component: () => import('@/vue/views/Shopee/Seller/FlashSale/Clone.vue'),
    name: 'ShopeeFlashSaleClone',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_FLASHSALE',
      pageIcon: 'fa fa-flash',
      requireAuth: true,
      requirePlan: 'Vip',
    },
    beforeEnter: validatorRouter.paramIdNumber,
  },
  // Ads
  {
    path: '/shopee/seller/ads',
    component: () => import('@/vue/views/Shopee/Seller/Ads/Index.vue'),
    name: 'ShopeeAdsIndex',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_ADS',
      pageIcon: 'fa fa-location-arrow',
      requireAuth: true,
      requirePlan: 'Vip',
    },
  },
  {
    path: '/shopee/seller/ads/:id',
    component: () => import('@/vue/views/Shopee/Seller/Ads/Detail.vue'),
    name: 'ShopeeAdsId',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_ADS',
      pageIcon: 'fa fa-location-arrow',
      requireAuth: true,
      requirePlan: 'Vip',
    },
    beforeEnter: validatorRouter.paramIdNumber,
  },
];

const keywordRouter = [
  {
    path: '/shopee/seller/keyword',
    component: () => import('@/vue/views/Shopee/Seller/Keyword/Index.vue'),
    name: 'ShopeeKeywordIndex',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_KEYWORD',
      pageIcon: 'fa fa-book',
      requireAuth: true,
      requirePlan: 'Vip',
    },
  },
  {
    path: '/shopee/seller/keyword/Research',
    component: () => import('@/vue/views/Shopee/Seller/Keyword/Research.vue'),
    name: 'ShopeeKeywordResearch',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_KEYWORD',
      pageIcon: 'fa fa-book',
      requireAuth: true,
      requirePlan: 'Vip',
    },
  },
  {
    path: '/shopee/seller/keyword/:id',
    component: () => import('@/vue/views/Shopee/Seller/Keyword/Detail.vue'),
    name: 'ShopeeKeywordId',
    meta: {
      layout: 'default',
      pageTitleKey: 'SHOPEE_KEYWORD',
      pageIcon: 'fa fa-book',
      requireAuth: true,
      requirePlan: 'Vip',
    },
    beforeEnter: validatorRouter.paramIdNumber,
  },
];

export default [
  {
    path: '/',
    redirect: '/shopee/tab/all',
  },
  ...shopeeRouter,
  ...sellerRouter,
  ...spyRouter,
  ...keywordRouter,
];
