2022-08-15 14:27:40 +00:00
|
|
|
import { LANGUAGE, AppServerConfig } from "../constants";
|
2020-09-30 08:43:19 +00:00
|
|
|
import sjcl from "sjcl";
|
2020-10-13 12:51:14 +00:00
|
|
|
import { isMobile } from "react-device-detect";
|
2022-07-22 19:01:25 +00:00
|
|
|
import TopLoaderService from "@docspace/components/top-loading-indicator";
|
2022-07-08 15:30:50 +00:00
|
|
|
import { Encoder } from "./encoder";
|
2022-08-17 07:23:46 +00:00
|
|
|
import FilesFilter from "../api/files/filter";
|
2022-07-08 15:30:50 +00:00
|
|
|
|
2022-08-15 14:27:40 +00:00
|
|
|
const { proxyURL } = AppServerConfig;
|
2019-11-19 12:35:56 +00:00
|
|
|
export const toUrlParams = (obj, skipNull) => {
|
|
|
|
let str = "";
|
|
|
|
for (var key in obj) {
|
2021-04-15 07:27:23 +00:00
|
|
|
if (skipNull && !obj[key]) continue;
|
2019-11-19 12:35:56 +00:00
|
|
|
|
|
|
|
if (str !== "") {
|
|
|
|
str += "&";
|
|
|
|
}
|
|
|
|
|
2022-07-05 07:03:12 +00:00
|
|
|
if (typeof obj[key] === "object") {
|
2022-07-08 07:40:04 +00:00
|
|
|
str += key + "=" + encodeURIComponent(JSON.stringify(obj[key]));
|
2022-07-05 07:03:12 +00:00
|
|
|
} else {
|
|
|
|
str += key + "=" + encodeURIComponent(obj[key]);
|
|
|
|
}
|
2019-11-19 12:35:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return str;
|
2020-09-19 15:24:48 +00:00
|
|
|
};
|
2019-11-19 12:35:56 +00:00
|
|
|
|
2022-07-08 15:29:50 +00:00
|
|
|
export const decodeDisplayName = (items) => {
|
2022-07-08 15:20:25 +00:00
|
|
|
return items.map((item) => {
|
|
|
|
if (!item) return item;
|
|
|
|
|
|
|
|
if (item.updatedBy?.displayName) {
|
|
|
|
item.updatedBy.displayName = Encoder.htmlDecode(
|
|
|
|
item.updatedBy.displayName
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (item.createdBy?.displayName) {
|
|
|
|
item.createdBy.displayName = Encoder.htmlDecode(
|
|
|
|
item.createdBy.displayName
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return item;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2019-11-19 12:35:56 +00:00
|
|
|
export function getObjectByLocation(location) {
|
|
|
|
if (!location.search || !location.search.length) return null;
|
|
|
|
|
|
|
|
const searchUrl = location.search.substring(1);
|
2021-11-11 12:37:23 +00:00
|
|
|
const decodedString = decodeURIComponent(searchUrl)
|
2022-07-08 07:40:04 +00:00
|
|
|
.replace(/\["/g, '["')
|
|
|
|
.replace(/"\]/g, '"]')
|
2021-11-11 12:37:23 +00:00
|
|
|
.replace(/"/g, '\\"')
|
|
|
|
.replace(/&/g, '","')
|
|
|
|
.replace(/=/g, '":"')
|
2022-07-08 07:40:04 +00:00
|
|
|
.replace(/\\/g, "\\\\")
|
|
|
|
.replace(/\[\\\\"/g, '["')
|
|
|
|
.replace(/\\\\"\]/g, '"]')
|
|
|
|
.replace(/"\[/g, "[")
|
|
|
|
.replace(/\]"/g, "]")
|
|
|
|
.replace(/\\\\",\\\\"/g, '","');
|
|
|
|
|
2021-11-11 12:37:23 +00:00
|
|
|
const object = JSON.parse(`{"${decodedString}"}`);
|
2019-11-19 12:35:56 +00:00
|
|
|
|
|
|
|
return object;
|
|
|
|
}
|
2020-01-21 05:56:04 +00:00
|
|
|
|
2022-08-05 14:21:14 +00:00
|
|
|
export function changeLanguage(i18n, currentLng = getCookie(LANGUAGE)) {
|
2020-09-19 15:24:48 +00:00
|
|
|
return currentLng
|
|
|
|
? i18n.language !== currentLng
|
|
|
|
? i18n.changeLanguage(currentLng)
|
|
|
|
: Promise.resolve((...args) => i18n.t(...args))
|
|
|
|
: i18n.changeLanguage("en");
|
2020-01-21 05:56:04 +00:00
|
|
|
}
|
2020-09-18 08:12:09 +00:00
|
|
|
|
2020-09-30 21:44:49 +00:00
|
|
|
export function createPasswordHash(password, hashSettings) {
|
2020-10-01 16:04:10 +00:00
|
|
|
if (
|
|
|
|
!password ||
|
|
|
|
!hashSettings ||
|
|
|
|
typeof password !== "string" ||
|
|
|
|
typeof hashSettings !== "object" ||
|
|
|
|
!hashSettings.hasOwnProperty("salt") ||
|
|
|
|
!hashSettings.hasOwnProperty("size") ||
|
|
|
|
!hashSettings.hasOwnProperty("iterations") ||
|
|
|
|
typeof hashSettings.size !== "number" ||
|
|
|
|
typeof hashSettings.iterations !== "number" ||
|
|
|
|
typeof hashSettings.salt !== "string"
|
|
|
|
)
|
|
|
|
throw new Error("Invalid params.");
|
|
|
|
|
2020-09-30 21:44:49 +00:00
|
|
|
const { size, iterations, salt } = hashSettings;
|
2020-09-30 08:43:19 +00:00
|
|
|
|
|
|
|
let bits = sjcl.misc.pbkdf2(password, salt, iterations);
|
|
|
|
bits = bits.slice(0, size / 32);
|
|
|
|
const hash = sjcl.codec.hex.fromBits(bits);
|
|
|
|
|
|
|
|
return hash;
|
2020-01-21 05:56:04 +00:00
|
|
|
}
|
2020-10-05 12:37:09 +00:00
|
|
|
|
2020-12-07 08:11:04 +00:00
|
|
|
export function updateTempContent(isAuth = false) {
|
|
|
|
if (isAuth) {
|
2021-02-03 12:42:47 +00:00
|
|
|
const el = document.getElementById("burger-loader-svg");
|
|
|
|
if (el) {
|
|
|
|
el.style.display = "block";
|
|
|
|
}
|
|
|
|
|
|
|
|
const el1 = document.getElementById("logo-loader-svg");
|
|
|
|
if (el1) {
|
|
|
|
el1.style.display = "block";
|
|
|
|
}
|
2020-12-07 08:11:04 +00:00
|
|
|
|
2021-02-03 12:42:47 +00:00
|
|
|
const el2 = document.getElementById("avatar-loader-svg");
|
|
|
|
if (el2) {
|
|
|
|
el2.style.display = "block";
|
|
|
|
}
|
2020-12-07 08:11:04 +00:00
|
|
|
} else {
|
|
|
|
const tempElm = document.getElementById("temp-content");
|
|
|
|
if (tempElm) {
|
|
|
|
tempElm.outerHTML = "";
|
|
|
|
}
|
2020-09-23 15:42:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-11 14:29:29 +00:00
|
|
|
let timer = null;
|
|
|
|
|
2020-09-23 15:42:47 +00:00
|
|
|
export function hideLoader() {
|
2020-10-13 12:51:14 +00:00
|
|
|
if (isMobile) return;
|
2021-06-11 14:29:29 +00:00
|
|
|
if (timer) {
|
|
|
|
clearTimeout(timer);
|
|
|
|
timer = null;
|
|
|
|
}
|
2021-03-04 11:36:31 +00:00
|
|
|
TopLoaderService.end();
|
2020-09-23 15:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function showLoader() {
|
2020-10-13 12:51:14 +00:00
|
|
|
if (isMobile) return;
|
2021-06-11 14:29:29 +00:00
|
|
|
|
|
|
|
hideLoader();
|
|
|
|
|
|
|
|
timer = setTimeout(() => TopLoaderService.start(), 500);
|
2020-09-23 15:42:47 +00:00
|
|
|
}
|
2020-11-17 03:29:24 +00:00
|
|
|
|
|
|
|
export { withLayoutSize } from "./withLayoutSize";
|
2020-12-04 11:21:51 +00:00
|
|
|
|
2021-02-17 14:53:18 +00:00
|
|
|
export function isMe(user, userName) {
|
|
|
|
return (
|
|
|
|
user && user.id && (userName === "@self" || user.userName === userName)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function isAdmin(currentUser, currentProductId) {
|
2022-07-28 13:11:55 +00:00
|
|
|
return (
|
|
|
|
currentUser.isAdmin ||
|
|
|
|
currentUser.isOwner ||
|
|
|
|
currentUser?.listAdminModules?.length > 0
|
|
|
|
);
|
2021-02-17 14:53:18 +00:00
|
|
|
}
|
2021-03-21 21:34:21 +00:00
|
|
|
|
2021-03-22 14:35:33 +00:00
|
|
|
import combineUrlFunc from "./combineUrl";
|
|
|
|
|
|
|
|
export const combineUrl = combineUrlFunc;
|
2021-04-05 12:49:02 +00:00
|
|
|
|
|
|
|
export function getCookie(name) {
|
|
|
|
let matches = document.cookie.match(
|
|
|
|
new RegExp(
|
|
|
|
"(?:^|; )" +
|
2022-10-24 10:01:43 +00:00
|
|
|
name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, "\\$1") +
|
|
|
|
"=([^;]*)"
|
2021-04-05 12:49:02 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
return matches ? decodeURIComponent(matches[1]) : undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setCookie(name, value, options = {}) {
|
|
|
|
options = {
|
|
|
|
path: "/",
|
|
|
|
...options,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (options.expires instanceof Date) {
|
|
|
|
options.expires = options.expires.toUTCString();
|
|
|
|
}
|
|
|
|
|
|
|
|
let updatedCookie =
|
|
|
|
encodeURIComponent(name) + "=" + encodeURIComponent(value);
|
|
|
|
|
|
|
|
for (let optionKey in options) {
|
|
|
|
updatedCookie += "; " + optionKey;
|
|
|
|
let optionValue = options[optionKey];
|
|
|
|
if (optionValue !== true) {
|
|
|
|
updatedCookie += "=" + optionValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
document.cookie = updatedCookie;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function deleteCookie(name) {
|
|
|
|
setCookie(name, "", {
|
|
|
|
"max-age": -1,
|
|
|
|
});
|
|
|
|
}
|
2021-04-16 17:23:08 +00:00
|
|
|
|
|
|
|
export function clickBackdrop() {
|
|
|
|
var elms = document.getElementsByClassName("backdrop-active");
|
|
|
|
if (elms && elms.length > 0) {
|
|
|
|
elms[0].click();
|
|
|
|
}
|
|
|
|
}
|
2021-04-29 10:44:37 +00:00
|
|
|
|
2021-04-30 14:25:26 +00:00
|
|
|
export function objectToGetParams(object) {
|
2021-04-29 10:44:37 +00:00
|
|
|
const params = Object.entries(object)
|
|
|
|
.filter(([, value]) => value !== undefined && value !== null)
|
|
|
|
.map(
|
|
|
|
([key, value]) =>
|
|
|
|
`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
|
|
|
|
);
|
|
|
|
|
|
|
|
return params.length > 0 ? `?${params.join("&")}` : "";
|
|
|
|
}
|
2021-04-30 14:25:26 +00:00
|
|
|
|
|
|
|
export function toCommunityHostname(hostname) {
|
|
|
|
let communityHostname;
|
|
|
|
try {
|
|
|
|
communityHostname =
|
|
|
|
hostname.indexOf("m.") > -1
|
|
|
|
? hostname.substring(2, hostname.length)
|
|
|
|
: hostname;
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
communityHostname = hostname;
|
|
|
|
}
|
|
|
|
|
|
|
|
return communityHostname;
|
|
|
|
}
|
2021-05-21 12:00:30 +00:00
|
|
|
|
|
|
|
export function getProviderTranslation(provider, t) {
|
|
|
|
switch (provider) {
|
2021-09-27 06:55:44 +00:00
|
|
|
case "google":
|
2021-05-21 13:37:46 +00:00
|
|
|
return t("Common:SignInWithGoogle");
|
2021-09-27 06:55:44 +00:00
|
|
|
case "facebook":
|
2021-05-21 13:37:46 +00:00
|
|
|
return t("Common:SignInWithFacebook");
|
2021-09-27 06:55:44 +00:00
|
|
|
case "twitter":
|
2021-05-21 13:37:46 +00:00
|
|
|
return t("Common:SignInWithTwitter");
|
2021-09-27 06:55:44 +00:00
|
|
|
case "linkedin":
|
2021-05-21 13:37:46 +00:00
|
|
|
return t("Common:SignInWithLinkedIn");
|
2022-02-02 22:10:12 +00:00
|
|
|
case "sso":
|
|
|
|
return t("Common:SignInWithSso");
|
2021-05-21 12:00:30 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-02 10:55:11 +00:00
|
|
|
|
2021-09-07 15:34:30 +00:00
|
|
|
export function getLanguage(lng) {
|
2021-06-02 10:55:11 +00:00
|
|
|
try {
|
|
|
|
let language = lng == "en-US" || lng == "en-GB" ? "en" : lng;
|
|
|
|
|
|
|
|
const splitted = lng.split("-");
|
|
|
|
|
|
|
|
if (splitted.length == 2 && splitted[0] == splitted[1].toLowerCase()) {
|
|
|
|
language = splitted[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
return language;
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return lng;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function loadLanguagePath(homepage, fixedNS = null) {
|
|
|
|
return (lng, ns) => {
|
|
|
|
const language = getLanguage(lng instanceof Array ? lng[0] : lng);
|
|
|
|
|
|
|
|
if (ns.length > 0 && ns[0] === "Common") {
|
|
|
|
return `/static/locales/${language}/Common.json`;
|
|
|
|
}
|
|
|
|
return `${homepage}/locales/${language}/${fixedNS || ns}.json`;
|
|
|
|
};
|
|
|
|
}
|
2021-08-19 10:30:15 +00:00
|
|
|
|
|
|
|
export function loadScript(url, id, onLoad, onError) {
|
|
|
|
try {
|
|
|
|
const script = document.createElement("script");
|
|
|
|
script.setAttribute("type", "text/javascript");
|
|
|
|
script.setAttribute("id", id);
|
|
|
|
|
|
|
|
if (onLoad) script.onload = onLoad;
|
|
|
|
if (onError) script.onerror = onError;
|
|
|
|
|
|
|
|
script.src = url;
|
|
|
|
script.async = true;
|
|
|
|
|
|
|
|
document.body.appendChild(script);
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
}
|
2022-07-21 15:05:23 +00:00
|
|
|
}
|
2021-10-13 12:19:31 +00:00
|
|
|
|
|
|
|
export function isRetina() {
|
|
|
|
if (window.devicePixelRatio > 1) return true;
|
|
|
|
|
|
|
|
var mediaQuery =
|
|
|
|
"(-webkit-min-device-pixel-ratio: 1.5),\
|
|
|
|
(min--moz-device-pixel-ratio: 1.5),\
|
|
|
|
(-o-min-device-pixel-ratio: 3/2),\
|
|
|
|
(min-resolution: 1.5dppx),\
|
|
|
|
(min-device-pixel-ratio: 1.5)";
|
|
|
|
|
|
|
|
if (window.matchMedia && window.matchMedia(mediaQuery).matches) return true;
|
|
|
|
return false;
|
|
|
|
}
|
2021-12-23 11:01:08 +00:00
|
|
|
|
|
|
|
export function convertLanguage(key) {
|
|
|
|
switch (key) {
|
2022-09-06 09:52:57 +00:00
|
|
|
case "en":
|
|
|
|
return "en-GB";
|
2021-12-23 11:01:08 +00:00
|
|
|
case "ru-RU":
|
|
|
|
return "ru";
|
|
|
|
case "de-DE":
|
|
|
|
return "de";
|
|
|
|
case "it-IT":
|
|
|
|
return "it";
|
|
|
|
case "fr-FR":
|
|
|
|
return "fr";
|
|
|
|
}
|
|
|
|
|
|
|
|
return key;
|
|
|
|
}
|
2022-04-15 11:03:20 +00:00
|
|
|
|
|
|
|
export function getFolderOptions(folderId, filter) {
|
|
|
|
if (folderId && typeof folderId === "string") {
|
|
|
|
folderId = encodeURIComponent(folderId.replace(/\\\\/g, "\\"));
|
|
|
|
}
|
|
|
|
|
|
|
|
const params =
|
|
|
|
filter && filter instanceof FilesFilter
|
|
|
|
? `${folderId}?${filter.toApiUrlParams()}`
|
|
|
|
: folderId;
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
method: "get",
|
|
|
|
url: `/files/${params}`,
|
|
|
|
};
|
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
2022-04-28 19:05:43 +00:00
|
|
|
|
|
|
|
export function sleep(ms) {
|
|
|
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
|
}
|
2022-05-13 16:16:28 +00:00
|
|
|
|
|
|
|
export function isElementInViewport(el) {
|
|
|
|
if (!el) return;
|
|
|
|
|
|
|
|
const rect = el.getBoundingClientRect();
|
|
|
|
|
|
|
|
return (
|
|
|
|
rect.top >= 0 &&
|
|
|
|
rect.left >= 0 &&
|
|
|
|
rect.bottom <=
|
2022-10-24 10:01:43 +00:00
|
|
|
(window.innerHeight || document.documentElement.clientHeight) &&
|
2022-05-13 16:16:28 +00:00
|
|
|
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
|
|
|
|
);
|
|
|
|
}
|
2022-06-28 16:31:28 +00:00
|
|
|
|
|
|
|
export function assign(obj, keyPath, value) {
|
|
|
|
const lastKeyIndex = keyPath.length - 1;
|
|
|
|
for (let i = 0; i < lastKeyIndex; ++i) {
|
|
|
|
const key = keyPath[i];
|
|
|
|
if (!(key in obj)) {
|
|
|
|
obj[key] = {};
|
|
|
|
}
|
|
|
|
obj = obj[key];
|
|
|
|
}
|
|
|
|
obj[keyPath[lastKeyIndex]] = value;
|
|
|
|
}
|
2022-08-03 11:48:54 +00:00
|
|
|
|
2022-08-26 21:49:06 +00:00
|
|
|
export function getOAuthToken(
|
|
|
|
tokenGetterWin: Window | string | null
|
|
|
|
): Promise<string> {
|
2022-08-15 14:27:40 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
localStorage.removeItem("code");
|
2022-08-26 21:49:06 +00:00
|
|
|
let interval: ReturnType<typeof setInterval>;
|
2022-08-15 14:27:40 +00:00
|
|
|
interval = setInterval(() => {
|
|
|
|
try {
|
|
|
|
const code = localStorage.getItem("code");
|
2022-08-26 21:49:06 +00:00
|
|
|
if (typeof tokenGetterWin !== "string") {
|
|
|
|
if (code) {
|
|
|
|
localStorage.removeItem("code");
|
|
|
|
clearInterval(interval);
|
|
|
|
resolve(code);
|
|
|
|
} else if (tokenGetterWin && tokenGetterWin.closed) {
|
|
|
|
clearInterval(interval);
|
|
|
|
reject();
|
|
|
|
}
|
2022-08-15 14:27:40 +00:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
clearInterval(interval);
|
|
|
|
reject(e);
|
|
|
|
}
|
|
|
|
}, 500);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-08-26 21:49:06 +00:00
|
|
|
export function getLoginLink(token: string, code: string) {
|
2022-08-15 14:27:40 +00:00
|
|
|
return combineUrl(proxyURL, `/login.ashx?p=${token}&code=${code}`);
|
|
|
|
}
|
2022-08-17 08:19:49 +00:00
|
|
|
|
|
|
|
export function checkIsSSR() {
|
|
|
|
return typeof window === "undefined";
|
|
|
|
}
|
2022-08-24 07:17:39 +00:00
|
|
|
|
2022-08-04 10:29:42 +00:00
|
|
|
export const frameCallbackData = (data) => {
|
2022-08-03 11:48:54 +00:00
|
|
|
window.parent.postMessage(
|
|
|
|
JSON.stringify({
|
|
|
|
type: "onMethodReturn",
|
|
|
|
methodReturnData: data,
|
|
|
|
}),
|
|
|
|
"*"
|
|
|
|
);
|
|
|
|
};
|
2022-08-04 10:29:42 +00:00
|
|
|
|
|
|
|
export const frameCallCommand = (command) => {
|
|
|
|
window.parent.postMessage(
|
|
|
|
JSON.stringify({
|
|
|
|
type: "onCallCommand",
|
|
|
|
commandName: command,
|
|
|
|
}),
|
|
|
|
"*"
|
|
|
|
);
|
|
|
|
};
|
2022-09-14 13:01:40 +00:00
|
|
|
|
|
|
|
export const getConvertedSize = (t, size) => {
|
|
|
|
let sizeNames;
|
|
|
|
|
2022-10-11 07:58:10 +00:00
|
|
|
if (size < 0) return `${8 + " " + t("Common:Exabyte")}`;
|
|
|
|
|
2022-09-14 13:01:40 +00:00
|
|
|
if (size < 1024 * 1024) {
|
2022-09-15 09:54:00 +00:00
|
|
|
sizeNames = [
|
|
|
|
t("Common:Megabyte"),
|
|
|
|
t("Common:Gigabyte"),
|
|
|
|
t("Common:Terabyte"),
|
|
|
|
];
|
2022-09-14 13:01:40 +00:00
|
|
|
} else {
|
|
|
|
sizeNames = [
|
2022-09-15 09:54:00 +00:00
|
|
|
t("Common:Bytes"),
|
|
|
|
t("Common:Kilobyte"),
|
|
|
|
t("Common:Megabyte"),
|
|
|
|
t("Common:Gigabyte"),
|
|
|
|
t("Common:Terabyte"),
|
2022-10-11 07:58:10 +00:00
|
|
|
t("Common:Petabyte"),
|
|
|
|
t("Common:Exabyte"),
|
2022-09-14 13:01:40 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
const bytes = size;
|
|
|
|
|
|
|
|
if (bytes == 0) return `${"0" + " " + t("Bytes")}`;
|
|
|
|
|
|
|
|
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
|
|
|
|
|
|
return (
|
|
|
|
parseFloat((bytes / Math.pow(1024, i)).toFixed(2)) + " " + sizeNames[i]
|
|
|
|
);
|
|
|
|
};
|
2022-10-24 10:01:43 +00:00
|
|
|
|
|
|
|
export const getBgPattern = (colorSchemeId: number) => {
|
|
|
|
switch (colorSchemeId) {
|
|
|
|
case 1:
|
|
|
|
return "url('/static/images/background.pattern.react.svg')";
|
|
|
|
case 2:
|
|
|
|
return "url('/static/images/background.pattern.orange.react.svg')";
|
|
|
|
case 3:
|
|
|
|
return "url('/static/images/background.pattern.green.react.svg')";
|
|
|
|
case 4:
|
|
|
|
return "url('/static/images/background.pattern.red.react.svg')";
|
|
|
|
case 5:
|
|
|
|
return "url('/static/images/background.pattern.purple.react.svg')";
|
|
|
|
case 6:
|
|
|
|
return "url('/static/images/background.pattern.lightBlue.react.svg')";
|
|
|
|
case 7:
|
|
|
|
return "url('/static/images/background.pattern.black.react.svg')";
|
|
|
|
default:
|
|
|
|
return "url('/static/images/background.pattern.react.svg')";
|
|
|
|
}
|
|
|
|
};
|