mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-04-14 11:38:31 -04:00
Rename Lovers -> Profiles
This commit is contained in:
@@ -9,7 +9,7 @@ import {log} from 'shared/monitoring/log'
|
||||
import {metrics} from 'shared/monitoring/metrics'
|
||||
import {banUser} from './ban-user'
|
||||
import {blockUser, unblockUser} from './block-user'
|
||||
import {getCompatibleLoversHandler} from './compatible-profiles'
|
||||
import {getCompatibleProfilesHandler} from './compatible-profiles'
|
||||
import {createComment} from './create-comment'
|
||||
import {createCompatibilityQuestion} from './create-compatibility-question'
|
||||
import {createLover} from './create-lover'
|
||||
@@ -31,7 +31,7 @@ import {removePinnedPhoto} from './remove-pinned-photo'
|
||||
import {report} from './report'
|
||||
import {searchLocation} from './search-location'
|
||||
import {searchNearCity} from './search-near-city'
|
||||
import {shipLovers} from './ship-profiles'
|
||||
import {shipProfiles} from './ship-profiles'
|
||||
import {starLover} from './star-lover'
|
||||
import {updateLover} from './update-lover'
|
||||
import {updateMe} from './update-me'
|
||||
@@ -142,7 +142,7 @@ const handlers: { [k in APIPath]: APIHandler<k> } = {
|
||||
'me/delete': deleteMe,
|
||||
'update-lover': updateLover,
|
||||
'like-lover': likeLover,
|
||||
'ship-profiles': shipLovers,
|
||||
'ship-profiles': shipProfiles,
|
||||
'get-likes-and-ships': getLikesAndShips,
|
||||
'has-free-like': hasFreeLike,
|
||||
'star-lover': starLover,
|
||||
@@ -153,7 +153,7 @@ const handlers: { [k in APIPath]: APIHandler<k> } = {
|
||||
'create-comment': createComment,
|
||||
'hide-comment': hideComment,
|
||||
'create-compatibility-question': createCompatibilityQuestion,
|
||||
'compatible-profiles': getCompatibleLoversHandler,
|
||||
'compatible-profiles': getCompatibleProfilesHandler,
|
||||
'search-location': searchLocation,
|
||||
'search-near-city': searchNearCity,
|
||||
'create-private-user-message': createPrivateUserMessage,
|
||||
|
||||
@@ -4,17 +4,17 @@ import { getCompatibilityScore } from 'common/love/compatibility-score'
|
||||
import {
|
||||
getLover,
|
||||
getCompatibilityAnswers,
|
||||
getGenderCompatibleLovers,
|
||||
getGenderCompatibleProfiles,
|
||||
} from 'shared/love/supabase'
|
||||
import { log } from 'shared/utils'
|
||||
|
||||
export const getCompatibleLoversHandler: APIHandler<
|
||||
export const getCompatibleProfilesHandler: APIHandler<
|
||||
'compatible-profiles'
|
||||
> = async (props) => {
|
||||
return getCompatibleLovers(props.userId)
|
||||
return getCompatibleProfiles(props.userId)
|
||||
}
|
||||
|
||||
export const getCompatibleLovers = async (userId: string) => {
|
||||
export const getCompatibleProfiles = async (userId: string) => {
|
||||
const lover = await getLover(userId)
|
||||
|
||||
log('got lover', {
|
||||
@@ -25,7 +25,7 @@ export const getCompatibleLovers = async (userId: string) => {
|
||||
|
||||
if (!lover) throw new APIError(404, 'Lover not found')
|
||||
|
||||
const profiles = await getGenderCompatibleLovers(lover)
|
||||
const profiles = await getGenderCompatibleProfiles(lover)
|
||||
|
||||
const loverAnswers = await getCompatibilityAnswers([
|
||||
userId,
|
||||
@@ -47,7 +47,7 @@ export const getCompatibleLovers = async (userId: string) => {
|
||||
)
|
||||
)
|
||||
|
||||
const sortedCompatibleLovers = sortBy(
|
||||
const sortedCompatibleProfiles = sortBy(
|
||||
profiles,
|
||||
(l) => loverCompatibilityScores[l.user_id].score
|
||||
).reverse()
|
||||
@@ -55,7 +55,7 @@ export const getCompatibleLovers = async (userId: string) => {
|
||||
return {
|
||||
status: 'success',
|
||||
lover,
|
||||
compatibleLovers: sortedCompatibleLovers,
|
||||
compatibleProfiles: sortedCompatibleProfiles,
|
||||
loverCompatibilityScores,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import {type APIHandler} from 'api/helpers/endpoint'
|
||||
import {convertRow} from 'shared/love/supabase'
|
||||
import {createSupabaseDirectClient} from 'shared/supabase/init'
|
||||
import {from, join, limit, orderBy, renderSql, select, where,} from 'shared/supabase/sql-builder'
|
||||
import {getCompatibleLovers} from 'api/compatible-profiles'
|
||||
import {getCompatibleProfiles} from 'api/compatible-profiles'
|
||||
import {intersection} from 'lodash'
|
||||
import {MAX_INT, MIN_INT} from "common/constants";
|
||||
|
||||
@@ -59,8 +59,8 @@ export const loadProfiles = async (props: profileQueryType) => {
|
||||
throw Error('Incompatible with user ID')
|
||||
}
|
||||
|
||||
const {compatibleLovers} = await getCompatibleLovers(compatibleWithUserId)
|
||||
const profiles = compatibleLovers.filter(
|
||||
const {compatibleProfiles} = await getCompatibleProfiles(compatibleWithUserId)
|
||||
const profiles = compatibleProfiles.filter(
|
||||
(l) =>
|
||||
(!name || l.user.name.toLowerCase().includes(name.toLowerCase())) &&
|
||||
(!genders || genders.includes(l.gender)) &&
|
||||
|
||||
@@ -5,7 +5,7 @@ import { log } from 'shared/utils'
|
||||
import { tryCatch } from 'common/util/try-catch'
|
||||
import { insert } from 'shared/supabase/utils'
|
||||
|
||||
export const shipLovers: APIHandler<'ship-profiles'> = async (props, auth) => {
|
||||
export const shipProfiles: APIHandler<'ship-profiles'> = async (props, auth) => {
|
||||
const { targetUserId1, targetUserId2, remove } = props
|
||||
const creatorId = auth.uid
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ export const getProfiles = async (userIds: string[]) => {
|
||||
)
|
||||
}
|
||||
|
||||
export const getGenderCompatibleLovers = async (lover: LoverRow) => {
|
||||
export const getGenderCompatibleProfiles = async (lover: LoverRow) => {
|
||||
const pg = createSupabaseDirectClient()
|
||||
const profiles = await pg.map(
|
||||
`
|
||||
@@ -80,7 +80,7 @@ export const getGenderCompatibleLovers = async (lover: LoverRow) => {
|
||||
return profiles.filter((l: Lover) => areGenderCompatible(lover, l))
|
||||
}
|
||||
|
||||
export const getCompatibleLovers = async (
|
||||
export const getCompatibleProfiles = async (
|
||||
lover: LoverRow,
|
||||
radiusKm: number | undefined
|
||||
) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
contentSchema,
|
||||
combinedLoveUsersSchema,
|
||||
baseLoversSchema,
|
||||
baseProfilesSchema,
|
||||
arraybeSchema,
|
||||
} from 'common/api/zod-types'
|
||||
import { PrivateChatMessage } from 'common/chat-message'
|
||||
@@ -92,7 +92,7 @@ export const API = (_apiTypeCheck = {
|
||||
method: 'POST',
|
||||
authed: true,
|
||||
returns: {} as Row<'profiles'>,
|
||||
props: baseLoversSchema,
|
||||
props: baseProfilesSchema,
|
||||
},
|
||||
report: {
|
||||
method: 'POST',
|
||||
@@ -218,7 +218,7 @@ export const API = (_apiTypeCheck = {
|
||||
props: z.object({ userId: z.string() }),
|
||||
returns: {} as {
|
||||
lover: Lover
|
||||
compatibleLovers: Lover[]
|
||||
compatibleProfiles: Lover[]
|
||||
loverCompatibilityScores: {
|
||||
[userId: string]: CompatibilityScore
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ const genderType = z.string()
|
||||
// ])
|
||||
const genderTypes = z.array(genderType)
|
||||
|
||||
export const baseLoversSchema = z.object({
|
||||
export const baseProfilesSchema = z.object({
|
||||
// Required fields
|
||||
age: z.number().min(18).max(100).optional(),
|
||||
gender: genderType,
|
||||
@@ -74,7 +74,7 @@ export const baseLoversSchema = z.object({
|
||||
referred_by_username: z.string().optional(),
|
||||
})
|
||||
|
||||
const optionalLoversSchema = z.object({
|
||||
const optionalProfilesSchema = z.object({
|
||||
political_beliefs: z.array(z.string()).optional(),
|
||||
religious_belief_strength: z.number().optional(),
|
||||
religious_beliefs: z.string().optional(),
|
||||
@@ -100,4 +100,4 @@ const optionalLoversSchema = z.object({
|
||||
})
|
||||
|
||||
export const combinedLoveUsersSchema =
|
||||
baseLoversSchema.merge(optionalLoversSchema)
|
||||
baseProfilesSchema.merge(optionalProfilesSchema)
|
||||
|
||||
@@ -17,7 +17,7 @@ export type FilterFields = {
|
||||
| 'pref_age_min'
|
||||
| 'pref_age_max'
|
||||
>
|
||||
export const orderLovers = (
|
||||
export const orderProfiles = (
|
||||
profiles: Lover[],
|
||||
starredUserIds: string[] | undefined
|
||||
) => {
|
||||
|
||||
@@ -20,17 +20,17 @@ import { Input } from 'web/components/widgets/input'
|
||||
|
||||
export const BrowseMatchesButton = (props: {
|
||||
lover: Lover
|
||||
potentialLovers: Lover[]
|
||||
potentialProfiles: Lover[]
|
||||
compatibilityScores: Record<string, CompatibilityScore>
|
||||
className?: string
|
||||
}) => {
|
||||
const { lover, potentialLovers, compatibilityScores, className } = props
|
||||
const { lover, potentialProfiles, compatibilityScores, className } = props
|
||||
|
||||
const currentUser = useUser()
|
||||
const isCurrentUser = currentUser?.id === lover.user_id
|
||||
|
||||
const [dialogOpen, setDialogOpen] = useState(false)
|
||||
const key = `comment ${potentialLovers.map((l) => l.id).join(',')}`
|
||||
const key = `comment ${potentialProfiles.map((l) => l.id).join(',')}`
|
||||
const editor = useTextEditor({
|
||||
key,
|
||||
size: 'sm',
|
||||
@@ -82,7 +82,7 @@ export const BrowseMatchesButton = (props: {
|
||||
{dialogOpen && (
|
||||
<BrowseMatchesDialog
|
||||
lover={lover}
|
||||
potentialLovers={potentialLovers}
|
||||
potentialProfiles={potentialProfiles}
|
||||
compatibilityScores={compatibilityScores}
|
||||
isSubmitting={isSubmitting}
|
||||
setOpen={setDialogOpen}
|
||||
@@ -96,7 +96,7 @@ export const BrowseMatchesButton = (props: {
|
||||
|
||||
const BrowseMatchesDialog = (props: {
|
||||
lover: Lover
|
||||
potentialLovers: Lover[]
|
||||
potentialProfiles: Lover[]
|
||||
compatibilityScores: Record<string, CompatibilityScore>
|
||||
isSubmitting: boolean
|
||||
setOpen: (open: boolean) => void
|
||||
@@ -105,7 +105,7 @@ const BrowseMatchesDialog = (props: {
|
||||
}) => {
|
||||
const {
|
||||
lover,
|
||||
potentialLovers,
|
||||
potentialProfiles,
|
||||
compatibilityScores,
|
||||
isSubmitting,
|
||||
setOpen,
|
||||
@@ -119,12 +119,12 @@ const BrowseMatchesDialog = (props: {
|
||||
const currentUser = useUser()
|
||||
const isCurrentUser = currentUser?.id === lover.user_id
|
||||
|
||||
const filteredLovers = potentialLovers.filter((lover) =>
|
||||
const filteredProfiles = potentialProfiles.filter((lover) =>
|
||||
lover.user.name.toLowerCase().includes(query.toLowerCase())
|
||||
)
|
||||
const [potentialIndex, setPotentialIndex] = useState(0)
|
||||
const index = Math.min(potentialIndex, filteredLovers.length - 1)
|
||||
const potentialLover = filteredLovers[index]
|
||||
const index = Math.min(potentialIndex, filteredProfiles.length - 1)
|
||||
const potentialLover = filteredProfiles[index]
|
||||
|
||||
const compatibility = potentialLover
|
||||
? compatibilityScores[potentialLover.user_id]
|
||||
@@ -151,7 +151,7 @@ const BrowseMatchesDialog = (props: {
|
||||
}}
|
||||
/>
|
||||
</Row>
|
||||
{filteredLovers.length === 0 ? (
|
||||
{filteredProfiles.length === 0 ? (
|
||||
<Col className="gap-4">
|
||||
<div>No remaining compatible matches.</div>
|
||||
<Link href="/referrals">
|
||||
@@ -163,7 +163,7 @@ const BrowseMatchesDialog = (props: {
|
||||
className="self-start"
|
||||
page={index}
|
||||
setPage={setPotentialIndex}
|
||||
totalItems={filteredLovers.length}
|
||||
totalItems={filteredProfiles.length}
|
||||
pageSize={1}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -2,7 +2,7 @@ import {Lover} from 'common/love/lover'
|
||||
import {removeNullOrUndefinedProps} from 'common/util/object'
|
||||
import {Search} from 'web/components/filters/search'
|
||||
import {useLover} from 'web/hooks/use-lover'
|
||||
import {useCompatibleLovers} from 'web/hooks/use-profiles'
|
||||
import {useCompatibleProfiles} from 'web/hooks/use-profiles'
|
||||
import {getStars} from 'web/lib/supabase/stars'
|
||||
import Router from 'next/router'
|
||||
import {useCallback, useEffect, useRef, useState} from 'react'
|
||||
@@ -15,7 +15,7 @@ import {usePersistentInMemoryState} from 'web/hooks/use-persistent-in-memory-sta
|
||||
import {useUser} from 'web/hooks/use-user'
|
||||
import {api} from 'web/lib/api'
|
||||
import {useBookmarkedSearches} from "web/hooks/use-bookmarked-searches";
|
||||
import {orderLovers} from "common/filters";
|
||||
import {orderProfiles} from "common/filters";
|
||||
import {useFilters} from "web/components/filters/use-filters";
|
||||
|
||||
export function ProfilesHome() {
|
||||
@@ -32,7 +32,7 @@ export function ProfilesHome() {
|
||||
locationFilterProps,
|
||||
} = useFilters(you ?? undefined);
|
||||
|
||||
const [profiles, setLovers] = usePersistentInMemoryState<Lover[] | undefined>(undefined, 'profile-profiles');
|
||||
const [profiles, setProfiles] = usePersistentInMemoryState<Lover[] | undefined>(undefined, 'profile-profiles');
|
||||
const {bookmarkedSearches, refreshBookmarkedSearches} = useBookmarkedSearches(user?.id)
|
||||
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
||||
const [isReloading, setIsReloading] = useState(false);
|
||||
@@ -60,7 +60,7 @@ export function ProfilesHome() {
|
||||
...filters
|
||||
}) as any)
|
||||
.then(({profiles}) => {
|
||||
if (current === id.current) setLovers(profiles);
|
||||
if (current === id.current) setProfiles(profiles);
|
||||
})
|
||||
.finally(() => {
|
||||
if (current === id.current) setIsReloading(false);
|
||||
@@ -68,8 +68,8 @@ export function ProfilesHome() {
|
||||
}, [filters]);
|
||||
|
||||
const {data: starredUserIds, refresh: refreshStars} = useGetter('star', user?.id, getStars);
|
||||
const compatibleLovers = useCompatibleLovers(user?.id);
|
||||
const displayLovers = profiles && orderLovers(profiles, starredUserIds);
|
||||
const compatibleProfiles = useCompatibleProfiles(user?.id);
|
||||
const displayProfiles = profiles && orderProfiles(profiles, starredUserIds);
|
||||
|
||||
const loadMore = useCallback(async () => {
|
||||
if (!profiles || isLoadingMore) return false;
|
||||
@@ -83,7 +83,7 @@ export function ProfilesHome() {
|
||||
...filters
|
||||
}) as any);
|
||||
if (result.profiles.length === 0) return false;
|
||||
setLovers((prev) => (prev ? [...prev, ...result.profiles] : result.profiles));
|
||||
setProfiles((prev) => (prev ? [...prev, ...result.profiles] : result.profiles));
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.error('Failed to load more profiles', err);
|
||||
@@ -91,7 +91,7 @@ export function ProfilesHome() {
|
||||
} finally {
|
||||
setIsLoadingMore(false);
|
||||
}
|
||||
}, [profiles, filters, isLoadingMore, setLovers]);
|
||||
}, [profiles, filters, isLoadingMore, setProfiles]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -109,15 +109,15 @@ export function ProfilesHome() {
|
||||
bookmarkedSearches={bookmarkedSearches}
|
||||
refreshBookmarkedSearches={refreshBookmarkedSearches}
|
||||
/>
|
||||
{displayLovers === undefined || compatibleLovers === undefined ? (
|
||||
{displayProfiles === undefined || compatibleProfiles === undefined ? (
|
||||
<LoadingIndicator/>
|
||||
) : (
|
||||
<ProfileGrid
|
||||
profiles={displayLovers}
|
||||
profiles={displayProfiles}
|
||||
loadMore={loadMore}
|
||||
isLoadingMore={isLoadingMore}
|
||||
isReloading={isReloading}
|
||||
compatibilityScores={compatibleLovers?.loverCompatibilityScores}
|
||||
compatibilityScores={compatibleProfiles?.loverCompatibilityScores}
|
||||
starredUserIds={starredUserIds}
|
||||
refreshStars={refreshStars}
|
||||
/>
|
||||
|
||||
@@ -6,7 +6,7 @@ import { APIResponse } from 'common/api/schema'
|
||||
import { useLoverByUserId } from './use-lover'
|
||||
import { getProfilesCompatibilityFactor } from 'common/love/compatibility-score'
|
||||
|
||||
export const useCompatibleLovers = (
|
||||
export const useCompatibleProfiles = (
|
||||
userId: string | null | undefined,
|
||||
options?: { sortWithModifiers?: boolean }
|
||||
) => {
|
||||
@@ -31,7 +31,7 @@ export const useCompatibleLovers = (
|
||||
}, [userId])
|
||||
|
||||
if (data && lover && options?.sortWithModifiers) {
|
||||
data.compatibleLovers = sortBy(data.compatibleLovers, (l) => {
|
||||
data.compatibleProfiles = sortBy(data.compatibleProfiles, (l) => {
|
||||
const modifier = !lover ? 1 : getProfilesCompatibilityFactor(lover, l)
|
||||
return -1 * modifier * data.loverCompatibilityScores[l.user.id].score
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user