diff --git a/backend/api/src/app.ts b/backend/api/src/app.ts index 60b826c..0658116 100644 --- a/backend/api/src/app.ts +++ b/backend/api/src/app.ts @@ -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 {createProfile} from './create-lover' +import {createProfile} from './create-profile' import {createUser} from './create-user' import {getCompatibilityQuestions} from './get-compatibililty-questions' import {getLikesAndShips} from './get-likes-and-ships' -import {getProfileAnswers} from './get-lover-answers' +import {getProfileAnswers} from './get-profile-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 {likeProfile} from './like-lover' +import {likeProfile} from './like-profile' 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 {starProfile} from './star-lover' -import {updateProfile} from './update-lover' +import {starProfile} from './star-profile' +import {updateProfile} from './update-profile' 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 } = { 'ban-user': banUser, report: report, 'create-user': createUser, - 'create-lover': createProfile, + 'create-profile': createProfile, me: getMe, 'me/private': getCurrentPrivateUser, 'me/update': updateMe, 'update-notif-settings': updateNotifSettings, 'me/delete': deleteMe, - 'update-lover': updateProfile, - 'like-lover': likeProfile, + 'update-profile': updateProfile, + 'like-profile': likeProfile, 'ship-profiles': shipProfiles, 'get-likes-and-ships': getLikesAndShips, 'has-free-like': hasFreeLike, - 'star-lover': starProfile, + 'star-profile': starProfile, 'get-profiles': getProfiles, - 'get-lover-answers': getProfileAnswers, + 'get-profile-answers': getProfileAnswers, 'get-compatibility-questions': getCompatibilityQuestions, 'remove-pinned-photo': removePinnedPhoto, 'create-comment': createComment, diff --git a/backend/api/src/compatible-profiles.ts b/backend/api/src/compatible-profiles.ts index 3b31a4a..f39979c 100644 --- a/backend/api/src/compatible-profiles.ts +++ b/backend/api/src/compatible-profiles.ts @@ -15,32 +15,32 @@ export const getCompatibleProfilesHandler: APIHandler< } export const getCompatibleProfiles = async (userId: string) => { - const lover = await getProfile(userId) + const profile = await getProfile(userId) - log('got lover', { - id: lover?.id, - userId: lover?.user_id, - username: lover?.user?.username, + log('got profile', { + id: profile?.id, + userId: profile?.user_id, + username: profile?.user?.username, }) - if (!lover) throw new APIError(404, 'Profile not found') + if (!profile) throw new APIError(404, 'Profile not found') - const profiles = await getGenderCompatibleProfiles(lover) + const profiles = await getGenderCompatibleProfiles(profile) - const loverAnswers = await getCompatibilityAnswers([ + const profileAnswers = await getCompatibilityAnswers([ userId, ...profiles.map((l) => l.user_id), ]) - log('got lover answers ' + loverAnswers.length) + log('got profile answers ' + profileAnswers.length) - const answersByUserId = groupBy(loverAnswers, 'creator_id') - const loverCompatibilityScores = Object.fromEntries( + const answersByUserId = groupBy(profileAnswers, 'creator_id') + const profileCompatibilityScores = Object.fromEntries( profiles.map( (l) => [ l.user_id, getCompatibilityScore( - answersByUserId[lover.user_id] ?? [], + answersByUserId[profile.user_id] ?? [], answersByUserId[l.user_id] ?? [] ), ] as const @@ -49,13 +49,13 @@ export const getCompatibleProfiles = async (userId: string) => { const sortedCompatibleProfiles = sortBy( profiles, - (l) => loverCompatibilityScores[l.user_id].score + (l) => profileCompatibilityScores[l.user_id].score ).reverse() return { status: 'success', - lover, + profile, compatibleProfiles: sortedCompatibleProfiles, - loverCompatibilityScores, + profileCompatibilityScores, } } diff --git a/backend/api/src/create-comment.ts b/backend/api/src/create-comment.ts index ed34b53..4fcc887 100644 --- a/backend/api/src/create-comment.ts +++ b/backend/api/src/create-comment.ts @@ -32,8 +32,8 @@ export const createComment: APIHandler<'create-comment'> = async ( if (!onUser) throw new APIError(404, 'User not found') const pg = createSupabaseDirectClient() - const comment = await pg.one>( - `insert into lover_comments (user_id, user_name, user_username, user_avatar_url, on_user_id, content, reply_to_comment_id) + const comment = await pg.one>( + `insert into profile_comments (user_id, user_name, user_username, user_avatar_url, on_user_id, content, reply_to_comment_id) values ($1, $2, $3, $4, $5, $6, $7) returning *`, [ creator.id, @@ -104,7 +104,7 @@ const createNewCommentOnProfileNotification = async ( createdTime: Date.now(), isSeen: false, sourceId: commentId.toString(), - sourceType: 'comment_on_lover', + sourceType: 'comment_on_profile', sourceUpdateType: 'created', sourceUserName: creator.name, sourceUserUsername: creator.username, diff --git a/backend/api/src/create-lover.ts b/backend/api/src/create-profile.ts similarity index 90% rename from backend/api/src/create-lover.ts rename to backend/api/src/create-profile.ts index fcd6d6d..fab03e1 100644 --- a/backend/api/src/create-lover.ts +++ b/backend/api/src/create-profile.ts @@ -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 createProfile: APIHandler<'create-lover'> = async (body, auth) => { +export const createProfile: APIHandler<'create-profile'> = async (body, auth) => { const pg = createSupabaseDirectClient() const { data: existingUser } = await tryCatch( @@ -40,7 +40,7 @@ export const createProfile: APIHandler<'create-lover'> = async (body, auth) => { } log('Created user', data) - await track(user.id, 'create lover', { username: user.username }) + await track(user.id, 'create profile', { username: user.username }) return data } diff --git a/backend/api/src/create-user.ts b/backend/api/src/create-user.ts index aa2b821..c2dcebc 100644 --- a/backend/api/src/create-user.ts +++ b/backend/api/src/create-user.ts @@ -123,7 +123,7 @@ export const createUser: APIHandler<'create-user'> = async ( log('created user ', { username: user.username, firebaseId: auth.uid }) const continuation = async () => { - await track(auth.uid, 'create lover', { username: user.username }) + await track(auth.uid, 'create profile', { username: user.username }) } return { diff --git a/backend/api/src/get-lover-answers.ts b/backend/api/src/get-profile-answers.ts similarity index 87% rename from backend/api/src/get-lover-answers.ts rename to backend/api/src/get-profile-answers.ts index b712de9..fc3b757 100644 --- a/backend/api/src/get-lover-answers.ts +++ b/backend/api/src/get-profile-answers.ts @@ -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 getProfileAnswers: APIHandler<'get-lover-answers'> = async ( +export const getProfileAnswers: APIHandler<'get-profile-answers'> = async ( props, _auth ) => { diff --git a/backend/api/src/hide-comment.ts b/backend/api/src/hide-comment.ts index e5f85a8..3a57e54 100644 --- a/backend/api/src/hide-comment.ts +++ b/backend/api/src/hide-comment.ts @@ -10,8 +10,8 @@ export const hideComment: APIHandler<'hide-comment'> = async ( auth ) => { const pg = createSupabaseDirectClient() - const comment = await pg.oneOrNone>( - `select * from lover_comments where id = $1`, + const comment = await pg.oneOrNone>( + `select * from profile_comments where id = $1`, [commentId] ) if (!comment) { @@ -26,7 +26,7 @@ export const hideComment: APIHandler<'hide-comment'> = async ( throw new APIError(403, 'You are not allowed to hide this comment') } - await pg.none(`update lover_comments set hidden = $2 where id = $1`, [ + await pg.none(`update profile_comments set hidden = $2 where id = $1`, [ commentId, hide, ]) diff --git a/backend/api/src/like-lover.ts b/backend/api/src/like-profile.ts similarity index 95% rename from backend/api/src/like-lover.ts rename to backend/api/src/like-profile.ts index 01a07ce..4726d7b 100644 --- a/backend/api/src/like-lover.ts +++ b/backend/api/src/like-profile.ts @@ -6,7 +6,7 @@ import { log } from 'shared/utils' import { tryCatch } from 'common/util/try-catch' import { Row } from 'common/supabase/utils' -export const likeProfile: APIHandler<'like-lover'> = async (props, auth) => { +export const likeProfile: APIHandler<'like-profile'> = async (props, auth) => { const { targetUserId, remove } = props const creatorId = auth.uid diff --git a/backend/api/src/star-lover.ts b/backend/api/src/star-profile.ts similarity index 94% rename from backend/api/src/star-lover.ts rename to backend/api/src/star-profile.ts index 12ebc1f..fa1e72a 100644 --- a/backend/api/src/star-lover.ts +++ b/backend/api/src/star-profile.ts @@ -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 starProfile: APIHandler<'star-lover'> = async (props, auth) => { +export const starProfile: APIHandler<'star-profile'> = async (props, auth) => { const { targetUserId, remove } = props const creatorId = auth.uid diff --git a/backend/api/src/update-lover.ts b/backend/api/src/update-profile.ts similarity index 83% rename from backend/api/src/update-lover.ts rename to backend/api/src/update-profile.ts index 618e34c..6d2da4a 100644 --- a/backend/api/src/update-lover.ts +++ b/backend/api/src/update-profile.ts @@ -7,7 +7,7 @@ import { tryCatch } from 'common/util/try-catch' import { update } from 'shared/supabase/utils' import { type Row } from 'common/supabase/utils' -export const updateProfile: APIHandler<'update-lover'> = async ( +export const updateProfile: APIHandler<'update-profile'> = async ( parsedBody, auth ) => { @@ -25,7 +25,7 @@ export const updateProfile: APIHandler<'update-lover'> = async ( } !parsedBody.last_online_time && - log('Updating lover', { userId: auth.uid, parsedBody }) + log('Updating profile', { userId: auth.uid, parsedBody }) await removePinnedUrlFromPhotoUrls(parsedBody) if (parsedBody.avatar_url) { @@ -37,8 +37,8 @@ export const updateProfile: APIHandler<'update-lover'> = async ( ) if (error) { - log('Error updating lover', error) - throw new APIError(500, 'Error updating lover') + log('Error updating profile', error) + throw new APIError(500, 'Error updating profile') } return data diff --git a/backend/email/emails/functions/helpers.tsx b/backend/email/emails/functions/helpers.tsx index 57f148f..cde76c3 100644 --- a/backend/email/emails/functions/helpers.tsx +++ b/backend/email/emails/functions/helpers.tsx @@ -20,8 +20,8 @@ const from = 'Compass ' // 'new_match' // ) // if (!privateUser.email || !sendToEmail) return -// const lover = await getProfile(privateUser.id) -// if (!lover) return +// const profile = await getProfile(privateUser.id) +// if (!profile) return // // return await sendEmail({ // from, @@ -29,10 +29,10 @@ const from = 'Compass ' // to: privateUser.email, // react: ( // // ), @@ -51,9 +51,9 @@ export const sendNewMessageEmail = async ( ) if (!privateUser.email || !sendToEmail) return - const lover = await getProfile(fromUser.id) + const profile = await getProfile(fromUser.id) - if (!lover) { + if (!profile) { console.error('Could not send email notification: User not found') return } @@ -65,7 +65,7 @@ export const sendNewMessageEmail = async ( html: await render( { console.log(`\nSearching comments for ${nodeName}...`) const commentQuery = renderSql( select('id, user_id, on_user_id, content'), - from('lover_comments'), + from('profile_comments'), where(`jsonb_path_exists(content, '$.**.type ? (@ == "${nodeName}")')`) ) const comments = await pg.manyOrNone(commentQuery) diff --git a/backend/scripts/remove-tiptap-nodes.ts b/backend/scripts/remove-tiptap-nodes.ts index 102a1f8..9f16f30 100644 --- a/backend/scripts/remove-tiptap-nodes.ts +++ b/backend/scripts/remove-tiptap-nodes.ts @@ -33,7 +33,7 @@ runScript(async ({ pg }) => { console.log('\nSearching comments for linkPreviews...') const commentQuery = renderSql( select('id, content'), - from('lover_comments'), + from('profile_comments'), where(`jsonb_path_exists(content, '$.**.type ? (@ == "${nodeType}")')`) ) const comments = await pg.manyOrNone(commentQuery) @@ -45,7 +45,7 @@ runScript(async ({ pg }) => { console.log('before', comment.content) console.log('after', newContent) - await pg.none('update lover_comments set content = $1 where id = $2', [ + await pg.none('update profile_comments set content = $1 where id = $2', [ newContent, comment.id, ]) diff --git a/backend/shared/src/create-love-notification.ts b/backend/shared/src/create-love-notification.ts index ab350d2..2b18495 100644 --- a/backend/shared/src/create-love-notification.ts +++ b/backend/shared/src/create-love-notification.ts @@ -10,9 +10,9 @@ 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 getProfile(creator_id) + const profile = await getProfile(creator_id) - if (!targetPrivateUser || !lover) return + if (!targetPrivateUser || !profile) return const { sendToBrowser } = getNotificationDestinationsForUser( targetPrivateUser, @@ -30,9 +30,9 @@ export const createLoveLikeNotification = async (like: Row<'love_likes'>) => { sourceId: like_id, sourceType: 'love_like', sourceUpdateType: 'created', - sourceUserName: lover.user.name, - sourceUserUsername: lover.user.username, - sourceUserAvatarUrl: lover.pinned_url ?? lover.user.avatarUrl, + sourceUserName: profile.user.name, + sourceUserUsername: profile.user.username, + sourceUserAvatarUrl: profile.pinned_url ?? profile.user.avatarUrl, sourceText: '', } const pg = createSupabaseDirectClient() @@ -48,13 +48,13 @@ export const createLoveShipNotification = async ( const creator = await getUser(creator_id) const targetPrivateUser = await getPrivateUser(recipientId) - const lover = await getProfile(otherTargetId) + const profile = await getProfile(otherTargetId) - if (!creator || !targetPrivateUser || !lover) { + if (!creator || !targetPrivateUser || !profile) { console.error('Could not load user object', { creator, targetPrivateUser, - lover, + profile, }) return } @@ -75,9 +75,9 @@ export const createLoveShipNotification = async ( sourceId: ship_id, sourceType: 'love_ship', sourceUpdateType: 'created', - sourceUserName: lover.user.name, - sourceUserUsername: lover.user.username, - sourceUserAvatarUrl: lover.pinned_url ?? lover.user.avatarUrl, + sourceUserName: profile.user.name, + sourceUserUsername: profile.user.username, + sourceUserAvatarUrl: profile.pinned_url ?? profile.user.avatarUrl, sourceText: '', data: { creatorId: creator_id, diff --git a/backend/shared/src/love/supabase.ts b/backend/shared/src/love/supabase.ts index 421ad26..e8c2096 100644 --- a/backend/shared/src/love/supabase.ts +++ b/backend/shared/src/love/supabase.ts @@ -1,5 +1,5 @@ import { areGenderCompatible } from 'common/love/compatibility-util' -import { type Profile, type ProfileRow } from 'common/love/lover' +import { type Profile, type ProfileRow } from 'common/love/profile' import { type User } from 'common/user' import { Row } from 'common/supabase/utils' import { createSupabaseDirectClient } from 'shared/supabase/init' @@ -58,7 +58,7 @@ export const getProfiles = async (userIds: string[]) => { ) } -export const getGenderCompatibleProfiles = async (lover: ProfileRow) => { +export const getGenderCompatibleProfiles = async (profile: ProfileRow) => { const pg = createSupabaseDirectClient() const profiles = await pg.map( ` @@ -74,14 +74,14 @@ export const getGenderCompatibleProfiles = async (lover: ProfileRow) => { and (data->>'userDeleted' != 'true' or data->>'userDeleted' is null) and profiles.pinned_url is not null `, - { ...lover }, + { ...profile }, convertRow ) - return profiles.filter((l: Profile) => areGenderCompatible(lover, l)) + return profiles.filter((l: Profile) => areGenderCompatible(profile, l)) } export const getCompatibleProfiles = async ( - lover: ProfileRow, + profile: ProfileRow, radiusKm: number | undefined ) => { const pg = createSupabaseDirectClient() @@ -111,7 +111,7 @@ export const getCompatibleProfiles = async ( -- Location and calculate_earth_distance_km($(city_latitude), $(city_longitude), profiles.city_latitude, profiles.city_longitude) < $(radiusKm) `, - { ...lover, radiusKm: radiusKm ?? 40_000 }, + { ...profile, radiusKm: radiusKm ?? 40_000 }, convertRow ) } diff --git a/backend/supabase/migration.sql b/backend/supabase/migration.sql index d5ce3e5..0805c2d 100644 --- a/backend/supabase/migration.sql +++ b/backend/supabase/migration.sql @@ -9,7 +9,7 @@ BEGIN; \i backend/supabase/private_user_messages.sql \i backend/supabase/private_user_seen_message_channels.sql \i backend/supabase/love_answers.sql -\i backend/supabase/lover_comments.sql +\i backend/supabase/profile_comments.sql \i backend/supabase/love_compatibility_answers.sql \i backend/supabase/love_likes.sql \i backend/supabase/love_questions.sql diff --git a/backend/supabase/lover_comments.sql b/backend/supabase/profile_comments.sql similarity index 54% rename from backend/supabase/lover_comments.sql rename to backend/supabase/profile_comments.sql index ef09130..fa29ca7 100644 --- a/backend/supabase/lover_comments.sql +++ b/backend/supabase/profile_comments.sql @@ -1,4 +1,4 @@ -CREATE TABLE IF NOT EXISTS lover_comments ( +CREATE TABLE IF NOT EXISTS profile_comments ( id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, content JSONB NOT NULL, created_time TIMESTAMPTZ DEFAULT now() NOT NULL, @@ -12,12 +12,12 @@ CREATE TABLE IF NOT EXISTS lover_comments ( ); -- Row Level Security -ALTER TABLE lover_comments ENABLE ROW LEVEL SECURITY; +ALTER TABLE profile_comments ENABLE ROW LEVEL SECURITY; -- Policies -DROP POLICY IF EXISTS "public read" ON lover_comments; -CREATE POLICY "public read" ON lover_comments FOR ALL USING (true); +DROP POLICY IF EXISTS "public read" ON profile_comments; +CREATE POLICY "public read" ON profile_comments FOR ALL USING (true); -- Indexes -CREATE INDEX IF NOT EXISTS lover_comments_user_id_idx - ON public.lover_comments USING btree (on_user_id); +CREATE INDEX IF NOT EXISTS profile_comments_user_id_idx + ON public.profile_comments USING btree (on_user_id); diff --git a/backend/supabase/profiles.sql b/backend/supabase/profiles.sql index 0cda155..3a17056 100644 --- a/backend/supabase/profiles.sql +++ b/backend/supabase/profiles.sql @@ -1,8 +1,8 @@ DO $$ BEGIN - IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'lover_visibility') THEN -CREATE TYPE lover_visibility AS ENUM ('public', 'member'); + IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'profile_visibility') THEN +CREATE TYPE profile_visibility AS ENUM ('public', 'member'); END IF; END$$; @@ -47,7 +47,7 @@ CREATE TABLE IF NOT EXISTS profiles ( twitter TEXT, university TEXT, user_id TEXT NOT NULL, - visibility lover_visibility DEFAULT 'member'::lover_visibility NOT NULL, + visibility profile_visibility DEFAULT 'member'::profile_visibility NOT NULL, wants_kids_strength INTEGER DEFAULT 0 NOT NULL, website TEXT, CONSTRAINT profiles_pkey PRIMARY KEY (id) diff --git a/common/src/api/schema.ts b/common/src/api/schema.ts index 72135f5..58fe9bd 100644 --- a/common/src/api/schema.ts +++ b/common/src/api/schema.ts @@ -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 { Profile, ProfileRow } from 'common/love/lover' +import { Profile, ProfileRow } from 'common/love/profile' import { Row } from 'common/supabase/utils' import { PrivateUser, User } from 'common/user' import { z } from 'zod' @@ -88,7 +88,7 @@ export const API = (_apiTypeCheck = { }) .strict(), }, - 'create-lover': { + 'create-profile': { method: 'POST', authed: true, returns: {} as Row<'profiles'>, @@ -143,7 +143,7 @@ export const API = (_apiTypeCheck = { }), returns: {} as FullUser, }, - 'update-lover': { + 'update-profile': { method: 'POST', authed: true, props: combinedLoveUsersSchema.partial(), @@ -217,9 +217,9 @@ export const API = (_apiTypeCheck = { authed: false, props: z.object({ userId: z.string() }), returns: {} as { - lover: Profile + profile: Profile compatibleProfiles: Profile[] - loverCompatibilityScores: { + profileCompatibilityScores: { [userId: string]: CompatibilityScore } }, @@ -246,7 +246,7 @@ export const API = (_apiTypeCheck = { })[] }, }, - 'like-lover': { + 'like-profile': { method: 'POST', authed: true, props: z.object({ @@ -293,7 +293,7 @@ export const API = (_apiTypeCheck = { hasFreeLike: boolean }, }, - 'star-lover': { + 'star-profile': { method: 'POST', authed: true, props: z.object({ @@ -334,7 +334,7 @@ export const API = (_apiTypeCheck = { profiles: Profile[] }, }, - 'get-lover-answers': { + 'get-profile-answers': { method: 'GET', authed: false, props: z.object({ userId: z.string() }).strict(), diff --git a/common/src/comment.ts b/common/src/comment.ts index d2cbdac..d277ad9 100644 --- a/common/src/comment.ts +++ b/common/src/comment.ts @@ -11,8 +11,8 @@ export type Comment = { replyToCommentId?: string userId: string - // lover - commentType: 'lover' + // profile + commentType: 'profile' onUserId: string /** @deprecated - content now stored as JSON in content*/ diff --git a/common/src/filters.ts b/common/src/filters.ts index eec4e93..3b3cf6b 100644 --- a/common/src/filters.ts +++ b/common/src/filters.ts @@ -1,4 +1,4 @@ -import {Profile, ProfileRow} from "common/love/lover"; +import {Profile, ProfileRow} from "common/love/profile"; import {cloneDeep} from "lodash"; import {filterDefined} from "common/util/array"; diff --git a/common/src/love/compatibility-score.ts b/common/src/love/compatibility-score.ts index 05fa043..0b85495 100644 --- a/common/src/love/compatibility-score.ts +++ b/common/src/love/compatibility-score.ts @@ -1,5 +1,5 @@ import { keyBy, sumBy } from 'lodash' -import { ProfileRow } from 'common/love/lover' +import { ProfileRow } from 'common/love/profile' import { Row as rowFor } from 'common/supabase/utils' import { areAgeCompatible, @@ -133,13 +133,13 @@ export function getScoredAnswerCompatibility( } export const getProfilesCompatibilityFactor = ( - lover1: ProfileRow, - lover2: ProfileRow + profile1: ProfileRow, + profile2: ProfileRow ) => { let multiplier = 1 - multiplier *= areAgeCompatible(lover1, lover2) ? 1 : 0.5 - multiplier *= areRelationshipStyleCompatible(lover1, lover2) ? 1 : 0.5 - multiplier *= areWantKidsCompatible(lover1, lover2) ? 1 : 0.5 - multiplier *= areLocationCompatible(lover1, lover2) ? 1 : 0.1 + multiplier *= areAgeCompatible(profile1, profile2) ? 1 : 0.5 + multiplier *= areRelationshipStyleCompatible(profile1, profile2) ? 1 : 0.5 + multiplier *= areWantKidsCompatible(profile1, profile2) ? 1 : 0.5 + multiplier *= areLocationCompatible(profile1, profile2) ? 1 : 0.1 return multiplier } diff --git a/common/src/love/compatibility-util.ts b/common/src/love/compatibility-util.ts index 74f0442..4314889 100644 --- a/common/src/love/compatibility-util.ts +++ b/common/src/love/compatibility-util.ts @@ -1,4 +1,4 @@ -import { ProfileRow } from 'common/love/lover' +import { ProfileRow } from 'common/love/profile' import {MAX_INT, MIN_INT} from "common/constants"; const isPreferredGender = ( @@ -18,53 +18,53 @@ const isPreferredGender = ( return preferredGenders.includes(gender) || gender === 'non-binary' } -export const areGenderCompatible = (lover1: ProfileRow, lover2: ProfileRow) => { - // console.log('areGenderCompatible', isPreferredGender(lover1.pref_gender, lover2.gender), isPreferredGender(lover2.pref_gender, lover1.gender)) +export const areGenderCompatible = (profile1: ProfileRow, profile2: ProfileRow) => { + // console.log('areGenderCompatible', isPreferredGender(profile1.pref_gender, profile2.gender), isPreferredGender(profile2.pref_gender, profile1.gender)) return ( - isPreferredGender(lover1.pref_gender, lover2.gender) && - isPreferredGender(lover2.pref_gender, lover1.gender) + isPreferredGender(profile1.pref_gender, profile2.gender) && + isPreferredGender(profile2.pref_gender, profile1.gender) ) } -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) +const satisfiesAgeRange = (profile: ProfileRow, age: number | null | undefined) => { + return (age ?? MAX_INT) >= (profile.pref_age_min ?? MIN_INT) && (age ?? MIN_INT) <= (profile.pref_age_max ?? MAX_INT) } -export const areAgeCompatible = (lover1: ProfileRow, lover2: ProfileRow) => { +export const areAgeCompatible = (profile1: ProfileRow, profile2: ProfileRow) => { return ( - satisfiesAgeRange(lover1, lover2.age) && - satisfiesAgeRange(lover2, lover1.age) + satisfiesAgeRange(profile1, profile2.age) && + satisfiesAgeRange(profile2, profile1.age) ) } -export const areLocationCompatible = (lover1: ProfileRow, lover2: ProfileRow) => { +export const areLocationCompatible = (profile1: ProfileRow, profile2: ProfileRow) => { if ( - !lover1.city_latitude || - !lover2.city_latitude || - !lover1.city_longitude || - !lover2.city_longitude + !profile1.city_latitude || + !profile2.city_latitude || + !profile1.city_longitude || + !profile2.city_longitude ) - return lover1.city.trim().toLowerCase() === lover2.city.trim().toLowerCase() + return profile1.city.trim().toLowerCase() === profile2.city.trim().toLowerCase() - const latitudeDiff = Math.abs(lover1.city_latitude - lover2.city_latitude) - const longigudeDiff = Math.abs(lover1.city_longitude - lover2.city_longitude) + const latitudeDiff = Math.abs(profile1.city_latitude - profile2.city_latitude) + const longigudeDiff = Math.abs(profile1.city_longitude - profile2.city_longitude) const root = (latitudeDiff ** 2 + longigudeDiff ** 2) ** 0.5 return root < 2.5 } export const areRelationshipStyleCompatible = ( - lover1: ProfileRow, - lover2: ProfileRow + profile1: ProfileRow, + profile2: ProfileRow ) => { - return lover1.pref_relation_styles.some((style) => - lover2.pref_relation_styles.includes(style) + return profile1.pref_relation_styles.some((style) => + profile2.pref_relation_styles.includes(style) ) } -export const areWantKidsCompatible = (lover1: ProfileRow, lover2: ProfileRow) => { - const { wants_kids_strength: kids1 } = lover1 - const { wants_kids_strength: kids2 } = lover2 +export const areWantKidsCompatible = (profile1: ProfileRow, profile2: ProfileRow) => { + const { wants_kids_strength: kids1 } = profile1 + const { wants_kids_strength: kids2 } = profile2 if (kids1 === undefined || kids2 === undefined) return true diff --git a/common/src/love/og-image.ts b/common/src/love/og-image.ts index 2e41bd9..1d63448 100644 --- a/common/src/love/og-image.ts +++ b/common/src/love/og-image.ts @@ -1,5 +1,5 @@ import { User } from 'common/user' -import { ProfileRow } from 'common/love/lover' +import { ProfileRow } from 'common/love/profile' import { buildOgUrl } from 'common/util/og' // TODO: handle age, gender undefined better @@ -8,21 +8,21 @@ export type LoveOgProps = { avatarUrl: string username: string name: string - // lover props + // profile props age: string city: string gender: string } -export function getLoveOgImageUrl(user: User, lover?: ProfileRow | null) { +export function getLoveOgImageUrl(user: User, profile?: ProfileRow | null) { const loveProps = { - avatarUrl: lover?.pinned_url, + avatarUrl: profile?.pinned_url, username: user.username, name: user.name, - age: lover?.age?.toString() ?? '25', - city: lover?.city ?? 'Internet', - gender: lover?.gender ?? '???', + age: profile?.age?.toString() ?? '25', + city: profile?.city ?? 'Internet', + gender: profile?.gender ?? '???', } as LoveOgProps - return buildOgUrl(loveProps, 'lover') + return buildOgUrl(loveProps, 'profile') } diff --git a/common/src/love/lover.ts b/common/src/love/profile.ts similarity index 100% rename from common/src/love/lover.ts rename to common/src/love/profile.ts diff --git a/common/src/notifications.ts b/common/src/notifications.ts index b616f83..2d46387 100644 --- a/common/src/notifications.ts +++ b/common/src/notifications.ts @@ -31,7 +31,7 @@ export type Notification = { export const NOTIFICATION_TYPES_TO_SELECT = [ 'new_match', // new match markets - 'comment_on_lover', // endorsements + 'comment_on_profile', // endorsements 'love_like', 'love_ship', ] diff --git a/common/src/supabase/comment.ts b/common/src/supabase/comment.ts index becbb67..2ad73a3 100644 --- a/common/src/supabase/comment.ts +++ b/common/src/supabase/comment.ts @@ -2,10 +2,10 @@ import { type JSONContent } from '@tiptap/core' import { type Row, tsToMillis } from './utils' import { type Comment } from 'common/comment' -export const convertComment = (row: Row<'lover_comments'>): Comment => ({ +export const convertComment = (row: Row<'profile_comments'>): Comment => ({ id: row.id + '', userId: row.user_id, - commentType: 'lover', + commentType: 'profile', onUserId: row.on_user_id, createdTime: tsToMillis(row.created_time), userName: row.user_name, diff --git a/common/src/supabase/schema.ts b/common/src/supabase/schema.ts index 877b0af..b8024bf 100644 --- a/common/src/supabase/schema.ts +++ b/common/src/supabase/schema.ts @@ -221,7 +221,7 @@ export type Database = { } Relationships: [] } - lover_comments: { + profile_comments: { Row: { content: Json created_time: string @@ -260,147 +260,6 @@ export type Database = { } Relationships: [] } - lovers: { - Row: { - age: number | null - bio: Json | null - bio_text: unknown | null - born_in_location: string | null - city: string - city_latitude: number | null - city_longitude: number | null - comments_enabled: boolean - company: string | null - country: string | null - created_time: string - drinks_per_month: number | null - education_level: string | null - ethnicity: string[] | null - gender: string - geodb_city_id: string | null - has_kids: number | null - height_in_inches: number | null - id: number - is_smoker: boolean | null - is_vegetarian_or_vegan: boolean | null - last_modification_time: string - last_online_time: string - looking_for_matches: boolean - messaging_status: string - occupation: string | null - occupation_title: string | null - photo_urls: string[] | null - pinned_url: string | null - political_beliefs: string[] | null - pref_age_max: number | null - pref_age_min: number | null - pref_gender: string[] - pref_relation_styles: string[] - referred_by_username: string | null - region_code: string | null - religious_belief_strength: number | null - religious_beliefs: string | null - twitter: string | null - university: string | null - user_id: string - visibility: Database['public']['Enums']['lover_visibility'] - wants_kids_strength: number - website: string | null - } - Insert: { - age?: number | null - bio?: Json | null - bio_text?: unknown | null - born_in_location?: string | null - city: string - city_latitude?: number | null - city_longitude?: number | null - comments_enabled?: boolean - company?: string | null - country?: string | null - created_time?: string - drinks_per_month?: number | null - education_level?: string | null - ethnicity?: string[] | null - gender: string - geodb_city_id?: string | null - has_kids?: number | null - height_in_inches?: number | null - id?: never - is_smoker?: boolean | null - is_vegetarian_or_vegan?: boolean | null - last_modification_time?: string - last_online_time?: string - looking_for_matches?: boolean - messaging_status?: string - occupation?: string | null - occupation_title?: string | null - photo_urls?: string[] | null - pinned_url?: string | null - political_beliefs?: string[] | null - pref_age_max?: number | null - pref_age_min?: number | null - pref_gender: string[] - pref_relation_styles: string[] - referred_by_username?: string | null - region_code?: string | null - religious_belief_strength?: number | null - religious_beliefs?: string | null - twitter?: string | null - university?: string | null - user_id: string - visibility?: Database['public']['Enums']['lover_visibility'] - wants_kids_strength?: number - website?: string | null - } - Update: { - age?: number | null - bio?: Json | null - bio_text?: unknown | null - born_in_location?: string | null - city?: string - city_latitude?: number | null - city_longitude?: number | null - comments_enabled?: boolean - company?: string | null - country?: string | null - created_time?: string - drinks_per_month?: number | null - education_level?: string | null - ethnicity?: string[] | null - gender?: string - geodb_city_id?: string | null - has_kids?: number | null - height_in_inches?: number | null - id?: never - is_smoker?: boolean | null - is_vegetarian_or_vegan?: boolean | null - last_modification_time?: string - last_online_time?: string - looking_for_matches?: boolean - messaging_status?: string - occupation?: string | null - occupation_title?: string | null - photo_urls?: string[] | null - pinned_url?: string | null - political_beliefs?: string[] | null - pref_age_max?: number | null - pref_age_min?: number | null - pref_gender?: string[] - pref_relation_styles?: string[] - referred_by_username?: string | null - region_code?: string | null - religious_belief_strength?: number | null - religious_beliefs?: string | null - twitter?: string | null - university?: string | null - user_id?: string - visibility?: Database['public']['Enums']['lover_visibility'] - wants_kids_strength?: number - website?: string | null - } - Relationships: [] - } private_user_message_channel_members: { Row: { channel_id: number @@ -584,7 +443,7 @@ export type Database = { twitter: string | null university: string | null user_id: string - visibility: Database['public']['Enums']['lover_visibility'] + visibility: Database['public']['Enums']['profile_visibility'] wants_kids_strength: number website: string | null } @@ -629,7 +488,7 @@ export type Database = { twitter?: string | null university?: string | null user_id: string - visibility?: Database['public']['Enums']['lover_visibility'] + visibility?: Database['public']['Enums']['profile_visibility'] wants_kids_strength?: number website?: string | null } @@ -674,7 +533,7 @@ export type Database = { twitter?: string | null university?: string | null user_id?: string - visibility?: Database['public']['Enums']['lover_visibility'] + visibility?: Database['public']['Enums']['profile_visibility'] wants_kids_strength?: number website?: string | null } @@ -834,10 +693,6 @@ export type Database = { Args: Record Returns: Record[] } - get_love_question_answers_and_lovers: { - Args: { p_question_id: number } - Returns: Record[] - } get_love_question_answers_and_profiles: { Args: { p_question_id: number } Returns: Record[] @@ -900,7 +755,7 @@ export type Database = { } } Enums: { - lover_visibility: 'public' | 'member' + profile_visibility: 'public' | 'member' } CompositeTypes: { [_ in never]: never @@ -1028,7 +883,7 @@ export type CompositeTypes< export const Constants = { public: { Enums: { - lover_visibility: ['public', 'member'], + profile_visibility: ['public', 'member'], }, }, } as const diff --git a/docs/knowledge.md b/docs/knowledge.md index 04ff32d..769f541 100644 --- a/docs/knowledge.md +++ b/docs/knowledge.md @@ -400,7 +400,7 @@ const { data, error } = await tryCatch( insert(pg, 'profiles', { user_id: auth.uid, ...body }) ) -if (error) throw APIError(500, 'Error creating lover: ' + error.message) +if (error) throw APIError(500, 'Error creating profile: ' + error.message) await update(pg, 'profiles', 'user_id', { user_id: auth.uid, age: 99 }) diff --git a/web/components/answers/compatibility-questions-display.tsx b/web/components/answers/compatibility-questions-display.tsx index 3c38546..ea7d079 100644 --- a/web/components/answers/compatibility-questions-display.tsx +++ b/web/components/answers/compatibility-questions-display.tsx @@ -3,11 +3,11 @@ import { getAnswerCompatibility, getScoredAnswerCompatibility, } from 'common/love/compatibility-score' -import { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' import { Row as rowFor } from 'common/supabase/utils' import { User } from 'common/user' import { partition, sortBy, keyBy } from 'lodash' -import { useProfile } from 'web/hooks/use-lover' +import { useProfile } from 'web/hooks/use-profile' import { QuestionWithCountType, useCompatibilityQuestionsWithAnswerCount, @@ -25,7 +25,7 @@ import { Row } from 'web/components/layout/row' import { Linkify } from 'web/components/widgets/linkify' import { Pagination } from 'web/components/widgets/pagination' import { db } from 'web/lib/supabase/db' -import { Subtitle } from '../widgets/lover-subtitle' +import { Subtitle } from '../widgets/profile-subtitle' import { AddCompatibilityQuestionButton } from './add-compatibility-question-button' import { AnswerCompatibilityQuestionButton, @@ -81,11 +81,11 @@ type CompatibilitySort = export function CompatibilityQuestionsDisplay(props: { isCurrentUser: boolean user: User - lover: Profile + profile: Profile fromSignup?: boolean fromProfilePage?: Profile }) { - const { isCurrentUser, user, fromSignup, fromProfilePage, lover } = props + const { isCurrentUser, user, fromSignup, fromProfilePage, profile } = props const { refreshCompatibilityQuestions, compatibilityQuestions } = useCompatibilityQuestionsWithAnswerCount() @@ -223,7 +223,7 @@ export function CompatibilityQuestionsDisplay(props: { user={user} isCurrentUser={isCurrentUser} refreshCompatibilityAll={refreshCompatibilityAll} - lover={lover} + profile={profile} fromProfilePage={fromProfilePage} /> ) @@ -314,7 +314,7 @@ function CompatibilityAnswerBlock(props: { yourQuestions: QuestionWithCountType[] user: User isCurrentUser: boolean - lover: Profile + profile: Profile refreshCompatibilityAll: () => void fromProfilePage?: Profile }) { @@ -322,7 +322,7 @@ function CompatibilityAnswerBlock(props: { answer, yourQuestions, user, - lover, + profile, isCurrentUser, refreshCompatibilityAll, fromProfilePage, @@ -374,9 +374,9 @@ function CompatibilityAnswerBlock(props: {
@@ -437,9 +437,9 @@ function CompatibilityAnswerBlock(props: { @@ -476,8 +476,8 @@ function CompatibilityAnswerBlock(props: { function CompatibilityDisplay(props: { question: QuestionWithCountType - lover1: Profile - lover2: Profile + profile1: Profile + profile2: Profile answer1: rowFor<'love_compatibility_answers'> currentUserIsComparedProfile: boolean currentUser: User | null | undefined @@ -485,8 +485,8 @@ function CompatibilityDisplay(props: { }) { const { question, - lover1, - lover2, + profile1, + profile2, answer1, currentUserIsComparedProfile, currentUser, @@ -499,7 +499,7 @@ function CompatibilityDisplay(props: { async function getComparedProfileAnswer() { db.from('love_compatibility_answers') .select() - .eq('creator_id', lover2.user_id) + .eq('creator_id', profile2.user_id) .eq('question_id', question.id) .then((res) => { if (res.error) { @@ -515,21 +515,21 @@ function CompatibilityDisplay(props: { const [open, setOpen] = useState(false) - if (lover1.id === lover2.id) return null + if (profile1.id === profile2.id) return null const showCreateAnswer = (!answer2 || answer2.importance == -1) && currentUserIsComparedProfile && !!currentUser - const isCurrentUser = currentUser?.id === lover2.user_id + const isCurrentUser = currentUser?.id === profile2.user_id const answerCompatibility = answer2 ? getAnswerCompatibility(answer1, answer2) : //getScoredAnswerCompatibility(answer1, answer2) undefined - const user1 = lover1.user - const user2 = lover2.user + const user1 = profile1.user + const user2 = profile2.user const importanceScore = answer1.importance diff --git a/web/components/answers/free-response-add-question.tsx b/web/components/answers/free-response-add-question.tsx index 81595d7..2951d8d 100644 --- a/web/components/answers/free-response-add-question.tsx +++ b/web/components/answers/free-response-add-question.tsx @@ -12,7 +12,7 @@ import { import { Row } from 'web/components/layout/row' import { IndividualQuestionRow } from '../questions-form' import { TbMessage } from 'react-icons/tb' -import { OtherProfileAnswers } from './other-lover-answers' +import { OtherProfileAnswers } from './other-profile-answers' import { ArrowLeftIcon } from '@heroicons/react/outline' import { usePersistentInMemoryState } from 'web/hooks/use-persistent-in-memory-state' diff --git a/web/components/answers/free-response-display.tsx b/web/components/answers/free-response-display.tsx index 41e950a..2449788 100644 --- a/web/components/answers/free-response-display.tsx +++ b/web/components/answers/free-response-display.tsx @@ -10,14 +10,14 @@ import { Col } from 'web/components/layout/col' import { Row } from 'web/components/layout/row' import { Linkify } from 'web/components/widgets/linkify' import { IndividualQuestionRow } from '../questions-form' -import { Subtitle } from '../widgets/lover-subtitle' +import { Subtitle } from '../widgets/profile-subtitle' import { QuestionWithCountType, useFRQuestionsWithAnswerCount, useUserAnswers, } from 'web/hooks/use-questions' import { TbMessage } from 'react-icons/tb' -import { OtherProfileAnswers } from './other-lover-answers' +import { OtherProfileAnswers } from './other-profile-answers' import { MODAL_CLASS, Modal, @@ -26,7 +26,7 @@ import { import { partition } from 'lodash' import { shortenName } from 'web/components/widgets/user-link' import { AddQuestionButton } from './free-response-add-question' -import { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' export function FreeResponseDisplay(props: { isCurrentUser: boolean diff --git a/web/components/answers/opinion-scale-display.tsx b/web/components/answers/opinion-scale-display.tsx index e66df9c..bdc8d3e 100644 --- a/web/components/answers/opinion-scale-display.tsx +++ b/web/components/answers/opinion-scale-display.tsx @@ -8,7 +8,7 @@ import { capitalize, orderBy } from 'lodash' import { Button } from 'web/components/buttons/button' import { Col } from 'web/components/layout/col' import { Row } from 'web/components/layout/row' -import { Subtitle } from '../widgets/lover-subtitle' +import { Subtitle } from '../widgets/profile-subtitle' import { BiTachometer } from 'react-icons/bi' export function OpinionScale(props: { diff --git a/web/components/answers/other-lover-answers.tsx b/web/components/answers/other-profile-answers.tsx similarity index 100% rename from web/components/answers/other-lover-answers.tsx rename to web/components/answers/other-profile-answers.tsx diff --git a/web/components/answers/lover-answers.tsx b/web/components/answers/profile-answers.tsx similarity index 82% rename from web/components/answers/lover-answers.tsx rename to web/components/answers/profile-answers.tsx index 0c9f366..4b8c025 100644 --- a/web/components/answers/lover-answers.tsx +++ b/web/components/answers/profile-answers.tsx @@ -2,23 +2,23 @@ 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 { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' export function ProfileAnswers(props: { isCurrentUser: boolean user: User - lover: Profile + profile: Profile fromSignup?: boolean fromProfilePage?: Profile }) { - const { isCurrentUser, user, fromSignup, fromProfilePage, lover } = props + const { isCurrentUser, user, fromSignup, fromProfilePage, profile } = props return ( diff --git a/web/components/bio/editable-bio.tsx b/web/components/bio/editable-bio.tsx index 4a2c640..c9f1212 100644 --- a/web/components/bio/editable-bio.tsx +++ b/web/components/bio/editable-bio.tsx @@ -1,6 +1,6 @@ import { JSONContent } from '@tiptap/core' import { MAX_DESCRIPTION_LENGTH } from 'common/envs/constants' -import { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' import { tryCatch } from 'common/util/try-catch' import { Button } from 'web/components/buttons/button' import { Col } from 'web/components/layout/col' @@ -10,18 +10,18 @@ import { updateProfile } from 'web/lib/api' import { track } from 'web/lib/service/analytics' export function EditableBio(props: { - lover: Profile + profile: Profile onSave: () => void onCancel?: () => void }) { - const { lover, onCancel, onSave } = props + const { profile, onCancel, onSave } = props const editor = useTextEditor({ max: MAX_DESCRIPTION_LENGTH, - defaultValue: (lover.bio as JSONContent) ?? '', + defaultValue: (profile.bio as JSONContent) ?? '', placeholder: "Tell us about yourself — and what you're looking for!", }) - const hideButtons = editor?.getText().length === 0 && !lover.bio + const hideButtons = editor?.getText().length === 0 && !profile.bio const saveBio = async () => { if (!editor) return @@ -32,7 +32,7 @@ export function EditableBio(props: { return } - track('edited lover bio') + track('edited profile bio') } return ( diff --git a/web/components/bio/lover-bio-block.tsx b/web/components/bio/profile-bio-block.tsx similarity index 83% rename from web/components/bio/lover-bio-block.tsx rename to web/components/bio/profile-bio-block.tsx index aac56b9..7ececb5 100644 --- a/web/components/bio/lover-bio-block.tsx +++ b/web/components/bio/profile-bio-block.tsx @@ -2,7 +2,7 @@ import { PencilIcon, XIcon } from '@heroicons/react/outline' import { JSONContent } from '@tiptap/core' import clsx from 'clsx' -import { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' import DropdownMenu from 'web/components/comments/dropdown-menu' import { Col } from 'web/components/layout/col' import { Row } from 'web/components/layout/row' @@ -13,12 +13,12 @@ import { tryCatch } from 'common/util/try-catch' export function BioBlock(props: { isCurrentUser: boolean - lover: Profile + profile: Profile refreshProfile: () => void edit: boolean setEdit: (edit: boolean) => void }) { - const { isCurrentUser, refreshProfile, lover, edit, setEdit } = props + const { isCurrentUser, refreshProfile, profile, edit, setEdit } = props return ( - {!edit && lover.bio && ( + {!edit && profile.bio && ( - + )} {edit && ( setEdit(false) : undefined} + profile={profile} + onCancel={profile.bio ? () => setEdit(false) : undefined} onSave={() => { refreshProfile() setEdit(false) diff --git a/web/components/bio/lover-bio.tsx b/web/components/bio/profile-bio.tsx similarity index 52% rename from web/components/bio/lover-bio.tsx rename to web/components/bio/profile-bio.tsx index be0d95c..4c5b941 100644 --- a/web/components/bio/lover-bio.tsx +++ b/web/components/bio/profile-bio.tsx @@ -1,29 +1,29 @@ -import { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' import { useState } from 'react' import { Col } from 'web/components/layout/col' -import { Subtitle } from '../widgets/lover-subtitle' -import { BioBlock } from './lover-bio-block' +import { Subtitle } from '../widgets/profile-subtitle' +import { BioBlock } from './profile-bio-block' export function ProfileBio(props: { isCurrentUser: boolean - lover: Profile + profile: Profile refreshProfile: () => void fromProfilePage?: Profile }) { - const { isCurrentUser, lover, refreshProfile, fromProfilePage } = props + const { isCurrentUser, profile, refreshProfile, fromProfilePage } = props const [edit, setEdit] = useState(false) - if (!isCurrentUser && !lover.bio) return null - if (fromProfilePage && !lover.bio) return null + if (!isCurrentUser && !profile.bio) return null + if (fromProfilePage && !profile.bio) return null return ( About Me diff --git a/web/components/browse-matches-button.tsx b/web/components/browse-matches-button.tsx index 755fae0..a166469 100644 --- a/web/components/browse-matches-button.tsx +++ b/web/components/browse-matches-button.tsx @@ -4,7 +4,7 @@ import { useState } from 'react' import Link from 'next/link' import { MAX_COMMENT_LENGTH } from 'common/comment' -import { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' 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,21 +13,21 @@ 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 { ProfileProfile } from './profile/lover-profile' +import { ProfileProfile } from './profile/profile-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: Profile + profile: Profile potentialProfiles: Profile[] compatibilityScores: Record className?: string }) => { - const { lover, potentialProfiles, compatibilityScores, className } = props + const { profile, potentialProfiles, compatibilityScores, className } = props const currentUser = useUser() - const isCurrentUser = currentUser?.id === lover.user_id + const isCurrentUser = currentUser?.id === profile.user_id const [dialogOpen, setDialogOpen] = useState(false) const key = `comment ${potentialProfiles.map((l) => l.id).join(',')}` @@ -46,7 +46,7 @@ export const BrowseMatchesButton = (props: { // setIsSubmitting(true) // const result = await createMatch({ - // userId1: lover.user_id, + // userId1: profile.user_id, // userId2: selectedMatchId, // betAmount, // introduction, @@ -61,7 +61,7 @@ export const BrowseMatchesButton = (props: { // window.location.reload() // } } - if (!lover.looking_for_matches) + if (!profile.looking_for_matches) return (
Not looking for more matches right now @@ -77,11 +77,11 @@ export const BrowseMatchesButton = (props: { disabled={isSubmitting} loading={isSubmitting} > - Browse {isCurrentUser ? 'your compatible' : `for ${lover.user.name}`} + Browse {isCurrentUser ? 'your compatible' : `for ${profile.user.name}`} {dialogOpen && ( isSubmitting: boolean @@ -104,7 +104,7 @@ const BrowseMatchesDialog = (props: { editor: Editor | null }) => { const { - lover, + profile, potentialProfiles, compatibilityScores, isSubmitting, @@ -117,10 +117,10 @@ const BrowseMatchesDialog = (props: { const [error, setError] = useState(undefined) const currentUser = useUser() - const isCurrentUser = currentUser?.id === lover.user_id + const isCurrentUser = currentUser?.id === profile.user_id - const filteredProfiles = potentialProfiles.filter((lover) => - lover.user.name.toLowerCase().includes(query.toLowerCase()) + const filteredProfiles = potentialProfiles.filter((profile) => + profile.user.name.toLowerCase().includes(query.toLowerCase()) ) const [potentialIndex, setPotentialIndex] = useState(0) const index = Math.min(potentialIndex, filteredProfiles.length - 1) @@ -140,7 +140,7 @@ const BrowseMatchesDialog = (props: { - Browse {!isCurrentUser && `for ${lover.user.name}`} + Browse {!isCurrentUser && `for ${profile.user.name}`} window.location.reload()} - fromProfilePage={lover} + fromProfilePage={profile} /> - {/* + {/* ( location ? originToCity(location) : youCity || DEFAULT_LAST_CITY, diff --git a/web/components/filters/mobile-filters.tsx b/web/components/filters/mobile-filters.tsx index 15209e7..38c8564 100644 --- a/web/components/filters/mobile-filters.tsx +++ b/web/components/filters/mobile-filters.tsx @@ -24,7 +24,7 @@ import { } from './wants-kids-filter' import { FaChild } from 'react-icons/fa6' import { MyMatchesToggle } from './my-matches-toggle' -import { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' import { Gender } from 'common/gender' import { RelationshipType } from 'web/lib/util/convert-relationship-type' import {FilterFields} from "common/filters"; diff --git a/web/components/filters/my-matches-toggle.tsx b/web/components/filters/my-matches-toggle.tsx index f857d3a..6d211bb 100644 --- a/web/components/filters/my-matches-toggle.tsx +++ b/web/components/filters/my-matches-toggle.tsx @@ -1,6 +1,6 @@ import { Row } from 'web/components/layout/row' import clsx from 'clsx' -import { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' export function MyMatchesToggle(props: { setYourFilters: (checked: boolean) => void diff --git a/web/components/filters/search.tsx b/web/components/filters/search.tsx index bf5a7fe..6381cb4 100644 --- a/web/components/filters/search.tsx +++ b/web/components/filters/search.tsx @@ -1,4 +1,4 @@ -import {Profile} from 'common/love/lover' +import {Profile} from 'common/love/profile' import React, {useEffect, useState} from 'react' import {IoFilterSharp} from 'react-icons/io5' import {Button} from 'web/components/buttons/button' diff --git a/web/components/filters/use-filters.ts b/web/components/filters/use-filters.ts index 6c2da24..d821a17 100644 --- a/web/components/filters/use-filters.ts +++ b/web/components/filters/use-filters.ts @@ -1,4 +1,4 @@ -import {Profile} from "common/love/lover"; +import {Profile} from "common/love/profile"; import {useIsLooking} from "web/hooks/use-is-looking"; import {usePersistentLocalState} from "web/hooks/use-persistent-local-state"; import {useCallback} from "react"; diff --git a/web/components/love-page.tsx b/web/components/love-page.tsx index db8221d..2ecf159 100644 --- a/web/components/love-page.tsx +++ b/web/components/love-page.tsx @@ -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 {useProfile} from 'web/hooks/use-lover' -import {Profile} from 'common/love/lover' +import {useProfile} from 'web/hooks/use-profile' +import {Profile} from 'common/love/profile' import {NotificationsIcon, SolidNotificationsIcon} from './notifications-icon' export function LovePage(props: { @@ -40,9 +40,9 @@ export function LovePage(props: { } = props const user = useUser() const isMobile = useIsMobile() - const lover = useProfile() + const profile = useProfile() const bottomNavOptions = user - ? getBottomNavigation(user, lover) + ? getBottomNavigation(user, profile) : signedOutNavigation() // const [isModalOpen, setIsModalOpen] = useState(false) const desktopSidebarOptions = getDesktopNav(user) @@ -106,13 +106,13 @@ 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: Profile | null | undefined) { +function getBottomNavigation(user: User, profile: Profile | null | undefined) { return buildArray( Profiles, NotifsSolid, { name: 'Profile', - href: lover === null ? '/signup' : `/${user.username}`, + href: profile === null ? '/signup' : `/${user.username}`, icon: SolidHomeIcon, }, { diff --git a/web/components/matches/match-avatars.tsx b/web/components/matches/match-avatars.tsx index d31dad6..9d55beb 100644 --- a/web/components/matches/match-avatars.tsx +++ b/web/components/matches/match-avatars.tsx @@ -1,6 +1,6 @@ import { Row } from 'web/components/layout/row' import { HeartIcon } from '@heroicons/react/solid' -import { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' import Image from 'next/image' import { Col } from 'web/components/layout/col' import { UserIcon } from '@heroicons/react/solid' diff --git a/web/components/nav/love-bottom-nav-bar.tsx b/web/components/nav/love-bottom-nav-bar.tsx index 8bd35f0..a14d41b 100644 --- a/web/components/nav/love-bottom-nav-bar.tsx +++ b/web/components/nav/love-bottom-nav-bar.tsx @@ -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 { useProfile } from 'web/hooks/use-lover' +import { useProfile } from 'web/hooks/use-profile' 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 = useProfile() + const profile = useProfile() return (
diff --git a/web/components/nav/love-profile-summary.tsx b/web/components/nav/love-profile-summary.tsx index 2948621..bd61b10 100644 --- a/web/components/nav/love-profile-summary.tsx +++ b/web/components/nav/love-profile-summary.tsx @@ -1,5 +1,5 @@ import clsx from 'clsx' -import { useProfile } from 'web/hooks/use-lover' +import { useProfile } from 'web/hooks/use-profile' import Link from 'next/link' import { Avatar } from 'web/components/widgets/avatar' import { User } from 'web/lib/firebase/users' @@ -8,11 +8,11 @@ import { trackCallback } from 'web/lib/service/analytics' export function ProfileSummary(props: { user: User; className?: string }) { const { user, className } = props - const lover = useProfile() + const profile = useProfile() return (
diff --git a/web/components/nav/love-sidebar.tsx b/web/components/nav/love-sidebar.tsx index f0dbaea..542e642 100644 --- a/web/components/nav/love-sidebar.tsx +++ b/web/components/nav/love-sidebar.tsx @@ -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 { useProfile } from 'web/hooks/use-lover' +import { useProfile } from 'web/hooks/use-profile' 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 = useProfile() + const profile = useProfile() const { theme, setTheme } = useTheme() @@ -58,7 +58,7 @@ export default function Sidebar(props: { {user === null && } {/*{user === null && }*/} - {user && lover === null && ( + {user && profile === null && ( diff --git a/web/components/notification-items.tsx b/web/components/notification-items.tsx index 20fe578..362d9c3 100644 --- a/web/components/notification-items.tsx +++ b/web/components/notification-items.tsx @@ -26,7 +26,7 @@ export function NotificationItem(props: { notification: Notification }) { setHighlighted, } - if (sourceType === 'comment_on_lover') { + if (sourceType === 'comment_on_profile') { return } else if (sourceType === 'new_match') { return diff --git a/web/components/optional-lover-form.tsx b/web/components/optional-profile-form.tsx similarity index 91% rename from web/components/optional-lover-form.tsx rename to web/components/optional-profile-form.tsx index 447ca82..40d1554 100644 --- a/web/components/optional-lover-form.tsx +++ b/web/components/optional-profile-form.tsx @@ -16,7 +16,7 @@ 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 {ProfileRow} from 'common/love/lover' +import {ProfileRow} from 'common/love/profile' import {removeNullOrUndefinedProps} from 'common/util/object' import {isEqual, range} from 'lodash' import {PlatformSelect} from 'web/components/widgets/platform-select' @@ -24,7 +24,7 @@ import {PLATFORM_LABELS, type Site, SITE_ORDER} from 'common/socials' import {PlusIcon, XIcon} from '@heroicons/react/solid' import {SocialIcon} from './user/social' import {Select} from 'web/components/widgets/select' -import {City, CityRow, loverToCity, useCitySearch} from "web/components/search-location"; +import {City, CityRow, profileToCity, useCitySearch} from "web/components/search-location"; import {AddPhotosWidget} from './widgets/add-photos' import {RadioToggleGroup} from "web/components/widgets/radio-toggle-group"; import {MultipleChoiceOptions} from "common/love/multiple-choice"; @@ -32,26 +32,26 @@ import {RELATIONSHIP_CHOICES} from "web/components/filters/choices"; import toast from "react-hot-toast"; export const OptionalLoveUserForm = (props: { - lover: ProfileRow + profile: ProfileRow setProfile: >(key: K, value: ProfileRow[K]) => void user: User buttonLabel?: string fromSignup?: boolean onSubmit?: () => Promise }) => { - const {lover, user, buttonLabel, setProfile, fromSignup, onSubmit} = props + const {profile, user, buttonLabel, setProfile, fromSignup, onSubmit} = props const [isSubmitting, setIsSubmitting] = useState(false) const [lookingRelationship, setLookingRelationship] = useState(false) const router = useRouter() const [heightFeet, setHeightFeet] = useState( - lover.height_in_inches - ? Math.floor((lover['height_in_inches'] ?? 0) / 12) + profile.height_in_inches + ? Math.floor((profile['height_in_inches'] ?? 0) / 12) : undefined ) const [heightInches, setHeightInches] = useState( - lover.height_in_inches - ? Math.floor((lover['height_in_inches'] ?? 0) % 12) + profile.height_in_inches + ? Math.floor((profile['height_in_inches'] ?? 0) % 12) : undefined ) @@ -64,7 +64,7 @@ export const OptionalLoveUserForm = (props: { const handleSubmit = async () => { setIsSubmitting(true) - const {bio: _, ...otherProfileProps} = lover + const {bio: _, ...otherProfileProps} = profile const {error} = await tryCatch( updateProfile(removeNullOrUndefinedProps(otherProfileProps) as any) ) @@ -105,7 +105,7 @@ export const OptionalLoveUserForm = (props: { } const [trans, setTrans] = useState( - lover['gender'].includes('trans') + profile['gender'].includes('trans') ) function setProfileCity(inputCity: City | undefined) { @@ -135,7 +135,7 @@ export const OptionalLoveUserForm = (props: { } useEffect(() => { - const currentState = lover['gender'] + const currentState = profile['gender'] if (currentState === 'non-binary') { setTrans(undefined) } else if (trans && !currentState.includes('trans-')) { @@ -143,7 +143,7 @@ export const OptionalLoveUserForm = (props: { } else if (!trans && currentState.includes('trans-')) { setProfile('gender', currentState.replace('trans-', '')) } - }, [trans, lover['gender']]) + }, [trans, profile['gender']]) return ( <> @@ -164,10 +164,10 @@ export const OptionalLoveUserForm = (props: { - {lover.city ? ( + {profile.city ? ( { }} className="pointer-events-none" @@ -195,7 +195,7 @@ export const OptionalLoveUserForm = (props: { setProfile('age', Number(e.target.value))} @@ -206,7 +206,7 @@ export const OptionalLoveUserForm = (props: { setProfile('pref_gender', selected)} /> @@ -236,7 +236,7 @@ export const OptionalLoveUserForm = (props: { Min setProfile('pref_age_max', Number(e.target.value)) } @@ -274,7 +274,7 @@ export const OptionalLoveUserForm = (props: { setProfile('pref_relation_styles', selected) } @@ -359,7 +359,7 @@ export const OptionalLoveUserForm = (props: { 'Pause AI': 'pause ai', Other: 'other', }} - selected={lover['political_beliefs'] ?? []} + selected={profile['political_beliefs'] ?? []} onChange={(selected) => setProfile('political_beliefs', selected)} /> @@ -370,14 +370,14 @@ export const OptionalLoveUserForm = (props: { type="text" onChange={(e) => setProfile('religious_beliefs', e.target.value)} className={'w-full sm:w-96'} - value={lover['religious_beliefs'] ?? undefined} + value={profile['religious_beliefs'] ?? undefined} /> @@ -451,7 +451,7 @@ export const OptionalLoveUserForm = (props: { type="text" onChange={(e) => setProfileState('born_in_location', e.target.value)} className={'w-52'} - value={lover['born_in_location'] ?? undefined} + value={profile['born_in_location'] ?? undefined} /> */} @@ -459,7 +459,7 @@ export const OptionalLoveUserForm = (props: { setProfile('ethnicity', selected)} /> @@ -470,7 +470,7 @@ export const OptionalLoveUserForm = (props: { setProfile('university', e.target.value)} className={'w-52'} - value={lover['university'] ?? undefined} + value={profile['university'] ?? undefined} /> @@ -498,19 +498,19 @@ export const OptionalLoveUserForm = (props: { type="text" onChange={(e) => setProfile('company', e.target.value)} className={'w-52'} - value={lover['company'] ?? undefined} + value={profile['company'] ?? undefined} /> setProfile('occupation_title', e.target.value)} className={'w-52'} - value={lover['occupation_title'] ?? undefined} + value={profile['occupation_title'] ?? undefined} /> @@ -525,7 +525,7 @@ export const OptionalLoveUserForm = (props: { }} className={'w-20'} min={0} - value={lover['has_kids'] ?? undefined} + value={profile['has_kids'] ?? undefined} /> @@ -549,7 +549,7 @@ export const OptionalLoveUserForm = (props: { setChoice={(choice) => { setProfile('wants_kids_strength', choice) }} - currentChoice={lover.wants_kids_strength ?? -1} + currentChoice={profile.wants_kids_strength ?? -1} /> } @@ -563,8 +563,8 @@ export const OptionalLoveUserForm = (props: { setProfile('photo_urls', urls)} setPinnedUrl={(url) => setProfile('pinned_url', url)} /> diff --git a/web/components/lover-about.tsx b/web/components/profile-about.tsx similarity index 77% rename from web/components/lover-about.tsx rename to web/components/profile-about.tsx index 95de024..beaf657 100644 --- a/web/components/lover-about.tsx +++ b/web/components/profile-about.tsx @@ -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 { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' export function AboutRow(props: { icon: ReactNode @@ -54,48 +54,48 @@ export function AboutRow(props: { ) } -export default function ProfileAbout(props: { lover: Profile }) { - const { lover } = props +export default function ProfileAbout(props: { profile: Profile }) { + const { profile } = props return ( - - - + + + } - text={lover.political_beliefs} + text={profile.political_beliefs} /> - - + + } - text={lover.religious_beliefs} + text={profile.religious_beliefs} /> } - text={lover.ethnicity + text={profile.ethnicity ?.filter((r) => r !== 'other') ?.map((r: any) => convertRace(r))} /> - - + + } - text={lover.is_vegetarian_or_vegan ? 'Vegetarian/Vegan' : null} + text={profile.is_vegetarian_or_vegan ? 'Vegetarian/Vegan' : null} /> - - + + ) } -function Seeking(props: { lover: Profile }) { - const { lover } = props - const prefGender = lover.pref_gender - const min = lover.pref_age_min - const max = lover.pref_age_max +function Seeking(props: { profile: Profile }) { + const { profile } = props + const prefGender = profile.pref_gender + const min = profile.pref_age_min + const max = profile.pref_age_max const seekingGenderText = stringOrStringArrayToText({ text: prefGender.length == 5 @@ -126,9 +126,9 @@ function Seeking(props: { lover: Profile }) { ) } -function RelationshipType(props: { lover: Profile }) { - const { lover } = props - const relationshipTypes = lover.pref_relation_styles +function RelationshipType(props: { profile: Profile }) { + const { profile } = props + const relationshipTypes = profile.pref_relation_styles const seekingGenderText = stringOrStringArrayToText({ text: relationshipTypes.map((rel) => convertRelationshipType(rel as RelationshipType).toLowerCase() @@ -149,10 +149,10 @@ function RelationshipType(props: { lover: Profile }) { ) } -function Education(props: { lover: Profile }) { - const { lover } = props - const educationLevel = lover.education_level - const university = lover.university +function Education(props: { profile: Profile }) { + const { profile } = props + const educationLevel = profile.education_level + const university = profile.university const noUniversity = !educationLevel || @@ -173,10 +173,10 @@ function Education(props: { lover: Profile }) { ) } -function Occupation(props: { lover: Profile }) { - const { lover } = props - const occupation_title = lover.occupation_title - const company = lover.company +function Occupation(props: { profile: Profile }) { + const { profile } = props + const occupation_title = profile.occupation_title + const company = profile.company if (!company && !occupation_title) { return <> @@ -194,9 +194,9 @@ function Occupation(props: { lover: Profile }) { ) } -function Smoker(props: { lover: Profile }) { - const { lover } = props - const isSmoker = lover.is_smoker +function Smoker(props: { profile: Profile }) { + const { profile } = props + const isSmoker = profile.is_smoker if (isSmoker == null) return null if (isSmoker) { return ( @@ -211,9 +211,9 @@ function Smoker(props: { lover: Profile }) { ) } -function Drinks(props: { lover: Profile }) { - const { lover } = props - const drinksPerMonth = lover.drinks_per_month +function Drinks(props: { profile: Profile }) { + const { profile } = props + const drinksPerMonth = profile.drinks_per_month if (drinksPerMonth == null) return null if (drinksPerMonth === 0) { return ( @@ -233,9 +233,9 @@ function Drinks(props: { lover: Profile }) { ) } -function WantsKids(props: { lover: Profile }) { - const { lover } = props - const wantsKidsStrength = lover.wants_kids_strength +function WantsKids(props: { profile: Profile }) { + const { profile } = props + const wantsKidsStrength = profile.wants_kids_strength if (wantsKidsStrength == null || wantsKidsStrength < 0) return null const wantsKidsText = wantsKidsStrength == 0 @@ -256,11 +256,11 @@ function WantsKids(props: { lover: Profile }) { ) } -function HasKids(props: { lover: Profile }) { - const { lover } = props +function HasKids(props: { profile: Profile }) { + const { profile } = props const hasKidsText = - lover.has_kids && lover.has_kids > 0 - ? `Has ${lover.has_kids} ${lover.has_kids > 1 ? 'kids' : 'kid'}` + profile.has_kids && profile.has_kids > 0 + ? `Has ${profile.has_kids} ${profile.has_kids > 1 ? 'kids' : 'kid'}` : null return } text={hasKidsText} /> } diff --git a/web/components/profile-carousel.tsx b/web/components/profile-carousel.tsx index 715a854..0690ff7 100644 --- a/web/components/profile-carousel.tsx +++ b/web/components/profile-carousel.tsx @@ -7,7 +7,7 @@ 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 { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' import { useAdmin } from 'web/hooks/use-admin' import { Button } from 'web/components/buttons/button' import { updateProfile } from 'web/lib/api' @@ -18,21 +18,21 @@ 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: Profile }) { - const { lover } = props - const photoNums = lover.photo_urls ? lover.photo_urls.length : 0 +export default function ProfileCarousel(props: { profile: Profile }) { + const { profile } = props + const photoNums = profile.photo_urls ? profile.photo_urls.length : 0 const [lightboxUrl, setLightboxUrl] = useState('') const [lightboxOpen, setLightboxOpen] = useState(false) const [isEditMode, setIsEditMode] = useState(false) const [addPhotosOpen, setAddPhotosOpen] = useState(false) - const [pinnedUrl, setPinnedUrl] = useState(lover.pinned_url) - const [photoUrls, setPhotoUrls] = useState(lover.photo_urls ?? []) + const [pinnedUrl, setPinnedUrl] = useState(profile.pinned_url) + const [photoUrls, setPhotoUrls] = useState(profile.photo_urls ?? []) const isAdmin = useAdmin() const currentUser = useUser() - const isCurrentUser = currentUser?.id === lover.user_id + const isCurrentUser = currentUser?.id === profile.user_id const handleSaveChanges = async () => { await updateProfile({ @@ -42,14 +42,14 @@ export default function ProfileCarousel(props: { lover: Profile }) { setIsEditMode(false) } - if (!currentUser && lover.visibility !== 'public') { + if (!currentUser && profile.visibility !== 'public') { return ( - {lover.pinned_url && ( + {profile.pinned_url && (
{ - api('remove-pinned-photo', { userId: lover.user_id }).then(() => + api('remove-pinned-photo', { userId: profile.user_id }).then(() => Router.back() ) }} @@ -105,8 +105,8 @@ export default function ProfileCarousel(props: { lover: Profile }) { } + {!profile && } Profiles diff --git a/web/components/required-lover-form.tsx b/web/components/required-profile-form.tsx similarity index 89% rename from web/components/required-lover-form.tsx rename to web/components/required-profile-form.tsx index 8195a9d..b4ebf95 100644 --- a/web/components/required-lover-form.tsx +++ b/web/components/required-profile-form.tsx @@ -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 {ProfileRow} from 'common/love/lover' +import {ProfileRow} from 'common/love/profile' 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: ProfileRow + profile: ProfileRow setProfile: >(key: K, value: ProfileRow[K] | undefined) => void isSubmitting: boolean onSubmit?: () => void - loverCreatedAlready?: boolean + profileCreatedAlready?: boolean }) => { - const {user, onSubmit, loverCreatedAlready, setProfile, lover, isSubmitting} = props + const {user, onSubmit, profileCreatedAlready, setProfile, profile, isSubmitting} = props const {updateUsername, updateDisplayName, userInfo, updateUserState} = useEditableUserInfo(user) const { @@ -67,9 +67,9 @@ export const RequiredLoveUserForm = (props: { const canContinue = true // const canContinue = - // (!lover.looking_for_matches || + // (!profile.looking_for_matches || // requiredKeys - // .map((k) => lover[k]) + // .map((k) => profile[k]) // .every((v) => // typeof v == 'string' // ? v !== '' @@ -83,7 +83,7 @@ export const RequiredLoveUserForm = (props: { return ( <> The Basics - {!loverCreatedAlready &&
No endless forms—write your own bio, your own way.
} + {!profileCreatedAlready &&
No endless forms—write your own bio, your own way.
} @@ -103,7 +103,7 @@ export const RequiredLoveUserForm = (props: { {errorName && {errorName}} - {!loverCreatedAlready && <> + {!profileCreatedAlready && <> @@ -128,7 +128,7 @@ export const RequiredLoveUserForm = (props: { { - console.log('bio changed', e, lover.bio) + console.log('bio changed', e, profile.bio) setProfile('bio', e) }} /> diff --git a/web/components/search-location.tsx b/web/components/search-location.tsx index f57fb96..994c7f2 100644 --- a/web/components/search-location.tsx +++ b/web/components/search-location.tsx @@ -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 { ProfileRow } from 'common/love/lover' +import { ProfileRow } from 'common/love/profile' import {OriginLocation} from "common/filters"; export type City = { @@ -15,15 +15,15 @@ export type City = { longitude: number } -export function loverToCity(lover: ProfileRow): City { +export function profileToCity(profile: ProfileRow): City { return { - geodb_city_id: lover.geodb_city_id!, - city: lover.city, - region_code: lover.region_code!, - country: lover.country!, + geodb_city_id: profile.geodb_city_id!, + city: profile.city, + region_code: profile.region_code!, + country: profile.country!, country_code: '', - latitude: lover.city_latitude!, - longitude: lover.city_longitude!, + latitude: profile.city_latitude!, + longitude: profile.city_longitude!, } } diff --git a/web/components/widgets/like-button.tsx b/web/components/widgets/like-button.tsx index da5905f..ee265f3 100644 --- a/web/components/widgets/like-button.tsx +++ b/web/components/widgets/like-button.tsx @@ -9,10 +9,10 @@ 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 { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' import { useUserById } from 'web/hooks/use-user-supabase' import { MatchAvatars } from '../matches/match-avatars' -import { useProfile } from 'web/hooks/use-lover' +import { useProfile } from 'web/hooks/use-profile' import { useAPIGetter } from 'web/hooks/use-api-getter' export const LikeButton = (props: { @@ -36,8 +36,8 @@ export const LikeButton = (props: { const like = async () => { setShowConfirmation(false) setIsLoading(true) - await api('like-lover', { targetUserId: targetId, remove: liked }) - track('like lover', { + await api('like-profile', { targetUserId: targetId, remove: liked }) + track('like profile', { targetId, remove: liked, }) diff --git a/web/components/widgets/likes-display.tsx b/web/components/widgets/likes-display.tsx index 1c455ce..8bb9e54 100644 --- a/web/components/widgets/likes-display.tsx +++ b/web/components/widgets/likes-display.tsx @@ -3,8 +3,8 @@ import Image from 'next/image' import Link from 'next/link' import { UserIcon } from '@heroicons/react/solid' -import { Profile } from 'common/love/lover' -import { useProfileByUserId } from 'web/hooks/use-lover' +import { Profile } from 'common/love/profile' +import { useProfileByUserId } from 'web/hooks/use-profile' import { Col } from 'web/components/layout/col' import { Avatar, EmptyAvatar } from 'web/components/widgets/avatar' import { Carousel } from 'web/components/widgets/carousel' @@ -13,7 +13,7 @@ import { useUser } from 'web/hooks/use-user' import { useUserById } from 'web/hooks/use-user-supabase' import { SendMessageButton } from 'web/components/messaging/send-message-button' import { ShipsList } from './ships-display' -import { Subtitle } from './lover-subtitle' +import { Subtitle } from './profile-subtitle' import { LikeData, ShipData } from 'common/api/love-types' export const LikesDisplay = (props: { @@ -122,17 +122,17 @@ const LikesList = (props: { label: string; likes: LikeData[] }) => { const UserAvatar = (props: { userId: string; className?: string }) => { const { userId, className } = props - const lover = useProfileByUserId(userId) + const profile = useProfileByUserId(userId) const user = useUserById(userId) - // console.log('UserAvatar', user?.username, lover?.pinned_url) + // console.log('UserAvatar', user?.username, profile?.pinned_url) - if (!lover) + if (!profile) return return ( ) @@ -143,14 +143,14 @@ export const MatchTile = (props: { matchUserId: string }) => { const { matchUserId, profileProfile } = props - const lover = useProfileByUserId(matchUserId) + const profile = useProfileByUserId(matchUserId) const user = useUserById(matchUserId) const currentUser = useUser() const isYourMatch = currentUser?.id === profileProfile.user_id - if (!lover || !user) + if (!profile || !user) return - const { pinned_url } = lover + const { pinned_url } = profile return ( diff --git a/web/components/widgets/lover-subtitle.tsx b/web/components/widgets/profile-subtitle.tsx similarity index 100% rename from web/components/widgets/lover-subtitle.tsx rename to web/components/widgets/profile-subtitle.tsx diff --git a/web/components/widgets/ships-display.tsx b/web/components/widgets/ships-display.tsx index 72f3044..8b9f178 100644 --- a/web/components/widgets/ships-display.tsx +++ b/web/components/widgets/ships-display.tsx @@ -5,14 +5,14 @@ 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 { Profile } from 'common/love/lover' -import { useProfileByUserId } from 'web/hooks/use-lover' +import { Profile } from 'common/love/profile' +import { useProfileByUserId } from 'web/hooks/use-profile' import { Col } from 'web/components/layout/col' import { EmptyAvatar, Avatar } from 'web/components/widgets/avatar' import { Carousel } from 'web/components/widgets/carousel' import { UserLink } from 'web/components/widgets/user-link' import { useUser } from 'web/hooks/use-user' -import { Subtitle } from './lover-subtitle' +import { Subtitle } from './profile-subtitle' import { ShipButton } from './ship-button' import { hasShipped } from 'web/lib/util/ship-util' import { ShipData } from 'common/api/love-types' @@ -144,15 +144,15 @@ const ShipsTargetDisplay = (props: { const UserAvatar = (props: { userId: string; className?: string }) => { const { userId, className } = props - const lover = useProfileByUserId(userId) + const profile = useProfileByUserId(userId) const user = useUserById(userId) - if (!lover || !lover.pinned_url) + if (!profile || !profile.pinned_url) return return ( @@ -162,14 +162,14 @@ const UserAvatar = (props: { userId: string; className?: string }) => { const UserInfoRow = (props: { userId: string; className?: string }) => { const { userId, className } = props const user = useUserById(userId) - const lover = useProfileByUserId(userId) + const profile = useProfileByUserId(userId) return ( - {!lover || !lover.pinned_url ? ( + {!profile || !profile.pinned_url ? ( ) : ( - + )} {user && } diff --git a/web/components/widgets/star-button.tsx b/web/components/widgets/star-button.tsx index 11672c2..88fd54a 100644 --- a/web/components/widgets/star-button.tsx +++ b/web/components/widgets/star-button.tsx @@ -6,7 +6,7 @@ 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 { Profile } from 'common/love/lover' +import { Profile } from 'common/love/profile' export const StarButton = (props: { targetProfile: Profile @@ -25,13 +25,13 @@ export const StarButton = (props: { const star = async () => { setIsStarred(!isStarred) - await api('star-lover', { + await api('star-profile', { targetUserId: targetId, remove: isStarred, }).catch(() => { setIsStarred(isStarred) }) - track('star lover', { + track('star profile', { targetId, remove: isStarred, }) diff --git a/web/hooks/use-comments-on-lover.ts b/web/hooks/use-comments-on-profile.ts similarity index 97% rename from web/hooks/use-comments-on-lover.ts rename to web/hooks/use-comments-on-profile.ts index c469a04..9f720c3 100644 --- a/web/hooks/use-comments-on-lover.ts +++ b/web/hooks/use-comments-on-profile.ts @@ -36,7 +36,7 @@ export function useLiveCommentsOnProfile(userId: string) { const getComments = async (userId: string) => { const { data, error } = await db - .from('lover_comments') + .from('profile_comments') .select('*') .eq('on_user_id', userId) if (error) { diff --git a/web/hooks/use-is-looking.ts b/web/hooks/use-is-looking.ts index 1f42ef7..cd47aa7 100644 --- a/web/hooks/use-is-looking.ts +++ b/web/hooks/use-is-looking.ts @@ -1,6 +1,6 @@ -import { useProfile } from './use-lover' +import { useProfile } from './use-profile' export const useIsLooking = () => { - const lover = useProfile() - return !!(lover && lover.looking_for_matches) + const profile = useProfile() + return !!(profile && profile.looking_for_matches) } diff --git a/web/hooks/use-lover.ts b/web/hooks/use-lover.ts deleted file mode 100644 index 8fe270c..0000000 --- a/web/hooks/use-lover.ts +++ /dev/null @@ -1,78 +0,0 @@ -import {useUser} from 'web/hooks/use-user' -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 {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 useProfile = () => { - const user = useUser() - const [lover, setProfile] = usePersistentLocalState< - Row<'profiles'> | undefined | null - >(undefined, `lover-${user?.id}`) - - const refreshProfile = () => { - if (user) { - console.log('Refreshing lover in useProfile for', user?.username, lover); - getProfileRow(user.id, db).then((lover) => { - if (!lover) setProfile(null) - else setProfile(lover) - }) - } - } - - useEffect(() => { - refreshProfile() - }, [user?.id]) - - return user && lover ? {...lover, user} : lover === null ? null : undefined -} - -export const useProfileByUser = (user: User | undefined) => { - const userId = user?.id - const [lover, setProfile] = usePersistentInMemoryState< - Profile | undefined | null - >(undefined, `lover-user-${userId}`) - - function refreshProfile() { - if (userId) { - console.log('Refreshing lover in useProfileByUser for', user?.username, lover); - getProfileRow(userId, db) - .then((lover) => { - if (!lover) setProfile(null) - else setProfile({...lover, user}) - }) - .catch(error => { - console.log('Warning: lover not found', user?.username, error); - setProfile(null) - return - }); - console.log('End Refreshing lover for', user?.username, lover); - } - } - - useEffect(() => { - refreshProfile() - }, [userId]) - - return {lover, refreshProfile} -} - -export const useProfileByUserId = (userId: string | undefined) => { - const [lover, setProfile] = usePersistentInMemoryState< - ProfileRow | undefined | null - >(undefined, `lover-${userId}`) - - useEffect(() => { - console.log('Refreshing lover in useProfileByUserId for', userId, lover); - if (userId) - getProfileRow(userId, db).then((lover) => { - if (!lover) setProfile(null) - else setProfile(lover) - }) - }, [userId]) - - return lover -} diff --git a/web/hooks/use-online.ts b/web/hooks/use-online.ts index c4bd785..fe0be71 100644 --- a/web/hooks/use-online.ts +++ b/web/hooks/use-online.ts @@ -1,18 +1,18 @@ import { useEffect } from 'react' -import { useProfile } from 'web/hooks/use-lover' +import { useProfile } from 'web/hooks/use-profile' 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 = useProfile() + const profile = useProfile() const isAuthed = useIsAuthorized() useEffect(() => { - if (!lover || !isAuthed) return + if (!profile || !isAuthed) return run( db .from('profiles') .update({ last_online_time: new Date().toISOString() }) - .eq('id', lover.id) + .eq('id', profile.id) ) }, []) } diff --git a/web/hooks/use-profile.ts b/web/hooks/use-profile.ts new file mode 100644 index 0000000..b989afb --- /dev/null +++ b/web/hooks/use-profile.ts @@ -0,0 +1,78 @@ +import {useUser} from 'web/hooks/use-user' +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 {getProfileRow, Profile, ProfileRow} from 'common/love/profile' +import {db} from 'web/lib/supabase/db' +import {usePersistentLocalState} from 'web/hooks/use-persistent-local-state' + +export const useProfile = () => { + const user = useUser() + const [profile, setProfile] = usePersistentLocalState< + Row<'profiles'> | undefined | null + >(undefined, `profile-${user?.id}`) + + const refreshProfile = () => { + if (user) { + console.log('Refreshing profile in useProfile for', user?.username, profile); + getProfileRow(user.id, db).then((profile) => { + if (!profile) setProfile(null) + else setProfile(profile) + }) + } + } + + useEffect(() => { + refreshProfile() + }, [user?.id]) + + return user && profile ? {...profile, user} : profile === null ? null : undefined +} + +export const useProfileByUser = (user: User | undefined) => { + const userId = user?.id + const [profile, setProfile] = usePersistentInMemoryState< + Profile | undefined | null + >(undefined, `profile-user-${userId}`) + + function refreshProfile() { + if (userId) { + console.log('Refreshing profile in useProfileByUser for', user?.username, profile); + getProfileRow(userId, db) + .then((profile) => { + if (!profile) setProfile(null) + else setProfile({...profile, user}) + }) + .catch(error => { + console.log('Warning: profile not found', user?.username, error); + setProfile(null) + return + }); + console.log('End Refreshing profile for', user?.username, profile); + } + } + + useEffect(() => { + refreshProfile() + }, [userId]) + + return {profile, refreshProfile} +} + +export const useProfileByUserId = (userId: string | undefined) => { + const [profile, setProfile] = usePersistentInMemoryState< + ProfileRow | undefined | null + >(undefined, `profile-${userId}`) + + useEffect(() => { + console.log('Refreshing profile in useProfileByUserId for', userId, profile); + if (userId) + getProfileRow(userId, db).then((profile) => { + if (!profile) setProfile(null) + else setProfile(profile) + }) + }, [userId]) + + return profile +} diff --git a/web/hooks/use-profiles.ts b/web/hooks/use-profiles.ts index 1f74811..a021de5 100644 --- a/web/hooks/use-profiles.ts +++ b/web/hooks/use-profiles.ts @@ -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 { useProfileByUserId } from './use-lover' +import { useProfileByUserId } from './use-profile' 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 = useProfileByUserId(userId ?? undefined) + const profile = useProfileByUserId(userId ?? undefined) useEffect(() => { if (userId) { @@ -30,10 +30,10 @@ export const useCompatibleProfiles = ( } else if (userId === null) setData(null) }, [userId]) - if (data && lover && options?.sortWithModifiers) { + if (data && profile && options?.sortWithModifiers) { data.compatibleProfiles = sortBy(data.compatibleProfiles, (l) => { - const modifier = !lover ? 1 : getProfilesCompatibilityFactor(lover, l) - return -1 * modifier * data.loverCompatibilityScores[l.user.id].score + const modifier = !profile ? 1 : getProfilesCompatibilityFactor(profile, l) + return -1 * modifier * data.profileCompatibilityScores[l.user.id].score }) } diff --git a/web/lib/api.ts b/web/lib/api.ts index d4b7b08..0e28756 100644 --- a/web/lib/api.ts +++ b/web/lib/api.ts @@ -28,6 +28,6 @@ function curriedAPI

(path: P) { return (params: APIParams

) => api(path, params) } -export const updateProfile = curriedAPI('update-lover') +export const updateProfile = curriedAPI('update-profile') export const updateUser = curriedAPI('me/update') export const report = curriedAPI('report') diff --git a/web/lib/util/signup.ts b/web/lib/util/signup.ts index 751b6db..8dfdbe0 100644 --- a/web/lib/util/signup.ts +++ b/web/lib/util/signup.ts @@ -1,15 +1,15 @@ import Router from 'next/router' import { firebaseLogin } from 'web/lib/firebase/users' import { db } from 'web/lib/supabase/db' -import { getProfileRow } from 'common/love/lover' +import { getProfileRow } from 'common/love/profile' export const signupThenMaybeRedirectToSignup = async () => { const creds = await firebaseLogin() await Router.push('/') const userId = creds?.user.uid if (userId) { - const lover = await getProfileRow(userId, db) - if (!lover) { + const profile = await getProfileRow(userId, db) + if (!profile) { await Router.push('/signup') } } diff --git a/web/pages/[username]/index.tsx b/web/pages/[username]/index.tsx index 46af58f..d00299f 100644 --- a/web/pages/[username]/index.tsx +++ b/web/pages/[username]/index.tsx @@ -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 {useProfileByUser} from 'web/hooks/use-lover' +import {useProfileByUser} from 'web/hooks/use-profile' 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 {getProfileRow, ProfileRow} from 'common/love/lover' +import {getProfileRow, ProfileRow} from 'common/love/profile' import {db} from 'web/lib/supabase/db' -import {ProfileProfile} from 'web/components/profile/lover-profile' +import {ProfileProfile} from 'web/components/profile/profile-profile' import {User} from 'common/user' import {getUserForStaticProps} from 'common/supabase/users' import {type GetStaticProps} from 'next' @@ -58,12 +58,12 @@ export const getStaticProps: GetStaticProps< } } - const lover = await getProfileRow(user.id, db) + const profile = await getProfileRow(user.id, db) return { props: { user, username, - lover, + profile, }, revalidate: 15, } @@ -82,7 +82,7 @@ type DeletedUserPageProps = { type ActiveUserPageProps = { user: User username: string - lover: ProfileRow + profile: ProfileRow } export default function UserPage(props: UserPageProps) { @@ -112,12 +112,12 @@ function UserPageInner(props: ActiveUserPageProps) { useTracking('view love profile', {username: user?.username}) const [staticProfile] = useState( - props.lover && user ? {...props.lover, user: user} : null + props.profile && user ? {...props.profile, user: user} : null ) - const {lover: clientProfile, refreshProfile} = useProfileByUser(user) + const {profile: clientProfile, refreshProfile} = useProfileByUser(user) // Show previous profile while loading another one - const lover = clientProfile ?? staticProfile - // console.log('lover:', user?.username, lover, clientProfile, staticProfile) + const profile = clientProfile ?? staticProfile + // console.log('profile:', user?.username, profile, clientProfile, staticProfile) return ( {(user.isBannedFromPosting || user.userDeleted) && ( @@ -140,10 +140,10 @@ function UserPageInner(props: ActiveUserPageProps) { {currentUser !== undefined && ( - {lover ? ( + {profile ? ( { - if (user === null || lover === null) { + if (user === null || profile === null) { Router.replace('/') } }, [user]) - return user && lover && + return user && profile && } -function ProfilePageInner(props: { user: User; lover: Profile }) { +function ProfilePageInner(props: { user: User; profile: Profile }) { const {user} = props - const [lover, setProfile] = useState({ - ...props.lover, + const [profile, setProfile] = useState({ + ...props.profile, user, }) @@ -46,15 +46,15 @@ function ProfilePageInner(props: { user: User; lover: Profile }) {

{ const checkProfileAndRedirect = async () => { if (user) { - const lover = await getProfileRow(user.id, db) - if (lover) { + const profile = await getProfileRow(user.id, db) + if (profile) { await Router.push('/') } else { await Router.push('/signup') diff --git a/web/pages/signin.tsx b/web/pages/signin.tsx index d79603d..aeb5f7c 100644 --- a/web/pages/signin.tsx +++ b/web/pages/signin.tsx @@ -7,7 +7,7 @@ import {auth, firebaseLogin} from "web/lib/firebase/users"; import FavIcon from "web/public/FavIcon"; import {signInWithEmailAndPassword} from "firebase/auth"; -import {getProfileRow} from "common/love/lover"; +import {getProfileRow} from "common/love/profile"; import {db} from "web/lib/supabase/db"; import Router from "next/router"; import {LovePage} from "web/components/love-page"; @@ -43,14 +43,14 @@ function RegisterComponent() { if (user) { console.log("User signed in:", user); try { - const lover = await getProfileRow(user.id, db) - if (lover) { + const profile = await getProfileRow(user.id, db) + if (profile) { await Router.push('/') } else { await Router.push('/signup') } } catch (error) { - console.error("Error fetching lover profile:", error); + console.error("Error fetching profile profile:", error); } setIsLoading(false); setIsLoadingGoogle(false); diff --git a/web/pages/signup.tsx b/web/pages/signup.tsx index 831437e..ac13ee2 100644 --- a/web/pages/signup.tsx +++ b/web/pages/signup.tsx @@ -1,7 +1,7 @@ import {useEffect, useState} from 'react' import {Col} from 'web/components/layout/col' -import {initialRequiredState, RequiredLoveUserForm,} from 'web/components/required-lover-form' -import {OptionalLoveUserForm} from 'web/components/optional-lover-form' +import {initialRequiredState, RequiredLoveUserForm,} from 'web/components/required-profile-form' +import {OptionalLoveUserForm} from 'web/components/optional-profile-form' import {useUser} from 'web/hooks/use-user' import {LoadingIndicator} from 'web/components/widgets/loading-indicator' import {CACHED_REFERRAL_USERNAME_KEY,} from 'web/lib/firebase/users' @@ -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 {useProfileByUserId} from 'web/hooks/use-lover' -import {ProfileRow} from 'common/love/lover' +import {useProfileByUserId} from 'web/hooks/use-profile' +import {ProfileRow} from 'common/love/profile' import {LovePage} from "web/components/love-page"; import {Button} from "web/components/buttons/button"; @@ -25,7 +25,7 @@ export default function SignupPage() { useTracking('view love signup page') // Omit the id, created_time? - const [loverForm, setProfileForm] = useState({ + const [profileForm, setProfileForm] = useState({ ...initialRequiredState, } as any) const setProfileState = (key: keyof ProfileRow, value: any) => { @@ -47,7 +47,7 @@ export default function SignupPage() { @@ -78,10 +78,10 @@ export default function SignupPage() { { - if (!loverForm.looking_for_matches) { + if (!profileForm.looking_for_matches) { router.push('/') return } @@ -91,11 +91,11 @@ export default function SignupPage() { : undefined setIsSubmitting(true) - console.log('loverForm', loverForm) - const lover = await api( - 'create-lover', + console.log('profileForm', profileForm) + const profile = await api( + 'create-profile', removeNullOrUndefinedProps({ - ...loverForm, + ...profileForm, referred_by_username: referredByUsername, }) as any ).catch((e: unknown) => { @@ -103,8 +103,8 @@ export default function SignupPage() { return null }) setIsSubmitting(false) - if (lover) { - setProfileForm(lover) + if (profile) { + setProfileForm(profile) setStep(1) scrollTo(0, 0) track('submit love required profile')