From fee77f8563fbd3bbbda74484897c8ee4d6ae6a4b Mon Sep 17 00:00:00 2001 From: basssy Date: Wed, 13 Nov 2024 15:18:03 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=AC=EC=A0=81=EC=84=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/estimate/Estimate.jsx | 44 ++++++++++++++++++---------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx index 697a0fd0..c4faccba 100644 --- a/src/components/estimate/Estimate.jsx +++ b/src/components/estimate/Estimate.jsx @@ -56,8 +56,6 @@ export default function Estimate({ params }) { //견적서 상세데이터 const { state, setState, addItem } = useEstimateController(params.pid) - const [itemList, setItemList] = useState([]) //기존 아이템 리스트 - //견적특이사항 List const [specialNoteList, setSpecialNoteList] = useState([]) @@ -183,11 +181,11 @@ export default function Estimate({ params }) { } //아이템 목록 - useEffect(() => { - if (isNotEmptyArray(state.itemList)) { - setItemList(state.itemList) - } - }, [state?.itemList]) + // useEffect(() => { + // if (isNotEmptyArray(state.itemList)) { + // setItemList(state.itemList) + // } + // }, [state?.itemList]) //가격표시 option 최초세팅 useEffect(() => { @@ -207,12 +205,6 @@ export default function Estimate({ params }) { } }, [state?.estimateType]) - // useEffect(() => { - // if (state.priceCd) { - // setTempPriceCd(state.priceCd) - // } - // }, [state?.priceCd]) - //가격표시 option 변경시 useEffect(() => { if (tempPriceCd !== '') { @@ -292,7 +284,24 @@ export default function Estimate({ params }) { //제품 삭제 const removeItem = () => { const array = [...selection] - console.log(array) + let tempList = [] + state.itemList.filter((row) => { + array.map((row2) => { + if (row2 === row.dispOrder) { + tempList.push({ ...row }) + } + }) + }) + + const result = state.itemList.filter((item) => { + return !tempList.some((other) => other.dispOrder === item.dispOrder) + }) + + setState({ + itemList: result, + }) + + setSelection(new Set()) } return ( @@ -809,7 +818,12 @@ export default function Estimate({ params }) {
- onChangeSelect(item.dispOrder)} /> + onChangeSelect(item.dispOrder)} + checked={selection.has(item.dispOrder) ? true : false} + />