Skip to content

Commit

Permalink
Merge pull request #270 from weni-ai/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
cristiantela authored Oct 26, 2023
2 parents 82db14a + 7e57a12 commit 70a8598
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions src/views/repository/content/BasesForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,14 @@
</template>

<script>
import { get } from 'lodash';
import RepositoryViewBase from '@/components/repository/RepositoryViewBase';
import Modal from '@/components/repository/CreateRepository/Modal';
import RepositoryBase from '../Base';
import { mapActions } from 'vuex';
import { LANGUAGES } from '@/utils/index';
import router from '@/router/index';
import { unnnicCallAlert } from '@weni/unnnic-system';
export default {
name: 'RepositoryBaseEdit',
Expand Down Expand Up @@ -191,6 +193,11 @@ export default {
'deleteQAKnowledgeBase',
'editQAKnowledgeBase'
]),
alertError(title) {
unnnicCallAlert({ props: { title, scheme: 'feedback-red', icon: 'alert-circle-1', }, seconds: 5 });
},
onTitleChange(event) {
this.knowledgeBase.title = event.srcElement.textContent;
},
Expand Down Expand Up @@ -259,31 +266,40 @@ export default {
language: this.knowledgeBase.text.language
};
this.submitting = true;
const responseEditKnowledgeBase = await this.editQAKnowledgeBase({
repositoryUUID: this.repositoryUUID,
id: this.$route.params.id,
title: this.knowledgeBase.title
});
try {
this.submitting = true;
this.knowledgeBase.oldTitle = responseEditKnowledgeBase.data.title;
const responseEditKnowledgeBase = await this.editQAKnowledgeBase({
repositoryUUID: this.repositoryUUID,
id: this.$route.params.id,
title: this.knowledgeBase.title
});
this.knowledgeBase.oldTitle = responseEditKnowledgeBase.data.title;
if (data.text) {
const action = data.id ? this.updateQAText : this.createQAText;
if (data.text) {
const action = data.id ? this.updateQAText : this.createQAText;
const responseText = await action(data);
const responseText = await action(data);
if (!this.knowledgeBase.text.id) {
this.knowledgeBase.text.id = responseText.data.id;
}
if (!this.knowledgeBase.text.id) {
this.knowledgeBase.text.id = responseText.data.id;
this.knowledgeBase.text.oldValue = responseText.data.text;
this.knowledgeBase.text.oldLanguage = responseText.data.language;
this.knowledgeBase.text.lastUpdate = responseText.data.last_update;
}
} catch (error) {
const errorMessage = get(error, 'response.data.text.0', '');
this.knowledgeBase.text.oldValue = responseText.data.text;
this.knowledgeBase.text.oldLanguage = responseText.data.language;
this.knowledgeBase.text.lastUpdate = responseText.data.last_update;
if (errorMessage) {
this.alertError(errorMessage);
}
} finally {
this.submitting = false;
}
this.submitting = false;
},
async deleteBase() {
const responseDeleteBase = await this.deleteQAKnowledgeBase({
Expand Down

0 comments on commit 70a8598

Please sign in to comment.