mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-25 01:51:37 -04:00
Fix typecheck 2
This commit is contained in:
@@ -5,32 +5,32 @@ import {cloneDeep} from 'lodash'
|
||||
|
||||
export type FilterFields = {
|
||||
orderBy: 'last_online_time' | 'created_time' | 'compatibility_score'
|
||||
last_active: string | undefined
|
||||
geodbCityIds: string[] | null
|
||||
lat: number | null
|
||||
lon: number | null
|
||||
radius: number | null
|
||||
raised_in_lat: number | null
|
||||
raised_in_lon: number | null
|
||||
raised_in_radius: number | null
|
||||
genders: string[]
|
||||
education_levels: string[]
|
||||
mbti: string[]
|
||||
name: string | undefined
|
||||
shortBio: boolean | undefined
|
||||
drinks_min: number | undefined
|
||||
drinks_max: number | undefined
|
||||
last_active: string | null | undefined
|
||||
geodbCityIds: string[] | null | undefined
|
||||
lat: number | null | undefined
|
||||
lon: number | null | undefined
|
||||
radius: number | null | undefined
|
||||
raised_in_lat: number | null | undefined
|
||||
raised_in_lon: number | null | undefined
|
||||
raised_in_radius: number | null | undefined
|
||||
genders: string[] | null | undefined
|
||||
education_levels: string[] | null | undefined
|
||||
mbti: string[] | null | undefined
|
||||
name: string | null | undefined
|
||||
shortBio: boolean | null | undefined
|
||||
drinks_min: number | null | undefined
|
||||
drinks_max: number | null | undefined
|
||||
// Big Five personality filters (0-100 range)
|
||||
big5_openness_min: number | undefined
|
||||
big5_openness_max: number | undefined
|
||||
big5_conscientiousness_min: number | undefined
|
||||
big5_conscientiousness_max: number | undefined
|
||||
big5_extraversion_min: number | undefined
|
||||
big5_extraversion_max: number | undefined
|
||||
big5_agreeableness_min: number | undefined
|
||||
big5_agreeableness_max: number | undefined
|
||||
big5_neuroticism_min: number | undefined
|
||||
big5_neuroticism_max: number | undefined
|
||||
big5_openness_min: number | null | undefined
|
||||
big5_openness_max: number | null | undefined
|
||||
big5_conscientiousness_min: number | null | undefined
|
||||
big5_conscientiousness_max: number | null | undefined
|
||||
big5_extraversion_min: number | null | undefined
|
||||
big5_extraversion_max: number | null | undefined
|
||||
big5_agreeableness_min: number | null | undefined
|
||||
big5_agreeableness_max: number | null | undefined
|
||||
big5_neuroticism_min: number | null | undefined
|
||||
big5_neuroticism_max: number | null | undefined
|
||||
} & {
|
||||
[K in OptionTableKey]: string[]
|
||||
} & Pick<
|
||||
|
||||
@@ -32,10 +32,20 @@ export function groupConsecutive<T, U>(xs: T[], key: (x: T) => U) {
|
||||
return result
|
||||
}
|
||||
|
||||
export function nullifyEmpty<T>(array: T[]) {
|
||||
export function undefineEmpty<T>(array: T[]): T[] | undefined {
|
||||
// Undefine a list if empty ([])
|
||||
return fallbackIfEmpty(array, undefined)
|
||||
}
|
||||
|
||||
export function nullifyEmpty<T>(array: T[]): T[] | null {
|
||||
// Nullify a list if empty ([])
|
||||
if (!Array.isArray(array)) return null
|
||||
return array.length > 0 ? array : null
|
||||
return fallbackIfEmpty(array, null)
|
||||
}
|
||||
|
||||
export function fallbackIfEmpty<T>(array: T[], fallback: any) {
|
||||
// Fallback a list if empty ([])
|
||||
if (!Array.isArray(array)) return fallback
|
||||
return array.length > 0 ? array : fallback
|
||||
}
|
||||
|
||||
export function nullifyDictValues(array: Record<any, any>) {
|
||||
|
||||
@@ -26,7 +26,7 @@ export function AddOptionEntry(props: {
|
||||
<MultiCheckbox
|
||||
choices={sortedChoices}
|
||||
selected={(profile[label] ?? []).map((s) => String(s))}
|
||||
onChange={(selected) => setProfile(label, selected)}
|
||||
onChange={(selected) => setProfile(label, selected as string[] | undefined)}
|
||||
addOption={(v: string) => {
|
||||
console.log(`Adding ${label}:`, v)
|
||||
setChoices((prev: string[]) => ({...prev, [v]: v}))
|
||||
|
||||
@@ -7,7 +7,7 @@ import {useT} from 'web/lib/locale'
|
||||
const DEFAULT_KEY = 'any'
|
||||
|
||||
export function LastActiveFilterText(props: {
|
||||
last_active: string | undefined
|
||||
last_active: string | undefined | null
|
||||
highlightedClass?: string
|
||||
}) {
|
||||
const {last_active, highlightedClass} = props
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import clsx from 'clsx'
|
||||
import {RELATIONSHIP_CHOICES} from 'common/choices'
|
||||
import {FilterFields} from 'common/filters'
|
||||
import {nullifyEmpty} from 'common/util/array'
|
||||
import {MultiCheckbox} from 'web/components/multi-checkbox'
|
||||
import {useT} from 'web/lib/locale'
|
||||
import {convertRelationshipType, RelationshipType} from 'web/lib/util/convert-types'
|
||||
@@ -60,7 +59,7 @@ export function RelationshipFilter(props: {
|
||||
choices={RELATIONSHIP_CHOICES as any}
|
||||
translationPrefix={'profile.relationship'}
|
||||
onChange={(c) => {
|
||||
updateFilter({pref_relation_styles: nullifyEmpty(c)})
|
||||
updateFilter({pref_relation_styles: c})
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user