64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import { fetchType, getFetchWithCount } from "@/components/lib/api";
|
|
import type { CommonTableProps } from "../../common/type/header";
|
|
import type { customHtdflBdst } from "../../ruseFcltMng/fcltReg/htdflReg";
|
|
import { htdflSttHeadListExport, htdflSttNodeListExport } from "../../ruseFcltMng/fcltSttn/htdflSttn/headList";
|
|
|
|
export const htdfMapSize = 15;
|
|
export type htdfMapState = {
|
|
htdfMap: {
|
|
htdfMapRes: customHtdflBdst[];
|
|
htdfMapCount: number;
|
|
isInit: boolean;
|
|
htdfSttHeadList: CommonTableProps[];
|
|
htdfSttNodeList: CommonTableProps[];
|
|
};
|
|
};
|
|
|
|
type htdfMapActions = {
|
|
htdfMapInit: (page: number, total: number, cityOrSgg: string) => void;
|
|
};
|
|
|
|
export type htdfMapType = htdfMapState & htdfMapActions;
|
|
|
|
export const htdfMapStateExport: htdfMapState = {
|
|
htdfMap: {
|
|
isInit: false,
|
|
htdfMapRes: [],
|
|
htdfMapCount: 1,
|
|
htdfSttHeadList: htdflSttHeadListExport,
|
|
htdfSttNodeList: htdflSttNodeListExport,
|
|
},
|
|
};
|
|
|
|
export const htdfMapActionsExport: (set: any) => htdfMapActions = (
|
|
set: any
|
|
) => {
|
|
return {
|
|
htdfMapInit: async (page: number, total: number, cityOrSgg: string) => {
|
|
try {
|
|
const htdfMapRes = await getFetchWithCount(
|
|
fetchType.WR,
|
|
`/drain/facilityList` +
|
|
(page ? `/${page}` : "/1") +
|
|
(total ? `/${total}` : "/20") +
|
|
(cityOrSgg ? `/${cityOrSgg}` : "/0")
|
|
);
|
|
|
|
set((state: htdfMapState) => {
|
|
return {
|
|
...state,
|
|
htdfMap: {
|
|
...state.htdfMap,
|
|
htdfMapRes: htdfMapRes.data,
|
|
htdfMapCount: htdfMapRes.count,
|
|
isInit: false,
|
|
},
|
|
};
|
|
});
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
},
|
|
};
|
|
};
|