46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
/**
|
|
* 📄 useStore
|
|
* SN 앱 Zustand 스토어
|
|
*
|
|
* - 시도 데이터 상태 관리 및 조회 기능
|
|
* - 시군구 데이터 상태 관리 및 조회 기능
|
|
* - 사업 구분 코드 상태 관리 및 조회 기능
|
|
* - 사업 유형 코드 상태 관리 및 조회 기능
|
|
* - Zustand를 통한 중앙 집중식 상태 관리
|
|
* - 데이터 변경 감지 및 불필요한 재렌더링 방지
|
|
*/
|
|
import { create } from "zustand";
|
|
import { fetchCtpv, fetchSgg, fetchBIZ_SE_CD, fetchBIZ_TY_CD } from "./index";
|
|
import { type SelectDataType } from "@common/business_components";
|
|
|
|
export type BIZ_CD_TYPE = {
|
|
lwpoCd: string,
|
|
upCd: string,
|
|
lwpoCdNm: string,
|
|
unit: string,
|
|
prntLwpoCd: null
|
|
};
|
|
|
|
interface SnStoreState {
|
|
ctpv: SelectDataType[];
|
|
sgg: SelectDataType[];
|
|
BIZ_SE_CD: BIZ_CD_TYPE[];
|
|
BIZ_TY_CD: BIZ_CD_TYPE[];
|
|
fetchCtpv: () => Promise<void>;
|
|
fetchSgg: () => Promise<void>;
|
|
fetchBIZ_SE_CD: () => Promise<void>;
|
|
fetchBIZ_TY_CD: () => Promise<void>;
|
|
}
|
|
|
|
const useStore = create<SnStoreState>((set) => ({
|
|
ctpv: [],
|
|
sgg: [],
|
|
BIZ_SE_CD: [],
|
|
BIZ_TY_CD: [],
|
|
fetchCtpv: () => fetchCtpv(set),
|
|
fetchSgg: () => fetchSgg(set),
|
|
fetchBIZ_SE_CD: () => fetchBIZ_SE_CD(set),
|
|
fetchBIZ_TY_CD: () => fetchBIZ_TY_CD(set),
|
|
}));
|
|
|
|
export default useStore; |