import { call, put } from 'redux-saga/effects';
import { get } from 'services/requests';
import { Api } from 'routes/Api';
import { handleError } from 'modules/error-handler';
import * as actions from 'lib/redux/actions/managed-content-actions';



export function* fetchManagedContent() {
	try {
		const res = yield call(() => get({
			url: Api.managedContent
		}));

		// dispatch a success action to the store with the fetched districts
		yield put(actions.fetchedManagedContent({ data: res.data }));

	}
	catch (error) {
		// dispatch a failure action to the store with the error
		yield put(actions.failedFetchManagedContent({ error: error.message }));

		handleError(error);
	}
}

