From e541b85c7e32b378809895929a80f79c89269a55 Mon Sep 17 00:00:00 2001 From: Shaanjot Gill Date: Thu, 23 May 2024 07:32:01 -0700 Subject: [PATCH] 20463 - Feat: Support Safe List Addition and Removal (#2834) * resolve conflicts Signed-off-by: Shaanjot Gill * resolve conflict with error msg Signed-off-by: Shaanjot Gill * lint fix Signed-off-by: Shaanjot Gill --------- Signed-off-by: Shaanjot Gill --- auth-web/package-lock.json | 4 +- auth-web/package.json | 2 +- auth-web/src/models/Staff.ts | 4 ++ auth-web/src/services/staff.services.ts | 18 +++++++- .../src/views/auth/staff/SafeEmailView.vue | 19 ++++++++ .../views/auth/staff/StaffDashboardView.vue | 46 +++++++++++++++++++ 6 files changed, 89 insertions(+), 4 deletions(-) diff --git a/auth-web/package-lock.json b/auth-web/package-lock.json index a6fb1dc8f3..5de569ad74 100644 --- a/auth-web/package-lock.json +++ b/auth-web/package-lock.json @@ -1,12 +1,12 @@ { "name": "auth-web", - "version": "2.6.13", + "version": "2.6.14", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "auth-web", - "version": "2.6.13", + "version": "2.6.14", "dependencies": { "@bcrs-shared-components/base-address": "2.0.3", "@bcrs-shared-components/bread-crumb": "1.0.8", diff --git a/auth-web/package.json b/auth-web/package.json index 723d4d3544..154711ba94 100644 --- a/auth-web/package.json +++ b/auth-web/package.json @@ -1,6 +1,6 @@ { "name": "auth-web", - "version": "2.6.13", + "version": "2.6.14", "appName": "Auth Web", "sbcName": "SBC Common Components", "private": true, diff --git a/auth-web/src/models/Staff.ts b/auth-web/src/models/Staff.ts index 140703106b..864718a102 100644 --- a/auth-web/src/models/Staff.ts +++ b/auth-web/src/models/Staff.ts @@ -75,3 +75,7 @@ export interface Configurations { export interface DissolutionStatistics { data: { eligibleCount: number } } + +export interface SafeListEmailsRequestBody { + email: string[] +} diff --git a/auth-web/src/services/staff.services.ts b/auth-web/src/services/staff.services.ts index 46f2e99c1e..e922a9d5cc 100644 --- a/auth-web/src/services/staff.services.ts +++ b/auth-web/src/services/staff.services.ts @@ -1,4 +1,12 @@ -import { AccountType, Configurations, DissolutionStatistics, ProductCode, Products, ProductsRequestBody } from '@/models/Staff' +import { + AccountType, + Configurations, + DissolutionStatistics, + ProductCode, + Products, + ProductsRequestBody, + SafeListEmailsRequestBody +} from '@/models/Staff' import { OrgFilterParams, OrgList, Organizations } from '@/models/Organization' import { AxiosResponse } from 'axios' import ConfigHelper from '@/util/config-helper' @@ -60,4 +68,12 @@ export default class StaffService { static async updateInvoluntaryDissolutionConfigurations (configurations: Configurations): Promise> { return axios.put(`${ConfigHelper.getLegalAPIV2Url()}/admin/configurations`, configurations) } + + static async deleteSafeEmail (email: string): Promise> { + return axios.delete(`${ConfigHelper.getNotifiyAPIUrl()}/safe_list/${email}`) + } + + static async addSafeEmail (safeListEmailsRequestBody: SafeListEmailsRequestBody): Promise> { + return axios.post(`${ConfigHelper.getNotifiyAPIUrl()}/safe_list`, safeListEmailsRequestBody) + } } diff --git a/auth-web/src/views/auth/staff/SafeEmailView.vue b/auth-web/src/views/auth/staff/SafeEmailView.vue index 67d736edb1..e0935e62d5 100644 --- a/auth-web/src/views/auth/staff/SafeEmailView.vue +++ b/auth-web/src/views/auth/staff/SafeEmailView.vue @@ -23,6 +23,14 @@ > {{ item.id }} {{ item.email }} + + + Delete + + @@ -43,11 +51,22 @@ export default defineComponent({ } const safeEmails = ref() + async function deleteEmail (email: string) { + // Call the service method to delete the email from the server + try { + await StaffService.deleteSafeEmail(email) + } catch (error) { + // eslint-disable-next-line no-console + console.error(`Unable to delete the email, ${error}`) + } + } + onMounted(async () => { safeEmails.value = await getSafeEmails() }) return { + deleteEmail, safeEmails } } diff --git a/auth-web/src/views/auth/staff/StaffDashboardView.vue b/auth-web/src/views/auth/staff/StaffDashboardView.vue index 3a1ed97170..ce53e02969 100644 --- a/auth-web/src/views/auth/staff/StaffDashboardView.vue +++ b/auth-web/src/views/auth/staff/StaffDashboardView.vue @@ -223,6 +223,34 @@ title="Safe Email List (DEV/TEST)" > @@ -276,7 +304,9 @@ import LaunchDarklyService from 'sbc-common-components/src/services/launchdarkly import { Organization } from '@/models/Organization' import PPRLauncher from '@/components/auth/staff/PPRLauncher.vue' import SafeEmailView from '@/views/auth/staff/SafeEmailView.vue' +import { SafeListEmailsRequestBody } from '@/models/Staff' import StaffAccountManagement from '@/components/auth/staff/account-management/StaffAccountManagement.vue' +import StaffService from '@/services/staff.services' import { Transactions } from '@/components/auth/account-settings/transaction' import { useBusinessStore } from '@/stores/business' import { useOrgStore } from '@/stores/org' @@ -311,6 +341,7 @@ export default defineComponent({ }, setup (props, { root }) { const searchBusinessForm: Ref = ref(null) + const emailToAdd = ref(null) const businessStore = useBusinessStore() const orgStore = useOrgStore() const userStore = useUserStore() @@ -392,6 +423,19 @@ export default defineComponent({ CommonUtils.formatIncorporationNumber(localVars.businessIdentifier) } + async function addEmail () { + // Call the service method to add the email to the safe list + try { + const safeListEmailsRequestBody: SafeListEmailsRequestBody = { + email: [emailToAdd.value] + } + await StaffService.addSafeEmail(safeListEmailsRequestBody) + } catch (error) { + // eslint-disable-next-line no-console + console.error(`Unable to add the email, ${error}`) + } + } + return { businessIdentifierRules, formatBusinessIdentifier, @@ -401,6 +445,8 @@ export default defineComponent({ isFormValid, search, searchBusinessForm, + emailToAdd, + addEmail, ...toRefs(localVars) } }