import { put, call, throttle} from 'redux-saga/effects';
import ACTION from '../actions/actiontsTypes';
import {getDynamicSearchLocationResult} from "../api/rest/restContoller";
import {citySelectQueryForApi} from '../constants/dynamicSeatchConstans'

export function* getLocationDynamicSearch({ query }) {
    yield put({type: ACTION.DYNAMIC_SEARCH_LOCATION_REQUEST, settings: query});
    try {
        citySelectQueryForApi.methodProperties["FindByString"] = query.city;
        const {data} = yield call(getDynamicSearchLocationResult, citySelectQueryForApi);
        yield put({type: ACTION.DYNAMIC_SEARCH_LOCATION_RESPONSE, data: data.data});
    } catch (e) {
        yield put({type: ACTION.DYNAMIC_SEARCH_LOCATION_ERROR, error: e})
    }
}