Skip to content

Commit

Permalink
feat : 입고 등록 및 삭제 기능 구현 #13
Browse files Browse the repository at this point in the history
  • Loading branch information
Ozini08 committed Aug 22, 2023
1 parent c993d6c commit 289409e
Show file tree
Hide file tree
Showing 10 changed files with 709 additions and 247 deletions.
33 changes: 16 additions & 17 deletions frontend/src/axios/ReceiveAxios.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
// porderAxios.js

import axios from 'axios';
import axios from "axios";

//발주리스트에서 select하면 통신
//입고리스트에서 select하면 통신
const ReceiveAxios = (selectedProducts, dispatch) => {

if (selectedProducts.length === 1) {
const productId = selectedProducts[0];
console.log(productId);
axios.get(`receiveAxios`)
.then((response) => {
console.log(response.data);
dispatch({type : "seletedReceiveDetails", payload: response.data})

})
.catch((error) => {
console.error(error);
});
}
};
if (selectedProducts.length === 1) {
const productId = selectedProducts[0];
console.log(productId);
axios
.get(`receiveAxios`)
.then((response) => {
console.log(response.data);
dispatch({ type: "seletedReceiveDetails", payload: response.data });
})
.catch((error) => {
console.error(error);
});
}
};

export default ReceiveAxios;
29 changes: 29 additions & 0 deletions frontend/src/axios/pOrderWaitIngAxios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import axios from "axios";

//입고 등록시 발주 "wait", "ing" 리스트 조회
// const pOrderWaitIngAxios = (searchPOrders) => {
// console.log("porders_Data : " + JSON.stringify(searchPOrders));
// axios
// .get("http://localhost:8888/api/receive/insertWaiting", { data: searchPOrders })
// .then((response) => {
// console.log(response.data);
// })
// .catch((error) => {
// console.error(error);
// });
// };

const pOrderWaitIngAxios = async (searchPOrders) => {
console.log("porders_Data : " + JSON.stringify(searchPOrders));
try {
const response = await axios.get("http://localhost:8888/api/receive/insertWaiting", {
data: searchPOrders,
});
return response.data;
} catch (error) {
console.error(error);
throw error;
}
};

export default pOrderWaitIngAxios;
27 changes: 27 additions & 0 deletions frontend/src/axios/receiveDeleteAxios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import axios from "axios";
import swal from "sweetalert2";

//입고리스트에서 delete하면 통신
const pOrderDeleteAxios = (selectedProducts) => {
axios
.delete("http://localhost:8888/api/receive/delete", {
data: selectedProducts,
})
.then((response) => {
console.log(response.data);
swal.fire({
title: "삭제 완료",
text: "재고가 삭제되었습니다.",
icon: "success",
});
})
.catch((error) => {
swal.fire({
title: "삭제 실패",
text: `Error: ${error.message}`,
icon: "error",
});
});
};

export default pOrderDeleteAxios;
29 changes: 29 additions & 0 deletions frontend/src/axios/receiveItemDeleteAxios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import axios from "axios";
import swal from "sweetalert2";

// 입고품목 리스트에서 delete하면 통신
const receiveItemDeleteAxios = (selectedProducts) => {
console.log("선택된데이터 : " + JSON.stringify(selectedProducts));

axios
.delete("http://localhost:8888/api/receive-item/delete", {
data: selectedProducts,
})
.then((response) => {
console.log(response.data);
swal.fire({
title: "삭제 완료",
text: "재고가 삭제되었습니다.",
icon: "success",
});
})
.catch((error) => {
swal.fire({
title: "삭제 실패",
text: `Error: ${error.message}`,
icon: "error",
});
});
};

export default receiveItemDeleteAxios;
24 changes: 24 additions & 0 deletions frontend/src/axios/receiveItemUpdateAxios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import axios from "axios";
import swal from "sweetalert2";

//입고품목 수정하면 통신
const receiveItemUpdateAxios = (indexData) => {
axios
.put(`http://localhost:8888/api/receive-item/delete/${indexData}`)
.then((response) => {
console.log(response.data);
swal.fire({
title: "수정 완료",
text: "입고품목이 수정되었습니다.",
icon: "success",
});
})
.catch((error) => {
swal.fire({
title: "수정 실패",
text: `Error: ${error.message}`,
icon: "error",
});
});
};
export default receiveItemUpdateAxios;
43 changes: 22 additions & 21 deletions frontend/src/redux/reducer.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import { combineReducers } from '@reduxjs/toolkit';
import porderModalDuck from './slices/porderModalDuck'
import selectedProductsReducer from './slices/selectedProductsReducer'
import selectedPOrderReducer from './slices/selectedPOrderReducer'
import pOrderListReducer from './slices/pOrderListReducer'
import receiveListReducer from './slices/receiveListReducer'
import warehouseListReducer from './slices/warehouseListReducer';
import SelectedPOrderListReducer from './slices/SelectedPOrderListReducer';
import loginResponseReducer from './slices/loginResponseReducer';
import logoutResponseReducer from './slices/logoutResponseReducer';
import { combineReducers } from "@reduxjs/toolkit";
import porderModalDuck from "./slices/porderModalDuck";
import selectedProductsReducer from "./slices/selectedProductsReducer";
import selectedPOrderReducer from "./slices/selectedPOrderReducer";
import pOrderListReducer from "./slices/pOrderListReducer";
import receiveListReducer from "./slices/receiveListReducer";
import warehouseListReducer from "./slices/warehouseListReducer";
import SelectedPOrderListReducer from "./slices/SelectedPOrderListReducer";
import loginResponseReducer from "./slices/loginResponseReducer";
import logoutResponseReducer from "./slices/logoutResponseReducer";
import receiveModalDuck from "./slices/receiveModalDuck";

const rootReducer = combineReducers({
porderModal: porderModalDuck,
selectedProduct: selectedProductsReducer,
selectedPOrder: selectedPOrderReducer,
pOrderList: pOrderListReducer,
receiveList: receiveListReducer,
warehouseList: warehouseListReducer,
selectedPOrderList: SelectedPOrderListReducer
loginResponse: loginResponseReducer,
logoutResponse: logoutResponseReducer
porderModal: porderModalDuck,
selectedProduct: selectedProductsReducer,
selectedPOrder: selectedPOrderReducer,
pOrderList: pOrderListReducer,
receiveList: receiveListReducer,
warehouseList: warehouseListReducer,
selectedPOrderList: SelectedPOrderListReducer,
loginResponse: loginResponseReducer,
logoutResponse: logoutResponseReducer,
receiveModal: receiveModalDuck,
});


export default rootReducer;
export default rootReducer;
33 changes: 33 additions & 0 deletions frontend/src/redux/slices/receiveModalDuck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { createSlice } from "@reduxjs/toolkit";

// 초기 상태
const initialState = {
openModal: false,
modalData: [],
editedProducts: {},
};

// 리듀서
const receiveModalReducer = createSlice({
name: "receiveModal",
initialState,
reducers: {
open_Modal: (state) => {
state.openModal = true;
console.log("모달오픈()");
},
close_Modal: (state) => {
state.openModal = false;
},
SAVE_MODAL_DATA: (state, action) => {
state.modalData.push(action.payload);
console.log("reducer에서: " + state.modalData);
state.openModal = false;
state.modalData = null;
},
},
});

export const { open_Modal, close_Modal, SAVE_MODAL_DATA } = receiveModalReducer.actions;

export default receiveModalReducer.reducer;
Loading

0 comments on commit 289409e

Please sign in to comment.