remove redundant localstorage use
This commit is contained in:
parent
c3ecaa5177
commit
c0f924ab09
@ -26,9 +26,6 @@ const ModalMini = ({ open, type, variant, close }: MWProps) => {
|
|||||||
const checkTariff = () => {
|
const checkTariff = () => {
|
||||||
if (fieldName.current != null && fieldTime.current != null && fieldPrice.current != null) {
|
if (fieldName.current != null && fieldTime.current != null && fieldPrice.current != null) {
|
||||||
if (fieldName.current.value && fieldTime.current.value && fieldPrice.current.value) {
|
if (fieldName.current.value && fieldTime.current.value && fieldPrice.current.value) {
|
||||||
const getData = localStorage.getItem("tariffs");
|
|
||||||
|
|
||||||
if (getData != null) { tariffsArray = JSON.parse(getData); }
|
|
||||||
|
|
||||||
const data = [0, 0, 0];
|
const data = [0, 0, 0];
|
||||||
|
|
||||||
@ -49,10 +46,7 @@ const ModalMini = ({ open, type, variant, close }: MWProps) => {
|
|||||||
|
|
||||||
tariffsArraySet(tariffsArrayNew);
|
tariffsArraySet(tariffsArrayNew);
|
||||||
|
|
||||||
localStorage.setItem("tariffs", JSON.stringify(tariffsArrayNew));
|
|
||||||
close();
|
close();
|
||||||
|
|
||||||
console.log(tariffsArrayNew);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -36,15 +36,11 @@ const Tariffs: React.FC = () => {
|
|||||||
handleOpenModalMini();
|
handleOpenModalMini();
|
||||||
};
|
};
|
||||||
|
|
||||||
const getData = localStorage.getItem("tariffs");
|
|
||||||
const tariffsArray = useTariffStore(state => state.tariffs);
|
const tariffsArray = useTariffStore(state => state.tariffs);
|
||||||
const tariffsArraySet = useTariffStore(state => state.setTariffs);
|
const tariffsArraySet = useTariffStore(state => state.setTariffs);
|
||||||
const tariffsSelectedRowsData = useTariffStore(state => state.tariffsSelectedRowsData);
|
const tariffsSelectedRowsData = useTariffStore(state => state.tariffsSelectedRowsData);
|
||||||
|
|
||||||
if (getData && !tariffsArray.length) {
|
|
||||||
const rows: Array<ArrayProps> = JSON.parse(getData);
|
|
||||||
if (rows.length) { tariffsArraySet(rows); };
|
|
||||||
}
|
|
||||||
|
|
||||||
const [openModalPackage, setOpenModalPackage] = React.useState(false);
|
const [openModalPackage, setOpenModalPackage] = React.useState(false);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user