- 관 용도, 관 재질 공통 코드 Store 등록 - I/I 분석 페이지 시도, 시군구 공통 코드 적용 - I/I 분석 페이지 환경청 삭제 - commonStore.ts 삭제 - Store 데이터 호출 로직을 layout.tsx로 이동
64 lines
2.2 KiB
TypeScript
64 lines
2.2 KiB
TypeScript
import { getGeoData, getCmsData } from "@/components/lib/api";
|
|
|
|
|
|
export interface Option { id: number, name: string }
|
|
|
|
export type BIZ_CD_TYPE = {
|
|
lwpoCd: string,
|
|
upCd: string,
|
|
lwpoCdNm: string,
|
|
unit: string,
|
|
prntLwpoCd: null
|
|
};
|
|
|
|
export const fetchCtpvData = async (set: (state: any) => void) => {
|
|
try {
|
|
const ctpvData = await getGeoData('/hasudo/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=hasudo%3Atb_ms_ctpv&outputFormat=application%2Fjson');
|
|
const ctpvList: Option[] = ctpvData.features
|
|
.map((feature: any) => ({
|
|
id: feature.properties.mctpv_cd.trim(),
|
|
name: feature.properties.mctpv_korn_nm
|
|
}))
|
|
.sort((a: Option, b: Option) => a.name.localeCompare(b.name, 'ko'));
|
|
set({ ctpv: ctpvList });
|
|
} catch (e: any) {
|
|
alert("시도 데이터 로드 실패: " + e.message);
|
|
console.error("CTPV 데이터 로드 실패:", e);
|
|
}
|
|
};
|
|
|
|
export const fetchSggData = async (set: (state: any) => void) => {
|
|
try {
|
|
const sggData = await getGeoData('/hasudo/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=hasudo%3Atb_ms_sgg&outputFormat=application%2Fjson');
|
|
const sggList: Option[] = sggData.features
|
|
.map((feature: any) => ({
|
|
id: feature.properties.sgg_cd,
|
|
name: feature.properties.sgg_korn_nm
|
|
}))
|
|
.sort((a: Option, b: Option) => a.name.localeCompare(b.name, 'ko'));
|
|
set({ sgg: sggList });
|
|
} catch (e: any) {
|
|
alert("시군구 데이터 로드 실패: " + e.message);
|
|
console.error("SGG 데이터 로드 실패:", e);
|
|
}
|
|
};
|
|
|
|
export const fetchBIZ_SE_CD = async (set: (state: any) => void) => {
|
|
try {
|
|
const res = await getCmsData(`/api/v1/code/cache/BIZSECD`);
|
|
set({ BIZ_SE_CD: res });
|
|
} catch (e: any) {
|
|
alert("BIZ_SE_CD 데이터 로드 실패: " + e.message);
|
|
console.error("BIZ_SE_CD 데이터 로드 실패:", e);
|
|
}
|
|
};
|
|
|
|
export const fetchBIZ_TY_CD = async (set: (state: any) => void) => {
|
|
try {
|
|
const res = await getCmsData(`/api/v1/code/cache/BIZTYCD`);
|
|
set({ BIZ_TY_CD: res });
|
|
} catch (e: any) {
|
|
alert("BIZ_TY_CD 데이터 로드 실패: " + e.message);
|
|
console.error("BIZ_TY_CD 데이터 로드 실패:", e);
|
|
}
|
|
}; |