import authorizationroles from "./authorizationroles";
const role = authorizationroles.AUTHORIZATION_ROLES;
/*
 
*/
export default {
  registry: [
    {
      roles: [
        role.BizAdmin,
        role.BizAdminRestricted,
        role.ServiceRestricted,
        role.Service,
        role.Accounting,
        role.Tech,
        role.TechRestricted
      ],
      title: "DashboardWorkOrderByStatusList",
      icon: "$sockiListAlt",
      type: "GzDashWorkorderByStatusList",
      singleOnly: false,
      settings: {
        customTitle: null,
        timeSpan: "*thisyear*",
        interval: "month",
        wostatus: null,
        wotags: [],
        wotagsany: true,
        woitemtags: [],
        woitemtagsany: true
      }
    },
    {
      roles: [
        role.BizAdmin,
        role.BizAdminRestricted,
        role.ServiceRestricted,
        role.Service,
        role.Accounting
      ],
      title: "DashboardWorkOrderStatusCount",
      icon: "$sockiChartBar",
      type: "GzDashWorkOrderStatusCount",
      scheduleableUserOnly: false,
      singleOnly: false,
      settings: {
        customTitle: null,
        timeSpan: "*thisyear*",
        interval: "month",
        wotags: [],
        wotagsany: true
      }
    },
    {
      roles: [
        role.BizAdmin,
        role.BizAdminRestricted,
        role.ServiceRestricted,
        role.Service,
        role.Accounting
      ],
      title: "DashboardWorkOrderStatusPct",
      icon: "$sockiChartBar",
      type: "GzDashWorkOrderStatusPct",
      scheduleableUserOnly: false,
      singleOnly: false,
      settings: {
        customTitle: null,
        timeSpan: "*thisyear*",
        interval: "month",
        wotags: [],
        wotagsany: true
      }
    },
    {
      roles: [
        role.BizAdmin,
        role.BizAdminRestricted,
        role.ServiceRestricted,
        role.Service,
        role.Accounting
      ],
      title: "DashboardPctWorkOrderCompletedOnTime",
      icon: "$sockiChartBar",
      type: "GzDashPctWorkOrderCompletedOnTimeBar",
      scheduleableUserOnly: false,
      singleOnly: false,
      settings: {
        customTitle: null,
        timeSpan: "*thisyear*",
        interval: "month",
        wotags: [],
        wotagsany: true,
        color: "#00205BFF"
      }
    },
    {
      roles: [
        role.BizAdmin,
        role.BizAdminRestricted,
        role.ServiceRestricted,
        role.Service,
        role.Accounting
      ],
      title: "DashboardCountWorkOrdersCreated",
      icon: "$sockiChartLine",
      type: "GzDashWorkOrderCreatedCountLine",
      scheduleableUserOnly: false,
      singleOnly: false,
      settings: {
        customTitle: null,
        timeSpan: "*thisyear*",
        interval: "day",
        wotags: [],
        wotagsany: true,
        woitemtags: [],
        woitemtagsany: true,
        color: "#00205BFF"
      }
    },
    {
      roles: [
        role.BizAdmin,
        role.BizAdminRestricted,
        role.ServiceRestricted,
        role.Service,
        role.Accounting
      ],
      title: "DashboardCountWorkOrdersCreated",
      icon: "$sockiChartBar",
      type: "GzDashWorkOrderCreatedCountBar",
      scheduleableUserOnly: false,
      singleOnly: false,
      settings: {
        customTitle: null,
        timeSpan: "*thisyear*",
        wotags: [],
        wotagsany: true,
        woitemtags: [],
        woitemtagsany: true,
        interval: "month",
        color: "#00205BFF"
      }
    },
    {
      roles: [
        role.BizAdmin,
        role.BizAdminRestricted,
        role.ServiceRestricted,
        role.Service,
        role.Accounting
      ],
      title: "DashboardOverdueAll",
      icon: "$sockiListAlt",
      type: "GzDashWorkorderOverdueAllList",
      scheduleableUserOnly: false,
      singleOnly: false,
      settings: {
        customTitle: null,
        wotags: [],
        wotagsany: true,
        woitemtags: [],
        woitemtagsany: true
      }
    },
    {
      roles: [role.Tech, role.TechRestricted],
      title: "DashboardOverdue",
      icon: "$sockiListAlt",
      type: "GzDashWorkorderOverduePersonalList",
      scheduleableUserOnly: true,
      singleOnly: true,
      settings: {
        customTitle: null,
        wotags: [],
        wotagsany: true,
        woitemtags: [],
        woitemtagsany: true
      }
    },
    {
      roles: [
        role.BizAdmin,
        role.BizAdminRestricted,
        role.ServiceRestricted,
        role.Service,
        role.Tech,
        role.TechRestricted
      ],
      title: "DashboardOpenCSR",
      icon: "$sockiListAlt",
      type: "GzDashCSROpenList",
      singleOnly: false,
      settings: {
        customTitle: null,
        custtags: [],
        custtagsany: true
      }
    },
    {
      roles: [
        role.BizAdmin,
        role.BizAdminRestricted,
        role.ServiceRestricted,
        role.Service,
        role.Accounting,
        role.Tech,
        role.TechRestricted
      ],
      title: "DashboardNotScheduled",
      icon: "$sockiListAlt",
      type: "GzDashWorkorderUnscheduledOpenList",
      singleOnly: false,
      settings: {
        customTitle: null,
        wostatus: null,
        wotags: [],
        wotagsany: true,
        woitemtags: [],
        woitemtagsany: true
      }
    },
    {
      roles: [
        role.BizAdmin,
        role.BizAdminRestricted,
        role.ServiceRestricted,
        role.Service,
        role.InventoryRestricted,
        role.Inventory,
        role.Accounting,
        role.Tech,
        role.TechRestricted,
        role.OpsAdmin,
        role.OpsAdminRestricted,
        role.Sales,
        role.SalesRestricted
      ],
      title: "ReminderList",
      icon: "$sockiCalendarDay",
      type: "GzDashTodayReminders",
      singleOnly: true,
      settings: {}
    },
    {
      roles: [
        role.BizAdmin,
        role.BizAdminRestricted,
        role.ServiceRestricted,
        role.Service,
        role.InventoryRestricted,
        role.Inventory,
        role.Accounting,
        role.Tech,
        role.TechRestricted,
        role.OpsAdmin,
        role.OpsAdminRestricted,
        role.Sales,
        role.SalesRestricted
      ],
      title: "ReviewList",
      icon: "$sockiCalendarDay",
      type: "GzDashTodayReviews",
      singleOnly: true,
      settings: {}
    },
    {
      roles: [role.Tech, role.TechRestricted],
      title: "DashboardScheduled",
      icon: "$sockiCalendarDay",
      type: "GzDashTodayScheduledWo",
      scheduleableUserOnly: true,
      singleOnly: true,
      settings: {}
    },
    {
      roles: [role.Tech, role.TechRestricted],
      title: "WorkOrderItemLaborServiceRateQuantity",
      icon: "$sockiChartLine",
      type: "GzDashLaborHoursPersonalLine",
      scheduleableUserOnly: true,
      singleOnly: false,
      settings: {
        customTitle: null,
        timeSpan: "*thisyear*",
        interval: "day",
        wotags: [],
        wotagsany: true,
        woitemtags: [],
        woitemtagsany: true,
        color: "#00205BFF"
      }
    },
    {
      roles: [role.Tech, role.TechRestricted],
      title: "WorkOrderItemLaborServiceRateQuantity",
      icon: "$sockiChartBar",
      type: "GzDashLaborHoursPersonalBar",
      scheduleableUserOnly: true,
      singleOnly: false,
      settings: {
        customTitle: null,
        timeSpan: "*thisyear*",
        wotags: [],
        wotagsany: true,
        woitemtags: [],
        woitemtagsany: true,
        interval: "month",
        color: "#00205BFF"
      }
    },
    {
      roles: [
        role.BizAdmin,
        role.BizAdminRestricted,
        role.ServiceRestricted,
        role.Service,
        role.Accounting
      ],
      title: "DashboardServiceRateQuantityAllUsers",
      icon: "$sockiChartLine",
      type: "GzDashLaborHoursEveryoneLine",
      scheduleableUserOnly: false,
      singleOnly: false,
      settings: {
        customTitle: null,
        timeSpan: "*thisyear*",
        interval: "month",
        wotags: [],
        wotagsany: true,
        woitemtags: [],
        woitemtagsany: true,
        techtags: [],
        techtagsany: true,
        userid: null,
        color: "#00205BFF"
      }
    },
    {
      roles: [
        role.BizAdmin,
        role.BizAdminRestricted,
        role.ServiceRestricted,
        role.Service,
        role.Accounting
      ],
      title: "DashboardServiceRateQuantityAllUsers",
      icon: "$sockiChartBar",
      type: "GzDashLaborHoursEveryoneBar",
      scheduleableUserOnly: false,
      singleOnly: false,
      settings: {
        customTitle: null,
        timeSpan: "*thisyear*",
        wotags: [],
        wotagsany: true,
        woitemtags: [],
        woitemtagsany: true,
        techtags: [],
        techtagsany: true,
        userid: null,
        interval: "month",
        color: "#00205BFF"
      }
    }
  ],
  availableItems() {
    const ret = [];
    for (let i = 0; i < this.registry.length; i++) {
      const item = this.registry[i];

      if (authorizationroles.hasRole(item.roles)) {
        //if it's only for sched users and not then skip
        if (
          item.scheduleableUserOnly &&
          !window.$gz.store.getters.isScheduleableUser
        ) {
          continue;
        }
        ret.push({
          id: i,
          title: item.title,
          icon: item.icon,
          type: item.type,
          singleOnly: item.singleOnly,
          settings: item.settings
        });
      }
    }
    return ret;
  },
  async cacheTranslationsForAvailableItems() {
    const items = this.availableItems();

    //await window.$gz.translation.cacheTranslations(items.map(z => z.title));
    await window.$gz.translation.cacheTranslations([
      ...new Set(items.map(z => z.title))
    ]);
  }
};
