45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { fetchType, getFetch, postFectch } from "@/components/lib/api";
|
|
import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
|
|
import type { DemandCompType } from "./type";
|
|
export type comFcltState = {
|
|
searchFclts: pubHasuType;
|
|
demandCompList: DemandCompType[];
|
|
};
|
|
export type comFcltActions = {
|
|
getSwtrmtFcltNm: (searchNm: string) => void;
|
|
getDemandCompList :(searchNm: string) => void
|
|
};
|
|
|
|
export const searchActions: (set: any) => comFcltActions = (set: any) => {
|
|
return {
|
|
getSwtrmtFcltNm: async (searchNm: string) => {
|
|
const fcltNm = await getFetch(
|
|
"common",
|
|
`/prcsFclt/info/1/20/${searchNm}`
|
|
);
|
|
const fcltNmCd: pubHasuType[] = fcltNm.map((item: any) => ({
|
|
bscFctCd: item.bscFctCd,
|
|
sido: item.sido,
|
|
gugun: item.gugun,
|
|
bscFctNm: item.bscFctNm,
|
|
addr: item.addr,
|
|
fctCpc: item.fctCpc,
|
|
}));
|
|
return set((state: comFcltState) => ({
|
|
...state,
|
|
searchFclts: fcltNmCd,
|
|
}));
|
|
},
|
|
getDemandCompList: async (searchNm: string) => {
|
|
const coList = await getFetch(
|
|
fetchType.WR,
|
|
`reuseFc/request/${searchNm}/{3}`
|
|
);
|
|
return set((state: comFcltState) => ({
|
|
...state,
|
|
demandCompList: coList,
|
|
}));
|
|
},
|
|
};
|
|
};
|