47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
import { createSlice } from "@reduxjs/toolkit";
|
|
|
|
export const initialState = {
|
|
table: [],
|
|
productData: [],
|
|
productHourData: [],
|
|
chart: {
|
|
year: [],
|
|
week: [],
|
|
month: [],
|
|
day: [],
|
|
},
|
|
};
|
|
|
|
const cuttingSlice = createSlice({
|
|
name: "cutting",
|
|
initialState,
|
|
reducers: {
|
|
setCuttingTable: (state, action) => {
|
|
if ("data" in action.payload) state.table = action.payload.data;
|
|
if ("productHourData" in action.payload)
|
|
state.productHourData = action.payload.productHourData;
|
|
if ("productData" in action.payload)
|
|
state.productData = action.payload.productData;
|
|
},
|
|
setCuttingChart: (state, action) => {
|
|
switch (action.payload.dateType) {
|
|
case "year":
|
|
state.chart.year = action.payload.detData;
|
|
break;
|
|
case "weekly":
|
|
state.chart.week = action.payload.detData;
|
|
break;
|
|
case "month":
|
|
state.chart.month = action.payload.detData;
|
|
break;
|
|
case "day":
|
|
state.chart.day = action.payload.detData;
|
|
break;
|
|
}
|
|
},
|
|
},
|
|
});
|
|
|
|
export default cuttingSlice.reducer;
|
|
export const { setCuttingTable, setCuttingChart } = cuttingSlice.actions;
|