Files
frontend/apps/dm_new/app/store/store.tsx
T
2026-02-19 14:54:30 +09:00

49 lines
1.1 KiB
TypeScript

import { createStore } from "zustand/vanilla";
import {
CommonReducer,
CommonState,
type CommonStore,
type CommonType,
} from "./common";
import { SdmReducer, SdmState, type SdmStore, type SdmType } from "./sdmMng";
import {
dmMapState,
type DmMapType,
type DmMapStore,
DmMapReducer,
} from "./map";
import { tokenManager } from "@/src/entities/auth/lib/token-manager";
import {
DmStatusReducer,
dmStatusState,
type DmStatusStore,
type DmStatusType,
} from "./wrStatus";
export type DmStore = CommonStore & SdmStore & DmMapStore & DmStatusStore;
export type DmState = CommonType & SdmType & DmMapType & DmStatusType;
export const StoreZus = (
initState: DmState = {
...CommonState,
...SdmState,
...dmMapState,
...dmStatusState,
}
) => {
return createStore<DmStore>()((set) => {
if (typeof window !== "undefined") {
tokenManager.setToken("site-id-key", process.env.NEXT_PUBLIC_SITE_ID||"DM");
tokenManager.setToken("site-theme-key", "green");
}
return {
...initState,
...CommonReducer(set),
...SdmReducer(set),
...DmMapReducer(set),
...DmStatusReducer(set),
};
});
};