Skip to content

Commit

Permalink
[UPDATE] Front - espécie: adiciona inserção #15
Browse files Browse the repository at this point in the history
  • Loading branch information
fernao committed Jun 11, 2019
1 parent 30905d1 commit 949494e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions front/src/helpers/api/Especie.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ export const updateEspecie = (params) => {
const path = '/api/v1/especie/especie/';
return api.putRequest(api.basePath + path, params, params.id);
};

export const adicionarEspecie = (params) => {
const path = '/api/v1/especie/especie/';
return api.postRequest(api.basePath + path, params);
};
9 changes: 9 additions & 0 deletions front/src/modules/especie/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ export const updateEspecie = ({ commit }, params) => {
commit(types.UPDATE_ESPECIE, response.data);
});
};

export const adicionarEspecie = async ({ commit }, params) => {
const resultado = await especieHelperAPI.adicionarEspecie(params)
.then((response) => {
commit(types.SET_ESPECIE, response.data);
return response.data;
});
return resultado;
};
6 changes: 6 additions & 0 deletions front/src/modules/especie/views/ListarEspecies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export default {
methods: {
...mapActions({
buscarEspecies: 'especie/buscarEspecies',
adicionarEspecie: 'especie/adicionarEspecie',
}),
visualizar(id) {
const path = `/especie/${id}`;
Expand All @@ -131,6 +132,11 @@ export default {
this.$router.push({ path });
},
adicionar() {
this.adicionarEspecie({
nomes_populares: '__',
}).then((response) => {
this.editar(response.id);
});
},
excluir(id) {
},
Expand Down

0 comments on commit 949494e

Please sign in to comment.