mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
refactoring: migrating to react-query to manage service-side state.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user