"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.setHtmlStyle = exports.noChangeMadeMessage = exports.isSuccessMode = exports.isMobileView = exports.isFieldANumber = exports.getUrl = exports.getSubDomainName = exports.getAPIPrefix = exports.VisibleDateFormat = exports.UpdateScreenAndTabTitle = exports.MomentDateFormat = exports.DateFormat = void 0;
var _jquery = _interopRequireDefault(require("jquery"));
const noChangeMadeMessage = exports.noChangeMadeMessage = "No changes made";
const DateFormat = exports.DateFormat = "MM/dd/yyyy";
const MomentDateFormat = exports.MomentDateFormat = "MM/DD/yyyy";
const VisibleDateFormat = exports.VisibleDateFormat = "YYYY-MM-DD";
const isFieldANumber = fieldValue => {
  if (fieldValue !== null && fieldValue !== undefined) {
    const stringFieldValue = fieldValue.toString();
    if (stringFieldValue.length > 0) {
      if (stringFieldValue.indexOf(".") > -1) {
        return false;
      }
      let isNaNValue = isNaN(stringFieldValue);
      if (isNaNValue === false) {
        let integerValue = parseInt(stringFieldValue);
        if (integerValue > 0) {
          return true;
        }
      }
      return false;
    }
    return false;
  }
  return false;
};
exports.isFieldANumber = isFieldANumber;
const isSuccessMode = response => {
  var _response$status;
  return (response === null || response === void 0 || (_response$status = response.status) === null || _response$status === void 0 ? void 0 : _response$status.toUpperCase()) === "SUCCESS";
};
exports.isSuccessMode = isSuccessMode;
const getSubDomainName = () => {
  return process.env.REACT_APP_SUB_DOMAIN_NAME; //TODO Add value in Consuming app
};
exports.getSubDomainName = getSubDomainName;
const getAPIPrefix = () => {
  return process.env.REACT_APP_API_PREFIX;
};
exports.getAPIPrefix = getAPIPrefix;
const getUrl = url => {
  let subDomainName = getSubDomainName();
  if (subDomainName !== null && subDomainName !== undefined && subDomainName.length > 0) {
    return subDomainName + url;
  }
  return url;
};
exports.getUrl = getUrl;
const isMobileView = () => {
  let width = window.visualViewport.width;
  //let height = window.visualViewport.height;
  if (width < 768) {
    return true;
  }
  return false;
};
exports.isMobileView = isMobileView;
const setHtmlStyle = showDialog => {
  let html = (0, _jquery.default)("html");
  let clsName = "dialog-opened";
  if (isMobileView() === true) {
    if (showDialog === true) {
      if (html.hasClass(clsName) === false) {
        html.addClass(clsName);
      }
    } else {
      html.removeClass(clsName);
    }
  }
};
exports.setHtmlStyle = setHtmlStyle;
const UpdateScreenAndTabTitle = which => {
  let title = "Restaurant " + which + " Management";
  (0, _jquery.default)("[name=main-page-title]").html(title);
  (0, _jquery.default)(".subheader-mainlink").html(title);
};
exports.UpdateScreenAndTabTitle = UpdateScreenAndTabTitle;