65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
import { fetchType, getFetchWithCount } from "@/components/lib/api";
|
|
import type { CommonTableProps } from "../../common/type/header";
|
|
import type { customRswtBdst } from "../../ruseFcltMng/fcltReg/rswtReg";
|
|
import { rswtSttHeadListExport, rswtSttNodeListExport } from "../../ruseFcltMng/fcltSttn/rswtSttn/headList";
|
|
|
|
|
|
export const rswtMapSize = 15
|
|
export type rswtMapState = {
|
|
rswtMap: {
|
|
rswtMapRes: customRswtBdst[];
|
|
rswtMapCount: number;
|
|
isInit: boolean;
|
|
rswtSttHeadList: CommonTableProps[];
|
|
rswtSttNodeList: CommonTableProps[];
|
|
};
|
|
};
|
|
|
|
type rswtMapActions = {
|
|
rswtMapInit: (page: number, total: number, cityOrSgg:string) => void;
|
|
};
|
|
|
|
export type rswtMapType = rswtMapState & rswtMapActions;
|
|
|
|
export const rswtMapStateExport: rswtMapState = {
|
|
rswtMap: {
|
|
isInit: false,
|
|
rswtMapRes: [],
|
|
rswtMapCount: 1,
|
|
rswtSttHeadList: rswtSttHeadListExport,
|
|
rswtSttNodeList: rswtSttNodeListExport,
|
|
},
|
|
};
|
|
|
|
export const rswtMapActionsExport: (set: any) => rswtMapActions = (
|
|
set: any
|
|
) => {
|
|
return {
|
|
rswtMapInit: async (page: number, total: number, cityOrSgg:string) => {
|
|
try {
|
|
const rswtMapRes = await getFetchWithCount(
|
|
fetchType.WR,
|
|
`/reuseFc/waterreuseFc` +
|
|
(page ? `/${page}` : "/1") +
|
|
(total ? `/${total}` : "/20") +
|
|
(cityOrSgg ? `/${cityOrSgg}` : "/0")
|
|
);
|
|
|
|
set((state: rswtMapState) => {
|
|
return {
|
|
...state,
|
|
rswtMap: {
|
|
...state.rswtMap,
|
|
rswtMapRes: rswtMapRes.data,
|
|
rswtMapCount: rswtMapRes.count,
|
|
isInit: false,
|
|
},
|
|
};
|
|
});
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
},
|
|
};
|
|
};
|