Files
Compass/web/lib/profile/seeking.ts
Martin Braquet ba9b3cfb06 Add pretty formatting (#29)
* 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
2026-02-20 17:32:27 +01:00

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
}