feat: 중수도시설, 온배수시설 삭제 버튼 구현
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getFetchWithCount, postFectch, putFectch } from "@/components/lib/api";
|
||||
import { getFetchWithCount, postFectch, putFectch, deleteFectch } from "@/components/lib/api";
|
||||
|
||||
import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import toast from "react-hot-toast";
|
||||
@@ -102,6 +102,7 @@ type htdflFacSActions = {
|
||||
htdflNmSearch: (code: string | number, fcltNm:string) => void;
|
||||
htdflBdstUpdate: (data: customHtdflBdst, code: string | number,myUUID:string) => void;
|
||||
htdflBdstReg: (data: customHtdflBdst, code: string | number,myUUID:string) => void;
|
||||
htdflBdstDelete: (data: customHtdflBdst, code: string | number) => void;
|
||||
getHtdflBdstData: (pageNation: number, code: string | number) => void;
|
||||
resetHtdflTableIndex:(index:number)=>void;
|
||||
};
|
||||
@@ -220,7 +221,30 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
|
||||
console.log(errorReg);
|
||||
|
||||
}
|
||||
},htdflNmSearch :async(code:string | number, fcltNm:string) =>{
|
||||
},
|
||||
// 온배수시설을 삭제한다.
|
||||
htdflBdstDelete: async (data: customHtdflBdst, code: string | number) => {
|
||||
try {
|
||||
await deleteFectch(`/reuseFc/htdflInfo/${data.reuseBuilding?.[0]?.bdstRuseFcltSn}`);
|
||||
toast.success(`${data.bdstNm} 시설이 삭제되었습니다.`);
|
||||
|
||||
const htdflRes = await initFetch(String(code));
|
||||
set((state: htdflFacState) => ({
|
||||
...state,
|
||||
htdfl: {
|
||||
...state.htdfl,
|
||||
htdflRes: htdflRes.data,
|
||||
htdflResCount: htdflRes.count,
|
||||
},
|
||||
}));
|
||||
} catch (e) {
|
||||
console.log("e", e);
|
||||
const errorMessage = e instanceof Error ? e.message : "삭제 중 오류가 발생했습니다.";
|
||||
toast.error(errorMessage);
|
||||
} finally {
|
||||
}
|
||||
},
|
||||
htdflNmSearch :async(code:string | number, fcltNm:string) =>{
|
||||
try {
|
||||
const htdflRes = await getFetchWithCount("wr", `/drain/facilityList/1/11/${code}/${fcltNm}`);
|
||||
set((state: htdflFacState) => {
|
||||
|
||||
@@ -75,6 +75,7 @@ type rswtFacSActions = {
|
||||
code: string | number
|
||||
) => void;
|
||||
rswtBdstReg: (data: customRswtBdst, code: string | number,myUUID:string) => void;
|
||||
rswtBdstDelete: (data: customRswtBdst, code: string | number) => void;
|
||||
resetRswtTableIndex:(index:number)=>void;
|
||||
};
|
||||
|
||||
@@ -247,6 +248,28 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
|
||||
} finally {
|
||||
}
|
||||
},
|
||||
// 중수도시설을 삭제한다.
|
||||
rswtBdstDelete: async (data: customRswtBdst, code: string | number) => {
|
||||
try {
|
||||
await deleteFectch(`/reuseFc/rswtInfo/${data.reuseBuilding?.[0]?.bdstRuseFcltSn}`);
|
||||
toast.success(`${data.bdstNm} 시설이 삭제되었습니다.`);
|
||||
|
||||
const rswtRes = await initFetch(code);
|
||||
set((state: rswtFacState) => ({
|
||||
...state,
|
||||
rswt: {
|
||||
...state.rswt,
|
||||
rswtRes: rswtRes.data,
|
||||
rswtResCount: rswtRes.count,
|
||||
},
|
||||
}));
|
||||
} catch (e) {
|
||||
console.log("e", e);
|
||||
const errorMessage = e instanceof Error ? e.message : "삭제 중 오류가 발생했습니다.";
|
||||
toast.error(errorMessage);
|
||||
} finally {
|
||||
}
|
||||
},
|
||||
resetRswtTableIndex: (index: number) => {
|
||||
// 1) 동일값도 '변경'으로 느끼게 잠깐 -1
|
||||
set((state: rswtFacState) => ({
|
||||
|
||||
@@ -42,7 +42,7 @@ export default function HtdflRegForm({
|
||||
setIsModal?: (modal: boolean) => void;
|
||||
isMap?: boolean;
|
||||
}) {
|
||||
const { auth, code, htdflBdstUpdate, htdflBdstReg, resetHtdflTableIndex,getMyUUID } =
|
||||
const { auth, code, htdflBdstUpdate, htdflBdstReg, htdflBdstDelete, resetHtdflTableIndex, getMyUUID } =
|
||||
useWrStore((state) => state);
|
||||
const [frontPHdata, setFrontPHdata] = useState("");
|
||||
const [backPHdata, setBackPHdata] = useState("");
|
||||
@@ -89,6 +89,11 @@ export default function HtdflRegForm({
|
||||
}
|
||||
};
|
||||
|
||||
const onDelete = async () => {
|
||||
const code = htdflForm.ctpvCd ? htdflForm.ctpvCd : htdflForm.sggCd ? htdflForm.sggCd : "noCd";
|
||||
confirmToast(`정말 ${htdflForm.bdstNm} 시설을 삭제하시겠습니까?`, () => htdflBdstDelete(htdflForm, code));
|
||||
}
|
||||
|
||||
const cleanHtdflData = (raw: any): z.infer<typeof hdtflZod> => {
|
||||
const buildings =
|
||||
raw?.reuseBuilding && raw.reuseBuilding.length > 0
|
||||
@@ -263,13 +268,23 @@ export default function HtdflRegForm({
|
||||
온배수 시설 등록
|
||||
</h1>
|
||||
{!readonly && (
|
||||
<Button
|
||||
type="submit"
|
||||
className="col-start-12 col-span-1"
|
||||
size={"sm"}
|
||||
>
|
||||
저장
|
||||
</Button>
|
||||
<div className="flex justify-end gap-2 mt-4">
|
||||
<Button
|
||||
type="submit"
|
||||
className="col-start-12 col-span-1"
|
||||
size={"sm"}
|
||||
>
|
||||
저장
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
className="!bg-red-500 text-white"
|
||||
size={"sm"}
|
||||
onClick={onDelete}
|
||||
>
|
||||
삭제
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -43,7 +43,7 @@ export default function RswtrRegForm({
|
||||
readonly?: boolean;
|
||||
isMap?: boolean;
|
||||
}) {
|
||||
const { auth,code, rswtBdstUpdate, rswtBdstReg ,resetRswtTableIndex,getMyUUID} = useWrStore((state) => state);
|
||||
const { auth,code, rswtBdstUpdate, rswtBdstReg, rswtBdstDelete, resetRswtTableIndex,getMyUUID} = useWrStore((state) => state);
|
||||
// const [divStyle, setDivStyle] = useState("h-[53vh]");
|
||||
const {laeSeCd } = auth;
|
||||
useEffect(() => {
|
||||
@@ -95,6 +95,11 @@ export default function RswtrRegForm({
|
||||
}
|
||||
};
|
||||
|
||||
const onDelete = async () => {
|
||||
const code = rswtForm.ctpvCd ? rswtForm.ctpvCd : rswtForm.sggCd ? rswtForm.sggCd : "noCd";
|
||||
confirmToast(`정말 ${rswtForm.bdstNm} 시설을 삭제하시겠습니까?`, () => rswtBdstDelete(rswtForm, code));
|
||||
}
|
||||
|
||||
const cleanRswtData = (raw: any): z.infer<typeof rswtZod> => {
|
||||
const buildings =
|
||||
raw?.reuseBuilding && raw.reuseBuilding.length > 0
|
||||
@@ -171,13 +176,23 @@ export default function RswtrRegForm({
|
||||
건축물 정보
|
||||
</h1>
|
||||
{!readonly && (
|
||||
<Button
|
||||
type="submit"
|
||||
className="col-start-12 col-span-1"
|
||||
size={"sm"}
|
||||
>
|
||||
저장
|
||||
</Button>
|
||||
<div className="flex justify-end gap-2 mt-4">
|
||||
<Button
|
||||
type="submit"
|
||||
className="col-start-12 col-span-1"
|
||||
size={"sm"}
|
||||
>
|
||||
저장
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
className="!bg-red-500 text-white"
|
||||
size={"sm"}
|
||||
onClick={onDelete}
|
||||
>
|
||||
삭제
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user