fix: product and inventory
This commit is contained in:
@@ -13,7 +13,6 @@ const initialState: { productRequest: ProductRequest } = {
|
||||
sku: '',
|
||||
name: '',
|
||||
description: '',
|
||||
barcode: '',
|
||||
price: 0,
|
||||
cost: 0,
|
||||
printer_type: '',
|
||||
|
||||
@@ -1,20 +1,71 @@
|
||||
// Third-party Imports
|
||||
import type { PayloadAction } from '@reduxjs/toolkit'
|
||||
import { createSlice } from '@reduxjs/toolkit'
|
||||
import { ProductRecipe } from '../../types/services/productRecipe'
|
||||
|
||||
// Type Imports
|
||||
|
||||
// Data Imports
|
||||
|
||||
const initialState: { currentProductRecipe: any } = {
|
||||
currentProductRecipe: {}
|
||||
const initialState: { currentVariant: any, currentProductRecipe: ProductRecipe } = {
|
||||
currentVariant: {},
|
||||
currentProductRecipe: {
|
||||
id: '',
|
||||
organization_id: '',
|
||||
outlet_id: null,
|
||||
product_id: '',
|
||||
variant_id: null,
|
||||
ingredient_id: '',
|
||||
quantity: 0,
|
||||
created_at: '',
|
||||
updated_at: '',
|
||||
product: {
|
||||
ID: '',
|
||||
OrganizationID: '',
|
||||
CategoryID: '',
|
||||
SKU: '',
|
||||
Name: '',
|
||||
Description: null,
|
||||
Price: 0,
|
||||
Cost: 0,
|
||||
BusinessType: '',
|
||||
ImageURL: '',
|
||||
PrinterType: '',
|
||||
UnitID: null,
|
||||
HasIngredients: false,
|
||||
Metadata: {},
|
||||
IsActive: false,
|
||||
CreatedAt: '',
|
||||
UpdatedAt: ''
|
||||
},
|
||||
ingredient: {
|
||||
id: '',
|
||||
organization_id: '',
|
||||
outlet_id: null,
|
||||
name: '',
|
||||
unit_id: '',
|
||||
cost: 0,
|
||||
stock: 0,
|
||||
is_semi_finished: false,
|
||||
is_active: false,
|
||||
metadata: {},
|
||||
created_at: '',
|
||||
updated_at: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const productRecipeSlice = createSlice({
|
||||
name: 'productRecipe',
|
||||
initialState,
|
||||
reducers: {
|
||||
setProductRecipe: (state, action: PayloadAction<any>) => {
|
||||
setProductVariant: (state, action: PayloadAction<any>) => {
|
||||
state.currentVariant = action.payload
|
||||
},
|
||||
resetProductVariant: state => {
|
||||
state.currentVariant = initialState.currentVariant
|
||||
},
|
||||
setProductRecipe: (state, action: PayloadAction<ProductRecipe>) => {
|
||||
state.currentProductRecipe = action.payload
|
||||
},
|
||||
resetProductRecipe: state => {
|
||||
@@ -23,6 +74,6 @@ export const productRecipeSlice = createSlice({
|
||||
}
|
||||
})
|
||||
|
||||
export const { setProductRecipe, resetProductRecipe } = productRecipeSlice.actions
|
||||
export const { setProductVariant, resetProductVariant, setProductRecipe, resetProductRecipe } = productRecipeSlice.actions
|
||||
|
||||
export default productRecipeSlice.reducer
|
||||
|
||||
Reference in New Issue
Block a user