Fixes/ll inventory (#69)
* inventory data changes * update Inventory changes * Fixed: removed unnecessary imports * Disabled: cycle count * Added: Inventory types sagas * Fix: null check * Updated: policies * Fixed: formik values * update: allow single image * Update: Policies control * Updated: new inventory add form * Update: new inventory conditional render * Update: populate formik fields * Added: Validation * Added: edit functionality, disabled fields * Update: housekeeping * Fix: iconslug and key * Update: route handling * Added: endpoints * Added: widget nested page * Added: sagas * Added: redux handling * Update: new product page functionality * Added: inventory page functionality * Fixed: form validation * Fix: route handling Co-authored-by: evdigitech <evdigitech@gmail.com> Co-authored-by: Llewellyn Dsouza <lledsouza2209@gmail.com>
This commit is contained in:
58
src/sagas/Widget.js
Normal file
58
src/sagas/Widget.js
Normal file
@@ -0,0 +1,58 @@
|
||||
import { AuthorizedAPI } from 'config';
|
||||
import { call, put, takeEvery } from 'redux-saga/effects';
|
||||
import ApiServices from 'services/API/ApiServices';
|
||||
import WidgetActions, { WidgetTypes } from '../redux/WidgetRedux';
|
||||
|
||||
export function* onRequestWidget({ payload }) {
|
||||
const response = yield call(
|
||||
ApiServices[payload?.method],
|
||||
AuthorizedAPI,
|
||||
payload?.slug,
|
||||
payload?.data
|
||||
);
|
||||
if (response?.status === 200) {
|
||||
yield put(
|
||||
WidgetActions.widgetSuccess({
|
||||
loader: payload?.loader,
|
||||
widgets: response?.data?.data
|
||||
})
|
||||
);
|
||||
} else {
|
||||
yield put(
|
||||
WidgetActions.widgetFailure({
|
||||
loader: payload?.loader,
|
||||
error: response?.message
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function* onEditRequestWidget({ payload }) {
|
||||
const response = yield call(
|
||||
ApiServices[payload?.method],
|
||||
AuthorizedAPI,
|
||||
payload?.slug,
|
||||
payload?.data
|
||||
);
|
||||
if (response?.status === 200) {
|
||||
yield put(
|
||||
WidgetActions.editWidgetSuccess({
|
||||
loader: payload?.loader,
|
||||
widget: response?.data?.data,
|
||||
type: payload?.type
|
||||
})
|
||||
);
|
||||
} else {
|
||||
yield put(
|
||||
WidgetActions.widgetFailure({
|
||||
loader: payload?.loader,
|
||||
error: response?.message
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default [
|
||||
takeEvery(WidgetTypes.WIDGET_REQUEST, onRequestWidget),
|
||||
takeEvery(WidgetTypes.EDIT_WIDGET_REQUEST, onEditRequestWidget)
|
||||
];
|
||||
Reference in New Issue
Block a user