diff --git a/src/stores/tariffs.ts b/src/stores/tariffs.ts index 81e6420..1aad0c6 100644 --- a/src/stores/tariffs.ts +++ b/src/stores/tariffs.ts @@ -1,34 +1,22 @@ import { Tariff } from "@root/model/tariff"; import { create } from "zustand"; -import { devtools, persist } from "zustand/middleware"; +import { devtools } from "zustand/middleware"; import { exampleTariffs } from "./mocks/tariffs"; interface TariffStore { tariffs: Tariff[]; - addTariffs: (newTariffs: Tariff[]) => void; - deleteTariffs: (tariffsToDelete: Tariff[]) => void; - deleteAllTariffs: () => void; } export const useTariffStore = create()( devtools( - // persist( - (set, get) => ({ - tariffs: exampleTariffs, - addTariffs: (newTariffs: Tariff[]) => set(state => ({ tariffs: [...state.tariffs, ...newTariffs] })), - deleteTariffs: tariffsToDelete => set(state => ( - { tariffs: state.tariffs.filter(tariff => !tariffsToDelete.includes(tariff)) } - )), - deleteAllTariffs: () => set({ tariffs: [] }), - }), - // { - // name: "tariffs", - // getStorage: () => localStorage, - // } - // ), + (set, get) => ({ + tariffs: exampleTariffs, + }), { name: "Tariff store" } ) -); \ No newline at end of file +); + +export const addTariffs = (newTariffs: Tariff[]) => useTariffStore.setState(state => ({ tariffs: [...state.tariffs, ...newTariffs] })); \ No newline at end of file