Skip to content

Commit

Permalink
8001 r50 allow adding user when not in results (#128)
Browse files Browse the repository at this point in the history
* Added navigation for results

* allow deploy from a specific branch

* Revert "allow deploy from a specific branch"

This reverts commit 9563343.

* Clarified comment

* Updated style and improved layout

* Clear alerts before navigating to new screen
  • Loading branch information
daveb-hni authored Oct 12, 2022
1 parent a1f1dab commit 82a6f62
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
39 changes: 36 additions & 3 deletions frontend/src/components/coverage/enrollment/NameSearchResults.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,54 @@
<template>
<div>
<p>Number of Matches: {{ candidates.length }}</p>
<div v-for="candidate in candidates">
<NameSearchCandidate :candidate="candidate" />
<p>
Number of Matches: <b>{{ numberOfMatches }}</b>
</p>
<div v-if="hasCandidates">
<NameSearchCandidate v-for="candidate in candidates" :candidate="candidate" :key="candidate.phn" />
</div>
<hr />
<p>If the individual for whom you are searching is not listed, you can select "Create New PHN" or "Refine Search"</p>
<AppRow>
<AppButton @click="registerWithoutPHN" mode="secondary" type="button">Create New PHN</AppButton>
<AppButton @click="refineSearch" mode="secondary" type="button">Refine Search</AppButton>
</AppRow>
</div>
</template>
<script>
import NameSearchCandidate from './NameSearchCandidate.vue'
import { useAlertStore } from '../../../stores/alert'
export default {
name: 'NameSearchResults',
props: {
candidates: Array,
},
emits: ['set-page-action'],
components: {
NameSearchCandidate,
},
setup() {
return {
alertStore: useAlertStore(),
}
},
computed: {
numberOfMatches() {
return this.candidates ? this.candidates.length : 0
},
hasCandidates() {
return this.candidates && this.candidates.length > 0
},
},
methods: {
registerWithoutPHN() {
this.alertStore.dismissAlert()
this.$emit('set-page-action', 'REGISTRATION')
},
refineSearch() {
this.alertStore.dismissAlert()
this.$emit('set-page-action', 'NAME_SEARCH')
},
},
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<p>If no matches are found based on the search criteria, enter the information about the person you wish to add. This will create a PHN for the person and give the option to add another Study Permit Holder.</p>
</AppHelp>
<NameSearch v-if="isNameSearch" @search-for-candidates="searchForCandidates" :searching="searching" />
<NameSearchResults v-else-if="isNameSearchResults" :candidates="this.nameSearchResult.candidates" />
<NameSearchResults v-else-if="isNameSearchResults" :candidates="this.nameSearchResult.candidates" @set-page-action="setPageAction" />
<ResidentDetailsWithoutPHN v-else-if="isStudentRegistration" :resident="this.registrationPerson" @register-resident="registerResident" :submitting="submitting" />
<RegistrationConfirmation v-else-if="isConfirmation" :resident="this.registrationPerson" />
</template>
Expand Down Expand Up @@ -104,19 +104,12 @@ export default {
this.alertStore.setWarningAlert(this.nameSearchResult?.message)
}
this.registrationPerson = { ...searchCriteria } //make the search criteria available for the Registration screen for populating it in the case where the user wants to use it to create a new PHN
if (!this.nameSearchResult.candidates || this.nameSearchResult.candidates.length == 0) {
//found no result so need to register and enroll without a PHN
this.registrationPerson = { ...searchCriteria }
//found no result so add message for user
this.alertStore.setInfoAlert(this.nameSearchResult?.message)
this.pageAction = this.PAGE_ACTION.REGISTRATION
} else if (this.nameSearchResult.candidates.length === 1) {
//found 1 result so can auto select it for use in Register with PHN
this.studyPermitHolderStore.resident = this.nameSearchResult.candidates[0]
this.$router.push({ name: 'AddVisaResidentWithPHN', query: { pageAction: 'REGISTRATION' } })
} else {
this.pageAction = this.PAGE_ACTION.NAME_SEARCH_RESULTS
}
this.pageAction = this.PAGE_ACTION.NAME_SEARCH_RESULTS
} catch (err) {
handleServiceError(err, this.alertStore, this.$router)
} finally {
Expand Down Expand Up @@ -145,6 +138,9 @@ export default {
this.submitting = false
}
},
setPageAction(pageAction) {
this.pageAction = pageAction
},
},
}
</script>

0 comments on commit 82a6f62

Please sign in to comment.