803 lines
22 KiB
JavaScript
803 lines
22 KiB
JavaScript
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
import {
|
|
axiosRetailInstanceData,
|
|
axiosCommonInstanceData,
|
|
axiosRetailOcrData,
|
|
} from '../AuthenicationToken/AuthenticationToken';
|
|
|
|
// export const getUserGuideLines = createAsyncThunk('product/getBranchData', async ({ formType, userId }) => {
|
|
// if (formType !=null && formType !=undefined && userId !=null && userId !=undefined) {
|
|
// return await axiosCommonInstanceData.get(`/UserGuideLines?formType=${formType}&userId=${userId}`);
|
|
// }
|
|
// }
|
|
// )
|
|
// export const postUserGuideLines = createAsyncThunk('product/getBranchData', async (postdata) => {
|
|
// return await axiosCommonInstanceData.post(`/UserGuideLines`,postdata);
|
|
// }
|
|
// )
|
|
export const getAllprodIName = createAsyncThunk(
|
|
'product/getAllprodIName',
|
|
async (ProdData) => {
|
|
if (
|
|
ProdData?.CompId != null &&
|
|
ProdData?.CompId != undefined &&
|
|
ProdData?.BranchId != null &&
|
|
ProdData?.BranchId != undefined &&
|
|
ProdData?.AppId != null &&
|
|
ProdData?.AppId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/product?CompId=${ProdData?.CompId}&BranchId=${ProdData?.BranchId}&AppId=${ProdData?.AppId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
export const getTopSellingProduct = createAsyncThunk(
|
|
'product/getProductDataPageNo',
|
|
async ({ CompId, BranchId, AppId, FromDate, ToDate, pageNumber }) => {
|
|
if (
|
|
CompId != null &&
|
|
CompId != undefined &&
|
|
BranchId != null &&
|
|
BranchId != undefined &&
|
|
AppId != null &&
|
|
AppId != undefined
|
|
) {
|
|
const params = new URLSearchParams({
|
|
CompId,
|
|
BranchId,
|
|
AppId,
|
|
fromDate: FromDate,
|
|
toDate: ToDate,
|
|
});
|
|
|
|
if (pageNumber) params.append('pageNumber', pageNumber);
|
|
|
|
return await axiosRetailInstanceData.get(
|
|
`/product/TopSellingProducts?${params.toString()}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
export const PostPedalOCR = createAsyncThunk(
|
|
'Stock/PostPedalOCR',
|
|
async (fileOrFormData) => {
|
|
let formdata;
|
|
if (fileOrFormData instanceof FormData) {
|
|
formdata = fileOrFormData;
|
|
} else {
|
|
formdata = new FormData();
|
|
formdata.append('file', fileOrFormData);
|
|
}
|
|
return await axiosRetailOcrData.post(`Productlistupload`, formdata);
|
|
}
|
|
);
|
|
export const getBranchData = createAsyncThunk(
|
|
'product/getBranchData',
|
|
async ({ CompId, AppId }) => {
|
|
if (
|
|
CompId != null &&
|
|
CompId != undefined &&
|
|
AppId != null &&
|
|
AppId != undefined
|
|
) {
|
|
return await axiosCommonInstanceData.get(
|
|
`/appAccess?CompId=${CompId}&AppId=${AppId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getAdmin = createAsyncThunk(
|
|
'product/adminTax',
|
|
async ({ CompId, AppId }) => {
|
|
if (
|
|
CompId != null &&
|
|
CompId != undefined &&
|
|
AppId != null &&
|
|
AppId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/tax?ActiveStatus=A&CompId=${CompId}&AppId=${AppId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getProductTypeData = createAsyncThunk(
|
|
'product/getProductTypeData',
|
|
async () => {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Product Type`
|
|
);
|
|
}
|
|
);
|
|
export const getHsnData = createAsyncThunk('/getHSNData', async (HsnCode) => {
|
|
{
|
|
return await axiosRetailInstanceData.get(`/HSNData?hSN_CD=${HsnCode}`);
|
|
}
|
|
});
|
|
export const getConfigTypeData = createAsyncThunk(
|
|
'product/getConfigTypeData',
|
|
async ({ TypeName }) => {
|
|
if (TypeName != null && TypeName != undefined) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configType?TypeName=${TypeName}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getUomData = createAsyncThunk('product/getUomData', async () => {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Unit Of Measure`
|
|
);
|
|
});
|
|
|
|
export const getWholesaleQuantityData = createAsyncThunk(
|
|
'product/getWholesaleQuantityData',
|
|
async () => {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Wholesale Quantity`
|
|
);
|
|
}
|
|
);
|
|
export const getWholesaleQuantityDatawithActiveStatus = createAsyncThunk(
|
|
'product/getWholesaleQuantityData',
|
|
async () => {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Wholesale Quantity&Type=WQ`
|
|
);
|
|
}
|
|
);
|
|
export const getWholesaleUomData = createAsyncThunk(
|
|
'product/getWholesaleUomData',
|
|
async () => {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Wholesale Unit Of Measure`
|
|
);
|
|
}
|
|
);
|
|
export const ServiceType = createAsyncThunk('product/ServiceType', async () => {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Service Type`
|
|
);
|
|
});
|
|
|
|
export const getProdCatData = createAsyncThunk(
|
|
'product/getProdCatData',
|
|
async ({ AppId }) => {
|
|
if (AppId != null && AppId != undefined) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Product Category&AppId=${AppId}`
|
|
);
|
|
} else {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Product Category`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getProdTaxData = createAsyncThunk(
|
|
'product/getProdTaxData',
|
|
async ({ AppId }) => {
|
|
if (AppId != null && AppId != undefined) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Product Tax&AppId=${AppId}`
|
|
);
|
|
} else {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Product Tax`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getProdSubCatData = createAsyncThunk(
|
|
'product/getProdSubCatData',
|
|
async ({ ConfigId }) => {
|
|
if (ConfigId != null && ConfigId != undefined) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Product Sub-Category&Type=M&ConfigId=${ConfigId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getActiveProdSubCatData = createAsyncThunk(
|
|
'product/getActiveProdSubCatData',
|
|
async ({ AppId }) => {
|
|
if (AppId !== null && AppId !== undefined) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Product Sub-Category&AppId=${AppId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getProductData = createAsyncThunk(
|
|
'product/getProductData',
|
|
async (ProdData) => {
|
|
if (
|
|
ProdData?.CompId != null &&
|
|
ProdData?.CompId != undefined &&
|
|
ProdData?.BranchId != null &&
|
|
ProdData?.BranchId != undefined &&
|
|
ProdData?.AppId != null &&
|
|
ProdData?.AppId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/product?CompId=${ProdData?.CompId}&BranchId=${ProdData?.BranchId}&AppId=${ProdData?.AppId}`
|
|
);
|
|
} else {
|
|
return await axiosRetailInstanceData.get(`/product`);
|
|
}
|
|
}
|
|
);
|
|
export const getProductDataPageNo = createAsyncThunk(
|
|
'product/getProductDataPageNo',
|
|
async (ProdData) => {
|
|
if (
|
|
ProdData?.CompId != null &&
|
|
ProdData?.CompId != undefined &&
|
|
ProdData?.BranchId != null &&
|
|
ProdData?.BranchId != undefined &&
|
|
ProdData?.AppId != null &&
|
|
ProdData?.AppId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/product?CompId=${ProdData?.CompId}&BranchId=${ProdData?.BranchId}&AppId=${ProdData?.AppId}&PageNumber=${ProdData?.PageNumber}`
|
|
);
|
|
} else {
|
|
return await axiosRetailInstanceData.get(`/product`);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getDirectSaleProducts = createAsyncThunk(
|
|
'product/getDirectSaleProducts',
|
|
async (data) => {
|
|
const { CompId, BranchId, AppId, page } = data
|
|
if (
|
|
CompId != null && CompId != undefined &&
|
|
BranchId != null && BranchId != undefined &&
|
|
AppId != null && AppId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/product?CompId=${CompId}&BranchId=${BranchId}&AppId=${AppId}&SalesType=DS&PageNumber=${page}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getAllprodIds = createAsyncThunk(
|
|
'product/getAllprodIds',
|
|
async (ProdData) => {
|
|
if (
|
|
ProdData?.CompId != null &&
|
|
ProdData?.CompId != undefined &&
|
|
ProdData?.BranchId != null &&
|
|
ProdData?.BranchId != undefined &&
|
|
ProdData?.AppId != null &&
|
|
ProdData?.AppId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/Product/ProductId?compId=${ProdData?.CompId}&branchId=${ProdData?.BranchId}&appId=${ProdData?.AppId}`
|
|
);
|
|
} else if (
|
|
ProdData?.CompId != null &&
|
|
ProdData?.CompId != undefined &&
|
|
ProdData?.AppId != null &&
|
|
ProdData?.AppId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/Product/ProductId?compId=${ProdData?.CompId}&appId=${ProdData?.AppId}`
|
|
);
|
|
} else {
|
|
return await axiosRetailInstanceData.get(`/product`);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getAllProductShortCodes = createAsyncThunk('product/getAllProductShortCodes', async (data) => {
|
|
const { AppId, CompId, BranchId } = data;
|
|
if (AppId != null && AppId && BranchId != null && BranchId && AppId && AppId != null) {
|
|
return await axiosRetailInstanceData.get(`/Product/ProdShortCodes?CompId=${CompId}&BranchId=${BranchId}&AppId=${AppId}`);
|
|
}
|
|
});
|
|
|
|
export const getProductDataSearch = createAsyncThunk(
|
|
'product/getProductDataSearch',
|
|
async (ProdData) => {
|
|
if (
|
|
ProdData?.CompId != null &&
|
|
ProdData?.CompId != undefined &&
|
|
ProdData?.BranchId != null &&
|
|
ProdData?.BranchId != undefined &&
|
|
ProdData?.AppId != null &&
|
|
ProdData?.AppId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/ProductMasterSearch?CompId=${ProdData?.CompId}&BranchId=${ProdData?.BranchId}&AppId=${ProdData?.AppId}&prodName=${ProdData?.prodName}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getDirectSaleSearchedProduct = createAsyncThunk(
|
|
'product/getDirectSaleSearchedProduct',
|
|
async (data) => {
|
|
const { CompId, BranchId, AppId, prodName } = data;
|
|
if (
|
|
CompId != null && CompId != undefined &&
|
|
BranchId != null && BranchId != undefined &&
|
|
AppId != undefined && AppId != null
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/ProductMasterSearch?CompId=${CompId}&BranchId=${BranchId}&AppId=${AppId}&prodName=${prodName}&SalesType=DS`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getBrandData = createAsyncThunk(
|
|
'product/getBrandData',
|
|
async ({ ConfigId }) => {
|
|
if (ConfigId != null && ConfigId != undefined) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=Product Brand&Type=M&ConfigId=${ConfigId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getQrcodeData = createAsyncThunk(
|
|
'product/getQrcodeData',
|
|
async ({ QRCode }) => {
|
|
if (QRCode != null && QRCode != undefined) {
|
|
return await axiosRetailInstanceData.get(`/product?QRCode=${QRCode}`);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getQrcode = createAsyncThunk(
|
|
'product/getQrcode',
|
|
async ({ CompId, AppId, BranchId }) => {
|
|
if (
|
|
CompId != null &&
|
|
CompId != undefined &&
|
|
AppId != null &&
|
|
AppId != undefined &&
|
|
BranchId
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/qrCode?AppId=${AppId}&CompId=${CompId}&BranchId=${BranchId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getSupplierData = createAsyncThunk(
|
|
'product/getSupplierData',
|
|
async ({ CompId, AppId, BranchId }) => {
|
|
if (
|
|
CompId != null &&
|
|
CompId != undefined &&
|
|
AppId != null &&
|
|
AppId != undefined &&
|
|
BranchId
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/supplierlist?AppId=${AppId}&CompId=${CompId}&BranchId=${BranchId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const postProductData = createAsyncThunk(
|
|
'product/postProductData',
|
|
async (postData) => {
|
|
return await axiosRetailInstanceData.post(`/product`, postData);
|
|
}
|
|
);
|
|
|
|
export const postConfiguration = createAsyncThunk(
|
|
'product/postConfiguration',
|
|
async (postData) => {
|
|
return await axiosRetailInstanceData.post(`/configMaster`, postData);
|
|
}
|
|
);
|
|
|
|
export const postConfigurationmultiple = createAsyncThunk(
|
|
'product/postConfiguration',
|
|
async (postData) => {
|
|
return await axiosRetailInstanceData.post(
|
|
`/configMaster/Multiple`,
|
|
postData
|
|
);
|
|
}
|
|
);
|
|
|
|
export const postTax = createAsyncThunk('product/postTax', async (postData) => {
|
|
return await axiosRetailInstanceData.post(`/tax`, postData);
|
|
});
|
|
|
|
export const postSupplier = createAsyncThunk(
|
|
'product/postsupplier',
|
|
async (postData) => {
|
|
return await axiosRetailInstanceData.post(`/supplier`, postData);
|
|
}
|
|
);
|
|
|
|
export const putProductData = createAsyncThunk(
|
|
'product/putProductData',
|
|
async (putData) => {
|
|
return await axiosRetailInstanceData.put(`/product`, putData);
|
|
}
|
|
);
|
|
|
|
export const deleteProductData = createAsyncThunk(
|
|
'product/deleteProductData',
|
|
async (deleteData) => {
|
|
return await axiosRetailInstanceData.delete(`/product`, {
|
|
params: deleteData,
|
|
});
|
|
}
|
|
);
|
|
|
|
export const updateProductImage = createAsyncThunk(
|
|
'product/updateProductImage',
|
|
async (data) => {
|
|
return await axiosRetailInstanceData.put(`/Product/ImageUpload`, data);
|
|
}
|
|
);
|
|
|
|
export const onlineimages = createAsyncThunk(
|
|
'image/onlineimages',
|
|
async (data) => {
|
|
if (data != null && data != undefined) {
|
|
return await axiosRetailInstanceData.get(`/image?Name=${data}`);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getAllsubcatdata = createAsyncThunk(
|
|
'configMaster/getAllsubcatdata',
|
|
async ({ TypeName, AppId }) => {
|
|
if (
|
|
TypeName != null &&
|
|
TypeName != undefined &&
|
|
AppId != null &&
|
|
AppId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=${TypeName}&AppId=${AppId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getAllbrandcatdata = createAsyncThunk(
|
|
'configMaster/getAllbrandcatdata',
|
|
async ({ TypeName, AppId }) => {
|
|
if (
|
|
TypeName != null &&
|
|
TypeName != undefined &&
|
|
AppId != null &&
|
|
AppId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=${TypeName}&AppId=${AppId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getAlltaxdata = createAsyncThunk(
|
|
'configMaster/getAlltaxdata',
|
|
async ({ TypeName, AppId }) => {
|
|
if (
|
|
TypeName != null &&
|
|
TypeName != undefined &&
|
|
AppId != null &&
|
|
AppId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/configMaster?TypeName=${TypeName}&AppId=${AppId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getsingleQrcodeData = createAsyncThunk(
|
|
'product/getsingleQrcodeData',
|
|
async ({ QRCode }) => {
|
|
if (QRCode) {
|
|
return await axiosRetailInstanceData.get(`/product?onePcQR=${QRCode}`);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const bulkpostdata = createAsyncThunk(
|
|
'configMaster/bulkpostdata',
|
|
async (postData) => {
|
|
return await axiosRetailInstanceData.post(`/productBulkUpload`, postData);
|
|
}
|
|
);
|
|
|
|
export const putImageBulkUpload = createAsyncThunk(
|
|
'ImageBulkUpload',
|
|
async (putData) => {
|
|
return await axiosRetailInstanceData.put('ImageBulkUpload', putData);
|
|
}
|
|
);
|
|
|
|
export const Deletebulkdatas = createAsyncThunk(
|
|
'Deletebulkdata',
|
|
async (data) => {
|
|
console.log(data, 'datadatadatadatadatadatadatadata');
|
|
return await axiosRetailInstanceData.put(`/ProductBulkDelete`, data);
|
|
}
|
|
);
|
|
|
|
export const getExpireProductsList = createAsyncThunk(
|
|
'/getExpireProductsList',
|
|
async ({ compId, branchId, appId }) => {
|
|
if (
|
|
compId != null &&
|
|
compId != undefined &&
|
|
branchId != null &&
|
|
branchId != undefined &&
|
|
appId != null &&
|
|
appId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/Product/ExpiryNotificationAlert?compId=${compId}&branchId=${branchId}&appId=${appId}`
|
|
);
|
|
} else if (
|
|
compId != null &&
|
|
compId != undefined &&
|
|
appId != null &&
|
|
appId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/Product/ExpiryNotificationAlert?compId=${compId}&appId=${appId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getLowStockAlertProductsList = createAsyncThunk(
|
|
'/getLowStockAlertProductsList',
|
|
async ({ compId, branchId, appId }) => {
|
|
if (
|
|
compId != null &&
|
|
compId != undefined &&
|
|
branchId != null &&
|
|
branchId != undefined &&
|
|
appId != null &&
|
|
appId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/Product/LowStockAlert?compId=${compId}&branchId=${branchId}&appId=${appId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const postFieldSetup = createAsyncThunk(
|
|
'FieldConfig/postFieldSetup',
|
|
async (postData) => {
|
|
return await axiosRetailInstanceData.post(`/FieldConfig`, postData);
|
|
}
|
|
);
|
|
|
|
export const getFieldSetupData = createAsyncThunk(
|
|
'FieldConfig/getFieldSetupData',
|
|
async ({ AppId, CompId, BranchId, categoryId, Type }) => {
|
|
if (
|
|
AppId != null &&
|
|
AppId != undefined &&
|
|
CompId != null &&
|
|
CompId != undefined &&
|
|
BranchId != null &&
|
|
BranchId != undefined &&
|
|
categoryId != null &&
|
|
categoryId != undefined &&
|
|
Type != null &&
|
|
Type != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/FieldConfig?AppId=${AppId}&CompId=${CompId}&BranchId=${BranchId}&catId=${categoryId}&Type=${Type}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
////////////////////////
|
|
// post /RackMaster
|
|
export const postRackData = createAsyncThunk(
|
|
'postRackData/RackMaster',
|
|
async (postData) => {
|
|
return await axiosRetailInstanceData.post(`/RackMaster`, postData);
|
|
}
|
|
);
|
|
export const putRackData = createAsyncThunk(
|
|
'putRackData/RackMaster',
|
|
async (postData) => {
|
|
return await axiosRetailInstanceData.put(`/RackMaster`, postData);
|
|
}
|
|
);
|
|
|
|
export const getRackData = createAsyncThunk(
|
|
'getRackData/RackMaster',
|
|
async ({ AppId, CompId, BranchId }) => {
|
|
if (
|
|
AppId != null &&
|
|
AppId != undefined &&
|
|
CompId != null &&
|
|
CompId != undefined &&
|
|
BranchId != null &&
|
|
BranchId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/RackMaster?AppId=${AppId}&CompId=${CompId}&BranchId=${BranchId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
export const deleteRackData = createAsyncThunk(
|
|
'deleteRackData/RackMaster',
|
|
async ({ activeStatus, updatedBy, rackId }) => {
|
|
if (
|
|
updatedBy != null &&
|
|
updatedBy != undefined &&
|
|
activeStatus != null &&
|
|
activeStatus != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.delete(
|
|
`/RackMaster?activeStatus=${activeStatus}&updatedBy=${updatedBy}&rackId=${rackId}`
|
|
);
|
|
}
|
|
}
|
|
);
|
|
|
|
|
|
|
|
|
|
const initialState = {
|
|
branchData: [],
|
|
productTypeData: [],
|
|
uomData: [],
|
|
prodCatData: [],
|
|
prodSubCatData: [],
|
|
allProdSubCatData: [],
|
|
productData: [],
|
|
prodTaxData: [],
|
|
taxData: [],
|
|
brandData: [],
|
|
supplierData: [],
|
|
WholesaleUomData: [],
|
|
WholesaleQuantityData: [],
|
|
};
|
|
|
|
const productSlice = createSlice({
|
|
name: 'product',
|
|
initialState,
|
|
extraReducers: (builder) => {
|
|
(builder.addCase(getBranchData.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.branchData = action?.payload?.data?.data;
|
|
} else {
|
|
state.branchData = [];
|
|
}
|
|
}),
|
|
builder.addCase(getProductTypeData.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.productTypeData = action?.payload?.data?.data;
|
|
} else {
|
|
state.productTypeData = [];
|
|
}
|
|
}),
|
|
builder.addCase(getUomData.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.uomData = action?.payload?.data?.data;
|
|
} else {
|
|
state.uomData = [];
|
|
}
|
|
}),
|
|
builder.addCase(getWholesaleUomData.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.WholesaleUomData = action?.payload?.data?.data;
|
|
} else {
|
|
state.WholesaleUomData = [];
|
|
}
|
|
}),
|
|
builder.addCase(getWholesaleQuantityData.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.WholesaleQuantityData = action?.payload?.data?.data;
|
|
} else {
|
|
state.WholesaleQuantityData = [];
|
|
}
|
|
}),
|
|
builder.addCase(getProdCatData.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.prodCatData = action?.payload?.data?.data;
|
|
} else {
|
|
state.prodCatData = [];
|
|
}
|
|
}),
|
|
builder.addCase(getProdSubCatData.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.prodSubCatData = action?.payload?.data?.data;
|
|
} else {
|
|
state.prodSubCatData = [];
|
|
}
|
|
}),
|
|
builder.addCase(getActiveProdSubCatData.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.allProdSubCatData = action?.payload?.data?.data;
|
|
} else {
|
|
state.allProdSubCatData = [];
|
|
}
|
|
}),
|
|
builder.addCase(getBrandData.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.brandData = action?.payload?.data?.data;
|
|
} else {
|
|
state.brandData = [];
|
|
}
|
|
}),
|
|
builder.addCase(getProdTaxData.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.prodTaxData = action?.payload?.data?.data;
|
|
} else {
|
|
state.prodTaxData = [];
|
|
}
|
|
}),
|
|
builder.addCase(getProductData.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.productData = action?.payload?.data?.data;
|
|
} else {
|
|
state.productData = [];
|
|
}
|
|
}),
|
|
builder.addCase(getAdmin.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.taxData = action?.payload?.data?.data;
|
|
} else {
|
|
state.taxData = [];
|
|
}
|
|
}),
|
|
builder.addCase(getSupplierData.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.supplierData = action?.payload?.data?.data;
|
|
} else {
|
|
state.supplierData = [];
|
|
}
|
|
}));
|
|
},
|
|
});
|
|
|
|
export const branchDataSelector = (state) => state.productPage?.branchData;
|
|
export const productTypeDataSelector = (state) =>
|
|
state.productPage?.productTypeData;
|
|
export const uomDataSelector = (state) => state.productPage?.uomData;
|
|
export const prodCatDataSelector = (state) => state.productPage?.prodCatData;
|
|
export const prodSubCatDataSelector = (state) =>
|
|
state.productPage?.prodSubCatData;
|
|
export const allProdSubCatDataSelector = (state) =>
|
|
state.productPage?.allProdSubCatData;
|
|
export const productDataSelector = (state) => state.productPage?.productData;
|
|
export const brandDataSelector = (state) => state.productPage?.brandData;
|
|
export const taxSelector = (state) => state.productPage?.taxData;
|
|
export const prodTaxDataSelector = (state) => state.productPage?.prodTaxData;
|
|
export const supplierSelector = (state) => state.productPage?.supplierData;
|
|
export const WholesaleUomDataSelector = (state) =>
|
|
state.productPage?.WholesaleUomData;
|
|
export const WholesaleQuantityData = (state) =>
|
|
state.productPage?.WholesaleQuantityData;
|
|
|
|
export default productSlice.reducer;
|