This commit is contained in:
MartinBraquet
2025-10-27 01:34:30 +01:00
parent cdbc9c305e
commit 9a31cfa938
8 changed files with 15 additions and 30 deletions

View File

@@ -82,4 +82,4 @@ export const initialFilters: Partial<FilterFields> = {
export const FilterKeys = Object.keys(initialFilters) as (keyof FilterFields)[]
export type OriginLocation = { id: string; name: string, lat: number, lon: number }
export type OriginLocation = { id: string; name: string | null, lat: number, lon: number }

View File

@@ -49,8 +49,8 @@ function MobileFilters(props: {
const [openFilter, setOpenFilter] = useState<string | undefined>(undefined)
function hasAny(filterArray: any[] | undefined) {
return filterArray && filterArray.length > 0
function hasAny(filterArray: any[] | undefined | null): boolean {
return !!filterArray && filterArray.length > 0
}
const [noMinAge, noMaxAge] = getNoMinMaxAge(

View File

@@ -69,7 +69,7 @@ export const useFilters = (you: Profile | undefined) => {
education_levels: you?.education_level ? [you.education_level] : undefined,
pref_age_max: (you?.pref_age_max ?? MAX_INT) < 100 ? you?.pref_age_max : undefined,
pref_age_min: (you?.pref_age_min ?? MIN_INT) > 18 ? you?.pref_age_min : undefined,
pref_relation_styles: you?.pref_relation_styles.length ? you.pref_relation_styles : undefined,
pref_relation_styles: you?.pref_relation_styles?.length ? you.pref_relation_styles : undefined,
pref_romantic_styles: you?.pref_romantic_styles?.length ? you.pref_romantic_styles : undefined,
diet: you?.diet?.length ? you.diet : undefined,
political_beliefs: you?.political_beliefs?.length ? you.political_beliefs : undefined,

View File

@@ -1,4 +1,4 @@
import {Fragment, useEffect, useRef, useState} from 'react'
import {Fragment, useRef, useState} from 'react'
import {Title} from 'web/components/widgets/title'
import {Col} from 'web/components/layout/col'
import clsx from 'clsx'
@@ -112,10 +112,6 @@ export const OptionalProfileUserForm = (props: {
}
}
const [trans, setTrans] = useState<boolean | undefined>(
profile['gender'].includes('trans')
)
function setProfileCity(inputCity: City | undefined) {
if (!inputCity) {
setProfile('geodb_city_id', null)
@@ -142,17 +138,6 @@ export const OptionalProfileUserForm = (props: {
}
}
useEffect(() => {
const currentState = profile['gender']
if (currentState === 'non-binary') {
setTrans(undefined)
} else if (trans && !currentState.includes('trans-')) {
setProfile('gender', 'trans-' + currentState.replace('trans-', ''))
} else if (!trans && currentState.includes('trans-')) {
setProfile('gender', currentState.replace('trans-', ''))
}
}, [trans, profile['gender']])
return (
<>
{/*<Row className={'justify-end'}>*/}
@@ -214,7 +199,7 @@ export const OptionalProfileUserForm = (props: {
<Col className={'gap-1'}>
<label className={clsx(labelClassName)}>Gender</label>
<ChoicesToggleGroup
currentChoice={profile['gender'].replace('trans-', '')}
currentChoice={profile['gender']}
choicesMap={{
Woman: 'female',
Man: 'male',
@@ -233,7 +218,7 @@ export const OptionalProfileUserForm = (props: {
Men: 'male',
Other: 'other',
}}
selected={profile['pref_gender']}
selected={profile['pref_gender'] || []}
onChange={(selected) => setProfile('pref_gender', selected)}
/>
</Col>
@@ -282,7 +267,7 @@ export const OptionalProfileUserForm = (props: {
<label className={clsx(labelClassName)}>Connection type</label>
<MultiCheckbox
choices={RELATIONSHIP_CHOICES}
selected={profile['pref_relation_styles']}
selected={profile['pref_relation_styles'] || []}
onChange={(selected) => {
setProfile('pref_relation_styles', selected)
setLookingRelationship((selected || []).includes('relationship'))

View File

@@ -113,9 +113,9 @@ function Seeking(props: { profile: Profile }) {
const max = profile.pref_age_max
const seekingGenderText = stringOrStringArrayToText({
text:
prefGender.length == 5
prefGender?.length == 5
? ['people']
: prefGender.map((gender) => convertGenderPlural(gender as Gender)),
: prefGender?.map((gender) => convertGenderPlural(gender as Gender)),
preText: 'Interested in',
asSentence: true,
capitalizeFirstLetterOption: false,
@@ -150,7 +150,7 @@ function RelationshipType(props: { profile: Profile }) {
const {profile} = props
const relationshipTypes = profile.pref_relation_styles
let seekingGenderText = stringOrStringArrayToText({
text: relationshipTypes.map((rel) =>
text: relationshipTypes?.map((rel) =>
convertRelationshipType(rel as RelationshipType).toLowerCase()
).sort(),
preText: 'Seeking',
@@ -161,7 +161,7 @@ function RelationshipType(props: { profile: Profile }) {
asSentence: true,
capitalizeFirstLetterOption: false,
})
if (relationshipTypes.includes('relationship')) {
if (relationshipTypes?.includes('relationship')) {
const romanticStyles = profile.pref_romantic_styles
?.map((style) => REVERTED_ROMANTIC_CHOICES[style].toLowerCase())
.filter(Boolean)

View File

@@ -11,7 +11,7 @@ function isDigitString(value: string): boolean {
export type City = {
geodb_city_id: string
city: string
city: string | null
region_code: string
country: string
country_code: string

View File

@@ -15,7 +15,7 @@ export type ColorType = keyof typeof colorClasses
export function ChoicesToggleGroup<T extends Record<string, string | number | boolean>>(
props: {
currentChoice: T[keyof T] | undefined
currentChoice: T[keyof T] | undefined | null
choicesMap: T
disabled?: boolean
disabledOptions?: Array<T[keyof T]>

View File

@@ -1,7 +1,7 @@
import { filterDefined } from 'common/util/array'
export default function stringOrStringArrayToText(fields: {
text: string[] | string
text: string[] | string | null | undefined
preText?: string
postText?: string
asSentence?: boolean