51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
import { axiosRetailInstanceData } from '../../AuthenicationToken/AuthenticationToken';
|
|
|
|
export const gettinghold = createAsyncThunk('gettinghold', async (data) => {
|
|
if (
|
|
data?.AppId != null &&
|
|
data?.AppId != undefined &&
|
|
data?.CompId != null &&
|
|
data?.CompId != undefined &&
|
|
data?.BranchId != null &&
|
|
data?.BranchId != undefined
|
|
) {
|
|
return await axiosRetailInstanceData.get(
|
|
`/hold?CompId=${data?.CompId}&BranchId=${data?.BranchId}&AppId=${data?.AppId}`
|
|
);
|
|
}
|
|
});
|
|
|
|
export const puttinghold = createAsyncThunk('puttinghold', async (putData) => {
|
|
return await axiosRetailInstanceData.put(`/hold`, putData);
|
|
});
|
|
|
|
const initialState = {
|
|
holddata: [],
|
|
};
|
|
|
|
const HoldOption = createSlice({
|
|
name: 'HoldOption',
|
|
initialState,
|
|
reducers: {
|
|
changeholddata: (state, action) => {
|
|
state.holddata = action?.payload;
|
|
},
|
|
},
|
|
extraReducers: (builder) => {
|
|
builder.addCase(gettinghold.fulfilled, (state, action) => {
|
|
if (action?.payload?.status) {
|
|
state.holddata = action?.payload?.data?.data;
|
|
} else {
|
|
state.holddata = [];
|
|
}
|
|
});
|
|
},
|
|
});
|
|
|
|
export const { changeholddata } = HoldOption.actions;
|
|
|
|
export const globalholddata = (state) => state?.HoldOption?.holddata;
|
|
|
|
export default HoldOption.reducer;
|