refactoring: migrating to react-query to manage service-side state.

This commit is contained in:
a.bouhuolia
2021-02-07 08:10:21 +02:00
parent e093be0663
commit adac2386bb
284 changed files with 8255 additions and 6610 deletions

View File

@@ -404,7 +404,7 @@ export const toSafeNumber = (number) => {
};
export const transformToCamelCase = (object) => {
return deepMapKeys(object, (key) => _.snakeCase(key));
return deepMapKeys(object, (key) => _.camelCase(key));
};
export const transfromToSnakeCase = (object) => {
@@ -432,3 +432,38 @@ export function flatObject(obj) {
return flatObject;
}
export function randomNumber(min, max) {
if (min > max) {
let temp = max;
max = min;
min = temp;
}
if (min <= 0) {
return Math.floor(Math.random() * (max + Math.abs(min) + 1)) + min;
} else {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
}
export function transformResponse(response) {
return transformToCamelCase(response);
}
export function transactionNumber(prefix, number) {
const codes = [];
if (prefix) {
codes.push(prefix);
}
if (number) {
codes.push(number);
}
return codes.join('-');
}
export function safeCallback(callback, ...args) {
return () => callback && callback(...args);
}