Skip to content

Commit

Permalink
22015 displaying wrong examiner name (#1484)
Browse files Browse the repository at this point in the history
* Added a function to transactions store to get the last idir that updated a given NR

* Made examiner status try to find the last IDIR for a NR

* Bumped up version number
  • Loading branch information
EPortman authored Jul 3, 2024
1 parent b6bfcfc commit 8899e0b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
19 changes: 13 additions & 6 deletions app/components/examine/request_info/Status.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="flex items-center">
<h2 class="font-bold">Status:&nbsp;</h2>
<p>{{ additionalStatus }}</p>
<p>{{ nrStatus }}</p>
</div>

<div class="flex items-center">
Expand All @@ -20,12 +20,14 @@
import { Status } from '~/enums/nr-status'
import { useExamination } from '~/store/examine'
import { usePayments } from '~/store/examine/payments'
import { useTransactions } from '~/store/transactions'
const examine = useExamination()
const payments = usePayments()
const { $userProfile } = useNuxtApp()
const transactions = useTransactions()
const examinerStatus = ref(examine.examiner)
const additionalStatus = computed(() => {
const nrStatus = computed(() => {
const approvedName = examine.nameChoices.find((name) =>
[Status.Approved, Status.Condition].includes(name.state)
)
Expand All @@ -48,8 +50,13 @@ const additionalStatus = computed(() => {
return examine.nrStatus
})
const examinerStatus = computed(() => {
const notAssigned = examine.examiner === 'nro_service_account' || examine.examiner === '' || examine.examiner === 'name_request_service_account'
return notAssigned ? $userProfile.username : examine.examiner
// Find the last Idir that edited the NR in transations
onMounted(async () => {
if (!examinerStatus.value?.includes('idir')) {
const lastIdirUpdate = await transactions.getLatestIdir(examine.nrNumber)
if (lastIdirUpdate !== 'N/A') {
examinerStatus.value = lastIdirUpdate
}
}
})
</script>
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "name-examination",
"version": "1.2.23",
"version": "1.2.24",
"private": true,
"scripts": {
"build": "nuxt generate",
Expand Down
17 changes: 17 additions & 0 deletions app/store/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ export const useTransactions = defineStore('transactions', () => {
: 'Not required'
}

async function getLatestIdir(nrNumber: string) {
try {
await loadNr(nrNumber)
await loadTransactions(nrNumber)

const latestIdirEntry = transactions.value
.filter(entry => entry.user_name.includes('idir'))
.sort((a, b) => new Date(b.eventDate).getTime() - new Date(a.eventDate).getTime())
[0]

return latestIdirEntry ? latestIdirEntry.user_name : 'N/A'
} catch (error) {
return 'N/A'
}
}

return {
nr,
transactions,
Expand All @@ -103,5 +119,6 @@ export const useTransactions = defineStore('transactions', () => {
getStatusDisplay,
getRequestTypeDisplay,
getConsentDisplay,
getLatestIdir
}
})

0 comments on commit 8899e0b

Please sign in to comment.