Skip to content

Commit

Permalink
DAH-2464 display for rank in tiered case (#649)
Browse files Browse the repository at this point in the history
* DAH-2464 display for rank in tiered case

* DAH-2464 update tests

* DAH-2464 remove unneeded changes

* DAH-2464 remove unneeded comment
  • Loading branch information
tallulahkay authored Aug 6, 2024
1 parent ddf1057 commit 1f2fc29
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ const getRank = (prefKey, prefLotteryRank) => {
return prefLotteryRank ? `${prefKey} ${prefLotteryRank}` : 'Unranked'
}

const getPrefKey = (application) => {
// Override the key we display for certain cases
if (application.preference_name === 'General') {
return 'General'
} else if (application.preference_name?.includes('Right to Return')) {
return 'RtR'
} else if (application.preference_name?.includes('Tier')) {
return application.custom_preference_type.replace('G', 'General')
}

return application.custom_preference_type
? application.custom_preference_type
: application.preference_record_type
}

// Format applications for the Lease Up applications table
export const buildRowData = (application) => {
const rowData = cloneDeep(application)
Expand All @@ -23,18 +38,7 @@ export const buildRowData = (application) => {
rowData.accessibility = accessibilityKeys.map((key) => capitalize(key.split('_')[0])).join(', ')
}

// Override the key we display for certain cases
let prefKey
if (application.preference_name?.includes('General')) {
prefKey = 'General'
} else if (application.preference_name?.includes('Right to Return')) {
prefKey = 'RtR'
} else {
// TODO: DAH-1904 - clean up references to unused prefrenece type field
prefKey = application.custom_preference_type
? application.custom_preference_type
: application.preference_record_type
}
const prefKey = getPrefKey(application)

rowData.preference_rank = getRank(prefKey, application.preference_lottery_rank)
const prefNum = parseFloat(application.preference_order)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ describe('LeaseUpApplicationsTableContainer', () => {
expect(buildRowData(application).preference_rank).toBe('General 13')
application.preference_name = 'Alice Griffith'
expect(buildRowData(application).preference_rank).toBe('AG 13')
application.preference_name = 'Tier 1 General Pool'
application.custom_preference_type = 'T1-G'
expect(buildRowData(application).preference_rank).toBe('T1-General 13')
})
})
})

0 comments on commit 1f2fc29

Please sign in to comment.