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} + />