import { getFetch } from "@/components/lib/api"; import type { EnvPartSelectDataType, SelectDataType } from "@common/business_components/ui"; export const btnClass = "p-4 m-2 text-white rounded-sm text-lg font-medium " const yn: SelectDataType[] = [ { val: 'Y', text: 'Y' }, { val: 'N', text: 'N' }, ] //공통 건축물 용도 const bdstUsgCd: SelectDataType[] = [ { val: '-1', text: "확인불가" }, { val: '1', text: "운동장" }, { val: '2', text: "체육관" }, { val: '3', text: "공공업무시설" }, { val: '4', text: "공공기관의청사" }, { val: '5', text: "아파트" }, { val: '6', text: "연립주택" }, { val: '7', text: "다세대주택" }, { val: '8', text: "기숙사" }, { val: '9', text: "초등학교" }, { val: '10', text: "중학교" }, { val: '11', text: "고등학교" }, { val: '12', text: "전문대학" }, { val: '13', text: "대학및대학교" }, { val: '14', text: "골프장" }, { val: '15', text: "대규모점포" }, { val: '16', text: "기타" }, ]; //빗물 집수면 종류 용도 const rainFcltCd = [ { val: "1", text: "지붕" }, { val: "2", text: "건물옥상" }, { val: "3", text: "골프장 연못" }, { val: "4", text: "운동장 바닥" }, { val: "5", text: "운동장 지붕" }, { val: "6", text: "주차장" }, { val: "7", text: "태양광패널" }, { val: "8", text: "연못" }, { val: "9", text: "기타" }, { val: "10", text: "확인불가" }, ]; // 중수도 필수 원수종류 const rswtBdstType: SelectDataType[] = [ { text: "숙박업", val: "17" }, { text: "목욕장업", val: "18" }, { text: "공장", val: "19" }, { text: "발전시설", val: "20" }, { text: "관광단지개발사업", val: "21" }, { text: "도시개발사업", val: "22" }, { text: "산업단지개발사업", val: "23" }, { text: "택지개발사업", val: "24" }, { text: "대규모점포(대형마트)", val: "25" }, { text: "대규모점포(전문점)", val: "26" }, { text: "대규모점포(백화점)", val: "27" }, { text: "대규모점포(쇼핑센터)", val: "28" }, { text: "대규모점포(복합쇼핑몰)", val: "29" }, { text: "물류시설", val: "30" }, { text: "운수시설(여객자동차터미널)", val: "31" }, { text: "운수시설(철도시설)", val: "32" }, { text: "운수시설(공항시설)", val: "33" }, { text: "운수시설(항만시설)", val: "34" }, { text: "업무시설(공공업무시설)", val: "35" }, { text: "업무시설(금융업소)", val: "36" }, { text: "업무시설(사무소)", val: "37" }, { text: "업무시설(결혼상담소 등 소개업소)", val: "38" }, { text: "업무시설(출판사)", val: "39" }, { text: "업무시설(신문사)", val: "40" }, { text: "업무시설(오피스텔)", val: "41" }, { text: "교정시설", val: "42" }, { text: "방송국", val: "43" }, { text: "전신전화국", val: "44" }, { text: "기타", val: "45" } ]; const orgwtKndCd = [ { text: "오수(변기 오수 제외)", val: "1" }, { text: "오수", val: "2" }, { text: "폐수", val: "3" }, { text: "오수 및 폐수", val: "4" }, { text: "기타", val: "5" }, ]; const chBuCd = [ { val: "증축", text: "증축" }, { val: "개축", text: "개축" }, { val: "재축", text: "재축" }, ] const pplQulity = [ { val: "도복장강관", text: "도복장강관" }, { val: "PE관", text: "PE관" }, { val: "스테인레스관", text: "스테인레스관" }, { val: "덕타일주철관", text: "덕타일주철관" }, { val: "유리섬유복합관", text: "유리섬유복합관" }, { val: "기타", text: "기타" }, ] const pplLenght = [ { val: "D100", text: "D100" }, { val: "D200", text: "D200" }, { val: "D250", text: "D250" }, { val: "D300", text: "D300" }, { val: "D350", text: "D350" }, { val: "D400", text: "D400" }, { val: "D450", text: "D450" }, { val: "D500", text: "D500" }, { val: "D700", text: "D700" }, { val: "D900", text: "D900" }, { val: "D1000​", text: "D1000​" }, ] export const buildingType = { RST:"RST", RNB:"RNB", HTB:"HTB" } export type comCodeState = { code: { isInit: boolean; chBuCd: SelectDataType[] rainFcltCd: SelectDataType[]; bdstUsgCd: SelectDataType[]; cityCd: SelectDataType[]; sggCd: SelectDataType[]; rvbsnCd: SelectDataType[]; mdmbsnCd: SelectDataType[]; lgbsnCd: SelectDataType[]; lclgvrnmntCd: EnvPartSelectDataType[]; orgwtKndCd: SelectDataType[]; yn: SelectDataType[]; pplQulity: SelectDataType[]; pplLenght: SelectDataType[]; buildingType: { RST:string, RNB:string, HTB:string } }; }; export type comCodeType = comCodeState & comCodeActions; export const getSggCd = async (set: any) => { const sgg = await getFetch("common", "/addr/sgg"); const sggCd = sgg.map((item: any) => ({ val: item.adstDstrCd, text: item.gugun, })); set((state: comCodeState) => ({ code: { ...state.code, sggCd: sggCd, }, })); }; export const getCityCd = async (set: any) => { const city = await getFetch("common", "/addr/city"); const cityCd = city.map((item: any) => ({ val: item.adstDstrCd, text: item.sido, })); cityCd.unshift({ val: '0', text: '전체' }) set((state: comCodeState) => ({ code: { ...state.code, cityCd: cityCd, }, })); }; // 권역 API 호출 함수 추가 export const getRegionCd = async (set: any) => { try { const rvbsn = await getFetch("common", "/addr/sarea"); const rvbsnCd = rvbsn.map((item: any) => ({ val: item.rvbsnCd, text: item.rvbsn, })); rvbsnCd.unshift({ val: '0', text: '전체' }) set((state: comCodeState) => ({ code: { ...state.code, rvbsnCd: rvbsnCd, }, })); } catch (error) { console.error('권역 데이터를 가져오는데 실패했습니다:', error); } }; // 중권역 API 호출 함수 추가 export const getMiddleRegionCd = async (set: any) => { try { const mdmbsn = await getFetch("common", "/addr/midArea"); const mdmbsnCd = mdmbsn.map((item: any) => ({ val: item.rvbsnCd, text: item.mdmbsn, })); mdmbsnCd.unshift({ val: '0', text: '전체' }) set((state: comCodeState) => ({ code: { ...state.code, mdmbsnCd: mdmbsnCd, }, })); } catch (error) { console.error('중권역 데이터를 가져오는데 실패했습니다:', error); } }; // 단위유역 API 호출 함수 추가 export const getUnitWaterShedCd = async (set: any) => { try { const lgbsn = await getFetch("common", "/addr/largeArea"); const lgbsnCd = lgbsn.map((item: any) => ({ val: item.rvbsnCd, text: item.lgbsn, })); lgbsnCd.unshift({ val: '0', text: '전체' }) set((state: comCodeState) => ({ code: { ...state.code, lgbsnCd: lgbsnCd, }, })); } catch (error) { console.error('대영역 데이터를 가져오는데 실패했습니다:', error); } }; // 환경청 데이터 export const getEnvPartCd = async (set: any) => { try { const lclgvrnmnt = await getFetch('common', '/addr/govArea'); const lclgvrnmntCd = lclgvrnmnt.map((item: any) => ({ val: item.lclgvrnmntCd, text: item.lclgvrnmntNm, adstDliStrCd: item.adstDliStrCd || '' })); lclgvrnmntCd.unshift({ val: '0', text: '전체', adstDliStrCd: '' }) set((state: comCodeState) => ({ code: { ...state.code, lclgvrnmntCd: lclgvrnmntCd, }, })); } catch (error) { console.error('환경청 데이터를 가져오는데 실패했습니다:', error); } }; export const comCodeStateExport: comCodeState = { code: { isInit: false, rainFcltCd: rainFcltCd, bdstUsgCd: bdstUsgCd, chBuCd: chBuCd, orgwtKndCd: orgwtKndCd, cityCd: [], sggCd: [], rvbsnCd: [], mdmbsnCd: [], lgbsnCd: [], lclgvrnmntCd: [], pplQulity:pplQulity, pplLenght:pplLenght, yn: yn, buildingType:buildingType, }, }; export type comCodeActions = { codeInit: () => void; }; export const codeActionExport: (set: any) => comCodeActions = (set: any) => { return { codeInit: async () => { const sgg = await getFetch("common", "/addr/sgg"); const sggCd = sgg.map((item: any) => ({ val: item.adstDstrCd, text: item.gugun, })); const city = await getFetch("common", "/addr/city"); const cityCd = city.map((item: any) => ({ val: item.adstDstrCd, text: item.sido, })); return set((state: comCodeState) => ({ code: { ...state.code, sggCd: sggCd, cityCd: cityCd, }, })); }, divCityCd: async (cd: string) => { set((state: comCodeState) => ({ code: { ...state.code, sggCd: state.code.sggCd.filter((item) => { return item.val.toString().slice(0, 2) === cd }), }, })); }, }; };