Rename Lover -> Profile

This commit is contained in:
MartinBraquet
2025-09-17 15:43:19 +02:00
parent c6a139d88d
commit 593617c0ff
70 changed files with 506 additions and 506 deletions

View File

@@ -12,11 +12,11 @@ import {blockUser, unblockUser} from './block-user'
import {getCompatibleProfilesHandler} from './compatible-profiles'
import {createComment} from './create-comment'
import {createCompatibilityQuestion} from './create-compatibility-question'
import {createLover} from './create-lover'
import {createProfile} from './create-lover'
import {createUser} from './create-user'
import {getCompatibilityQuestions} from './get-compatibililty-questions'
import {getLikesAndShips} from './get-likes-and-ships'
import {getLoverAnswers} from './get-lover-answers'
import {getProfileAnswers} from './get-lover-answers'
import {getProfiles} from './get-profiles'
import {getSupabaseToken} from './get-supabase-token'
import {getDisplayUser, getUser} from './get-user'
@@ -25,15 +25,15 @@ import {hasFreeLike} from './has-free-like'
import {health} from './health'
import {type APIHandler, typedEndpoint} from './helpers/endpoint'
import {hideComment} from './hide-comment'
import {likeLover} from './like-lover'
import {likeProfile} from './like-lover'
import {markAllNotifsRead} from './mark-all-notifications-read'
import {removePinnedPhoto} from './remove-pinned-photo'
import {report} from './report'
import {searchLocation} from './search-location'
import {searchNearCity} from './search-near-city'
import {shipProfiles} from './ship-profiles'
import {starLover} from './star-lover'
import {updateLover} from './update-lover'
import {starProfile} from './star-lover'
import {updateProfile} from './update-lover'
import {updateMe} from './update-me'
import {deleteMe} from './delete-me'
import {getCurrentPrivateUser} from './get-current-private-user'
@@ -134,20 +134,20 @@ const handlers: { [k in APIPath]: APIHandler<k> } = {
'ban-user': banUser,
report: report,
'create-user': createUser,
'create-lover': createLover,
'create-lover': createProfile,
me: getMe,
'me/private': getCurrentPrivateUser,
'me/update': updateMe,
'update-notif-settings': updateNotifSettings,
'me/delete': deleteMe,
'update-lover': updateLover,
'like-lover': likeLover,
'update-lover': updateProfile,
'like-lover': likeProfile,
'ship-profiles': shipProfiles,
'get-likes-and-ships': getLikesAndShips,
'has-free-like': hasFreeLike,
'star-lover': starLover,
'star-lover': starProfile,
'get-profiles': getProfiles,
'get-lover-answers': getLoverAnswers,
'get-lover-answers': getProfileAnswers,
'get-compatibility-questions': getCompatibilityQuestions,
'remove-pinned-photo': removePinnedPhoto,
'create-comment': createComment,

View File

@@ -2,7 +2,7 @@ import { groupBy, sortBy } from 'lodash'
import { APIError, type APIHandler } from 'api/helpers/endpoint'
import { getCompatibilityScore } from 'common/love/compatibility-score'
import {
getLover,
getProfile,
getCompatibilityAnswers,
getGenderCompatibleProfiles,
} from 'shared/love/supabase'
@@ -15,7 +15,7 @@ export const getCompatibleProfilesHandler: APIHandler<
}
export const getCompatibleProfiles = async (userId: string) => {
const lover = await getLover(userId)
const lover = await getProfile(userId)
log('got lover', {
id: lover?.id,
@@ -23,7 +23,7 @@ export const getCompatibleProfiles = async (userId: string) => {
username: lover?.user?.username,
})
if (!lover) throw new APIError(404, 'Lover not found')
if (!lover) throw new APIError(404, 'Profile not found')
const profiles = await getGenderCompatibleProfiles(lover)

View File

@@ -46,7 +46,7 @@ export const createComment: APIHandler<'create-comment'> = async (
]
)
if (onUser.id !== creator.id)
await createNewCommentOnLoverNotification(
await createNewCommentOnProfileNotification(
onUser,
creator,
richTextToString(content),
@@ -84,7 +84,7 @@ const validateComment = async (
return { content, creator }
}
const createNewCommentOnLoverNotification = async (
const createNewCommentOnProfileNotification = async (
onUser: User,
creator: User,
sourceText: string,

View File

@@ -8,7 +8,7 @@ import { updateUser } from 'shared/supabase/users'
import { tryCatch } from 'common/util/try-catch'
import { insert } from 'shared/supabase/utils'
export const createLover: APIHandler<'create-lover'> = async (body, auth) => {
export const createProfile: APIHandler<'create-lover'> = async (body, auth) => {
const pg = createSupabaseDirectClient()
const { data: existingUser } = await tryCatch(

View File

@@ -2,7 +2,7 @@ import { type APIHandler } from 'api/helpers/endpoint'
import { createSupabaseDirectClient } from 'shared/supabase/init'
import { Row } from 'common/supabase/utils'
export const getLoverAnswers: APIHandler<'get-lover-answers'> = async (
export const getProfileAnswers: APIHandler<'get-lover-answers'> = async (
props,
_auth
) => {

View File

@@ -6,7 +6,7 @@ import { log } from 'shared/utils'
import { tryCatch } from 'common/util/try-catch'
import { Row } from 'common/supabase/utils'
export const likeLover: APIHandler<'like-lover'> = async (props, auth) => {
export const likeProfile: APIHandler<'like-lover'> = async (props, auth) => {
const { targetUserId, remove } = props
const creatorId = auth.uid

View File

@@ -5,7 +5,7 @@ import { tryCatch } from 'common/util/try-catch'
import { Row } from 'common/supabase/utils'
import { insert } from 'shared/supabase/utils'
export const starLover: APIHandler<'star-lover'> = async (props, auth) => {
export const starProfile: APIHandler<'star-lover'> = async (props, auth) => {
const { targetUserId, remove } = props
const creatorId = auth.uid

View File

@@ -7,21 +7,21 @@ import { tryCatch } from 'common/util/try-catch'
import { update } from 'shared/supabase/utils'
import { type Row } from 'common/supabase/utils'
export const updateLover: APIHandler<'update-lover'> = async (
export const updateProfile: APIHandler<'update-lover'> = async (
parsedBody,
auth
) => {
log('parsedBody', parsedBody)
const pg = createSupabaseDirectClient()
const { data: existingLover } = await tryCatch(
const { data: existingProfile } = await tryCatch(
pg.oneOrNone<Row<'profiles'>>('select * from profiles where user_id = $1', [
auth.uid,
])
)
if (!existingLover) {
throw new APIError(404, 'Lover not found')
if (!existingProfile) {
throw new APIError(404, 'Profile not found')
}
!parsedBody.last_online_time &&

View File

@@ -4,7 +4,7 @@ import {sendEmail} from './send-email'
import {NewMessageEmail} from '../new-message'
import {NewEndorsementEmail} from '../new-endorsement'
import {Test} from '../test'
import {getLover} from 'shared/love/supabase'
import {getProfile} from 'shared/love/supabase'
import { render } from "@react-email/render"
import {MatchesType} from "common/love/bookmarked_searches";
import NewSearchAlertsEmail from "email/new-search_alerts";
@@ -20,7 +20,7 @@ const from = 'Compass <no-reply@compassmeet.com>'
// 'new_match'
// )
// if (!privateUser.email || !sendToEmail) return
// const lover = await getLover(privateUser.id)
// const lover = await getProfile(privateUser.id)
// if (!lover) return
//
// return await sendEmail({
@@ -32,7 +32,7 @@ const from = 'Compass <no-reply@compassmeet.com>'
// onUser={lover.user}
// email={privateUser.email}
// matchedWithUser={matchedWithUser}
// matchedLover={lover}
// matchedProfile={lover}
// unsubscribeUrl={unsubscribeUrl}
// />
// ),
@@ -51,7 +51,7 @@ export const sendNewMessageEmail = async (
)
if (!privateUser.email || !sendToEmail) return
const lover = await getLover(fromUser.id)
const lover = await getProfile(fromUser.id)
if (!lover) {
console.error('Could not send email notification: User not found')
@@ -65,7 +65,7 @@ export const sendNewMessageEmail = async (
html: await render(
<NewMessageEmail
fromUser={fromUser}
fromUserLover={lover}
fromUserProfile={lover}
toUser={toUser}
channelId={channelId}
unsubscribeUrl={unsubscribeUrl}

View File

@@ -1,4 +1,4 @@
import { LoverRow } from 'common/love/lover'
import { ProfileRow } from 'common/love/lover'
import type { User } from 'common/user'
// for email template testing
@@ -27,7 +27,7 @@ export const sinclairUser: User = {
},
}
export const sinclairLover: LoverRow = {
export const sinclairProfile: ProfileRow = {
id: 55,
user_id: '0k1suGSJKVUnHbCPEhHNpgZPkUP2',
created_time: '2023-10-27T00:41:59.851776+00:00',
@@ -125,7 +125,7 @@ export const jamesUser: User = {
},
}
export const jamesLover: LoverRow = {
export const jamesProfile: ProfileRow = {
id: 2,
user_id: '5LZ4LgYuySdL1huCWe7bti02ghx2',
created_time: '2023-10-21T21:18:26.691211+00:00',

View File

@@ -1,14 +1,14 @@
import {Body, Button, Container, Head, Html, Preview, Section, Text,} from '@react-email/components'
import {DOMAIN} from 'common/envs/constants'
import {type LoverRow} from 'common/love/lover'
import {type ProfileRow} from 'common/love/lover'
import {type User} from 'common/user'
import {jamesLover, jamesUser, sinclairUser} from './functions/mock'
import {jamesProfile, jamesUser, sinclairUser} from './functions/mock'
import {Footer} from "email/utils";
interface NewMatchEmailProps {
onUser: User
matchedWithUser: User
matchedLover: LoverRow
matchedProfile: ProfileRow
unsubscribeUrl: string
email?: string
}
@@ -16,12 +16,12 @@ interface NewMatchEmailProps {
export const NewMatchEmail = ({
onUser,
matchedWithUser,
matchedLover,
matchedProfile,
unsubscribeUrl,
email
}: NewMatchEmailProps) => {
const name = onUser.name.split(' ')[0]
// const userImgSrc = getLoveOgImageUrl(matchedWithUser, matchedLover)
// const userImgSrc = getLoveOgImageUrl(matchedWithUser, matchedProfile)
const userUrl = `https://${DOMAIN}/${matchedWithUser.username}`
return (
@@ -72,7 +72,7 @@ export const NewMatchEmail = ({
NewMatchEmail.PreviewProps = {
onUser: sinclairUser,
matchedWithUser: jamesUser,
matchedLover: jamesLover,
matchedProfile: jamesProfile,
email: 'someone@gmail.com',
unsubscribeUrl: 'https://compassmeet.com/unsubscribe',
} as NewMatchEmailProps

View File

@@ -11,11 +11,11 @@ import {
Text,
} from '@react-email/components'
import { type User } from 'common/user'
import { type LoverRow } from 'common/love/lover'
import { type ProfileRow } from 'common/love/lover'
import {
jamesLover,
jamesProfile,
jamesUser,
sinclairLover,
sinclairProfile,
sinclairUser,
} from './functions/mock'
import { DOMAIN } from 'common/envs/constants'
@@ -24,7 +24,7 @@ import {button, container, content, Footer, imageContainer, main, paragraph, pro
interface NewMessageEmailProps {
fromUser: User
fromUserLover: LoverRow
fromUserProfile: ProfileRow
toUser: User
channelId: number
unsubscribeUrl: string
@@ -33,7 +33,7 @@ interface NewMessageEmailProps {
export const NewMessageEmail = ({
fromUser,
fromUserLover,
fromUserProfile,
toUser,
channelId,
unsubscribeUrl,
@@ -42,7 +42,7 @@ export const NewMessageEmail = ({
const name = toUser.name.split(' ')[0]
const creatorName = fromUser.name
const messagesUrl = `https://${DOMAIN}/messages/${channelId}`
const userImgSrc = getLoveOgImageUrl(fromUser, fromUserLover)
const userImgSrc = getLoveOgImageUrl(fromUser, fromUserProfile)
return (
<Html>
@@ -90,7 +90,7 @@ export const NewMessageEmail = ({
NewMessageEmail.PreviewProps = {
fromUser: jamesUser,
fromUserLover: jamesLover,
fromUserProfile: jamesProfile,
toUser: sinclairUser,
channelId: 1,
email: 'someone@gmail.com',

View File

@@ -4,13 +4,13 @@ import { createSupabaseDirectClient } from './supabase/init'
import { getNotificationDestinationsForUser } from 'common/user-notification-preferences'
import { Notification } from 'common/notifications'
import { insertNotificationToSupabase } from './supabase/notifications'
import { getLover } from './love/supabase'
import { getProfile } from './love/supabase'
export const createLoveLikeNotification = async (like: Row<'love_likes'>) => {
const { creator_id, target_id, like_id } = like
const targetPrivateUser = await getPrivateUser(target_id)
const lover = await getLover(creator_id)
const lover = await getProfile(creator_id)
if (!targetPrivateUser || !lover) return
@@ -48,7 +48,7 @@ export const createLoveShipNotification = async (
const creator = await getUser(creator_id)
const targetPrivateUser = await getPrivateUser(recipientId)
const lover = await getLover(otherTargetId)
const lover = await getProfile(otherTargetId)
if (!creator || !targetPrivateUser || !lover) {
console.error('Could not load user object', {

View File

@@ -1,28 +1,28 @@
import { areGenderCompatible } from 'common/love/compatibility-util'
import { type Lover, type LoverRow } from 'common/love/lover'
import { type Profile, type ProfileRow } from 'common/love/lover'
import { type User } from 'common/user'
import { Row } from 'common/supabase/utils'
import { createSupabaseDirectClient } from 'shared/supabase/init'
export type LoverAndUserRow = LoverRow & {
export type ProfileAndUserRow = ProfileRow & {
name: string
username: string
user: any
}
export function convertRow(row: LoverAndUserRow): Lover
export function convertRow(row: LoverAndUserRow | undefined): Lover | null {
export function convertRow(row: ProfileAndUserRow): Profile
export function convertRow(row: ProfileAndUserRow | undefined): Profile | null {
if (!row) return null
return {
...row,
user: { ...row.user, name: row.name, username: row.username } as User,
} as Lover
} as Profile
}
const LOVER_COLS = 'profiles.*, name, username, users.data as user'
export const getLover = async (userId: string) => {
export const getProfile = async (userId: string) => {
const pg = createSupabaseDirectClient()
return await pg.oneOrNone(
`
@@ -58,7 +58,7 @@ export const getProfiles = async (userIds: string[]) => {
)
}
export const getGenderCompatibleProfiles = async (lover: LoverRow) => {
export const getGenderCompatibleProfiles = async (lover: ProfileRow) => {
const pg = createSupabaseDirectClient()
const profiles = await pg.map(
`
@@ -77,11 +77,11 @@ export const getGenderCompatibleProfiles = async (lover: LoverRow) => {
{ ...lover },
convertRow
)
return profiles.filter((l: Lover) => areGenderCompatible(lover, l))
return profiles.filter((l: Profile) => areGenderCompatible(lover, l))
}
export const getCompatibleProfiles = async (
lover: LoverRow,
lover: ProfileRow,
radiusKm: number | undefined
) => {
const pg = createSupabaseDirectClient()

View File

@@ -7,7 +7,7 @@ import {
import { PrivateChatMessage } from 'common/chat-message'
import { CompatibilityScore } from 'common/love/compatibility-score'
import { MAX_COMPATIBILITY_QUESTION_LENGTH } from 'common/love/constants'
import { Lover, LoverRow } from 'common/love/lover'
import { Profile, ProfileRow } from 'common/love/lover'
import { Row } from 'common/supabase/utils'
import { PrivateUser, User } from 'common/user'
import { z } from 'zod'
@@ -147,7 +147,7 @@ export const API = (_apiTypeCheck = {
method: 'POST',
authed: true,
props: combinedLoveUsersSchema.partial(),
returns: {} as LoverRow,
returns: {} as ProfileRow,
},
'update-notif-settings': {
method: 'POST',
@@ -217,8 +217,8 @@ export const API = (_apiTypeCheck = {
authed: false,
props: z.object({ userId: z.string() }),
returns: {} as {
lover: Lover
compatibleProfiles: Lover[]
lover: Profile
compatibleProfiles: Profile[]
loverCompatibilityScores: {
[userId: string]: CompatibilityScore
}
@@ -331,7 +331,7 @@ export const API = (_apiTypeCheck = {
.strict(),
returns: {} as {
status: 'success' | 'fail'
profiles: Lover[]
profiles: Profile[]
},
},
'get-lover-answers': {

View File

@@ -1,4 +1,4 @@
import {Lover, LoverRow} from "common/love/lover";
import {Profile, ProfileRow} from "common/love/lover";
import {cloneDeep} from "lodash";
import {filterDefined} from "common/util/array";
@@ -8,7 +8,7 @@ export type FilterFields = {
genders: string[]
name: string | undefined
} & Pick<
LoverRow,
ProfileRow,
| 'wants_kids_strength'
| 'pref_relation_styles'
| 'is_smoker'
@@ -18,7 +18,7 @@ export type FilterFields = {
| 'pref_age_max'
>
export const orderProfiles = (
profiles: Lover[],
profiles: Profile[],
starredUserIds: string[] | undefined
) => {
if (!profiles) return

View File

@@ -1,5 +1,5 @@
import { keyBy, sumBy } from 'lodash'
import { LoverRow } from 'common/love/lover'
import { ProfileRow } from 'common/love/lover'
import { Row as rowFor } from 'common/supabase/utils'
import {
areAgeCompatible,
@@ -133,8 +133,8 @@ export function getScoredAnswerCompatibility(
}
export const getProfilesCompatibilityFactor = (
lover1: LoverRow,
lover2: LoverRow
lover1: ProfileRow,
lover2: ProfileRow
) => {
let multiplier = 1
multiplier *= areAgeCompatible(lover1, lover2) ? 1 : 0.5

View File

@@ -1,4 +1,4 @@
import { LoverRow } from 'common/love/lover'
import { ProfileRow } from 'common/love/lover'
import {MAX_INT, MIN_INT} from "common/constants";
const isPreferredGender = (
@@ -18,7 +18,7 @@ const isPreferredGender = (
return preferredGenders.includes(gender) || gender === 'non-binary'
}
export const areGenderCompatible = (lover1: LoverRow, lover2: LoverRow) => {
export const areGenderCompatible = (lover1: ProfileRow, lover2: ProfileRow) => {
// console.log('areGenderCompatible', isPreferredGender(lover1.pref_gender, lover2.gender), isPreferredGender(lover2.pref_gender, lover1.gender))
return (
isPreferredGender(lover1.pref_gender, lover2.gender) &&
@@ -26,18 +26,18 @@ export const areGenderCompatible = (lover1: LoverRow, lover2: LoverRow) => {
)
}
const satisfiesAgeRange = (lover: LoverRow, age: number | null | undefined) => {
const satisfiesAgeRange = (lover: ProfileRow, age: number | null | undefined) => {
return (age ?? MAX_INT) >= (lover.pref_age_min ?? MIN_INT) && (age ?? MIN_INT) <= (lover.pref_age_max ?? MAX_INT)
}
export const areAgeCompatible = (lover1: LoverRow, lover2: LoverRow) => {
export const areAgeCompatible = (lover1: ProfileRow, lover2: ProfileRow) => {
return (
satisfiesAgeRange(lover1, lover2.age) &&
satisfiesAgeRange(lover2, lover1.age)
)
}
export const areLocationCompatible = (lover1: LoverRow, lover2: LoverRow) => {
export const areLocationCompatible = (lover1: ProfileRow, lover2: ProfileRow) => {
if (
!lover1.city_latitude ||
!lover2.city_latitude ||
@@ -54,15 +54,15 @@ export const areLocationCompatible = (lover1: LoverRow, lover2: LoverRow) => {
}
export const areRelationshipStyleCompatible = (
lover1: LoverRow,
lover2: LoverRow
lover1: ProfileRow,
lover2: ProfileRow
) => {
return lover1.pref_relation_styles.some((style) =>
lover2.pref_relation_styles.includes(style)
)
}
export const areWantKidsCompatible = (lover1: LoverRow, lover2: LoverRow) => {
export const areWantKidsCompatible = (lover1: ProfileRow, lover2: ProfileRow) => {
const { wants_kids_strength: kids1 } = lover1
const { wants_kids_strength: kids2 } = lover2

View File

@@ -1,10 +1,10 @@
import { Row, run, SupabaseClient } from 'common/supabase/utils'
import { User } from 'common/user'
export type LoverRow = Row<'profiles'>
export type Lover = LoverRow & { user: User }
export const getLoverRow = async (userId: string, db: SupabaseClient) => {
console.log('getLoverRow', userId)
export type ProfileRow = Row<'profiles'>
export type Profile = ProfileRow & { user: User }
export const getProfileRow = async (userId: string, db: SupabaseClient) => {
console.log('getProfileRow', userId)
const res = await run(db.from('profiles').select('*').eq('user_id', userId))
return res.data[0]
}

View File

@@ -1,5 +1,5 @@
import { User } from 'common/user'
import { LoverRow } from 'common/love/lover'
import { ProfileRow } from 'common/love/lover'
import { buildOgUrl } from 'common/util/og'
// TODO: handle age, gender undefined better
@@ -14,7 +14,7 @@ export type LoveOgProps = {
gender: string
}
export function getLoveOgImageUrl(user: User, lover?: LoverRow | null) {
export function getLoveOgImageUrl(user: User, lover?: ProfileRow | null) {
const loveProps = {
avatarUrl: lover?.pinned_url,
username: user.username,

View File

@@ -3,11 +3,11 @@ import {
getAnswerCompatibility,
getScoredAnswerCompatibility,
} from 'common/love/compatibility-score'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
import { Row as rowFor } from 'common/supabase/utils'
import { User } from 'common/user'
import { partition, sortBy, keyBy } from 'lodash'
import { useLover } from 'web/hooks/use-lover'
import { useProfile } from 'web/hooks/use-lover'
import {
QuestionWithCountType,
useCompatibilityQuestionsWithAnswerCount,
@@ -81,11 +81,11 @@ type CompatibilitySort =
export function CompatibilityQuestionsDisplay(props: {
isCurrentUser: boolean
user: User
lover: Lover
lover: Profile
fromSignup?: boolean
fromLoverPage?: Lover
fromProfilePage?: Profile
}) {
const { isCurrentUser, user, fromSignup, fromLoverPage, lover } = props
const { isCurrentUser, user, fromSignup, fromProfilePage, lover } = props
const { refreshCompatibilityQuestions, compatibilityQuestions } =
useCompatibilityQuestionsWithAnswerCount()
@@ -120,12 +120,12 @@ export function CompatibilityQuestionsDisplay(props: {
const isLooking = useIsLooking()
const [sort, setSort] = usePersistentInMemoryState<CompatibilitySort>(
!isLooking && !fromLoverPage ? 'their-important' : 'your-important',
!isLooking && !fromProfilePage ? 'their-important' : 'your-important',
`compatibility-sort-${user.id}`
)
const currentUser = useUser()
const comparedUserId = fromLoverPage?.user_id ?? currentUser?.id
const comparedUserId = fromProfilePage?.user_id ?? currentUser?.id
const { compatibilityAnswers: comparedAnswers } =
useUserCompatibilityAnswers(comparedUserId)
const questionIdToComparedAnswer = keyBy(comparedAnswers, 'question_id')
@@ -178,13 +178,13 @@ export function CompatibilityQuestionsDisplay(props: {
<Subtitle>{`${
isCurrentUser ? 'Your' : shortenName(user.name) + `'s`
} Compatibility Prompts`}</Subtitle>
{(!isCurrentUser || fromLoverPage) && (
{(!isCurrentUser || fromProfilePage) && (
<CompatibilitySortWidget
className="text-sm sm:flex"
sort={sort}
setSort={setSort}
user={user}
fromLoverPage={fromLoverPage}
fromProfilePage={fromProfilePage}
/>
)}
</Row>
@@ -198,7 +198,7 @@ export function CompatibilityQuestionsDisplay(props: {
</span>
) : (
<>
{isCurrentUser && !fromLoverPage && (
{isCurrentUser && !fromProfilePage && (
<span className='customlink'>
{otherQuestions.length < 1 ? (
<span className="text-ink-600 text-sm">
@@ -224,7 +224,7 @@ export function CompatibilityQuestionsDisplay(props: {
isCurrentUser={isCurrentUser}
refreshCompatibilityAll={refreshCompatibilityAll}
lover={lover}
fromLoverPage={fromLoverPage}
fromProfilePage={fromProfilePage}
/>
)
})}
@@ -233,7 +233,7 @@ export function CompatibilityQuestionsDisplay(props: {
)}
</>
)}
{otherQuestions.length >= 1 && isCurrentUser && !fromLoverPage && (
{otherQuestions.length >= 1 && isCurrentUser && !fromProfilePage && (
<AnswerCompatibilityQuestionButton
user={user}
otherQuestions={otherQuestions}
@@ -266,15 +266,15 @@ function CompatibilitySortWidget(props: {
sort: CompatibilitySort
setSort: (sort: CompatibilitySort) => void
user: User
fromLoverPage: Lover | undefined
fromProfilePage: Profile | undefined
className?: string
}) {
const { sort, setSort, user, fromLoverPage, className } = props
const { sort, setSort, user, fromProfilePage, className } = props
const currentUser = useUser()
const sortToDisplay = {
'your-important': fromLoverPage
? `Important to ${fromLoverPage.user.name}`
'your-important': fromProfilePage
? `Important to ${fromProfilePage.user.name}`
: 'Important to you',
'their-important': `Important to ${user.name}`,
disagree: 'Incompatible',
@@ -285,7 +285,7 @@ function CompatibilitySortWidget(props: {
'your-important',
'their-important',
'disagree',
(!fromLoverPage || fromLoverPage.user_id === currentUser?.id) &&
(!fromProfilePage || fromProfilePage.user_id === currentUser?.id) &&
'your-unanswered'
)
@@ -314,9 +314,9 @@ function CompatibilityAnswerBlock(props: {
yourQuestions: QuestionWithCountType[]
user: User
isCurrentUser: boolean
lover: Lover
lover: Profile
refreshCompatibilityAll: () => void
fromLoverPage?: Lover
fromProfilePage?: Profile
}) {
const {
answer,
@@ -325,18 +325,18 @@ function CompatibilityAnswerBlock(props: {
lover,
isCurrentUser,
refreshCompatibilityAll,
fromLoverPage,
fromProfilePage,
} = props
const question = yourQuestions.find((q) => q.id === answer.question_id)
const [editOpen, setEditOpen] = useState<boolean>(false)
const currentUser = useUser()
const currentLover = useLover()
const currentProfile = useProfile()
const comparedLover = isCurrentUser
const comparedProfile = isCurrentUser
? null
: !!fromLoverPage
? fromLoverPage
: { ...currentLover, user: currentUser }
: !!fromProfilePage
? fromProfilePage
: { ...currentProfile, user: currentUser }
if (
!question ||
@@ -370,14 +370,14 @@ function CompatibilityAnswerBlock(props: {
<Row className="text-ink-800 justify-between gap-1 font-semibold">
{question.question}
<Row className="gap-4 font-normal">
{comparedLover && (
{comparedProfile && (
<div className="hidden sm:block">
<CompatibilityDisplay
question={question}
lover1={lover}
answer1={answer}
lover2={comparedLover as Lover}
currentUserIsComparedLover={!fromLoverPage}
lover2={comparedProfile as Profile}
currentUserIsComparedProfile={!fromProfilePage}
currentUser={currentUser}
/>
</div>
@@ -433,14 +433,14 @@ function CompatibilityAnswerBlock(props: {
)}
<Col>
{comparedLover && (
{comparedProfile && (
<Row className="w-full justify-end sm:hidden">
<CompatibilityDisplay
question={question}
lover1={lover}
answer1={answer}
lover2={comparedLover as Lover}
currentUserIsComparedLover={!fromLoverPage}
lover2={comparedProfile as Profile}
currentUserIsComparedProfile={!fromProfilePage}
currentUser={currentUser}
/>
</Row>
@@ -476,10 +476,10 @@ function CompatibilityAnswerBlock(props: {
function CompatibilityDisplay(props: {
question: QuestionWithCountType
lover1: Lover
lover2: Lover
lover1: Profile
lover2: Profile
answer1: rowFor<'love_compatibility_answers'>
currentUserIsComparedLover: boolean
currentUserIsComparedProfile: boolean
currentUser: User | null | undefined
className?: string
}) {
@@ -488,7 +488,7 @@ function CompatibilityDisplay(props: {
lover1,
lover2,
answer1,
currentUserIsComparedLover,
currentUserIsComparedProfile,
currentUser,
} = props
@@ -496,7 +496,7 @@ function CompatibilityDisplay(props: {
rowFor<'love_compatibility_answers'> | null | undefined
>(undefined)
async function getComparedLoverAnswer() {
async function getComparedProfileAnswer() {
db.from('love_compatibility_answers')
.select()
.eq('creator_id', lover2.user_id)
@@ -510,7 +510,7 @@ function CompatibilityDisplay(props: {
})
}
useEffect(() => {
getComparedLoverAnswer()
getComparedProfileAnswer()
}, [])
const [open, setOpen] = useState(false)
@@ -519,7 +519,7 @@ function CompatibilityDisplay(props: {
const showCreateAnswer =
(!answer2 || answer2.importance == -1) &&
currentUserIsComparedLover &&
currentUserIsComparedProfile &&
!!currentUser
const isCurrentUser = currentUser?.id === lover2.user_id
@@ -544,7 +544,7 @@ function CompatibilityDisplay(props: {
<AnswerCompatibilityQuestionButton
user={currentUser}
otherQuestions={[question]}
refreshCompatibilityAll={getComparedLoverAnswer}
refreshCompatibilityAll={getComparedProfileAnswer}
size="sm"
/>
) : (

View File

@@ -12,7 +12,7 @@ import {
import { Row } from 'web/components/layout/row'
import { IndividualQuestionRow } from '../questions-form'
import { TbMessage } from 'react-icons/tb'
import { OtherLoverAnswers } from './other-lover-answers'
import { OtherProfileAnswers } from './other-lover-answers'
import { ArrowLeftIcon } from '@heroicons/react/outline'
import { usePersistentInMemoryState } from 'web/hooks/use-persistent-in-memory-state'
@@ -87,7 +87,7 @@ function AddQuestionModal(props: {
</Button>
<span className="font-semibold">{expandedQuestion.question}</span>
</Row>
<OtherLoverAnswers
<OtherProfileAnswers
question={expandedQuestion}
user={user}
className={SCROLLABLE_MODAL_CLASS}

View File

@@ -17,7 +17,7 @@ import {
useUserAnswers,
} from 'web/hooks/use-questions'
import { TbMessage } from 'react-icons/tb'
import { OtherLoverAnswers } from './other-lover-answers'
import { OtherProfileAnswers } from './other-lover-answers'
import {
MODAL_CLASS,
Modal,
@@ -26,14 +26,14 @@ import {
import { partition } from 'lodash'
import { shortenName } from 'web/components/widgets/user-link'
import { AddQuestionButton } from './free-response-add-question'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
export function FreeResponseDisplay(props: {
isCurrentUser: boolean
user: User
fromLoverPage: Lover | undefined
fromProfilePage: Profile | undefined
}) {
const { isCurrentUser, user, fromLoverPage } = props
const { isCurrentUser, user, fromProfilePage } = props
const { refreshAnswers, answers: allAnswers } = useUserAnswers(user?.id)
@@ -79,7 +79,7 @@ export function FreeResponseDisplay(props: {
})}
</Col>
{isCurrentUser && !fromLoverPage && (
{isCurrentUser && !fromProfilePage && (
<AddQuestionButton
isFirstQuestion={answers.length < 1}
questions={otherFRQuestions}
@@ -164,7 +164,7 @@ function AnswerBlock(props: {
<Modal open={otherAnswerModal} setOpen={setOtherAnswerModal}>
<Col className={MODAL_CLASS}>
<span className="font-semibold">{question.question}</span>
<OtherLoverAnswers
<OtherProfileAnswers
question={question}
user={user}
className={SCROLLABLE_MODAL_CLASS}

View File

@@ -2,16 +2,16 @@ import { User } from 'common/user'
import { Col } from 'web/components/layout/col'
import { CompatibilityQuestionsDisplay } from './compatibility-questions-display'
import { FreeResponseDisplay } from './free-response-display'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
export function LoverAnswers(props: {
export function ProfileAnswers(props: {
isCurrentUser: boolean
user: User
lover: Lover
lover: Profile
fromSignup?: boolean
fromLoverPage?: Lover
fromProfilePage?: Profile
}) {
const { isCurrentUser, user, fromSignup, fromLoverPage, lover } = props
const { isCurrentUser, user, fromSignup, fromProfilePage, lover } = props
return (
<Col className={'mt-2 gap-5'}>
@@ -20,12 +20,12 @@ export function LoverAnswers(props: {
user={user}
lover={lover}
fromSignup={fromSignup}
fromLoverPage={fromLoverPage}
fromProfilePage={fromProfilePage}
/>
{/*<FreeResponseDisplay*/}
{/* isCurrentUser={isCurrentUser}*/}
{/* user={user}*/}
{/* fromLoverPage={fromLoverPage}*/}
{/* fromProfilePage={fromProfilePage}*/}
{/*/>*/}
</Col>
)

View File

@@ -12,7 +12,7 @@ import { capitalize } from 'lodash'
import clsx from 'clsx'
import { shortenedFromNow } from 'web/lib/util/shortenedFromNow'
export function OtherLoverAnswers(props: {
export function OtherProfileAnswers(props: {
question: QuestionWithCountType
user?: User
className?: string

View File

@@ -1,16 +1,16 @@
import { JSONContent } from '@tiptap/core'
import { MAX_DESCRIPTION_LENGTH } from 'common/envs/constants'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
import { tryCatch } from 'common/util/try-catch'
import { Button } from 'web/components/buttons/button'
import { Col } from 'web/components/layout/col'
import { Row } from 'web/components/layout/row'
import { TextEditor, useTextEditor } from 'web/components/widgets/editor'
import { updateLover } from 'web/lib/api'
import { updateProfile } from 'web/lib/api'
import { track } from 'web/lib/service/analytics'
export function EditableBio(props: {
lover: Lover
lover: Profile
onSave: () => void
onCancel?: () => void
}) {
@@ -25,7 +25,7 @@ export function EditableBio(props: {
const saveBio = async () => {
if (!editor) return
const { error } = await tryCatch(updateLover({ bio: editor.getJSON() }))
const { error } = await tryCatch(updateProfile({ bio: editor.getJSON() }))
if (error) {
console.error(error)

View File

@@ -2,23 +2,23 @@ import { PencilIcon, XIcon } from '@heroicons/react/outline'
import { JSONContent } from '@tiptap/core'
import clsx from 'clsx'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
import DropdownMenu from 'web/components/comments/dropdown-menu'
import { Col } from 'web/components/layout/col'
import { Row } from 'web/components/layout/row'
import { Content } from 'web/components/widgets/editor'
import { updateLover } from 'web/lib/api'
import { updateProfile } from 'web/lib/api'
import { EditableBio } from './editable-bio'
import { tryCatch } from 'common/util/try-catch'
export function BioBlock(props: {
isCurrentUser: boolean
lover: Lover
refreshLover: () => void
lover: Profile
refreshProfile: () => void
edit: boolean
setEdit: (edit: boolean) => void
}) {
const { isCurrentUser, refreshLover, lover, edit, setEdit } = props
const { isCurrentUser, refreshProfile, lover, edit, setEdit } = props
return (
<Col
@@ -38,7 +38,7 @@ export function BioBlock(props: {
lover={lover}
onCancel={lover.bio ? () => setEdit(false) : undefined}
onSave={() => {
refreshLover()
refreshProfile()
setEdit(false)
}}
/>
@@ -55,9 +55,9 @@ export function BioBlock(props: {
name: 'Delete',
icon: <XIcon className="h-5 w-5" />,
onClick: async () => {
const { error } = await tryCatch(updateLover({ bio: null }))
const { error } = await tryCatch(updateProfile({ bio: null }))
if (error) console.error(error)
else refreshLover()
else refreshProfile()
},
},
]}

View File

@@ -1,20 +1,20 @@
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
import { useState } from 'react'
import { Col } from 'web/components/layout/col'
import { Subtitle } from '../widgets/lover-subtitle'
import { BioBlock } from './lover-bio-block'
export function LoverBio(props: {
export function ProfileBio(props: {
isCurrentUser: boolean
lover: Lover
refreshLover: () => void
fromLoverPage?: Lover
lover: Profile
refreshProfile: () => void
fromProfilePage?: Profile
}) {
const { isCurrentUser, lover, refreshLover, fromLoverPage } = props
const { isCurrentUser, lover, refreshProfile, fromProfilePage } = props
const [edit, setEdit] = useState(false)
if (!isCurrentUser && !lover.bio) return null
if (fromLoverPage && !lover.bio) return null
if (fromProfilePage && !lover.bio) return null
return (
<Col>
@@ -22,7 +22,7 @@ export function LoverBio(props: {
<BioBlock
isCurrentUser={isCurrentUser}
lover={lover}
refreshLover={refreshLover}
refreshProfile={refreshProfile}
edit={edit || (isCurrentUser && !lover.bio)}
setEdit={setEdit}
/>

View File

@@ -4,7 +4,7 @@ import { useState } from 'react'
import Link from 'next/link'
import { MAX_COMMENT_LENGTH } from 'common/comment'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
import { Button } from 'web/components/buttons/button'
import { Col } from 'web/components/layout/col'
import { Modal, SCROLLABLE_MODAL_CLASS } from 'web/components/layout/modal'
@@ -13,14 +13,14 @@ import { useTextEditor } from 'web/components/widgets/editor'
import { useUser } from 'web/hooks/use-user'
import { CompatibilityScore } from 'common/love/compatibility-score'
import { CompatibleBadge } from './widgets/compatible-badge'
import { LoverProfile } from './profile/lover-profile'
import { ProfileProfile } from './profile/lover-profile'
import { Pagination } from 'web/components/widgets/pagination'
import { Title } from 'web/components/widgets/title'
import { Input } from 'web/components/widgets/input'
export const BrowseMatchesButton = (props: {
lover: Lover
potentialProfiles: Lover[]
lover: Profile
potentialProfiles: Profile[]
compatibilityScores: Record<string, CompatibilityScore>
className?: string
}) => {
@@ -95,8 +95,8 @@ export const BrowseMatchesButton = (props: {
}
const BrowseMatchesDialog = (props: {
lover: Lover
potentialProfiles: Lover[]
lover: Profile
potentialProfiles: Profile[]
compatibilityScores: Record<string, CompatibilityScore>
isSubmitting: boolean
setOpen: (open: boolean) => void
@@ -124,10 +124,10 @@ const BrowseMatchesDialog = (props: {
)
const [potentialIndex, setPotentialIndex] = useState(0)
const index = Math.min(potentialIndex, filteredProfiles.length - 1)
const potentialLover = filteredProfiles[index]
const potentialProfile = filteredProfiles[index]
const compatibility = potentialLover
? compatibilityScores[potentialLover.user_id]
const compatibility = potentialProfile
? compatibilityScores[potentialProfile.user_id]
: undefined
return (
@@ -168,14 +168,14 @@ const BrowseMatchesDialog = (props: {
/>
)}
{potentialLover && (
{potentialProfile && (
<>
<CompatibilityScoreDisplay compatibility={compatibility} />
<LoverProfile
lover={potentialLover}
user={potentialLover.user}
refreshLover={() => window.location.reload()}
fromLoverPage={lover}
<ProfileProfile
lover={potentialProfile}
user={potentialProfile.user}
refreshProfile={() => window.location.reload()}
fromProfilePage={lover}
/>
{/* <Col key={lover.id} className={clsx('gap-4 px-3 py-2')}>

View File

@@ -22,13 +22,13 @@ import {
import { KidsLabel, wantsKidsLabelsWithIcon } from './wants-kids-filter'
import { HasKidsLabel } from './has-kids-filter'
import { MyMatchesToggle } from './my-matches-toggle'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
import {FilterFields} from "common/filters";
import {hasKidsLabels} from "common/has-kids";
export function DesktopFilters(props: {
filters: Partial<FilterFields>
youLover: Lover | undefined | null
youProfile: Profile | undefined | null
updateFilter: (newState: Partial<FilterFields>) => void
clearFilters: () => void
setYourFilters: (checked: boolean) => void
@@ -37,7 +37,7 @@ export function DesktopFilters(props: {
}) {
const {
filters,
youLover,
youProfile,
updateFilter,
clearFilters,
setYourFilters,
@@ -49,9 +49,9 @@ export function DesktopFilters(props: {
<>
<MyMatchesToggle
setYourFilters={setYourFilters}
youLover={youLover}
youProfile={youProfile}
on={isYourFilters}
hidden={!youLover}
hidden={!youProfile}
/>
{/* CONNECTION */}
<CustomizeableDropdown
@@ -85,7 +85,7 @@ export function DesktopFilters(props: {
<DropdownButton
content={
<LocationFilterText
youLover={youLover}
youProfile={youProfile}
location={locationFilterProps.location}
radius={locationFilterProps.radius}
highlightedClass={open ? 'text-primary-500' : ''}
@@ -96,7 +96,7 @@ export function DesktopFilters(props: {
)}
dropdownMenuContent={
<LocationFilter
youLover={youLover}
youProfile={youProfile}
locationFilterProps={locationFilterProps}
/>
}

View File

@@ -4,7 +4,7 @@ import {Slider} from 'web/components/widgets/slider'
import {usePersistentInMemoryState} from 'web/hooks/use-persistent-in-memory-state'
import {Row} from 'web/components/layout/row'
import {City, CityRow, loverToCity, originToCity, useCitySearch,} from '../search-location'
import {Lover} from 'common/love/lover'
import {Profile} from 'common/love/lover'
import {useEffect, useState} from 'react'
import {Input} from 'web/components/widgets/input'
import {XIcon} from '@heroicons/react/solid'
@@ -14,7 +14,7 @@ import {OriginLocation} from "common/filters";
export function LocationFilterText(props: {
location: OriginLocation | undefined | null
youLover: Lover | undefined | null
youProfile: Profile | undefined | null
radius: number
highlightedClass?: string
}) {
@@ -57,14 +57,14 @@ const DEFAULT_LAST_CITY: City = {
}
export function LocationFilter(props: {
youLover: Lover | undefined | null
youProfile: Profile | undefined | null
locationFilterProps: LocationFilterProps
}) {
const { youLover } = props
const { youProfile } = props
const { location, setLocation, radius, setRadius } = props.locationFilterProps
const youCity = youLover && loverToCity(youLover)
const youCity = youProfile && loverToCity(youProfile)
const [lastCity, setLastCity] = usePersistentInMemoryState<City>(
location ? originToCity(location) : youCity || DEFAULT_LAST_CITY,

View File

@@ -24,7 +24,7 @@ import {
} from './wants-kids-filter'
import { FaChild } from 'react-icons/fa6'
import { MyMatchesToggle } from './my-matches-toggle'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
import { Gender } from 'common/gender'
import { RelationshipType } from 'web/lib/util/convert-relationship-type'
import {FilterFields} from "common/filters";
@@ -32,7 +32,7 @@ import {hasKidsLabels} from "common/has-kids";
export function MobileFilters(props: {
filters: Partial<FilterFields>
youLover: Lover | undefined | null
youProfile: Profile | undefined | null
updateFilter: (newState: Partial<FilterFields>) => void
clearFilters: () => void
setYourFilters: (checked: boolean) => void
@@ -41,7 +41,7 @@ export function MobileFilters(props: {
}) {
const {
filters,
youLover,
youProfile,
updateFilter,
clearFilters,
setYourFilters,
@@ -64,9 +64,9 @@ export function MobileFilters(props: {
<Col className="p-4 pb-2">
<MyMatchesToggle
setYourFilters={setYourFilters}
youLover={youLover}
youProfile={youProfile}
on={isYourFilters}
hidden={!youLover}
hidden={!youProfile}
/>
</Col>
{/* RELATIONSHIP STYLE */}
@@ -98,7 +98,7 @@ export function MobileFilters(props: {
<LocationFilterText
location={locationFilterProps.location}
radius={locationFilterProps.radius}
youLover={youLover}
youProfile={youProfile}
highlightedClass={
!locationFilterProps.location
? 'text-ink-400'
@@ -108,7 +108,7 @@ export function MobileFilters(props: {
}
>
<LocationFilter
youLover={youLover}
youProfile={youProfile}
locationFilterProps={locationFilterProps}
/>
</MobileFilterSection>

View File

@@ -1,10 +1,10 @@
import { Row } from 'web/components/layout/row'
import clsx from 'clsx'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
export function MyMatchesToggle(props: {
setYourFilters: (checked: boolean) => void
youLover: Lover | undefined | null
youProfile: Profile | undefined | null
on: boolean
hidden: boolean
}) {

View File

@@ -1,4 +1,4 @@
import {Lover} from 'common/love/lover'
import {Profile} from 'common/love/lover'
import React, {useEffect, useState} from 'react'
import {IoFilterSharp} from 'react-icons/io5'
import {Button} from 'web/components/buttons/button'
@@ -90,7 +90,7 @@ function getRandomPair(count = 3): string {
const MAX_BOOKMARKED_SEARCHES = 10;
export const Search = (props: {
youLover: Lover | undefined | null
youProfile: Profile | undefined | null
starredUserIds: string[]
// filter props
filters: Partial<FilterFields>
@@ -103,7 +103,7 @@ export const Search = (props: {
refreshBookmarkedSearches: () => void
}) => {
const {
youLover,
youProfile,
updateFilter,
clearFilters,
setYourFilters,
@@ -179,7 +179,7 @@ export const Search = (props: {
className={'w-18 border-ink-300 rounded-md'}
>
<option value="created_time">New</option>
{youLover && (
{youProfile && (
<option value="compatibility_score">Compatible</option>
)}
<option value="last_online_time">Active</option>
@@ -201,7 +201,7 @@ export const Search = (props: {
>
<DesktopFilters
filters={filters}
youLover={youLover}
youProfile={youProfile}
updateFilter={updateFilter}
clearFilters={clearFilters}
setYourFilters={setYourFilters}
@@ -216,7 +216,7 @@ export const Search = (props: {
>
<MobileFilters
filters={filters}
youLover={youLover}
youProfile={youProfile}
updateFilter={updateFilter}
clearFilters={clearFilters}
setYourFilters={setYourFilters}

View File

@@ -1,4 +1,4 @@
import {Lover} from "common/love/lover";
import {Profile} from "common/love/lover";
import {useIsLooking} from "web/hooks/use-is-looking";
import {usePersistentLocalState} from "web/hooks/use-persistent-local-state";
import {useCallback} from "react";
@@ -9,7 +9,7 @@ import {wantsKidsDatabase, wantsKidsDatabaseToWantsKidsFilter, wantsKidsToHasKid
import {FilterFields, initialFilters, OriginLocation} from "common/filters";
import {MAX_INT, MIN_INT} from "common/constants";
export const useFilters = (you: Lover | undefined) => {
export const useFilters = (you: Profile | undefined) => {
const isLooking = useIsLooking()
const [filters, setFilters] = usePersistentLocalState<Partial<FilterFields>>(
isLooking ? initialFilters : {...initialFilters, orderBy: 'created_time'},
@@ -117,7 +117,7 @@ export const useFilters = (you: Lover | undefined) => {
}
}
// const alternateWomenAndMen = (profiles: Lover[]) => {
// const alternateWomenAndMen = (profiles: Profile[]) => {
// const [women, nonWomen] = partition(profiles, (l) => l.gender === 'female')
// return filterDefined(zip(women, nonWomen).flat())
// }

View File

@@ -18,8 +18,8 @@ import {useTracking} from 'web/hooks/use-tracking'
import {useUser} from 'web/hooks/use-user'
import {GoogleOneTapLogin} from 'web/lib/firebase/google-onetap-login'
import Sidebar from './nav/love-sidebar'
import {useLover} from 'web/hooks/use-lover'
import {Lover} from 'common/love/lover'
import {useProfile} from 'web/hooks/use-lover'
import {Profile} from 'common/love/lover'
import {NotificationsIcon, SolidNotificationsIcon} from './notifications-icon'
export function LovePage(props: {
@@ -40,7 +40,7 @@ export function LovePage(props: {
} = props
const user = useUser()
const isMobile = useIsMobile()
const lover = useLover()
const lover = useProfile()
const bottomNavOptions = user
? getBottomNavigation(user, lover)
: signedOutNavigation()
@@ -106,7 +106,7 @@ const Notifs = {name: 'Notifs', href: `/notifications`, icon: NotificationsIcon}
const NotifsSolid = {name: 'Notifs', href: `/notifications`, icon: SolidNotificationsIcon};
const Messages = {name: 'Messages', href: '/messages', icon: PrivateMessagesIcon};
function getBottomNavigation(user: User, lover: Lover | null | undefined) {
function getBottomNavigation(user: User, lover: Profile | null | undefined) {
return buildArray(
Profiles,
NotifsSolid,

View File

@@ -28,7 +28,7 @@ import { Gender, convertGenderPlural } from 'common/gender'
import { HiOutlineGlobe } from 'react-icons/hi'
import { UserHandles } from 'web/components/user/user-handles'
import { convertRace } from './race'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
export function AboutRow(props: {
icon: ReactNode
@@ -54,7 +54,7 @@ export function AboutRow(props: {
)
}
export default function LoverAbout(props: { lover: Lover }) {
export default function ProfileAbout(props: { lover: Profile }) {
const { lover } = props
return (
<Col
@@ -91,7 +91,7 @@ export default function LoverAbout(props: { lover: Lover }) {
)
}
function Seeking(props: { lover: Lover }) {
function Seeking(props: { lover: Profile }) {
const { lover } = props
const prefGender = lover.pref_gender
const min = lover.pref_age_min
@@ -126,7 +126,7 @@ function Seeking(props: { lover: Lover }) {
)
}
function RelationshipType(props: { lover: Lover }) {
function RelationshipType(props: { lover: Profile }) {
const { lover } = props
const relationshipTypes = lover.pref_relation_styles
const seekingGenderText = stringOrStringArrayToText({
@@ -149,7 +149,7 @@ function RelationshipType(props: { lover: Lover }) {
)
}
function Education(props: { lover: Lover }) {
function Education(props: { lover: Profile }) {
const { lover } = props
const educationLevel = lover.education_level
const university = lover.university
@@ -173,7 +173,7 @@ function Education(props: { lover: Lover }) {
)
}
function Occupation(props: { lover: Lover }) {
function Occupation(props: { lover: Profile }) {
const { lover } = props
const occupation_title = lover.occupation_title
const company = lover.company
@@ -194,7 +194,7 @@ function Occupation(props: { lover: Lover }) {
)
}
function Smoker(props: { lover: Lover }) {
function Smoker(props: { lover: Profile }) {
const { lover } = props
const isSmoker = lover.is_smoker
if (isSmoker == null) return null
@@ -211,7 +211,7 @@ function Smoker(props: { lover: Lover }) {
)
}
function Drinks(props: { lover: Lover }) {
function Drinks(props: { lover: Profile }) {
const { lover } = props
const drinksPerMonth = lover.drinks_per_month
if (drinksPerMonth == null) return null
@@ -233,7 +233,7 @@ function Drinks(props: { lover: Lover }) {
)
}
function WantsKids(props: { lover: Lover }) {
function WantsKids(props: { lover: Profile }) {
const { lover } = props
const wantsKidsStrength = lover.wants_kids_strength
if (wantsKidsStrength == null || wantsKidsStrength < 0) return null
@@ -256,7 +256,7 @@ function WantsKids(props: { lover: Lover }) {
)
}
function HasKids(props: { lover: Lover }) {
function HasKids(props: { lover: Profile }) {
const { lover } = props
const hasKidsText =
lover.has_kids && lover.has_kids > 0
@@ -264,7 +264,7 @@ function HasKids(props: { lover: Lover }) {
: null
return <AboutRow icon={<FaChild className="h-5 w-5" />} text={hasKidsText} />
}
export const formatLoverValue = (key: string, value: any) => {
export const formatProfileValue = (key: string, value: any) => {
if (Array.isArray(value)) {
return value.join(', ')
}

View File

@@ -1,31 +1,31 @@
import { Col } from 'web/components/layout/col'
import { groupBy, orderBy } from 'lodash'
import { useLiveCommentsOnLover } from 'web/hooks/use-comments-on-lover'
import { useLiveCommentsOnProfile } from 'web/hooks/use-comments-on-lover'
import {
LoverCommentInput,
LoverProfileCommentThread,
ProfileCommentInput,
ProfileProfileCommentThread,
} from 'web/components/lover-comments'
import { User } from 'common/user'
import { Row } from 'web/components/layout/row'
import ShortToggle from 'web/components/widgets/short-toggle'
import { useState } from 'react'
import { updateLover } from 'web/lib/api'
import { updateProfile } from 'web/lib/api'
import { Tooltip } from 'web/components/widgets/tooltip'
import { toast } from 'react-hot-toast'
import { Subtitle } from './widgets/lover-subtitle'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
export const LoverCommentSection = (props: {
export const ProfileCommentSection = (props: {
onUser: User
lover: Lover
lover: Profile
currentUser: User | null | undefined
simpleView?: boolean
}) => {
const { onUser, currentUser, simpleView } = props
const comments = useLiveCommentsOnLover(onUser.id).filter((c) => !c.hidden)
const comments = useLiveCommentsOnProfile(onUser.id).filter((c) => !c.hidden)
const parentComments = comments.filter((c) => !c.replyToCommentId)
const commentsByParent = groupBy(comments, (c) => c.replyToCommentId ?? '_')
const [lover, setLover] = useState<Lover>(props.lover)
const [lover, setProfile] = useState<Profile>(props.lover)
const isCurrentUser = currentUser?.id === onUser.id
if (simpleView && (!lover.comments_enabled || parentComments.length == 0))
@@ -46,8 +46,8 @@ export const LoverCommentSection = (props: {
on={lover.comments_enabled}
setOn={(on) => {
const update = { comments_enabled: on }
setLover((l) => ({ ...l, ...update }))
toast.promise(updateLover(update), {
setProfile((l) => ({ ...l, ...update }))
toast.promise(updateProfile(update), {
loading: on
? 'Enabling endorsements from others'
: 'Disabling endorsements from others',
@@ -76,7 +76,7 @@ export const LoverCommentSection = (props: {
)}
</div>
{currentUser && !isCurrentUser && (
<LoverCommentInput
<ProfileCommentInput
className="mb-4 mr-px mt-px"
onUserId={onUser.id}
trackingLocation={'contract page'}
@@ -98,7 +98,7 @@ export const LoverCommentSection = (props: {
)}
{lover.comments_enabled &&
orderBy(parentComments, 'createdTime', 'desc').map((c) => (
<LoverProfileCommentThread
<ProfileProfileCommentThread
key={c.id + 'thread'}
trackingLocation={onUser.name + 'comments section'}
threadComments={commentsByParent[c.id] ?? []}

View File

@@ -29,11 +29,11 @@ import { api } from 'web/lib/api'
import { RelativeTimestamp } from 'web/components/relative-timestamp'
import { useAdmin } from 'web/hooks/use-admin'
import { EyeOffIcon } from '@heroicons/react/outline'
import { useLoverByUserId } from 'web/hooks/use-lover'
import { useProfileByUserId } from 'web/hooks/use-lover'
import { MAX_COMMENT_LENGTH, ReplyToUserInfo } from 'common/comment'
import { safeLocalStorage } from 'web/lib/util/local'
export function LoverProfileCommentThread(props: {
export function ProfileProfileCommentThread(props: {
onUser: User
threadComments: Comment[]
parentComment: Comment
@@ -123,7 +123,7 @@ export function LoverProfileCommentThread(props: {
{replyToUserInfo && (
<div className="stop-prop flex">
<div className="border-ink-100 -mt-3 ml-4 h-7 w-4 rounded-bl-xl border-b-2 border-l-2" />
<LoverCommentInput
<ProfileCommentInput
onUserId={onUser.id}
parentCommentId={parentComment.id}
replyToUserInfo={replyToUserInfo}
@@ -158,7 +158,7 @@ const ProfileComment = memo(function FeedComment(props: {
const [comment, setComment] = useState(props.comment)
const { userUsername, userAvatarUrl, userId, hidden } = comment
const isOwner = onUser.id === userId
const lover = useLoverByUserId(userId)
const lover = useProfileByUserId(userId)
useEffect(() => {
if (highlighted && ref.current) {
@@ -375,7 +375,7 @@ function CommentActions(props: {
)
}
export function LoverCommentInput(props: {
export function ProfileCommentInput(props: {
onUserId: string
className?: string
replyToUserInfo?: ReplyToUserInfo

View File

@@ -1,27 +1,27 @@
import { Row } from 'web/components/layout/row'
import { HeartIcon } from '@heroicons/react/solid'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
import Image from 'next/image'
import { Col } from 'web/components/layout/col'
import { UserIcon } from '@heroicons/react/solid'
import clsx from 'clsx'
export function MatchAvatars(props: {
profileLover: Lover
matchedLover: Lover
profileProfile: Profile
matchedProfile: Profile
className?: string
}) {
const { profileLover, matchedLover, className } = props
const { profileProfile, matchedProfile, className } = props
return (
<Row className={clsx(className, 'mx-auto items-center gap-1')}>
{profileLover.pinned_url ? (
{profileProfile.pinned_url ? (
<Image
src={profileLover.pinned_url}
src={profileProfile.pinned_url}
// You must set these so we don't pay an extra $1k/month to vercel
width={100}
height={100}
alt={profileLover.user.username}
alt={profileProfile.user.username}
className="h-24 w-24 rounded-full object-cover"
/>
) : (
@@ -31,13 +31,13 @@ export function MatchAvatars(props: {
)}
<HeartIcon className="text-ink-300 h-6 w-6" />
{matchedLover.pinned_url ? (
{matchedProfile.pinned_url ? (
<Image
src={matchedLover.pinned_url}
src={matchedProfile.pinned_url}
// You must set these so we don't pay an extra $1k/month to vercel
width={100}
height={100}
alt={matchedLover.user.username}
alt={matchedProfile.user.username}
className="h-24 w-24 rounded-full object-cover"
/>
) : (

View File

@@ -12,7 +12,7 @@ import { useIsIframe } from 'web/hooks/use-is-iframe'
import { trackCallback } from 'web/lib/service/analytics'
import { User } from 'common/user'
import { Col } from 'web/components/layout/col'
import { useLover } from 'web/hooks/use-lover'
import { useProfile } from 'web/hooks/use-lover'
const itemClass =
'sm:hover:bg-ink-200 block w-full py-1 px-3 text-center sm:hover:text-primary-700 transition-colors'
@@ -80,7 +80,7 @@ function ProfileItem(props: {
track: () => void
}) {
const { user, item, touched, setTouched, currentPage, track } = props
const lover = useLover()
const lover = useProfile()
return (
<Link
href={item.href ?? '#'}

View File

@@ -1,5 +1,5 @@
import clsx from 'clsx'
import { useLover } from 'web/hooks/use-lover'
import { useProfile } from 'web/hooks/use-lover'
import Link from 'next/link'
import { Avatar } from 'web/components/widgets/avatar'
import { User } from 'web/lib/firebase/users'
@@ -8,7 +8,7 @@ import { trackCallback } from 'web/lib/service/analytics'
export function ProfileSummary(props: { user: User; className?: string }) {
const { user, className } = props
const lover = useLover()
const lover = useProfile()
return (
<Link

View File

@@ -15,7 +15,7 @@ import { Item, SidebarItem } from './love-sidebar-item'
import SiteLogo from '../site-logo'
import { Button, ColorType, SizeType } from 'web/components/buttons/button'
import {signupRedirect} from 'web/lib/util/signup'
import { useLover } from 'web/hooks/use-lover'
import { useProfile } from 'web/hooks/use-lover'
import { useTheme } from 'web/hooks/use-theme'
export default function Sidebar(props: {
@@ -28,7 +28,7 @@ export default function Sidebar(props: {
const currentPage = router.pathname
const user = useUser()
const lover = useLover()
const lover = useProfile()
const { theme, setTheme } = useTheme()

View File

@@ -27,7 +27,7 @@ export function NotificationItem(props: { notification: Notification }) {
}
if (sourceType === 'comment_on_lover') {
return <CommentOnLoverNotification {...params} />
return <CommentOnProfileNotification {...params} />
} else if (sourceType === 'new_match') {
return <NewMatchNotification {...params} />
} else if (reason === 'new_love_like') {
@@ -39,7 +39,7 @@ export function NotificationItem(props: { notification: Notification }) {
}
}
export function CommentOnLoverNotification(props: {
export function CommentOnProfileNotification(props: {
notification: Notification
highlighted: boolean
setHighlighted: (highlighted: boolean) => void

View File

@@ -9,14 +9,14 @@ import {ChoicesToggleGroup} from 'web/components/widgets/choices-toggle-group'
import {Button, IconButton} from 'web/components/buttons/button'
import {colClassName, labelClassName} from 'web/pages/signup'
import {useRouter} from 'next/router'
import {updateLover, updateUser} from 'web/lib/api'
import {updateProfile, updateUser} from 'web/lib/api'
import {Column} from 'common/supabase/utils'
import {User} from 'common/user'
import {track} from 'web/lib/service/analytics'
import {Races} from './race'
import {Carousel} from 'web/components/widgets/carousel'
import {tryCatch} from 'common/util/try-catch'
import {LoverRow} from 'common/love/lover'
import {ProfileRow} from 'common/love/lover'
import {removeNullOrUndefinedProps} from 'common/util/object'
import {isEqual, range} from 'lodash'
import {PlatformSelect} from 'web/components/widgets/platform-select'
@@ -32,14 +32,14 @@ import {RELATIONSHIP_CHOICES} from "web/components/filters/choices";
import toast from "react-hot-toast";
export const OptionalLoveUserForm = (props: {
lover: LoverRow
setLover: <K extends Column<'profiles'>>(key: K, value: LoverRow[K]) => void
lover: ProfileRow
setProfile: <K extends Column<'profiles'>>(key: K, value: ProfileRow[K]) => void
user: User
buttonLabel?: string
fromSignup?: boolean
onSubmit?: () => Promise<void>
}) => {
const {lover, user, buttonLabel, setLover, fromSignup, onSubmit} = props
const {lover, user, buttonLabel, setProfile, fromSignup, onSubmit} = props
const [isSubmitting, setIsSubmitting] = useState(false)
const [lookingRelationship, setLookingRelationship] = useState(false)
@@ -64,9 +64,9 @@ export const OptionalLoveUserForm = (props: {
const handleSubmit = async () => {
setIsSubmitting(true)
const {bio: _, ...otherLoverProps} = lover
const {bio: _, ...otherProfileProps} = lover
const {error} = await tryCatch(
updateLover(removeNullOrUndefinedProps(otherLoverProps) as any)
updateProfile(removeNullOrUndefinedProps(otherProfileProps) as any)
)
if (error) {
console.error(error)
@@ -108,14 +108,14 @@ export const OptionalLoveUserForm = (props: {
lover['gender'].includes('trans')
)
function setLoverCity(inputCity: City | undefined) {
function setProfileCity(inputCity: City | undefined) {
if (!inputCity) {
setLover('geodb_city_id', null)
setLover('city', '')
setLover('region_code', null)
setLover('country', null)
setLover('city_latitude', null)
setLover('city_longitude', null)
setProfile('geodb_city_id', null)
setProfile('city', '')
setProfile('region_code', null)
setProfile('country', null)
setProfile('city_latitude', null)
setProfile('city_longitude', null)
} else {
const {
geodb_city_id,
@@ -125,12 +125,12 @@ export const OptionalLoveUserForm = (props: {
latitude: city_latitude,
longitude: city_longitude,
} = inputCity
setLover('geodb_city_id', geodb_city_id)
setLover('city', city)
setLover('region_code', region_code)
setLover('country', country)
setLover('city_latitude', city_latitude)
setLover('city_longitude', city_longitude)
setProfile('geodb_city_id', geodb_city_id)
setProfile('city', city)
setProfile('region_code', region_code)
setProfile('country', country)
setProfile('city_latitude', city_latitude)
setProfile('city_longitude', city_longitude)
}
}
@@ -139,9 +139,9 @@ export const OptionalLoveUserForm = (props: {
if (currentState === 'non-binary') {
setTrans(undefined)
} else if (trans && !currentState.includes('trans-')) {
setLover('gender', 'trans-' + currentState.replace('trans-', ''))
setProfile('gender', 'trans-' + currentState.replace('trans-', ''))
} else if (!trans && currentState.includes('trans-')) {
setLover('gender', currentState.replace('trans-', ''))
setProfile('gender', currentState.replace('trans-', ''))
}
}, [trans, lover['gender']])
@@ -175,7 +175,7 @@ export const OptionalLoveUserForm = (props: {
<button
className="text-ink-700 hover:text-primary-700 text-sm underline"
onClick={() => {
setLoverCity(undefined)
setProfileCity(undefined)
}}
>
Change
@@ -184,7 +184,7 @@ export const OptionalLoveUserForm = (props: {
) : (
<CitySearchBox
onCitySelected={(city: City | undefined) => {
setLoverCity(city)
setProfileCity(city)
}}
/>
)}
@@ -198,7 +198,7 @@ export const OptionalLoveUserForm = (props: {
value={lover['age'] ?? undefined}
min={18}
max={100}
onChange={(e) => setLover('age', Number(e.target.value))}
onChange={(e) => setProfile('age', Number(e.target.value))}
/>
</Col>
@@ -212,7 +212,7 @@ export const OptionalLoveUserForm = (props: {
Man: 'male',
Other: 'other',
}}
setChoice={(c) => setLover('gender', c)}
setChoice={(c) => setProfile('gender', c)}
/>
</Col>
</Row>
@@ -226,7 +226,7 @@ export const OptionalLoveUserForm = (props: {
Other: 'other',
}}
selected={lover['pref_gender']}
onChange={(selected) => setLover('pref_gender', selected)}
onChange={(selected) => setProfile('pref_gender', selected)}
/>
</Col>
@@ -238,7 +238,7 @@ export const OptionalLoveUserForm = (props: {
<Select
value={lover['pref_age_min'] ?? ''}
onChange={(e) =>
setLover('pref_age_min', Number(e.target.value))
setProfile('pref_age_min', Number(e.target.value))
}
className={'w-18 border-ink-300 rounded-md'}
>
@@ -255,7 +255,7 @@ export const OptionalLoveUserForm = (props: {
<Select
value={lover['pref_age_max'] ?? ''}
onChange={(e) =>
setLover('pref_age_max', Number(e.target.value))
setProfile('pref_age_max', Number(e.target.value))
}
className={'w-18 border-ink-300 rounded-md'}
>
@@ -276,7 +276,7 @@ export const OptionalLoveUserForm = (props: {
choices={RELATIONSHIP_CHOICES}
selected={lover['pref_relation_styles']}
onChange={(selected) =>
setLover('pref_relation_styles', selected)
setProfile('pref_relation_styles', selected)
}
/>
</Col>
@@ -360,7 +360,7 @@ export const OptionalLoveUserForm = (props: {
Other: 'other',
}}
selected={lover['political_beliefs'] ?? []}
onChange={(selected) => setLover('political_beliefs', selected)}
onChange={(selected) => setProfile('political_beliefs', selected)}
/>
</Col>
@@ -368,7 +368,7 @@ export const OptionalLoveUserForm = (props: {
<label className={clsx(labelClassName)}>Religious beliefs</label>
<Input
type="text"
onChange={(e) => setLover('religious_beliefs', e.target.value)}
onChange={(e) => setProfile('religious_beliefs', e.target.value)}
className={'w-full sm:w-96'}
value={lover['religious_beliefs'] ?? undefined}
/>
@@ -382,7 +382,7 @@ export const OptionalLoveUserForm = (props: {
Yes: true,
No: false,
}}
setChoice={(c) => setLover('is_smoker', c)}
setChoice={(c) => setProfile('is_smoker', c)}
/>
</Col>
@@ -395,7 +395,7 @@ export const OptionalLoveUserForm = (props: {
onChange={(e) => {
const value =
e.target.value === '' ? null : Number(e.target.value)
setLover('drinks_per_month', value)
setProfile('drinks_per_month', value)
}}
className={'w-20'}
min={0}
@@ -417,7 +417,7 @@ export const OptionalLoveUserForm = (props: {
setHeightFeet(Number(e.target.value))
const heightInInches =
Number(e.target.value) * 12 + (heightInches ?? 0)
setLover('height_in_inches', heightInInches)
setProfile('height_in_inches', heightInInches)
}
}}
className={'w-16'}
@@ -435,7 +435,7 @@ export const OptionalLoveUserForm = (props: {
setHeightInches(Number(e.target.value))
const heightInInches =
Number(e.target.value) + 12 * (heightFeet ?? 0)
setLover('height_in_inches', heightInInches)
setProfile('height_in_inches', heightInInches)
}
}}
className={'w-16'}
@@ -449,7 +449,7 @@ export const OptionalLoveUserForm = (props: {
<label className={clsx(labelClassName)}>Birthplace</label>
<Input
type="text"
onChange={(e) => setLoverState('born_in_location', e.target.value)}
onChange={(e) => setProfileState('born_in_location', e.target.value)}
className={'w-52'}
value={lover['born_in_location'] ?? undefined}
/>
@@ -460,7 +460,7 @@ export const OptionalLoveUserForm = (props: {
<MultiCheckbox
choices={Races}
selected={lover['ethnicity'] ?? []}
onChange={(selected) => setLover('ethnicity', selected)}
onChange={(selected) => setProfile('ethnicity', selected)}
/>
</Col>
@@ -479,7 +479,7 @@ export const OptionalLoveUserForm = (props: {
Masters: 'masters',
PhD: 'doctorate',
}}
setChoice={(c) => setLover('education_level', c)}
setChoice={(c) => setProfile('education_level', c)}
/>
</Carousel>
</Col>
@@ -487,7 +487,7 @@ export const OptionalLoveUserForm = (props: {
<label className={clsx(labelClassName)}>University</label>
<Input
type="text"
onChange={(e) => setLover('university', e.target.value)}
onChange={(e) => setProfile('university', e.target.value)}
className={'w-52'}
value={lover['university'] ?? undefined}
/>
@@ -496,7 +496,7 @@ export const OptionalLoveUserForm = (props: {
<label className={clsx(labelClassName)}>Company</label>
<Input
type="text"
onChange={(e) => setLover('company', e.target.value)}
onChange={(e) => setProfile('company', e.target.value)}
className={'w-52'}
value={lover['company'] ?? undefined}
/>
@@ -508,7 +508,7 @@ export const OptionalLoveUserForm = (props: {
</label>
<Input
type="text"
onChange={(e) => setLover('occupation_title', e.target.value)}
onChange={(e) => setProfile('occupation_title', e.target.value)}
className={'w-52'}
value={lover['occupation_title'] ?? undefined}
/>
@@ -521,7 +521,7 @@ export const OptionalLoveUserForm = (props: {
onChange={(e) => {
const value =
e.target.value === '' ? null : Number(e.target.value)
setLover('has_kids', value)
setProfile('has_kids', value)
}}
className={'w-20'}
min={0}
@@ -547,7 +547,7 @@ export const OptionalLoveUserForm = (props: {
className={'w-44'}
choicesMap={MultipleChoiceOptions}
setChoice={(choice) => {
setLover('wants_kids_strength', choice)
setProfile('wants_kids_strength', choice)
}}
currentChoice={lover.wants_kids_strength ?? -1}
/>
@@ -565,8 +565,8 @@ export const OptionalLoveUserForm = (props: {
user={user}
photo_urls={lover.photo_urls}
pinned_url={lover.pinned_url}
setPhotoUrls={(urls) => setLover('photo_urls', urls)}
setPinnedUrl={(url) => setLover('pinned_url', url)}
setPhotoUrls={(urls) => setProfile('photo_urls', urls)}
setPinnedUrl={(url) => setProfile('pinned_url', url)}
/>
</Col>

View File

@@ -7,10 +7,10 @@ import { Carousel } from 'web/components/widgets/carousel'
import { MODAL_CLASS, Modal } from 'web/components/layout/modal'
import { Col } from 'web/components/layout/col'
import { SignUpButton } from './nav/love-sidebar'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
import { useAdmin } from 'web/hooks/use-admin'
import { Button } from 'web/components/buttons/button'
import { updateLover } from 'web/lib/api'
import { updateProfile } from 'web/lib/api'
import { Row } from 'web/components/layout/row'
import { useUser } from 'web/hooks/use-user'
import { PlusIcon } from '@heroicons/react/solid'
@@ -18,7 +18,7 @@ import { api } from 'web/lib/api'
import { EditablePhotoGrid } from './widgets/editable-photo-grid'
import { AddPhotosWidget } from './widgets/add-photos'
export default function ProfileCarousel(props: { lover: Lover }) {
export default function ProfileCarousel(props: { lover: Profile }) {
const { lover } = props
const photoNums = lover.photo_urls ? lover.photo_urls.length : 0
@@ -35,7 +35,7 @@ export default function ProfileCarousel(props: { lover: Lover }) {
const isCurrentUser = currentUser?.id === lover.user_id
const handleSaveChanges = async () => {
await updateLover({
await updateProfile({
pinned_url: pinnedUrl ?? undefined,
photo_urls: photoUrls,
})

View File

@@ -1,4 +1,4 @@
import {Lover} from 'common/love/lover'
import {Profile} from 'common/love/lover'
import {CompatibilityScore} from 'common/love/compatibility-score'
import {LoadingIndicator} from 'web/components/widgets/loading-indicator'
import {LoadMoreUntilNotVisible} from 'web/components/widgets/visibility-observer'
@@ -14,7 +14,7 @@ import {CompatibleBadge} from "web/components/widgets/compatible-badge";
import {useUser} from "web/hooks/use-user";
export const ProfileGrid = (props: {
profiles: Lover[]
profiles: Profile[]
loadMore: () => Promise<boolean>
isLoadingMore: boolean
isReloading: boolean
@@ -75,7 +75,7 @@ export const ProfileGrid = (props: {
}
function ProfilePreview(props: {
lover: Lover
lover: Profile
compatibilityScore: CompatibilityScore | undefined
hasStar: boolean
refreshStars: () => Promise<void>
@@ -115,7 +115,7 @@ function ProfilePreview(props: {
{/* className="!pt-0"*/}
{/* isStarred={hasStar}*/}
{/* refresh={refreshStars}*/}
{/* targetLover={lover}*/}
{/* targetProfile={lover}*/}
{/* hideTooltip*/}
{/* />*/}
{/* ) : (*/}

View File

@@ -6,10 +6,10 @@ import { MdHeight } from 'react-icons/md'
import { Row } from 'web/components/layout/row'
import GenderIcon from '../gender-icon'
import { Gender, convertGender } from 'common/gender'
import { formatLoverValue } from '../lover-about'
import { Lover } from 'common/love/lover'
import { formatProfileValue } from '../lover-about'
import { Profile } from 'common/love/lover'
export default function LoverPrimaryInfo(props: { lover: Lover }) {
export default function ProfilePrimaryInfo(props: { lover: Profile }) {
const { lover } = props
const stateOrCountry =
lover.country === 'United States of America'
@@ -29,7 +29,7 @@ export default function LoverPrimaryInfo(props: { lover: Lover }) {
/>
{lover.height_in_inches != null && (
<IconWithInfo
text={formatLoverValue('height_in_inches', lover.height_in_inches)}
text={formatProfileValue('height_in_inches', lover.height_in_inches)}
icon={<MdHeight className="h-4 w-4 " />}
/>
)}

View File

@@ -8,27 +8,27 @@ import {MoreOptionsUserButton} from 'web/components/buttons/more-options-user-bu
import {Col} from 'web/components/layout/col'
import {Row} from 'web/components/layout/row'
import {SendMessageButton} from 'web/components/messaging/send-message-button'
import LoverPrimaryInfo from './lover-primary-info'
import ProfilePrimaryInfo from './lover-primary-info'
import {OnlineIcon} from '../online-icon'
import {track} from 'web/lib/service/analytics'
import DropdownMenu from 'web/components/comments/dropdown-menu'
import {ShareProfileButton} from '../widgets/share-profile-button'
import {Lover} from 'common/love/lover'
import {Profile} from 'common/love/lover'
import {useUser} from 'web/hooks/use-user'
import {linkClass} from 'web/components/widgets/site-link'
import {StarButton} from '../widgets/star-button'
import {api, updateLover} from 'web/lib/api'
import {api, updateProfile} from 'web/lib/api'
import React, {useState} from 'react'
import {VisibilityConfirmationModal} from './visibility-confirmation-modal'
export default function LoverProfileHeader(props: {
export default function ProfileProfileHeader(props: {
user: User
lover: Lover
lover: Profile
simpleView?: boolean
starredUserIds: string[]
refreshStars: () => Promise<void>
showMessageButton: boolean
refreshLover: () => void
refreshProfile: () => void
}) {
const {
user,
@@ -37,13 +37,13 @@ export default function LoverProfileHeader(props: {
starredUserIds,
refreshStars,
showMessageButton,
refreshLover,
refreshProfile,
} = props
const currentUser = useUser()
const isCurrentUser = currentUser?.id === user.id
const [showVisibilityModal, setShowVisibilityModal] = useState(false)
console.log('LoverProfileHeader', {user, lover, currentUser})
console.log('ProfileProfileHeader', {user, lover, currentUser})
return (
<Col className="w-full">
@@ -63,7 +63,7 @@ export default function LoverProfileHeader(props: {
, {lover.age}
</span>
</Row>
<LoverPrimaryInfo lover={lover}/>
<ProfilePrimaryInfo lover={lover}/>
</Col>
</Row>
{currentUser && isCurrentUser ? (
@@ -129,7 +129,7 @@ export default function LoverProfileHeader(props: {
/>
{currentUser && (
<StarButton
targetLover={lover}
targetProfile={lover}
isStarred={starredUserIds.includes(user.id)}
refresh={refreshStars}
/>
@@ -153,8 +153,8 @@ export default function LoverProfileHeader(props: {
onConfirm={async () => {
const newVisibility =
lover.visibility === 'member' ? 'public' : 'member'
await updateLover({visibility: newVisibility})
refreshLover()
await updateProfile({visibility: newVisibility})
refreshProfile()
}}
/>
</Col>

View File

@@ -1,35 +1,35 @@
import {LoverCommentSection} from 'web/components/lover-comment-section'
import LoverProfileHeader from 'web/components/profile/lover-profile-header'
import {ProfileCommentSection} from 'web/components/lover-comment-section'
import ProfileProfileHeader from 'web/components/profile/lover-profile-header'
import ProfileCarousel from 'web/components/profile-carousel'
import {Col} from 'web/components/layout/col'
import {Row} from 'web/components/layout/row'
import {useUser} from 'web/hooks/use-user'
import {User} from 'web/lib/firebase/users'
import LoverAbout from 'web/components/lover-about'
import {LoverAnswers} from 'web/components/answers/lover-answers'
import ProfileAbout from 'web/components/lover-about'
import {ProfileAnswers} from 'web/components/answers/lover-answers'
import {SignUpButton} from 'web/components/nav/love-sidebar'
import {Lover} from 'common/love/lover'
import {LoverBio} from 'web/components/bio/lover-bio'
import {Profile} from 'common/love/lover'
import {ProfileBio} from 'web/components/bio/lover-bio'
import {areGenderCompatible} from 'common/love/compatibility-util'
import {useLover} from 'web/hooks/use-lover'
import {useProfile} from 'web/hooks/use-lover'
import {useGetter} from 'web/hooks/use-getter'
import {getStars} from 'web/lib/supabase/stars'
import {Content} from "web/components/widgets/editor";
import {JSONContent} from "@tiptap/core";
import React from "react";
export function LoverProfile(props: {
lover: Lover
export function ProfileProfile(props: {
lover: Profile
user: User
refreshLover: () => void
fromLoverPage?: Lover
refreshProfile: () => void
fromProfilePage?: Profile
fromSignup?: boolean
}) {
console.log('Rendering LoverProfile for ', props)
const {lover, user, refreshLover, fromLoverPage, fromSignup} = props
console.log('Rendering ProfileProfile for ', props)
const {lover, user, refreshProfile, fromProfilePage, fromSignup} = props
const currentUser = useUser()
const currentLover = useLover()
const currentProfile = useProfile()
// const isCurrentUser = currentUser?.id === user.id
const {data: starredUserIds, refresh: refreshStars} = useGetter(
@@ -53,10 +53,10 @@ export function LoverProfile(props: {
// likesGiven.map((l) => l.user_id).includes(currentUser.id)
// const shipped =
// !!ships && hasShipped(currentUser, fromLoverPage?.user_id, user.id, ships)
// !!ships && hasShipped(currentUser, fromProfilePage?.user_id, user.id, ships)
const areCompatible =
!!currentLover && areGenderCompatible(currentLover, lover)
!!currentProfile && areGenderCompatible(currentProfile, lover)
// Allow everyone to message everyone for now
const showMessageButton = true // liked || likedBack || !areCompatible
@@ -65,21 +65,21 @@ export function LoverProfile(props: {
return (
<>
<LoverProfileHeader
<ProfileProfileHeader
user={user}
lover={lover}
simpleView={!!fromLoverPage}
simpleView={!!fromProfilePage}
starredUserIds={starredUserIds ?? []}
refreshStars={refreshStars}
showMessageButton={showMessageButton}
refreshLover={refreshLover}
refreshProfile={refreshProfile}
/>
{isProfileVisible ? (
<LoverContent
<ProfileContent
user={user}
lover={lover}
refreshLover={refreshLover}
fromLoverPage={fromLoverPage}
refreshProfile={refreshProfile}
fromProfilePage={fromProfilePage}
fromSignup={fromSignup}
// likesGiven={likesGiven ?? []}
// likesReceived={likesReceived ?? []}
@@ -103,19 +103,19 @@ export function LoverProfile(props: {
</Col>
)}
{/*{areCompatible &&*/}
{/* ((!fromLoverPage && !isCurrentUser) ||*/}
{/* (fromLoverPage && fromLoverPage.user_id === currentUser?.id)) && (*/}
{/* ((!fromProfilePage && !isCurrentUser) ||*/}
{/* (fromProfilePage && fromProfilePage.user_id === currentUser?.id)) && (*/}
{/* <Row className="right-0 mr-1 self-end lg:bottom-6">*/}
{/* <LikeButton targetLover={lover} liked={liked} refresh={refresh} />*/}
{/* <LikeButton targetProfile={lover} liked={liked} refresh={refresh} />*/}
{/* </Row>*/}
{/* )}*/}
{/*{fromLoverPage &&*/}
{/* fromLoverPage.user_id !== currentUser?.id &&*/}
{/*{fromProfilePage &&*/}
{/* fromProfilePage.user_id !== currentUser?.id &&*/}
{/* user.id !== currentUser?.id && (*/}
{/* <Row className="sticky bottom-[70px] right-0 mr-1 self-end lg:bottom-6">*/}
{/* <ShipButton*/}
{/* shipped={shipped}*/}
{/* targetId1={fromLoverPage.user_id}*/}
{/* targetId1={fromProfilePage.user_id}*/}
{/* targetId2={user.id}*/}
{/* refresh={refresh}*/}
{/* />*/}
@@ -126,11 +126,11 @@ export function LoverProfile(props: {
)
}
function LoverContent(props: {
function ProfileContent(props: {
user: User
lover: Lover
refreshLover: () => void
fromLoverPage?: Lover
lover: Profile
refreshProfile: () => void
fromProfilePage?: Profile
fromSignup?: boolean
// likesGiven: LikeData[]
// likesReceived: LikeData[]
@@ -140,8 +140,8 @@ function LoverContent(props: {
const {
user,
lover,
refreshLover,
fromLoverPage,
refreshProfile,
fromProfilePage,
fromSignup,
// likesGiven,
// likesReceived,
@@ -154,32 +154,32 @@ function LoverContent(props: {
return (
<>
<LoverAbout lover={lover}/>
<LoverBio
<ProfileAbout lover={lover}/>
<ProfileBio
isCurrentUser={isCurrentUser}
lover={lover}
refreshLover={refreshLover}
fromLoverPage={fromLoverPage}
refreshProfile={refreshProfile}
fromProfilePage={fromProfilePage}
/>
<LoverAnswers
<ProfileAnswers
isCurrentUser={isCurrentUser}
user={user}
fromSignup={fromSignup}
fromLoverPage={fromLoverPage}
fromProfilePage={fromProfilePage}
lover={lover}
/>
<LoverCommentSection
<ProfileCommentSection
onUser={user}
lover={lover}
currentUser={currentUser}
simpleView={!!fromLoverPage}
simpleView={!!fromProfilePage}
/>
{/*<LikesDisplay*/}
{/* likesGiven={likesGiven}*/}
{/* likesReceived={likesReceived}*/}
{/* ships={ships}*/}
{/* refreshShips={refreshShips}*/}
{/* profileLover={lover}*/}
{/* profileProfile={lover}*/}
{/*/>*/}
</>
)

View File

@@ -1,7 +1,7 @@
import {Lover} from 'common/love/lover'
import {Profile} 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 {useProfile} from 'web/hooks/use-lover'
import {useCompatibleProfiles} from 'web/hooks/use-profiles'
import {getStars} from 'web/lib/supabase/stars'
import Router from 'next/router'
@@ -20,7 +20,7 @@ import {useFilters} from "web/components/filters/use-filters";
export function ProfilesHome() {
const user = useUser();
const lover = useLover();
const lover = useProfile();
const you = lover;
const {
@@ -32,7 +32,7 @@ export function ProfilesHome() {
locationFilterProps,
} = useFilters(you ?? undefined);
const [profiles, setProfiles] = usePersistentInMemoryState<Lover[] | undefined>(undefined, 'profile-profiles');
const [profiles, setProfiles] = usePersistentInMemoryState<Profile[] | undefined>(undefined, 'profile-profiles');
const {bookmarkedSearches, refreshBookmarkedSearches} = useBookmarkedSearches(user?.id)
const [isLoadingMore, setIsLoadingMore] = useState(false);
const [isReloading, setIsReloading] = useState(false);
@@ -75,11 +75,11 @@ export function ProfilesHome() {
if (!profiles || isLoadingMore) return false;
try {
setIsLoadingMore(true);
const lastLover = profiles[profiles.length - 1];
const lastProfile = profiles[profiles.length - 1];
const result = await api('get-profiles', removeNullOrUndefinedProps({
limit: 20,
compatibleWithUserId: user?.id,
after: lastLover?.id.toString(),
after: lastProfile?.id.toString(),
...filters
}) as any);
if (result.profiles.length === 0) return false;
@@ -98,7 +98,7 @@ export function ProfilesHome() {
{!lover && <Button className="mb-4 lg:hidden" onClick={() => Router.push('signup')}>Create a profile</Button>}
<Title className="!mb-2 text-3xl">Profiles</Title>
<Search
youLover={you}
youProfile={you}
starredUserIds={starredUserIds ?? []}
filters={filters}
updateFilter={updateFilter}

View File

@@ -10,7 +10,7 @@ import {User} from 'common/user'
import {useEditableUserInfo} from 'web/hooks/use-editable-user-info'
import {LoadingIndicator} from 'web/components/widgets/loading-indicator'
import {Column} from 'common/supabase/utils'
import {LoverRow} from 'common/love/lover'
import {ProfileRow} from 'common/love/lover'
import {SignupBio} from "web/components/bio/editable-bio";
import {JSONContent} from "@tiptap/core";
@@ -40,13 +40,13 @@ export const RequiredLoveUserForm = (props: {
// TODO thread this properly instead of this jank
setEditUsername?: (name: string) => unknown
setEditDisplayName?: (name: string) => unknown
lover: LoverRow
setLover: <K extends Column<'profiles'>>(key: K, value: LoverRow[K] | undefined) => void
lover: ProfileRow
setProfile: <K extends Column<'profiles'>>(key: K, value: ProfileRow[K] | undefined) => void
isSubmitting: boolean
onSubmit?: () => void
loverCreatedAlready?: boolean
}) => {
const {user, onSubmit, loverCreatedAlready, setLover, lover, isSubmitting} = props
const {user, onSubmit, loverCreatedAlready, setProfile, lover, isSubmitting} = props
const {updateUsername, updateDisplayName, userInfo, updateUserState} = useEditableUserInfo(user)
const {
@@ -129,7 +129,7 @@ export const RequiredLoveUserForm = (props: {
<SignupBio
onChange={(e: JSONContent) => {
console.log('bio changed', e, lover.bio)
setLover('bio', e)
setProfile('bio', e)
}}
/>
</Col>

View File

@@ -2,7 +2,7 @@ import clsx from 'clsx'
import { useEffect, useRef, useState } from 'react'
import { api } from 'web/lib/api'
import { countryCodeToFlag } from 'web/lib/util/location'
import { LoverRow } from 'common/love/lover'
import { ProfileRow } from 'common/love/lover'
import {OriginLocation} from "common/filters";
export type City = {
@@ -15,7 +15,7 @@ export type City = {
longitude: number
}
export function loverToCity(lover: LoverRow): City {
export function loverToCity(lover: ProfileRow): City {
return {
geodb_city_id: lover.geodb_city_id!,
city: lover.city,

View File

@@ -9,20 +9,20 @@ import { Tooltip } from 'web/components/widgets/tooltip'
import { Col } from 'web/components/layout/col'
import { MODAL_CLASS, Modal } from 'web/components/layout/modal'
import { Row } from 'web/components/layout/row'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
import { useUserById } from 'web/hooks/use-user-supabase'
import { MatchAvatars } from '../matches/match-avatars'
import { useLover } from 'web/hooks/use-lover'
import { useProfile } from 'web/hooks/use-lover'
import { useAPIGetter } from 'web/hooks/use-api-getter'
export const LikeButton = (props: {
targetLover: Lover
targetProfile: Profile
liked: boolean
refresh: () => Promise<void>
className?: string
}) => {
const { targetLover, liked, refresh, className } = props
const targetId = targetLover.user_id
const { targetProfile, liked, refresh, className } = props
const targetId = targetProfile.user_id
const [isLoading, setIsLoading] = useState(false)
const { data, refresh: refreshHasFreeLike } = useAPIGetter(
@@ -70,14 +70,14 @@ export const LikeButton = (props: {
</Col>
</button>
<LikeConfirmationDialog
targetLover={targetLover}
targetProfile={targetProfile}
hasFreeLike={hasFreeLike}
submit={like}
open={!liked && showConfirmation}
setOpen={setShowConfirmation}
/>
<CancelLikeConfimationDialog
targetLover={targetLover}
targetProfile={targetProfile}
submit={like}
open={liked && showConfirmation}
setOpen={setShowConfirmation}
@@ -87,15 +87,15 @@ export const LikeButton = (props: {
}
const LikeConfirmationDialog = (props: {
targetLover: Lover
targetProfile: Profile
hasFreeLike: boolean
open: boolean
setOpen: (open: boolean) => void
submit: () => void
}) => {
const { open, setOpen, targetLover, hasFreeLike, submit } = props
const youLover = useLover()
const user = useUserById(targetLover.user_id)
const { open, setOpen, targetProfile, hasFreeLike, submit } = props
const youProfile = useProfile()
const user = useUserById(targetProfile.user_id)
return (
<Modal
@@ -115,10 +115,10 @@ const LikeConfirmationDialog = (props: {
<div className="text-ink-500">You get one like per day</div>
</Col>
{youLover && user && (
{youProfile && user && (
<MatchAvatars
profileLover={youLover}
matchedLover={{ ...targetLover, user: user as any }}
profileProfile={youProfile}
matchedProfile={{ ...targetProfile, user: user as any }}
/>
)}
@@ -138,13 +138,13 @@ const LikeConfirmationDialog = (props: {
}
const CancelLikeConfimationDialog = (props: {
targetLover: Lover
targetProfile: Profile
open: boolean
setOpen: (open: boolean) => void
submit: () => void
}) => {
const { open, setOpen, targetLover, submit } = props
const user = useUserById(targetLover.user_id)
const { open, setOpen, targetProfile, submit } = props
const user = useUserById(targetProfile.user_id)
return (
<Modal
open={open}

View File

@@ -3,8 +3,8 @@ import Image from 'next/image'
import Link from 'next/link'
import { UserIcon } from '@heroicons/react/solid'
import { Lover } from 'common/love/lover'
import { useLoverByUserId } from 'web/hooks/use-lover'
import { Profile } from 'common/love/lover'
import { useProfileByUserId } from 'web/hooks/use-lover'
import { Col } from 'web/components/layout/col'
import { Avatar, EmptyAvatar } from 'web/components/widgets/avatar'
import { Carousel } from 'web/components/widgets/carousel'
@@ -21,9 +21,9 @@ export const LikesDisplay = (props: {
likesReceived: LikeData[]
ships: ShipData[]
refreshShips: () => Promise<void>
profileLover: Lover
profileProfile: Profile
}) => {
const { likesGiven, likesReceived, ships, refreshShips, profileLover } = props
const { likesGiven, likesReceived, ships, refreshShips, profileProfile } = props
const likesGivenByUserId = keyBy(likesGiven, (l) => l.user_id)
const likesReceivedByUserId = keyBy(likesReceived, (l) => l.user_id)
@@ -68,7 +68,7 @@ export const LikesDisplay = (props: {
<MatchTile
key={like.user_id}
matchUserId={like.user_id}
profileLover={profileLover}
profileProfile={profileProfile}
/>
)
})}
@@ -86,7 +86,7 @@ export const LikesDisplay = (props: {
<ShipsList
label="Shipped with"
ships={ships}
profileLover={profileLover}
profileProfile={profileProfile}
refreshShips={refreshShips}
/>
)}
@@ -122,7 +122,7 @@ const LikesList = (props: { label: string; likes: LikeData[] }) => {
const UserAvatar = (props: { userId: string; className?: string }) => {
const { userId, className } = props
const lover = useLoverByUserId(userId)
const lover = useProfileByUserId(userId)
const user = useUserById(userId)
// console.log('UserAvatar', user?.username, lover?.pinned_url)
@@ -139,14 +139,14 @@ const UserAvatar = (props: { userId: string; className?: string }) => {
}
export const MatchTile = (props: {
profileLover: Lover
profileProfile: Profile
matchUserId: string
}) => {
const { matchUserId, profileLover } = props
const lover = useLoverByUserId(matchUserId)
const { matchUserId, profileProfile } = props
const lover = useProfileByUserId(matchUserId)
const user = useUserById(matchUserId)
const currentUser = useUser()
const isYourMatch = currentUser?.id === profileLover.user_id
const isYourMatch = currentUser?.id === profileProfile.user_id
if (!lover || !user)
return <Col className="mb-2 h-[184px] w-[200px] shrink-0"></Col>

View File

@@ -5,8 +5,8 @@ import clsx from 'clsx'
import { MODAL_CLASS, Modal } from 'web/components/layout/modal'
import { MatchAvatars } from '../matches/match-avatars'
import { Row } from 'web/components/layout/row'
import { Lover } from 'common/love/lover'
import { useLoverByUserId } from 'web/hooks/use-lover'
import { Profile } from 'common/love/lover'
import { useProfileByUserId } from 'web/hooks/use-lover'
import { Col } from 'web/components/layout/col'
import { EmptyAvatar, Avatar } from 'web/components/widgets/avatar'
import { Carousel } from 'web/components/widgets/carousel'
@@ -22,17 +22,17 @@ import { User } from 'common/user'
export const ShipsList = (props: {
label: string
ships: ShipData[]
profileLover: Lover
profileProfile: Profile
refreshShips: () => Promise<void>
}) => {
const { label, ships, profileLover, refreshShips } = props
const { label, ships, profileProfile, refreshShips } = props
const shipsWithTargetId = ships.map(
({ target1_id, target2_id, ...other }) => ({
...other,
target1_id,
target2_id,
targetId: target1_id === profileLover.user_id ? target2_id : target1_id,
targetId: target1_id === profileProfile.user_id ? target2_id : target1_id,
})
)
const shipsByTargetId = groupBy(shipsWithTargetId, (s) => s.targetId)
@@ -52,7 +52,7 @@ export const ShipsList = (props: {
<ShipsTargetDisplay
key={targetId}
ships={shipsByTargetId[targetId]}
profileLover={profileLover}
profileProfile={profileProfile}
refreshShips={refreshShips}
/>
)
@@ -68,18 +68,18 @@ export const ShipsList = (props: {
const ShipsTargetDisplay = (props: {
ships: (ShipData & { targetId: string })[]
refreshShips: () => Promise<void>
profileLover: Lover
profileProfile: Profile
className?: string
}) => {
const { ships, refreshShips, profileLover, className } = props
const { ships, refreshShips, profileProfile, className } = props
const { targetId } = ships[0]
const targetLover = useLoverByUserId(targetId)
const targetProfile = useProfileByUserId(targetId)
const targetUser = useUserById(targetId) as User | null | undefined
const [open, setOpen] = useState(false)
const currentUser = useUser()
const shipped = hasShipped(currentUser, profileLover.user_id, targetId, ships)
const shipped = hasShipped(currentUser, profileProfile.user_id, targetId, ships)
return (
<>
@@ -96,15 +96,15 @@ const ShipsTargetDisplay = (props: {
{open && (
<Modal open={open} setOpen={setOpen}>
<Col className={clsx(MODAL_CLASS, 'relative')}>
{targetLover && targetUser && (
{targetProfile && targetUser && (
<>
<MatchAvatars
profileLover={profileLover}
matchedLover={{ ...targetLover, user: targetUser }}
profileProfile={profileProfile}
matchedProfile={{ ...targetProfile, user: targetUser }}
/>
<Row className="w-full items-baseline justify-stretch gap-2 text-lg font-semibold">
<Row className="flex-1 justify-end">
<UserLink hideBadge user={profileLover.user} noLink />
<UserLink hideBadge user={profileProfile.user} noLink />
</Row>
&
<Row className="flex-1 justify-start">
@@ -124,12 +124,12 @@ const ShipsTargetDisplay = (props: {
</Col>
</Col>
{currentUser &&
profileLover.user_id !== currentUser?.id &&
profileProfile.user_id !== currentUser?.id &&
targetId !== currentUser?.id && (
<Row className="sticky bottom-[70px] right-0 mr-1 self-end lg:bottom-6">
<ShipButton
shipped={shipped}
targetId1={profileLover.user_id}
targetId1={profileProfile.user_id}
targetId2={targetId}
refresh={refreshShips}
/>
@@ -144,7 +144,7 @@ const ShipsTargetDisplay = (props: {
const UserAvatar = (props: { userId: string; className?: string }) => {
const { userId, className } = props
const lover = useLoverByUserId(userId)
const lover = useProfileByUserId(userId)
const user = useUserById(userId)
if (!lover || !lover.pinned_url)
@@ -162,7 +162,7 @@ const UserAvatar = (props: { userId: string; className?: string }) => {
const UserInfoRow = (props: { userId: string; className?: string }) => {
const { userId, className } = props
const user = useUserById(userId)
const lover = useLoverByUserId(userId)
const lover = useProfileByUserId(userId)
return (
<Row className={clsx(className, 'items-center gap-2')}>

View File

@@ -6,17 +6,17 @@ import { api } from 'web/lib/api'
import { buttonClass } from 'web/components/buttons/button'
import { track } from 'web/lib/service/analytics'
import { Tooltip } from 'web/components/widgets/tooltip'
import { Lover } from 'common/love/lover'
import { Profile } from 'common/love/lover'
export const StarButton = (props: {
targetLover: Lover
targetProfile: Profile
isStarred: boolean
refresh: () => Promise<void>
hideTooltip?: boolean
className?: string
}) => {
const { targetLover, refresh, hideTooltip, className } = props
const targetId = targetLover.user_id
const { targetProfile, refresh, hideTooltip, className } = props
const targetId = targetProfile.user_id
const [isStarred, setIsStarred] = useState(props.isStarred)
useEffect(() => {

View File

@@ -5,7 +5,7 @@ import { useEffect, useState } from 'react'
import { uniqBy } from 'lodash'
import { convertComment } from 'common/supabase/comment'
export function useLiveCommentsOnLover(userId: string) {
export function useLiveCommentsOnProfile(userId: string) {
const [comments, setComments] = useState<Comment[]>([])
useEffect(() => {

View File

@@ -1,6 +1,6 @@
import { useLover } from './use-lover'
import { useProfile } from './use-lover'
export const useIsLooking = () => {
const lover = useLover()
const lover = useProfile()
return !!(lover && lover.looking_for_matches)
}

View File

@@ -3,50 +3,50 @@ import {useEffect} from 'react'
import {Row} from 'common/supabase/utils'
import {usePersistentInMemoryState} from 'web/hooks/use-persistent-in-memory-state'
import {User} from 'common/user'
import {getLoverRow, Lover, LoverRow} from 'common/love/lover'
import {getProfileRow, Profile, ProfileRow} from 'common/love/lover'
import {db} from 'web/lib/supabase/db'
import {usePersistentLocalState} from 'web/hooks/use-persistent-local-state'
export const useLover = () => {
export const useProfile = () => {
const user = useUser()
const [lover, setLover] = usePersistentLocalState<
const [lover, setProfile] = usePersistentLocalState<
Row<'profiles'> | undefined | null
>(undefined, `lover-${user?.id}`)
const refreshLover = () => {
const refreshProfile = () => {
if (user) {
console.log('Refreshing lover in useLover for', user?.username, lover);
getLoverRow(user.id, db).then((lover) => {
if (!lover) setLover(null)
else setLover(lover)
console.log('Refreshing lover in useProfile for', user?.username, lover);
getProfileRow(user.id, db).then((lover) => {
if (!lover) setProfile(null)
else setProfile(lover)
})
}
}
useEffect(() => {
refreshLover()
refreshProfile()
}, [user?.id])
return user && lover ? {...lover, user} : lover === null ? null : undefined
}
export const useLoverByUser = (user: User | undefined) => {
export const useProfileByUser = (user: User | undefined) => {
const userId = user?.id
const [lover, setLover] = usePersistentInMemoryState<
Lover | undefined | null
const [lover, setProfile] = usePersistentInMemoryState<
Profile | undefined | null
>(undefined, `lover-user-${userId}`)
function refreshLover() {
function refreshProfile() {
if (userId) {
console.log('Refreshing lover in useLoverByUser for', user?.username, lover);
getLoverRow(userId, db)
console.log('Refreshing lover in useProfileByUser for', user?.username, lover);
getProfileRow(userId, db)
.then((lover) => {
if (!lover) setLover(null)
else setLover({...lover, user})
if (!lover) setProfile(null)
else setProfile({...lover, user})
})
.catch(error => {
console.log('Warning: lover not found', user?.username, error);
setLover(null)
setProfile(null)
return
});
console.log('End Refreshing lover for', user?.username, lover);
@@ -54,23 +54,23 @@ export const useLoverByUser = (user: User | undefined) => {
}
useEffect(() => {
refreshLover()
refreshProfile()
}, [userId])
return {lover, refreshLover}
return {lover, refreshProfile}
}
export const useLoverByUserId = (userId: string | undefined) => {
const [lover, setLover] = usePersistentInMemoryState<
LoverRow | undefined | null
export const useProfileByUserId = (userId: string | undefined) => {
const [lover, setProfile] = usePersistentInMemoryState<
ProfileRow | undefined | null
>(undefined, `lover-${userId}`)
useEffect(() => {
console.log('Refreshing lover in useLoverByUserId for', userId, lover);
console.log('Refreshing lover in useProfileByUserId for', userId, lover);
if (userId)
getLoverRow(userId, db).then((lover) => {
if (!lover) setLover(null)
else setLover(lover)
getProfileRow(userId, db).then((lover) => {
if (!lover) setProfile(null)
else setProfile(lover)
})
}, [userId])

View File

@@ -1,10 +1,10 @@
import { useEffect } from 'react'
import { useLover } from 'web/hooks/use-lover'
import { useProfile } from 'web/hooks/use-lover'
import { useIsAuthorized } from 'web/hooks/use-user'
import { run } from 'common/supabase/utils'
import { db } from 'web/lib/supabase/db'
export const useOnline = () => {
const lover = useLover()
const lover = useProfile()
const isAuthed = useIsAuthorized()
useEffect(() => {
if (!lover || !isAuthed) return

View File

@@ -3,7 +3,7 @@ import { useEffect } from 'react'
import { usePersistentInMemoryState } from 'web/hooks/use-persistent-in-memory-state'
import { api } from 'web/lib/api'
import { APIResponse } from 'common/api/schema'
import { useLoverByUserId } from './use-lover'
import { useProfileByUserId } from './use-lover'
import { getProfilesCompatibilityFactor } from 'common/love/compatibility-score'
export const useCompatibleProfiles = (
@@ -14,7 +14,7 @@ export const useCompatibleProfiles = (
APIResponse<'compatible-profiles'> | undefined | null
>(undefined, `compatible-profiles-${userId}`)
const lover = useLoverByUserId(userId ?? undefined)
const lover = useProfileByUserId(userId ?? undefined)
useEffect(() => {
if (userId) {

View File

@@ -28,6 +28,6 @@ function curriedAPI<P extends APIPath>(path: P) {
return (params: APIParams<P>) => api(path, params)
}
export const updateLover = curriedAPI('update-lover')
export const updateProfile = curriedAPI('update-lover')
export const updateUser = curriedAPI('me/update')
export const report = curriedAPI('report')

View File

@@ -1,14 +1,14 @@
import Router from 'next/router'
import { firebaseLogin } from 'web/lib/firebase/users'
import { db } from 'web/lib/supabase/db'
import { getLoverRow } from 'common/love/lover'
import { getProfileRow } from 'common/love/lover'
export const signupThenMaybeRedirectToSignup = async () => {
const creds = await firebaseLogin()
await Router.push('/')
const userId = creds?.user.uid
if (userId) {
const lover = await getLoverRow(userId, db)
const lover = await getProfileRow(userId, db)
if (!lover) {
await Router.push('/signup')
}

View File

@@ -3,7 +3,7 @@ import Router from 'next/router'
import Head from 'next/head'
import {useRouter} from 'next/router'
import {LovePage} from 'web/components/love-page'
import {useLoverByUser} from 'web/hooks/use-lover'
import {useProfileByUser} from 'web/hooks/use-lover'
import {Button} from 'web/components/buttons/button'
import {Col} from 'web/components/layout/col'
import {Row} from 'web/components/layout/row'
@@ -13,9 +13,9 @@ import {useTracking} from 'web/hooks/use-tracking'
import {BackButton} from 'web/components/back-button'
import {useSaveReferral} from 'web/hooks/use-save-referral'
import {getLoveOgImageUrl} from 'common/love/og-image'
import {getLoverRow, LoverRow} from 'common/love/lover'
import {getProfileRow, ProfileRow} from 'common/love/lover'
import {db} from 'web/lib/supabase/db'
import {LoverProfile} from 'web/components/profile/lover-profile'
import {ProfileProfile} from 'web/components/profile/lover-profile'
import {User} from 'common/user'
import {getUserForStaticProps} from 'common/supabase/users'
import {type GetStaticProps} from 'next'
@@ -58,7 +58,7 @@ export const getStaticProps: GetStaticProps<
}
}
const lover = await getLoverRow(user.id, db)
const lover = await getProfileRow(user.id, db)
return {
props: {
user,
@@ -82,7 +82,7 @@ type DeletedUserPageProps = {
type ActiveUserPageProps = {
user: User
username: string
lover: LoverRow
lover: ProfileRow
}
export default function UserPage(props: UserPageProps) {
@@ -111,13 +111,13 @@ function UserPageInner(props: ActiveUserPageProps) {
useSaveReferral(currentUser, {defaultReferrerUsername: username})
useTracking('view love profile', {username: user?.username})
const [staticLover] = useState(
const [staticProfile] = useState(
props.lover && user ? {...props.lover, user: user} : null
)
const {lover: clientLover, refreshLover} = useLoverByUser(user)
const {lover: clientProfile, refreshProfile} = useProfileByUser(user)
// Show previous profile while loading another one
const lover = clientLover ?? staticLover
// console.log('lover:', user?.username, lover, clientLover, staticLover)
const lover = clientProfile ?? staticProfile
// console.log('lover:', user?.username, lover, clientProfile, staticProfile)
return (
<LovePage
@@ -141,11 +141,11 @@ function UserPageInner(props: ActiveUserPageProps) {
{currentUser !== undefined && (
<Col className={'gap-4'}>
{lover ? (
<LoverProfile
<ProfileProfile
key={lover.user_id}
lover={lover}
user={user}
refreshLover={refreshLover}
refreshProfile={refreshProfile}
fromSignup={fromSignup}
/>
) : isCurrentUser ? (

View File

@@ -42,7 +42,7 @@ function capitalize(str: string) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
function OgLover(props: LoveOgProps) {
function OgProfile(props: LoveOgProps) {
const { avatarUrl, username, name, age, city, gender } = props
return (
<div
@@ -111,7 +111,7 @@ export default async function handler(req: NextRequest) {
const loveOgProps = Object.fromEntries(
searchParams.entries()
) as LoveOgProps
const image = OgLover(loveOgProps)
const image = OgProfile(loveOgProps)
return new ImageResponse(classToTw(image), options as ImageResponseOptions)
} catch (e: any) {

View File

@@ -1,9 +1,9 @@
import {Lover, LoverRow} from 'common/love/lover'
import {Profile, ProfileRow} from 'common/love/lover'
import {Column} from 'common/supabase/utils'
import {User} from 'common/user'
import {OptionalLoveUserForm} from 'web/components/optional-lover-form'
import {RequiredLoveUserForm} from 'web/components/required-lover-form'
import {useLoverByUser} from 'web/hooks/use-lover'
import {useProfileByUser} from 'web/hooks/use-lover'
import Router from 'next/router'
import {useEffect, useState} from 'react'
import {Col} from 'web/components/layout/col'
@@ -13,7 +13,7 @@ import {LovePage} from "web/components/love-page";
export default function ProfilePage() {
const user = useUser()
const {lover} = useLoverByUser(user ?? undefined)
const {lover} = useProfileByUser(user ?? undefined)
useEffect(() => {
if (user === null || lover === null) {
@@ -24,16 +24,16 @@ export default function ProfilePage() {
return user && lover && <ProfilePageInner user={user} lover={lover}/>
}
function ProfilePageInner(props: { user: User; lover: Lover }) {
function ProfilePageInner(props: { user: User; lover: Profile }) {
const {user} = props
const [lover, setLover] = useState<Lover>({
const [lover, setProfile] = useState<Profile>({
...props.lover,
user,
})
const setLoverState = <K extends Column<'profiles'>>(key: K, value: LoverRow[K] | undefined) => {
setLover((prevState) => ({...prevState, [key]: value}))
const setProfileState = <K extends Column<'profiles'>>(key: K, value: ProfileRow[K] | undefined) => {
setProfile((prevState) => ({...prevState, [key]: value}))
}
const [displayName, setDisplayName] = useState(user.name)
@@ -45,7 +45,7 @@ function ProfilePageInner(props: { user: User; lover: Lover }) {
<Col className={'w-full px-6 py-4'}>
<RequiredLoveUserForm
user={user}
setLover={setLoverState}
setProfile={setProfileState}
lover={lover}
loverCreatedAlready={true}
isSubmitting={false}
@@ -56,7 +56,7 @@ function ProfilePageInner(props: { user: User; lover: Lover }) {
<OptionalLoveUserForm
lover={lover}
user={user}
setLover={setLoverState}
setProfile={setProfileState}
buttonLabel={'Save'}
onSubmit={async () => {
api('me/update', {

View File

@@ -9,7 +9,7 @@ import {createUserWithEmailAndPassword} from "firebase/auth";
import {auth} from "web/lib/firebase/users";
import FavIcon from "web/public/FavIcon";
import {LovePage} from "web/components/love-page";
import {getLoverRow} from "common/love/lover";
import {getProfileRow} from "common/love/lover";
import {db} from "web/lib/supabase/db";
import Router from "next/router";
import {useUser} from "web/hooks/use-user";
@@ -40,9 +40,9 @@ function RegisterComponent() {
// }
useEffect(() => {
const checkLoverAndRedirect = async () => {
const checkProfileAndRedirect = async () => {
if (user) {
const lover = await getLoverRow(user.id, db)
const lover = await getProfileRow(user.id, db)
if (lover) {
await Router.push('/')
} else {
@@ -51,7 +51,7 @@ function RegisterComponent() {
setIsLoading(false);
}
}
checkLoverAndRedirect()
checkProfileAndRedirect()
}, [user]);
const handleEmailPasswordSignUp = async (email: string, password: string) => {

View File

@@ -7,7 +7,7 @@ import {auth, firebaseLogin} from "web/lib/firebase/users";
import FavIcon from "web/public/FavIcon";
import {signInWithEmailAndPassword} from "firebase/auth";
import {getLoverRow} from "common/love/lover";
import {getProfileRow} from "common/love/lover";
import {db} from "web/lib/supabase/db";
import Router from "next/router";
import {LovePage} from "web/components/love-page";
@@ -43,7 +43,7 @@ function RegisterComponent() {
if (user) {
console.log("User signed in:", user);
try {
const lover = await getLoverRow(user.id, db)
const lover = await getProfileRow(user.id, db)
if (lover) {
await Router.push('/')
} else {

View File

@@ -12,8 +12,8 @@ import {useTracking} from 'web/hooks/use-tracking'
import {track} from 'web/lib/service/analytics'
import {safeLocalStorage} from 'web/lib/util/local'
import {removeNullOrUndefinedProps} from 'common/util/object'
import {useLoverByUserId} from 'web/hooks/use-lover'
import {LoverRow} from 'common/love/lover'
import {useProfileByUserId} from 'web/hooks/use-lover'
import {ProfileRow} from 'common/love/lover'
import {LovePage} from "web/components/love-page";
import {Button} from "web/components/buttons/button";
@@ -25,28 +25,28 @@ export default function SignupPage() {
useTracking('view love signup page')
// Omit the id, created_time?
const [loverForm, setLoverForm] = useState<LoverRow>({
const [loverForm, setProfileForm] = useState<ProfileRow>({
...initialRequiredState,
} as any)
const setLoverState = (key: keyof LoverRow, value: any) => {
setLoverForm((prevState) => ({...prevState, [key]: value}))
const setProfileState = (key: keyof ProfileRow, value: any) => {
setProfileForm((prevState) => ({...prevState, [key]: value}))
}
const [isSubmitting, setIsSubmitting] = useState(false)
const existingLover = useLoverByUserId(user?.id)
const existingProfile = useProfileByUserId(user?.id)
useEffect(() => {
if (existingLover) {
setLoverForm(existingLover)
if (existingProfile) {
setProfileForm(existingProfile)
setStep(1)
}
}, [existingLover])
}, [existingProfile])
if (step === 1 && user) {
return <LovePage trackPageView={'register'}>
<Col className={'w-full px-6 py-4'}>
<OptionalLoveUserForm
setLover={setLoverState}
setProfile={setProfileState}
lover={loverForm}
user={user}
fromSignup
@@ -77,7 +77,7 @@ export default function SignupPage() {
{step === 0 ? (
<RequiredLoveUserForm
user={user}
setLover={setLoverState}
setProfile={setProfileState}
lover={loverForm}
isSubmitting={isSubmitting}
onSubmit={async () => {
@@ -104,7 +104,7 @@ export default function SignupPage() {
})
setIsSubmitting(false)
if (lover) {
setLoverForm(lover)
setProfileForm(lover)
setStep(1)
scrollTo(0, 0)
track('submit love required profile')