From 8852edd346a203b8ff62cb6fb1386e92ff71d268 Mon Sep 17 00:00:00 2001 From: Mariana Date: Fri, 9 Feb 2024 11:52:22 -0300 Subject: [PATCH 01/36] feat: Add delete sector button and modal --- src/locales/translations.json | 5 ++ src/services/api/resources/settings/sector.js | 5 ++ src/views/Settings/Sectors/Edit.vue | 73 ++++++++++++++++--- 3 files changed, 72 insertions(+), 11 deletions(-) diff --git a/src/locales/translations.json b/src/locales/translations.json index 8de540de..3929ecab 100644 --- a/src/locales/translations.json +++ b/src/locales/translations.json @@ -1171,6 +1171,11 @@ "en-us": "Save", "es": "Guardar" }, + "delete_sector": { + "pt-br": "Deletar setor", + "en-us": "Delete sector", + "es": "Eliminar sector" + }, "edit": { "pt-br": "Editar", "en-us": "Edit", diff --git a/src/services/api/resources/settings/sector.js b/src/services/api/resources/settings/sector.js index 134c846b..2449c4fc 100644 --- a/src/services/api/resources/settings/sector.js +++ b/src/services/api/resources/settings/sector.js @@ -49,6 +49,11 @@ export default { return response; }, + async deleteSector({ sectorUuid }) { + const response = http.delete(`/authorization/sector/${sectorUuid}`); + return response.data; + }, + async managers(sectorUuid) { const response = await http.get('/authorization/sector/', { params: { diff --git a/src/views/Settings/Sectors/Edit.vue b/src/views/Settings/Sectors/Edit.vue index 71e921ef..90074675 100644 --- a/src/views/Settings/Sectors/Edit.vue +++ b/src/views/Settings/Sectors/Edit.vue @@ -129,18 +129,50 @@ @click="cancel" v-if="this.isQuickMessageEditing" /> - + + + + + + ({ currentTab: '', openModal: false, + openModalDelete: false, sector: { uuid: '', name: '', @@ -448,6 +481,18 @@ export default { this.$router.push({ name: 'sectors' }); }, + async openModalDeleteSector() { + this.openModalDelete = true; + }, + + async closeModalDeleteSector() { + this.openModalDelete = false; + }, + + async deleteSector() { + console.log('vamos deletar?'); + }, + async removeManager(managerUuid) { await Sector.removeManager(managerUuid); this.removeManagerFromTheList(managerUuid); @@ -639,6 +684,12 @@ export default { } } + .buttons { + display: flex; + flex-direction: column; + gap: $unnnic-spacing-sm; + } + &__breadcrumb { margin: $unnnic-spacing-inline-sm 0; From e1db427a41b64a7748d48d1388a7959bdcac32c9 Mon Sep 17 00:00:00 2001 From: Paulo Bernardo Date: Fri, 9 Feb 2024 15:32:03 -0300 Subject: [PATCH 02/36] Create test-and-build.yml --- .github/workflows/test-and-build.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/test-and-build.yml diff --git a/.github/workflows/test-and-build.yml b/.github/workflows/test-and-build.yml new file mode 100644 index 00000000..cea8da34 --- /dev/null +++ b/.github/workflows/test-and-build.yml @@ -0,0 +1,26 @@ +name: Run Unit Tests, Lint Files and Build Project +on: push +jobs: + lint-test-build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Node 18 + uses: actions/setup-node@v2 + with: + node-version: '18' + - name: Install dependencies + run: | + npm install -g yarn + yarn install + - name: Run lint + run: yarn lint + - name: Run tests + run: yarn test:unit + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Build application + run: yarn build From fd38aa2e34db98b9d0ec085d44b3e45d8afc99b2 Mon Sep 17 00:00:00 2001 From: Mariana Date: Fri, 9 Feb 2024 18:19:57 -0300 Subject: [PATCH 03/36] feat: Add functions to delete the sector --- src/services/api/resources/settings/sector.js | 4 +-- src/store/modules/settings.js | 12 +++++++ src/views/Settings/Sectors/Edit.vue | 31 ++++++------------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/services/api/resources/settings/sector.js b/src/services/api/resources/settings/sector.js index 2449c4fc..70ac37eb 100644 --- a/src/services/api/resources/settings/sector.js +++ b/src/services/api/resources/settings/sector.js @@ -49,8 +49,8 @@ export default { return response; }, - async deleteSector({ sectorUuid }) { - const response = http.delete(`/authorization/sector/${sectorUuid}`); + async deleteSector(sectorUuid) { + const response = await http.delete(`/authorization/sector/?sector=${sectorUuid}`); return response.data; }, diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index ecbcf75c..2caa654b 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -1,4 +1,5 @@ import cloneDeep from 'lodash.clonedeep'; +import Sector from '@/services/api/resources/settings/sector'; const module = { namespaced: true, @@ -25,6 +26,10 @@ const module = { const index = state.sectors.findIndex((s) => s.id === sector.id); state.sectors.splice(index, 1, sector); }, + deleteSector(state, sectorUuid) { + state.sectors = state.sectors.filter((sector) => sector.uuid !== sectorUuid); + console.log(state.sectors); + }, }, actions: { @@ -36,6 +41,13 @@ const module = { commit('updateSector', sector); }, + async deleteSector({ commit }, sectorUuid) { + console.log(sectorUuid); + + await Sector.deleteSector(sectorUuid); + + commit('deleteSector', sectorUuid); + }, }, getters: { diff --git a/src/views/Settings/Sectors/Edit.vue b/src/views/Settings/Sectors/Edit.vue index 90074675..08b54e21 100644 --- a/src/views/Settings/Sectors/Edit.vue +++ b/src/views/Settings/Sectors/Edit.vue @@ -134,14 +134,9 @@ :text="$t('delete_sector')" type="warning" iconLeft="delete" - @click="openModalDeleteSector" + @click="openModalDelete = true" :disabled="isQuickMessageEditing && !isQuickMessagesFormValid" - v-if=" - this.currentTab === 'sector' || - this.queueToEdit || - this.isQuickMessageEditing || - currentTab === 'tags' - " + v-if="this.currentTab === 'sector'" /> queue.uuid !== queueUuid); - this.queueToEdit = null; - this.closeModalDeleteQueue(); + this.openModalDelete = true; }, async openModalDeleteQueue(queue) { this.selectedQueue = queue; @@ -481,16 +477,9 @@ export default { this.$router.push({ name: 'sectors' }); }, - async openModalDeleteSector() { - this.openModalDelete = true; - }, - - async closeModalDeleteSector() { - this.openModalDelete = false; - }, - - async deleteSector() { - console.log('vamos deletar?'); + async deleteSector(sectorUuid) { + console.log('o id é ', sectorUuid); + this.actionDeleteSector(sectorUuid); }, async removeManager(managerUuid) { From 235a369b979a04511a99523059cc92854bb0998a Mon Sep 17 00:00:00 2001 From: Mariana Date: Wed, 14 Feb 2024 15:11:18 -0300 Subject: [PATCH 04/36] feat: Add unnnicCallAlert and fix validateLabel --- src/views/Settings/Sectors/Edit.vue | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/views/Settings/Sectors/Edit.vue b/src/views/Settings/Sectors/Edit.vue index 08b54e21..acd9f8c1 100644 --- a/src/views/Settings/Sectors/Edit.vue +++ b/src/views/Settings/Sectors/Edit.vue @@ -161,7 +161,7 @@ :description="`Essa opção não poderá ser revertida.`" :validate="`${sector.name}`" :validatePlaceholder="`${sector.name}`" - :validateLabel="`Confirme digitando ${sector.name}`" + :validateLabel="`Confirme digitando "${sector.name}"`" :actionPrimaryLabel="$t('confirm')" :actionSecondaryLabel="$t('cancel')" @click-action-primary="deleteSector(sector.uuid)" @@ -479,7 +479,28 @@ export default { async deleteSector(sectorUuid) { console.log('o id é ', sectorUuid); - this.actionDeleteSector(sectorUuid); + // this.actionDelete Sector(sectorUuid); + try { + await this.actionDeleteSector(sectorUuid); + this.openModalDelete = false; + unnnicCallAlert({ + props: { + text: 'Setor deletado com sucesso!', + type: 'success', + }, + seconds: 5, + }); + } catch (error) { + console.log(error); + this.openModalDelete = false; + unnnicCallAlert({ + props: { + text: 'Não foi possível deletar o setor, tente novamente mais tarde.', + type: 'error', + }, + seconds: 5, + }); + } }, async removeManager(managerUuid) { From e77b6b607649959d8ea611e95e7db07410e1ff97 Mon Sep 17 00:00:00 2001 From: Mariana Date: Wed, 14 Feb 2024 16:41:42 -0300 Subject: [PATCH 05/36] fix: Adjust sector endpoint and add a refresh to other page when delete a sector --- src/services/api/resources/settings/sector.js | 2 +- src/views/Settings/Sectors/Edit.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/api/resources/settings/sector.js b/src/services/api/resources/settings/sector.js index 70ac37eb..a32a8f72 100644 --- a/src/services/api/resources/settings/sector.js +++ b/src/services/api/resources/settings/sector.js @@ -50,7 +50,7 @@ export default { }, async deleteSector(sectorUuid) { - const response = await http.delete(`/authorization/sector/?sector=${sectorUuid}`); + const response = await http.delete(`/sector/${sectorUuid}`); return response.data; }, diff --git a/src/views/Settings/Sectors/Edit.vue b/src/views/Settings/Sectors/Edit.vue index acd9f8c1..7e295657 100644 --- a/src/views/Settings/Sectors/Edit.vue +++ b/src/views/Settings/Sectors/Edit.vue @@ -479,9 +479,9 @@ export default { async deleteSector(sectorUuid) { console.log('o id é ', sectorUuid); - // this.actionDelete Sector(sectorUuid); try { await this.actionDeleteSector(sectorUuid); + this.$router.push({ name: 'sectors' }); this.openModalDelete = false; unnnicCallAlert({ props: { From 0f9e0c9982a9d22e6708fd7ae42bb5c408e49daa Mon Sep 17 00:00:00 2001 From: Mariana Date: Thu, 15 Feb 2024 11:44:02 -0300 Subject: [PATCH 06/36] feat: Add translation on delete sector modal --- src/locales/translations.json | 10 ++++++++++ src/views/Settings/Sectors/Edit.vue | 9 ++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/locales/translations.json b/src/locales/translations.json index 3929ecab..e577dbda 100644 --- a/src/locales/translations.json +++ b/src/locales/translations.json @@ -1176,6 +1176,16 @@ "en-us": "Delete sector", "es": "Eliminar sector" }, + "cant_revert": { + "pt-br": "Essa opção não poderá ser revertida", + "en-us": "This option cannot be reversed", + "es": "Esta opción no se puede revertir" + }, + "confirm_typing": { + "pt-br": "Confirme digitando", + "en-us": "Confirm by typing", + "es": "Confirmar escribiendo" + }, "edit": { "pt-br": "Editar", "en-us": "Edit", diff --git a/src/views/Settings/Sectors/Edit.vue b/src/views/Settings/Sectors/Edit.vue index 7e295657..9d683e4a 100644 --- a/src/views/Settings/Sectors/Edit.vue +++ b/src/views/Settings/Sectors/Edit.vue @@ -157,11 +157,11 @@ type="alert" icon="alert-circle-1" scheme="feedback-red" - :title="`Deletar setor ${sector.name}`" - :description="`Essa opção não poderá ser revertida.`" + :title="$t('delete_sector') + ` ${sector.name}`" + :description="$t('cant_revert')" :validate="`${sector.name}`" :validatePlaceholder="`${sector.name}`" - :validateLabel="`Confirme digitando "${sector.name}"`" + :validateLabel="$t('confirm_typing') + ` "${sector.name}"`" :actionPrimaryLabel="$t('confirm')" :actionSecondaryLabel="$t('cancel')" @click-action-primary="deleteSector(sector.uuid)" @@ -478,11 +478,10 @@ export default { }, async deleteSector(sectorUuid) { - console.log('o id é ', sectorUuid); try { await this.actionDeleteSector(sectorUuid); - this.$router.push({ name: 'sectors' }); this.openModalDelete = false; + this.$router.push({ name: 'sectors' }); unnnicCallAlert({ props: { text: 'Setor deletado com sucesso!', From 64d041f4ae254d4745fb6aaf143912b3a4f44c12 Mon Sep 17 00:00:00 2001 From: Mariana Date: Thu, 15 Feb 2024 11:47:06 -0300 Subject: [PATCH 07/36] fix: Remove console.log on lines code --- src/store/modules/settings.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index 2caa654b..67c7ed5c 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -28,7 +28,6 @@ const module = { }, deleteSector(state, sectorUuid) { state.sectors = state.sectors.filter((sector) => sector.uuid !== sectorUuid); - console.log(state.sectors); }, }, @@ -42,8 +41,6 @@ const module = { commit('updateSector', sector); }, async deleteSector({ commit }, sectorUuid) { - console.log(sectorUuid); - await Sector.deleteSector(sectorUuid); commit('deleteSector', sectorUuid); From e82682d0b28af864c9af03288333f91304a21a5f Mon Sep 17 00:00:00 2001 From: Mariana Date: Thu, 15 Feb 2024 11:49:25 -0300 Subject: [PATCH 08/36] fix: Remove unused variable --- src/views/Settings/Sectors/Edit.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/views/Settings/Sectors/Edit.vue b/src/views/Settings/Sectors/Edit.vue index 9d683e4a..7f399893 100644 --- a/src/views/Settings/Sectors/Edit.vue +++ b/src/views/Settings/Sectors/Edit.vue @@ -258,7 +258,6 @@ export default { managers: [], maxSimultaneousChatsByAgent: '', }, - sectorDelete: null, queue: { name: '', }, From 540a131277dbf02266859e3433d288f53674dff8 Mon Sep 17 00:00:00 2001 From: Mariana Date: Fri, 16 Feb 2024 15:17:01 -0300 Subject: [PATCH 09/36] feat: Add translation on unnnic call alert --- src/locales/translations.json | 10 ++++++++++ src/views/Settings/Sectors/Edit.vue | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/locales/translations.json b/src/locales/translations.json index e577dbda..15f28fb9 100644 --- a/src/locales/translations.json +++ b/src/locales/translations.json @@ -1186,6 +1186,16 @@ "en-us": "Confirm by typing", "es": "Confirmar escribiendo" }, + "sector_deleted_success": { + "pt-br": "Setor deletado com sucesso!", + "en-us": "Sector deleted successfully!", + "es": "¡Sector eliminado con éxito!" + }, + "sector_delete_error": { + "pt-br": "Não foi possível deletar o setor, tente novamente mais tarde.", + "en-us": "Unable to delete sector, please try again later.", + "es": "No se puede eliminar el sector. Vuelva a intentarlo más tarde." + }, "edit": { "pt-br": "Editar", "en-us": "Edit", diff --git a/src/views/Settings/Sectors/Edit.vue b/src/views/Settings/Sectors/Edit.vue index 7f399893..985b0173 100644 --- a/src/views/Settings/Sectors/Edit.vue +++ b/src/views/Settings/Sectors/Edit.vue @@ -483,7 +483,7 @@ export default { this.$router.push({ name: 'sectors' }); unnnicCallAlert({ props: { - text: 'Setor deletado com sucesso!', + text: this.$t('sector_deleted_success'), type: 'success', }, seconds: 5, @@ -493,7 +493,7 @@ export default { this.openModalDelete = false; unnnicCallAlert({ props: { - text: 'Não foi possível deletar o setor, tente novamente mais tarde.', + text: this.$t('sector_delete_error'), type: 'error', }, seconds: 5, From 95d7ff39bdfbf2fb374a613e1952cedd7c6c1f76 Mon Sep 17 00:00:00 2001 From: Mariana Date: Mon, 19 Feb 2024 15:03:37 -0300 Subject: [PATCH 10/36] fix: The delete sector button must be in the content of the sector tab --- src/components/settings/forms/Sector.vue | 63 ++++++++++++++++++++++++ src/views/Settings/Sectors/Edit.vue | 52 ------------------- 2 files changed, 63 insertions(+), 52 deletions(-) diff --git a/src/components/settings/forms/Sector.vue b/src/components/settings/forms/Sector.vue index d504cca6..3cf84787 100644 --- a/src/components/settings/forms/Sector.vue +++ b/src/components/settings/forms/Sector.vue @@ -130,12 +130,38 @@ class="form-section__inputs--fill-w" /> +
+ +
+