ebanutsya
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {createSlice} from "@reduxjs/toolkit";
|
||||
import {createSlice, PayloadAction} from "@reduxjs/toolkit";
|
||||
import {Order} from "../../types/order";
|
||||
|
||||
export interface AssemblyState {
|
||||
@@ -16,13 +16,30 @@ export const assembly = createSlice({
|
||||
setOrder: (state, action) => {
|
||||
state.order = action.payload;
|
||||
},
|
||||
setAssembled: (state, payload) => {
|
||||
state.order = ({...state.order, orderNumber:"2282"})
|
||||
setAssembled: (state, action: PayloadAction<{ orderProductId: number }>) => {
|
||||
if (!state.order || !state.order.products) return;
|
||||
|
||||
const orderProductId = action.payload.orderProductId;
|
||||
|
||||
state.order.products.forEach(product => {
|
||||
if (product.databaseId === orderProductId) {
|
||||
product.assembled = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
setShipped: (state) => {
|
||||
setShipped: (state, action: PayloadAction<{ orderProductId: number }>) => {
|
||||
if (!state.order || !state.order.products) return;
|
||||
|
||||
const orderProductId = action.payload.orderProductId;
|
||||
|
||||
state.order.products.forEach(product => {
|
||||
if (product.databaseId === orderProductId) {
|
||||
product.shipped = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export const {setOrder} = assembly.actions;
|
||||
export const {setOrder, setAssembled, setShipped} = assembly.actions;
|
||||
export default assembly.reducer;
|
||||
Reference in New Issue
Block a user