mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-25 10:02:27 -04:00
* Test * Add pretty formatting * Fix Tests * Fix Tests * Fix Tests * Fix * Add pretty formatting fix * Fix * Test * Fix tests * Clean typeckech * Add prettier check * Fix api tsconfig * Fix api tsconfig * Fix tsconfig * Fix * Fix * Prettier
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import {INVERTED_ROMANTIC_CHOICES} from 'common/choices'
|
|
import {Profile} from 'common/profiles/profile'
|
|
import {convertRelationshipType, RelationshipType} from 'web/lib/util/convert-types'
|
|
import stringOrStringArrayToText from 'web/lib/util/string-or-string-array-to-text'
|
|
|
|
export function getSeekingGenderText(profile: Profile, t: any) {
|
|
const relationshipTypes = profile.pref_relation_styles
|
|
if (!relationshipTypes?.length) return ''
|
|
let seekingGenderText = stringOrStringArrayToText({
|
|
text: relationshipTypes
|
|
?.map((rel) =>
|
|
t(
|
|
`profile.relationship.${rel}`,
|
|
convertRelationshipType(rel as RelationshipType),
|
|
).toLowerCase(),
|
|
)
|
|
.sort(),
|
|
preText: t('profile.seeking', 'Seeking'),
|
|
asSentence: true,
|
|
capitalizeFirstLetterOption: false,
|
|
t: t,
|
|
})
|
|
if (relationshipTypes?.includes('relationship')) {
|
|
const romanticStyles = profile.pref_romantic_styles
|
|
?.map((style) =>
|
|
t(`profile.romantic.${style}`, INVERTED_ROMANTIC_CHOICES[style]).toLowerCase(),
|
|
)
|
|
.filter(Boolean)
|
|
if (romanticStyles && romanticStyles.length > 0) {
|
|
seekingGenderText += ` (${romanticStyles.join(', ')})`
|
|
}
|
|
}
|
|
return seekingGenderText
|
|
}
|