Convert status data to objects

This commit is contained in:
Sam Carlton 2022-05-18 12:07:53 -05:00
parent ec8a789c9a
commit 32c0d81bff

View file

@ -2,16 +2,42 @@
const statuses = { const statuses = {
'✅': 'native', 'native': {
'✳️': 'rosetta', icon: '✅',
'⏹': 'no-in-progress', filterLabel: 'Native Support',
'🚫': 'no', snakeSlug: 'native',
'🔶': 'unreported', },
'rosetta': {
icon: '✳️',
filterLabel: 'Rosetta',
snakeSlug: 'rosetta',
},
'no-in-progress': {
icon: '⏹',
filterLabel: 'In Progress',
snakeSlug: 'no_in_progress',
},
'no': {
icon: '🚫',
filterLabel: 'Unsupported',
snakeSlug: 'no',
},
'unreported': {
icon: '🔶',
filterLabel: 'Unreported',
snakeSlug: 'unreported',
}
} }
const statusesByIcon = Object.keys( statuses ).reduce( ( acc, key ) => {
const status = statuses[ key ]
acc[ status.icon ] = key
return acc
}, {} )
export function getStatusName ( status ) { export function getStatusName ( status ) {
for (const key in statuses) { for (const key in statusesByIcon) {
if (status.trim().startsWith( key )) return statuses[key] if (status.trim().startsWith( key )) return statusesByIcon[key]
} }
throw new Error('Non status matched') throw new Error('Non status matched')
@ -33,4 +59,4 @@ export function getStatusOfScan ( appScan, includeVersion = true ) {
} }
export default statuses export default statusesByIcon