UNPKG

rap-react

Version:

To make it easy for you to get started with GitLab, here's a list of recommended next steps.

135 lines (130 loc) 3.81 kB
import { endPoints } from "../constants/enums"; import { entityNames, TriStateValue } from "../constants/enums"; import { getUrl } from "./wrapperService"; const baseUrl = process.env.REACT_APP_BASE_URL; export const getEntityUrl = (entityName) => { let entityUrl = undefined; let localUrl = "/hours-of-ops-ui/manage"; // getUrl("/manage"); let bUrl = baseUrl; switch (entityName) { case entityNames.DASHBOARD: { entityUrl = endPoints.CALL_BACK_DASHBOARD_URL; break; } case entityNames.OASTATUS: { entityUrl = endPoints.CALL_BACK_OASTATUS_URL; break; } case entityNames.OAMENUSTATUS: { entityUrl = endPoints.CALL_BACK_OAMENUSTATUS_URL; break; } case entityNames.OAREFUNDS: { entityUrl = endPoints.CALL_BACK_OAREFUNDS_URL; break; } case entityNames.PRICINGGROUP: { entityUrl = endPoints.CALL_BACK_BRIDGE_PRICINGGROUPS_URL; break; } case entityNames.MYRESTAURANTS: { entityUrl = endPoints.CALL_BACK_BRIDGE_MYRESTAURANTS_URL; break; } case entityNames.PRICEENTRY: { entityUrl = endPoints.CALL_BACK_BRIDGE_PRICEENTRY_URL; break; } case entityNames.SMARTSELLDMALEADERBOARD: { entityUrl = endPoints.CALL_BACK_SMARTSELLDMALEADERBOARD_URL; break; } case entityNames.SMARTSELLENTITYLEADERBOARD: { entityUrl = endPoints.CALL_BACK_SMARTSELLENTITYLEADERBOARD_URL; break; } case entityNames.ROLEMANAGEMENT: { entityUrl = endPoints.CALL_BACK_BRIDGE_ROLES_URL; break; } case entityNames.USERMANAGEMENT: { entityUrl = endPoints.CALL_BACK_BRIDGE_USERS_URL; break; } case "Groups": case entityNames.GROUPMANAGEMENT: { entityUrl = endPoints.CALL_BACK_BRIDGE_GROUPS_URL; break; } case entityNames.HOURSOPERATION: { bUrl = localUrl; entityUrl = "/hours"; break; } default: { break; } } // if (bUrl !== undefined && entityUrl !== undefined) { // return bUrl + entityUrl; // } return entityUrl; }; export const getEntityDescription = (privileges, entityName) => { let description = ""; if ( privileges !== undefined && privileges !== null && privileges.length > 0 ) { let found = privileges.find((x) => x.entityName === entityName); if (found !== null && found !== undefined) { description = found.entityDescription; } } return description; }; const getOldState = (arr) => { let value = TriStateValue.UNCHECKED; let foundValue = false; if (arr !== null && arr !== undefined && arr.length > 0) { for (let c = 0; c < arr.length; c++) { let obj = arr[c]; if ( obj.Value !== TriStateValue.CHECKED && obj.Value !== TriStateValue.PARTIAL ) { } else if (c === arr.length - 1) { value = TriStateValue.UNCHECKED; foundValue = true; } } if (foundValue === false) { for (let c = 0; c < arr.length; c++) { let obj = arr[c]; if ( obj.Value !== TriStateValue.UNCHECKED && obj.Value !== TriStateValue.CHECKED ) { } else if (c === arr.length - 1) { value = TriStateValue.PARTIAL; foundValue = true; } } } if (foundValue === false) { for (let c = 0; c < arr.length; c++) { let obj = arr[c]; if ( obj.Value !== TriStateValue.PARTIAL && obj.Value !== TriStateValue.UNCHECKED ) { } else if (c === arr.length - 1) { value = TriStateValue.CHECKED; foundValue = true; } } } } return value; };