94 lines
2.1 KiB
TypeScript
94 lines
2.1 KiB
TypeScript
import { createStore } from "zustand/vanilla";
|
|
|
|
export const BBS_TYPE = {
|
|
BBSNOTICE: "BBSNOTICE",
|
|
BBSNORMAL: "BBSNORMAL",
|
|
BBSFAQ: "BBSFAQ",
|
|
BBSIMAGE: "BBSIMAGE",
|
|
BBSMOVIE: "BBSMOVIE",
|
|
} as const;
|
|
|
|
export type BbsType = (typeof BBS_TYPE)[keyof typeof BBS_TYPE];
|
|
|
|
export interface IBbs {
|
|
bbsId: number;
|
|
bbsTypeCd: BbsType;
|
|
bbsTypeNm: string;
|
|
bbsNm: string;
|
|
bbsExpln: string;
|
|
rfrncUseYn: string;
|
|
atflUseYn: string;
|
|
atflMaxCnt: number;
|
|
atflMaxFileSz: number;
|
|
ansUseYn: string;
|
|
ansUseAuthrt: string;
|
|
cmntUseYn: string;
|
|
dgstfnEvlUseYn: string;
|
|
smsUseYn: string;
|
|
upndFixUseYn: string;
|
|
pstgPrdUseYn: string;
|
|
popupUseYn: string;
|
|
delYn: string;
|
|
useYn: string;
|
|
mdfcnDt: string;
|
|
mdfrNm: string;
|
|
}
|
|
|
|
interface IMenu {
|
|
menuCd: number;
|
|
menuKornNm: string;
|
|
menuEngNm: string;
|
|
parentId: number | null;
|
|
sortSeq: number;
|
|
iconNm?: string;
|
|
children: IMenu[] | null;
|
|
levelNo: number;
|
|
urlPath: string;
|
|
menuLnkgTypeCd: string;
|
|
menuLnkgSn: number;
|
|
menuPath: string;
|
|
qrcd: string;
|
|
useYn: string;
|
|
otptYn: string;
|
|
newWndwYn: string;
|
|
requiredUrlPath: boolean;
|
|
}
|
|
|
|
interface IAuthority {
|
|
mngAuthrtYn: string;
|
|
inqAuthrtYn: string;
|
|
regAuthrtYn: string;
|
|
mdfcnAuthrtYn: string;
|
|
delAuthrtYn: string;
|
|
}
|
|
|
|
export type MenuState = {
|
|
bbsInfo: IBbs | null;
|
|
currentMenuInfo: IMenu | null;
|
|
pageMenuAuthority: IAuthority | null;
|
|
};
|
|
|
|
export type MenuActions = {
|
|
setBbsInfo: (bbs: IBbs) => void;
|
|
setCurrentMenuInfo: (menu: IMenu) => void;
|
|
setPageMenuAuthority: (authority: IAuthority) => void;
|
|
};
|
|
|
|
export type MenuStore = MenuState & MenuActions;
|
|
|
|
export const defaultInitState: MenuState = {
|
|
currentMenuInfo: null,
|
|
bbsInfo: null,
|
|
pageMenuAuthority: null,
|
|
};
|
|
|
|
export const createMenuStore = (initState: MenuState = defaultInitState) => {
|
|
return createStore<MenuStore>()((set) => ({
|
|
...initState,
|
|
setBbsInfo: (bbs: IBbs) => set({ bbsInfo: bbs }),
|
|
setCurrentMenuInfo: (menu: IMenu) => set({ currentMenuInfo: menu }),
|
|
setPageMenuAuthority: (authority: IAuthority) =>
|
|
set({ pageMenuAuthority: authority }),
|
|
}));
|
|
};
|