import { query } from '@pages/{{{ COMPONENT_NAME }}}/services/index';

export interface {{{ COMPONENT_NAME }}}ModelState {
  name: string;
}

interface Payload {
  payload: any;
}

const {{{ COMPONENT_NAME }}}Model: any = {
  namespace: '{{{ NAME }}}',
  state: {
    name: '',
  },

  effects: {
    *query({ payload }: Payload, { call, put }: any) {
      const data = yield call(query, payload);
      yield put({
        type: 'save',
        payload: { name: data.text },
      });
    },
  },
  reducers: {
    save(state: {{{ COMPONENT_NAME }}}ModelState, { payload }: Payload) {
      return { ...state, ...payload };
    },
  },
};

export default {{{ COMPONENT_NAME }}}Model;
