Fix connection type

This commit is contained in:
MartinBraquet
2025-09-11 16:21:01 +02:00
parent 4cb14ec8cc
commit 3283843ef3
4 changed files with 39 additions and 44 deletions

View File

@@ -0,0 +1,11 @@
export const RELATIONSHIP_CHOICES = {
Monogamous: 'mono',
Polyamorous: 'poly',
'Open Relationship': 'open',
Other: 'other',
Collaboration: 'collaboration',
Friendship: 'friendship',
Relationship: 'relationship',
};
export const REVERTED_RELATIONSHIP_CHOICES = {}

View File

@@ -1,22 +1,21 @@
import clsx from 'clsx'
import {
RelationshipType,
convertRelationshipType,
} from 'web/lib/util/convert-relationship-type'
import {convertRelationshipType, RelationshipType,} from 'web/lib/util/convert-relationship-type'
import stringOrStringArrayToText from 'web/lib/util/string-or-string-array-to-text'
import { FilterFields } from './search'
import { MultiCheckbox } from 'web/components/multi-checkbox'
import {FilterFields} from './search'
import {MultiCheckbox} from 'web/components/multi-checkbox'
import {RELATIONSHIP_CHOICES} from "web/components/filters/choices";
export function RelationshipFilterText(props: {
relationship: RelationshipType[] | undefined
highlightedClass?: string
}) {
const { relationship, highlightedClass } = props
const {relationship, highlightedClass} = props
const relationshipLength = (relationship ?? []).length
if (!relationship || relationshipLength < 1) {
return (
<span className={clsx('text-semibold', highlightedClass)}>Any style</span>
<span className={clsx('text-semibold', highlightedClass)}>Any connection</span>
)
}
@@ -49,20 +48,13 @@ export function RelationshipFilter(props: {
filters: Partial<FilterFields>
updateFilter: (newState: Partial<FilterFields>) => void
}) {
const { filters, updateFilter } = props
const {filters, updateFilter} = props
return (
<MultiCheckbox
selected={filters.pref_relation_styles ?? []}
choices={
{
Monogamous: 'mono',
Polyamorous: 'poly',
'Open Relationship': 'open',
Other: 'other',
} as any
}
choices={RELATIONSHIP_CHOICES as any}
onChange={(c) => {
updateFilter({ pref_relation_styles: c })
updateFilter({pref_relation_styles: c})
}}
/>
)

View File

@@ -28,6 +28,7 @@ import {City, CityRow, loverToCity, useCitySearch} from "web/components/search-l
import {AddPhotosWidget} from './widgets/add-photos'
import {RadioToggleGroup} from "web/components/widgets/radio-toggle-group";
import {MultipleChoiceOptions} from "common/love/multiple-choice";
import {RELATIONSHIP_CHOICES} from "web/components/filters/choices";
export const OptionalLoveUserForm = (props: {
lover: LoverRow
@@ -225,7 +226,7 @@ export const OptionalLoveUserForm = (props: {
</Col>
<Col className={clsx(colClassName)}>
<label className={clsx(labelClassName)}>Aged between</label>
<label className={clsx(labelClassName)}>Who are aged between</label>
<Row className={'gap-2'}>
<Col>
<span>Min</span>
@@ -262,6 +263,17 @@ export const OptionalLoveUserForm = (props: {
</Row>
</Col>
<Col className={clsx(colClassName)}>
<label className={clsx(labelClassName)}>Connection type</label>
<MultiCheckbox
choices={RELATIONSHIP_CHOICES}
selected={lover['pref_relation_styles']}
onChange={(selected) =>
setLover('pref_relation_styles', selected)
}
/>
</Col>
<Col className={clsx(colClassName, 'pb-4')}>
<label className={clsx(labelClassName)}>Socials</label>
@@ -522,7 +534,7 @@ export const OptionalLoveUserForm = (props: {
{lookingRelationship && <>
<Col className={clsx(colClassName)}>
<label className={clsx(labelClassName)}>
You want to have kids
I would like to have kids
</label>
<RadioToggleGroup
className={'w-44'}
@@ -533,22 +545,6 @@ export const OptionalLoveUserForm = (props: {
currentChoice={lover.wants_kids_strength ?? -1}
/>
</Col>
<Col className={clsx(colClassName)}>
<label className={clsx(labelClassName)}>Relationship style</label>
<MultiCheckbox
choices={{
Monogamous: 'mono',
Polyamorous: 'poly',
'Open Relationship': 'open',
Other: 'other',
}}
selected={lover['pref_relation_styles']}
onChange={(selected) =>
setLover('pref_relation_styles', selected)
}
/>
</Col>
</>}
<Col className={clsx(colClassName)}>

View File

@@ -1,11 +1,7 @@
export type RelationshipType = 'mono' | 'poly' | 'open' | 'other'
import {REVERTED_RELATIONSHIP_CHOICES} from "web/components/filters/choices";
export type RelationshipType = keyof typeof REVERTED_RELATIONSHIP_CHOICES
export function convertRelationshipType(relationshipType: RelationshipType) {
if (relationshipType == 'mono') {
return 'monogamous'
}
if (relationshipType == 'poly') {
return 'polyamorous'
}
return relationshipType
return REVERTED_RELATIONSHIP_CHOICES[relationshipType]
}