rap-react
Version:
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
73 lines (66 loc) • 1.89 kB
JavaScript
import $ from "jquery";
export const noChangeMadeMessage = "No changes made";
export const DateFormat = "MM/dd/yyyy";
export const MomentDateFormat = "MM/DD/yyyy";
export const VisibleDateFormat = "YYYY-MM-DD";
export 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;
};
export const isSuccessMode = (response) => {
return response?.status?.toUpperCase() === "SUCCESS";
};
export const getSubDomainName = () => {
return process.env.REACT_APP_SUB_DOMAIN_NAME; //TODO Add value in Consuming app
};
export const getAPIPrefix = () => {
return process.env.REACT_APP_API_PREFIX;
};
export const getUrl = (url) => {
let subDomainName = getSubDomainName();
if (
subDomainName !== null &&
subDomainName !== undefined &&
subDomainName.length > 0
) {
return subDomainName + url;
}
return url;
};
export const isMobileView = () => {
let width = window.visualViewport.width;
//let height = window.visualViewport.height;
if (width < 768) {
return true;
}
return false;
};
export const setHtmlStyle = (showDialog) => {
let html = $("html");
let clsName = "dialog-opened";
if (isMobileView() === true) {
if (showDialog === true) {
if (html.hasClass(clsName) === false) {
html.addClass(clsName);
}
} else {
html.removeClass(clsName);
}
}
};