import { Uuid } from 'pc-component-v3';
import Common from './Common.js';


export default {
  getRouteUrl: function(menu) {
    var nodeType = menu.menuNodeType;
    if (nodeType == undefined || nodeType == 'NONE' || nodeType == 'Branch') {
      return '#';
    } else if (nodeType == 'Report' || nodeType == 'Process') {
      return '/desktop/process-report/' + menu.processReportNo;
    } else if (nodeType == 'WorkFlow') {
      return '#';
    } else if (nodeType == 'Window') {
      return (
        '/desktop/window/' + menu.curdWindowNo + '?uuid=' + Uuid.createUUID()
      );
    } else if (nodeType == 'Info') {
      return '/desktop/info/' + menu.infoWindowNo;
    } else if (nodeType == 'Customer') {
      if (menu.routeUrl != undefined) {
        if (menu.routeUrl[0] == '/') {
          return menu.routeUrl;
        } else {
          return '/desktop/' + menu.routeUrl;
        }
      }
      return '#';
    } else if (nodeType == 'HTML') {
      var htmlFileName = menu.htmlFileName;
      if (htmlFileName.indexOf('{URL}') >= 0) {
        htmlFileName = htmlFileName.replace(
          '{URL}',
          Common.getHostPageBaseURL(),
        );
      }
      return htmlFileName;
    }
  },
};
