diff --git a/frontend/src/views/dashboard/components/PorderComponents2.js b/frontend/src/views/dashboard/components/PorderComponents2.js index cd4de28..defccd6 100644 --- a/frontend/src/views/dashboard/components/PorderComponents2.js +++ b/frontend/src/views/dashboard/components/PorderComponents2.js @@ -20,14 +20,13 @@ import DashboardCard from '../../../components/shared/DashboardCard'; import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'; import axios from 'axios'; import { Pagination } from '@mui/material'; -import { LocalizationProvider, DesktopDateTimePicker, DatePicker } from '@mui/x-date-pickers'; +import { LocalizationProvider, DatePicker } from '@mui/x-date-pickers'; import swal from 'sweetalert2' import { toggleCheckbox } from 'src/redux/slices/pOrderInfoCheckboxReducer'; import { REMOVE_ALL_SELECTED_PRODUCTS } from 'src/redux/slices/selectedProductsReducer'; -import { seletedPOrderList } from '../../../redux/thunks/SelectedPOrderList'; -import reload from 'src/redux/slices/pOrderListReducer'; import { tableCellClasses } from "@mui/material/TableCell"; - +import { reload } from 'src/redux/slices/pOrderListReducer'; +import { seletedPOrderList } from '../../../redux/thunks/SelectedPOrderList'; const PorderComponets2 = () => { const [visibleCount, setVisibleCount] = useState(10); const [visibleProducts, setVisibleProducts] = useState([]); @@ -41,6 +40,7 @@ const PorderComponets2 = () => { const [isDataUpdated, setDataUpdated] = useState(false); const [pOrderCount, setPOrderCount] = useState(""); const [pOrderItemState, setPOrderItemState] = useState(""); + const reloadFlag = useSelector((state) => state.pOrderList.reload); const dispatch = useDispatch(); useEffect(() => { @@ -62,6 +62,13 @@ const PorderComponets2 = () => { }, [visibleProducts, dispatch]) + useEffect(() => { + if(reloadFlag === true){ + dispatch(reload(false)) + dispatch(seletedPOrderList(pOrderCode)) + } + }, [reloadFlag]) + const selectedProducts = useSelector((state) => state.pOrderInfoCheckbox.selectedCheckBox); const removeCheckboxPOrder = useSelector((state) => state.selectedProduct.selectedProduct); @@ -148,10 +155,6 @@ const PorderComponets2 = () => { icon: 'success', showConfirmButton: false, }); - // 생성한 newProduct을 콘솔에 출력하여 확인 - console.log('새로운 제품:', newProduct); - // dispatch(reload(false)) // 이 부분을 주석 처리 - console.log('업데이트된 visibleProducts:', updatedVisibleProducts); setItemCode(""); setSelectedDateTime(""); setPOrderItemPrice(""); @@ -230,7 +233,6 @@ const PorderComponets2 = () => { setIsModalOpen(false); } - const handleEdit = (productId) => { setEditMode((prevState) => ({ ...prevState, [productId]: !prevState[productId] })); if (editMode[productId]) { // 이 부분을 수정하여 "Save" 버튼을 눌렀을 때만 axios 통신이 일어나도록 함 @@ -377,7 +379,7 @@ const PorderComponets2 = () => { ) : ( visibleProducts.map((product, index) => ( - { } }}ㄴ > - + { @@ -393,11 +395,11 @@ const PorderComponets2 = () => { setPOrderItemState(product.porderState) }} /> - - + + {product.porderState} - - + + {editMode[product.porderItemNo] ? ( { {product.itemCode} )} - - + + {editMode[product.porderItemNo] ? ( { {product.itemName} )} - - + + {editMode[product.porderItemNo] ? ( { handleChange(product.porderItemNo, 'porderPrice', e.target.value) setEditPOrderItemPrice(e.target.value) - }} /> ) : ( @@ -446,15 +447,16 @@ const PorderComponets2 = () => { {product.porderPrice} )} - - + + {editMode[product.porderItemNo] ? ( { handleChange(product.porderItemNo, 'porderCount', e.target.value) setEditPOrderCount(e.target.value) + }} /> ) : ( @@ -462,8 +464,8 @@ const PorderComponets2 = () => { {product.porderCount} )} - - + + {editMode[product.porderItemNo] ? ( {editPOrderItemPrice * editPOrderCount} @@ -472,10 +474,9 @@ const PorderComponets2 = () => { {(+product.porderCount) * (+product.porderPrice)} )} - - + + {editMode[product.porderItemNo] ? ( - { {product.receiveDeadline} ) } - - + + {product.porderState !== "준비" ? ( ) } - + - + setPOrderCode(e.target.value)} /> - - + + )) )}