Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24658 Implement Staff Search by Filing ID #3186

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.126",
"version": "2.6.127",
"appName": "Auth Web",
"sbcName": "SBC Common Components",
"private": true,
Expand Down
4 changes: 4 additions & 0 deletions auth-web/src/services/business.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export default class BusinessService {
return axios.get(`${ConfigHelper.getLegalAPIV2Url()}/businesses/${businessRegNumber}/filings`)
}

static async searchFiling (filingID: string): Promise<AxiosResponse<any>> {
return axios.get(`${ConfigHelper.getLegalAPIV2Url()}/businesses/filings/search/${filingID}`)
}

static async updateFolioNumber (folioNumber: FolioNumberload): Promise<AxiosResponse<any>> {
return axios.patch(`${ConfigHelper.getAuthAPIUrl()}/entities/${folioNumber.businessIdentifier}`, folioNumber)
}
Expand Down
23 changes: 22 additions & 1 deletion auth-web/src/stores/business.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export const useBusinessStore = defineStore('business', () => {
const state = reactive({
currentBusiness: undefined as Business,
businesses: [] as Business[],
removeExistingAffiliationInvitation: false
removeExistingAffiliationInvitation: false,
filingID: ''
})

function $reset () {
Expand Down Expand Up @@ -268,6 +269,19 @@ export const useBusinessStore = defineStore('business', () => {
}
}

async function loadFiling () {
const filingID = ConfigHelper.getFromSession(SessionStorageKeys.FilingIdentifierKey)
state.filingID = filingID
const response = await BusinessService.searchFiling(filingID).catch(() => null)
if (response?.status === 200) {
ConfigHelper.addToSession(SessionStorageKeys.BusinessIdentifierKey, response?.data.filing.business.identifier)
} else if (response?.status === 404) {
throw Error('No match found for Filing Number')
severinbeauvais marked this conversation as resolved.
Show resolved Hide resolved
} else {
throw Error('Search failed')
}
}

async function addBusiness (payload: LoginPayload) {
const requestBody: CreateAffiliationRequestBody = {
businessIdentifier: payload.businessIdentifier,
Expand Down Expand Up @@ -558,6 +572,11 @@ export const useBusinessStore = defineStore('business', () => {
ConfigHelper.removeFromSession(SessionStorageKeys.BusinessIdentifierKey)
}

function resetFilingID (): void {
state.filingID = ''
ConfigHelper.removeFromSession(SessionStorageKeys.FilingIdentifierKey)
}

async function resetBusinessPasscode (passCodeResetLoad: PasscodeResetLoad) {
await BusinessService.resetBusinessPasscode(passCodeResetLoad)
}
Expand All @@ -571,6 +590,7 @@ export const useBusinessStore = defineStore('business', () => {
currentOrganization,
syncBusinesses,
loadBusiness,
loadFiling,
addBusiness,
addNameRequest,
createNamedBusiness,
Expand All @@ -589,6 +609,7 @@ export const useBusinessStore = defineStore('business', () => {
saveContact,
updateFolioNumber,
resetCurrentBusiness,
resetFilingID,
resetBusinessPasscode,
searchNRIndex,
setRemoveExistingAffiliationInvitation,
Expand Down
1 change: 1 addition & 0 deletions auth-web/src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export enum SessionStorageKeys {
KeyCloakToken = 'KEYCLOAK_TOKEN',
ApiConfigKey = 'AUTH_API_CONFIG',
BusinessIdentifierKey = 'BUSINESS_ID',
FilingIdentifierKey = 'FILING_ID',
CurrentAccount = 'CURRENT_ACCOUNT',
LaunchDarklyFlags = 'LD_FLAGS',
ExtraProvincialUser = 'EXTRAPROVINCIAL_USER',
Expand Down
28 changes: 19 additions & 9 deletions auth-web/src/views/auth/staff/IncorporationSearchResultView.vue
severinbeauvais marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export default class IncorporationSearchResultView extends Vue {
@Action(useOrgStore) readonly syncMembership!: (affiliatedOrganizationId: number) => Promise<Member>
@Action(useOrgStore) readonly setCurrentAccountSettings!: (accountSettings: AccountSettings) => void
@State(useBusinessStore) currentBusiness!: Business
@State(useBusinessStore) filingID!: string

@Prop({ default: false }) isVisible: boolean
@Prop() affiliatedOrg: Organization
Expand All @@ -94,9 +95,9 @@ export default class IncorporationSearchResultView extends Vue {
get actions (): object[] {
if (this.isThereAnAffiliatedAccount) {
return [
{ title: 'Entity Dashboard',
{ title: 'Manage Business',
icon: 'mdi-view-dashboard',
event: this.entityDashboardEvent
event: this.manageBusinessEvent
},
{ title: 'Manage Account',
icon: 'mdi-domain',
Expand All @@ -105,9 +106,9 @@ export default class IncorporationSearchResultView extends Vue {
]
} else {
return [
{ title: 'Entity Dashboard',
{ title: 'Manage Business',
icon: 'mdi-view-dashboard',
event: this.entityDashboardEvent
event: this.manageBusinessEvent
},
{ title: 'Generate Passcode',
icon: 'mdi-lock-outline',
Expand All @@ -122,7 +123,7 @@ export default class IncorporationSearchResultView extends Vue {
name: this.currentBusiness?.name,
orgType: this.affiliatedOrg?.orgType,
account: this.affiliatedOrg?.name || 'No Affiliation',
businessIdentifier: this.currentBusiness?.businessIdentifier,
businessIdentifier: this.filingID ? this.filingID : this.currentBusiness?.businessIdentifier,
severinbeauvais marked this conversation as resolved.
Show resolved Hide resolved
businessNumber: this.currentBusiness?.businessNumber,
accessType: this.affiliatedOrg?.accessType,
statusCode: this.affiliatedOrg?.statusCode
Expand All @@ -137,7 +138,7 @@ export default class IncorporationSearchResultView extends Vue {
width: '25%'
},
{
text: 'Entity#',
text: 'Number',
align: 'left',
sortable: false,
value: 'businessIdentifier',
Expand Down Expand Up @@ -176,8 +177,17 @@ export default class IncorporationSearchResultView extends Vue {
return orgTypeDisplay
}

async entityDashboardEvent () {
window.location.href = `${ConfigHelper.getBusinessURL()}${this.currentBusiness.businessIdentifier}`
async manageBusinessEvent () {
const businessIdentifier = this.currentBusiness.businessIdentifier
const filingId = this.filingID

let url = `${ConfigHelper.getBusinessURL()}${businessIdentifier}`

if (filingId) {
url += `?filingId=${filingId}`
severinbeauvais marked this conversation as resolved.
Show resolved Hide resolved
}

window.location.href = url
}

async manageAccountEvent () {
Expand All @@ -188,7 +198,7 @@ export default class IncorporationSearchResultView extends Vue {
this.$router.push(`/account/${this.currentOrganization.id}/business`)
} catch (error) {
// eslint-disable-next-line no-console
console.log('Error during entity dashboard click event!')
console.log('Error during manage business click event!')
}
}

Expand Down
84 changes: 57 additions & 27 deletions auth-web/src/views/auth/staff/StaffDashboardView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</v-col>
</v-row>
<p class="mb-5 mt-4">
Find an existing business to manage:
Find a business or filing number:
</p>
</div>

Expand All @@ -81,28 +81,28 @@
icon="mdi-alert-circle"
class="mb-0"
>
{{ errorMessage }} <strong>{{ searchedBusinessNumber }}</strong>
{{ errorMessage }} <strong>{{ searchedIdentifierNumber }}</strong>
</v-alert>
</div>
</v-expand-transition>

<v-form
ref="searchBusinessForm"
ref="searchIdentifierForm"
@submit.prevent="search"
>
<v-row no-gutters>
<v-col>
<v-text-field
id="txtBusinessNumber"
v-model="businessIdentifier"
id="txtSearchIdentifier"
v-model="searchIdentifier"
filled
dense
req
persistent-hint
label="Incorporation Number or Registration Number"
hint="Example: BC1234567, CP1234567 or FM1234567"
:rules="businessIdentifierRules"
@blur="formatBusinessIdentifier()"
label="Incorporation, registration or filing number"
hint="Example: BC1234567”, “CP1234567”, “FM1234567” or “123456”"
:rules="searchIdentifierRules"
@blur="formatSearchIdentifier()"
/>
</v-col>
<v-col cols="auto">
Expand Down Expand Up @@ -323,8 +323,8 @@ import { useUserStore } from '@/stores/user'

// FUTURE: remove after vue 3 upgrade
interface StaffDashboardViewI {
businessIdentifier: string
searchedBusinessNumber: string
searchIdentifier: string
searchedIdentifierNumber: string
searchActive: boolean
errorMessage: string
canViewIncorporationSearchResult: boolean
Expand Down Expand Up @@ -354,7 +354,7 @@ export default defineComponent({
Transactions
},
setup (props, { root }) {
const searchBusinessForm: Ref<HTMLFormElement> = ref(null)
const searchIdentifierForm: Ref<HTMLFormElement> = ref(null)
const emailToAdd = ref(null)
const safeEmailView = ref(null)
const businessStore = useBusinessStore()
Expand All @@ -363,14 +363,14 @@ export default defineComponent({
const currentOrganization = computed(() => orgStore.currentOrganization)
const currentUser = computed(() => userStore.currentUser)

const businessIdentifierRules = [
v => !!v || 'Incorporation Number or Registration Number is required',
v => CommonUtils.validateIncorporationNumber(v) || 'Incorporation Number or Registration Number is not valid'
const searchIdentifierRules = [
v => !!v || 'Incorporation, registration or filing number is required',
v => CommonUtils.validateIncorporationNumber(v) || 'Incorporation, registration or filing number is not valid'
]

const localVars = (reactive({
affiliatedOrg: {},
businessIdentifier: '',
searchIdentifier: '',
canSearchFAS: computed((): boolean => currentUser.value?.roles?.includes(Role.FasSearch)),
canViewAccounts: computed((): boolean => currentUser.value?.roles?.includes(Role.StaffViewAccounts)),
canViewAllTransactions: computed((): boolean => currentUser.value?.roles?.includes(Role.ViewAllTransactions)),
Expand All @@ -382,14 +382,14 @@ export default defineComponent({
registrySearchUrl: computed((): string => ConfigHelper.getRegistrySearchUrl()),
documentsUiUrl: computed((): string => ConfigHelper.getBcrosDocumentsUiURL()),
searchActive: false,
searchedBusinessNumber: '',
searchedIdentifierNumber: '',
showBusSearchlink: computed((): boolean => true),
showInvoluntaryDissolutionTile: computed((): boolean =>
LaunchDarklyService.getFlag(LDFlags.EnableInvoluntaryDissolution) || false),
showDrsTile: computed((): boolean => LaunchDarklyService.getFlag(LDFlags.EnableDRSLookup) || false)
}) as unknown) as StaffDashboardViewI

const isFormValid = () => localVars.businessIdentifier && searchBusinessForm.value?.validate()
const isFormValid = () => localVars.searchIdentifier && searchIdentifierForm.value?.validate()

const goToInvoluntaryDissolution = () => root.$router.push(`/staff/involuntary-dissolution`)

Expand All @@ -415,6 +415,16 @@ export default defineComponent({
}
]

const isFilingID = (identifier: string) => {
// Check if the identifier contains only numeric characters
return /^\d+$/.test(identifier)
}

const resetSearchState = () => {
businessStore.resetCurrentBusiness()
businessStore.resetFilingID()
}

const updateCurrentBusiness = async () => {
try {
// Search for business, action will set session storage
Expand All @@ -428,20 +438,38 @@ export default defineComponent({
}
}

const fetchFiling = async () => {
try {
await businessStore.loadFiling()
} catch (exception) {
businessStore.resetFilingID()
localVars.errorMessage = exception?.message
}
}

const search = async () => {
resetSearchState()

if (isFormValid()) {
localVars.searchActive = true

try {
ConfigHelper.addToSession(SessionStorageKeys.BusinessIdentifierKey, localVars.businessIdentifier)
localVars.errorMessage = ''

if (isFilingID(localVars.searchIdentifier)) {
ConfigHelper.addToSession(SessionStorageKeys.FilingIdentifierKey, localVars.searchIdentifier)
await fetchFiling()
} else {
ConfigHelper.addToSession(SessionStorageKeys.BusinessIdentifierKey, localVars.searchIdentifier)
}

await updateCurrentBusiness()
} catch (exception) {
localVars.searchedBusinessNumber = localVars.businessIdentifier
localVars.searchedIdentifierNumber = localVars.searchIdentifier
businessStore.resetCurrentBusiness()
// FUTURE: get this from t(noIncorporationNumberFound)
// having trouble with composition version of $t in the build.
localVars.errorMessage = 'No match found for Incorporation Number'
localVars.errorMessage = 'No match found for business, registration or filing number'
localVars.canViewIncorporationSearchResult = false
} finally {
localVars.searchActive = false
Expand All @@ -455,9 +483,10 @@ export default defineComponent({
window.location.href.includes('test.account')
)

const formatBusinessIdentifier = () => {
localVars.businessIdentifier =
CommonUtils.formatIncorporationNumber(localVars.businessIdentifier)
const formatSearchIdentifier = () => {
if (!isFilingID(localVars.searchIdentifier)) {
localVars.searchIdentifier = CommonUtils.formatIncorporationNumber(localVars.searchIdentifier)
}
}

async function addEmail () {
Expand All @@ -483,15 +512,16 @@ export default defineComponent({
}

return {
businessIdentifierRules,
formatBusinessIdentifier,
searchIdentifierRules,
formatSearchIdentifier,
goToInvoluntaryDissolution,
goToManageBusiness,
isDevOrTest,
safeEmailView,
isFormValid,
isFilingID,
search,
searchBusinessForm,
searchIdentifierForm,
emailToAdd,
addEmail,
launchTileConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('StaffDashboardView.vue', () => {
vuetify,
mocks: { isFormValid }
})
cmp.setData({ businessIdentifier: 'CP0000000' })
cmp.setData({ searchIdentifier: 'CP0000000' })

vi.resetModules()
vi.clearAllMocks()
Expand All @@ -66,7 +66,7 @@ describe('StaffDashboardView.vue', () => {
})

it('incorporation number is not empty', () => {
expect(cmp.vm.businessIdentifier).toBe('CP0000000')
expect(cmp.vm.searchIdentifier).toBe('CP0000000')
})

it('enter button click invokes isFormValid method', async () => {
Expand Down
Loading