@flare/js-utils update

master
Tudor Stanciu 2023-01-30 00:57:47 +02:00
parent 08dd469be3
commit 32a05db318
5 changed files with 10 additions and 44 deletions

6
package-lock.json generated
View File

@ -1325,9 +1325,9 @@
} }
}, },
"@flare/js-utils": { "@flare/js-utils": {
"version": "1.0.1", "version": "1.0.2",
"resolved": "https://lab.code-rove.com/public-node-registry/@flare%2fjs-utils/-/js-utils-1.0.1.tgz", "resolved": "https://lab.code-rove.com/public-node-registry/@flare%2fjs-utils/-/js-utils-1.0.2.tgz",
"integrity": "sha512-54zfXBeof4ns9wEGvUeORd6SiAvCcUNEIiamnLtbASVMY6TxrpGp7UL+Dm7iGdC5jmDb5stla6I8aHroQuvvqg==" "integrity": "sha512-49KjpcRUD6fXPC60bmCsPa8frU6wlQyI5RsjMD70zsuvk8BZFdopsETsjsCembbmzTScIhfMACU4RnimOEwg9Q=="
}, },
"@gar/promisify": { "@gar/promisify": {
"version": "1.1.3", "version": "1.1.3",

View File

@ -19,7 +19,7 @@
"node-fetch": "^2.6.1" "node-fetch": "^2.6.1"
}, },
"dependencies": { "dependencies": {
"@flare/js-utils": "^1.0.0", "@flare/js-utils": "^1.0.2",
"@material-ui/core": "^4.11.3", "@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2", "@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60", "@material-ui/lab": "^4.0.0-alpha.60",

View File

@ -1,7 +1,9 @@
import axios from "axios"; import axios from "axios";
import i18next from "i18next"; import i18next from "i18next";
import { getItem } from "./localStorage";
import { storageKeys } from "./identity"; import { storageKeys } from "./identity";
import { localStorage } from "@flare/js-utils";
const { getItem } = localStorage;
function getHeaders() { function getHeaders() {
const token = getItem(storageKeys.TOKEN); const token = getItem(storageKeys.TOKEN);

View File

@ -1,5 +1,7 @@
import { request } from "./axios"; import { request } from "./axios";
import { setItem, getItem, removeItem } from "./localStorage"; import { localStorage } from "@flare/js-utils";
const { setItem, getItem, removeItem } = localStorage;
const storageKeys = { const storageKeys = {
TOKEN: "AUTHORIZATION_TOKEN", TOKEN: "AUTHORIZATION_TOKEN",

View File

@ -1,38 +0,0 @@
import { typeValidator } from "@flare/js-utils";
const setItem = (key, value) => {
const { isArray, isObject } = typeValidator;
let valueToStore = value;
if (isArray(value) || isObject(value)) {
valueToStore = JSON.stringify(value);
}
window.localStorage.setItem(key, valueToStore);
};
const getItem = (key) => {
var value = window.localStorage.getItem(key);
const { isJson } = typeValidator;
var { data, success } = isJson(value);
if (success) {
return data;
} else {
return value;
}
};
const removeItem = (key) => {
window.localStorage.removeItem(key);
};
const clear = () => {
window.localStorage.clear();
};
const key = (index) => {
var keyName = window.localStorage.key(index);
return keyName;
};
export { setItem, getItem, removeItem, clear, key };