Skip to content

Commit

Permalink
20463 - Feat: Support Safe List Addition and Removal (#2834)
Browse files Browse the repository at this point in the history
* resolve conflicts

Signed-off-by: Shaanjot Gill <[email protected]>

* resolve conflict with error msg

Signed-off-by: Shaanjot Gill <[email protected]>

* lint fix

Signed-off-by: Shaanjot Gill <[email protected]>

---------

Signed-off-by: Shaanjot Gill <[email protected]>
  • Loading branch information
shaangill025 authored May 23, 2024
1 parent ae0a76a commit e541b85
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 4 deletions.
4 changes: 2 additions & 2 deletions auth-web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion auth-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auth-web",
"version": "2.6.13",
"version": "2.6.14",
"appName": "Auth Web",
"sbcName": "SBC Common Components",
"private": true,
Expand Down
4 changes: 4 additions & 0 deletions auth-web/src/models/Staff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ export interface Configurations {
export interface DissolutionStatistics {
data: { eligibleCount: number }
}

export interface SafeListEmailsRequestBody {
email: string[]
}
18 changes: 17 additions & 1 deletion auth-web/src/services/staff.services.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -60,4 +68,12 @@ export default class StaffService {
static async updateInvoluntaryDissolutionConfigurations (configurations: Configurations): Promise<AxiosResponse<Configurations>> {
return axios.put(`${ConfigHelper.getLegalAPIV2Url()}/admin/configurations`, configurations)
}

static async deleteSafeEmail (email: string): Promise<AxiosResponse<SafeEmail[]>> {
return axios.delete(`${ConfigHelper.getNotifiyAPIUrl()}/safe_list/${email}`)
}

static async addSafeEmail (safeListEmailsRequestBody: SafeListEmailsRequestBody): Promise<AxiosResponse<SafeEmail[]>> {
return axios.post(`${ConfigHelper.getNotifiyAPIUrl()}/safe_list`, safeListEmailsRequestBody)
}
}
19 changes: 19 additions & 0 deletions auth-web/src/views/auth/staff/SafeEmailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
>
<td>{{ item.id }}</td>
<td>{{ item.email }}</td>
<td>
<v-btn
small
@click="deleteEmail(item.email)"
>
Delete
</v-btn>
</td>
</tr>
</tbody>
</v-simple-table>
Expand All @@ -43,11 +51,22 @@ export default defineComponent({
}
const safeEmails = ref<SafeEmail[]>()
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
}
}
Expand Down
46 changes: 46 additions & 0 deletions auth-web/src/views/auth/staff/StaffDashboardView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,34 @@
title="Safe Email List (DEV/TEST)"
>
<template #content>
<v-container>
<p>Add to Safe Email List</p>
<v-form
ref="form"
class="mt-3"
>
<v-row>
<v-col cols="8">
<v-text-field
v-model="emailToAdd"
filled
label="Email"
class="ml-2"
/>
</v-col>
<v-col cols="4">
<v-btn
large
depressed
color="primary"
@click="addEmail"
>
<span>Add</span>
</v-btn>
</v-col>
</v-row>
</v-form>
</v-container>
<SafeEmailView />
</template>
</BaseVExpansionPanel>
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -311,6 +341,7 @@ export default defineComponent({
},
setup (props, { root }) {
const searchBusinessForm: Ref<HTMLFormElement> = ref(null)
const emailToAdd = ref(null)
const businessStore = useBusinessStore()
const orgStore = useOrgStore()
const userStore = useUserStore()
Expand Down Expand Up @@ -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,
Expand All @@ -401,6 +445,8 @@ export default defineComponent({
isFormValid,
search,
searchBusinessForm,
emailToAdd,
addEmail,
...toRefs(localVars)
}
}
Expand Down

0 comments on commit e541b85

Please sign in to comment.