): ReactElement | null {
+ const entries: ReactElement[] = []
+
+ let ageEntry = null
+ let ageMin: number | undefined = filters.pref_age_min
+ if (ageMin == 18) ageMin = undefined
+ let ageMax = filters.pref_age_max;
+ if (ageMax == 99) ageMax = undefined
+ if (ageMin || ageMax) {
+ let text: string = 'Age: '
+ if (ageMin) text = `${text}${ageMin}`
+ if (ageMax) {
+ if (ageMin) {
+ text = `${text}-${ageMax}`
+ } else {
+ text = `${text}up to ${ageMax}`
+ }
+ } else {
+ text = `${text}+`
+ }
+ ageEntry = {text}
+ }
+
+ Object.entries(filters).forEach(([key, value]) => {
+ const typedKey = key as keyof FilterFields
+
+ if (!value) return
+ if (typedKey == 'pref_age_min' || typedKey == 'pref_age_max' || typedKey == 'geodbCityIds') return
+ if (Array.isArray(value) && value.length === 0) return
+ if (initialFilters[typedKey] === value) return
+
+ const label = filterLabels[typedKey] ?? key
+
+ let stringValue = value
+ if (key === 'has_kids') stringValue = hasKidsNames[value as number]
+ if (key === 'wants_kids_strength') stringValue = wantsKidsNames[value as number]
+ if (key === 'location') stringValue = `${(value as locationType)?.location?.name} (${(value as locationType)?.radius}mi)`
+ if (Array.isArray(value)) stringValue = value.join(', ')
+
+ if (!label) {
+ const str = String(stringValue)
+ stringValue = str.charAt(0).toUpperCase() + str.slice(1)
+ }
+
+ let display: ReactElement
+ display = key === 'name'
+ ? {stringValue as string}
+ : <>{stringValue}>
+
+ entries.push(
+
+ {label}
+ {label ? ': ' : ''}
+ {display}
+
+ )
+ })
+
+ if (ageEntry) entries.push(ageEntry)
+
+ if (entries.length === 0) return null
+
+ // Join with " • " separators
+ return (
+
+ {entries.map((entry, i) => (
+
+ {entry}
+ {i < entries.length - 1 ? ' • ' : ''}
+
+ ))}
+
+ )
+}
+
function ButtonModal(props: {
open: boolean
setOpen: (open: boolean) => void
@@ -61,44 +162,31 @@ function ButtonModal(props: {
}}
>
- Bookmarked Searches
- We'll notify you daily when new people match your searches below.
+ Bookmarked Searches
+ We'll notify you daily when new people match your searches below.
- {(bookmarkedSearches || []).map((search) => (
-
-
- {JSON.stringify(
- Object.fromEntries(
- Object.entries(search.search_filters as Record).filter(([key, value]) => {
- // skip null/undefined
- if (value == null) return false
+
+ {(bookmarkedSearches || []).map((search) => (
+ -
+ {formatFilters(search.search_filters as Partial)}
+
+
+ ))}
+
- // skip empty arrays
- if (Array.isArray(value) && value.length === 0) return false
-
- // keep if different from initialFilters
- return initialFilters[key as keyof FilterFields] !== value
- })
-
- )
- )}
-
-
-
-
- ))}
{/*,
- userId: string | undefined | null
+ locationFilterProps: any,
+ userId: string | undefined | null,
) => {
if (!filters) return
if (!userId) return
- const row = {search_filters: filters, creator_id: userId}
+ const fullFilter = {...filters, ...{location: locationFilterProps}}
+
+ const row = {search_filters: fullFilter, creator_id: userId}
const input = {
...filterKeys(row, (key, _) => !['id', 'created_time', 'last_notified_at'].includes(key)),
} as BookmarkedSearchSubmitType