Skip to content

Commit 2ce2124

Browse files
committed
Add romantic style (poly, mono, other)
1 parent 8ea6c40 commit 2ce2124

9 files changed

Lines changed: 55 additions & 15 deletions

File tree

backend/api/src/get-profiles.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type profileQueryType = {
1616
pref_age_min?: number | undefined,
1717
pref_age_max?: number | undefined,
1818
pref_relation_styles?: String[] | undefined,
19+
pref_romantic_styles?: String[] | undefined,
1920
wants_kids_strength?: number | undefined,
2021
has_kids?: number | undefined,
2122
is_smoker?: boolean | undefined,
@@ -42,6 +43,7 @@ export const loadProfiles = async (props: profileQueryType) => {
4243
pref_age_min,
4344
pref_age_max,
4445
pref_relation_styles,
46+
pref_romantic_styles,
4547
wants_kids_strength,
4648
has_kids,
4749
is_smoker,
@@ -73,6 +75,8 @@ export const loadProfiles = async (props: profileQueryType) => {
7375
(!pref_age_max || (l.age ?? MIN_INT) <= pref_age_max) &&
7476
(!pref_relation_styles ||
7577
intersection(pref_relation_styles, l.pref_relation_styles).length) &&
78+
(!pref_romantic_styles ||
79+
intersection(pref_romantic_styles, l.pref_romantic_styles).length) &&
7680
(!wants_kids_strength ||
7781
wants_kids_strength == -1 ||
7882
(wants_kids_strength >= 2
@@ -136,6 +140,12 @@ export const loadProfiles = async (props: profileQueryType) => {
136140
{ pref_relation_styles }
137141
),
138142

143+
pref_romantic_styles?.length &&
144+
where(
145+
`pref_romantic_styles IS NULL OR pref_romantic_styles = '{}' OR pref_romantic_styles && $(pref_romantic_styles)`,
146+
{ pref_romantic_styles }
147+
),
148+
139149
!!wants_kids_strength &&
140150
wants_kids_strength !== -1 &&
141151
where(

backend/email/emails/functions/mock.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export const sinclairProfile: ProfileRow = {
3737
pref_gender: ['female', 'trans-female'],
3838
pref_age_min: 18,
3939
pref_age_max: 21,
40-
pref_relation_styles: ['poly', 'open', 'mono'],
40+
pref_relation_styles: ['friendship'],
41+
pref_romantic_styles: ['poly', 'open', 'mono'],
4142
wants_kids_strength: 3,
4243
looking_for_matches: true,
4344
visibility: 'public',
@@ -137,7 +138,8 @@ export const jamesProfile: ProfileRow = {
137138
pref_gender: ['female'],
138139
pref_age_min: 22,
139140
pref_age_max: 32,
140-
pref_relation_styles: ['mono'],
141+
pref_relation_styles: ['friendship'],
142+
pref_romantic_styles: ['poly', 'open', 'mono'],
141143
wants_kids_strength: 4,
142144
looking_for_matches: true,
143145
visibility: 'public',

backend/supabase/profiles.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ CREATE TABLE IF NOT EXISTS profiles (
4040
pref_age_min INTEGER NULL,
4141
pref_gender TEXT[] NOT NULL,
4242
pref_relation_styles TEXT[] NOT NULL,
43+
pref_romantic_styles TEXT[],
4344
referred_by_username TEXT,
4445
region_code TEXT,
4546
religious_belief_strength INTEGER,

common/src/api/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ export const API = (_apiTypeCheck = {
349349
pref_age_min: z.coerce.number().optional(),
350350
pref_age_max: z.coerce.number().optional(),
351351
pref_relation_styles: arraybeSchema.optional(),
352+
pref_romantic_styles: arraybeSchema.optional(),
352353
wants_kids_strength: z.coerce.number().optional(),
353354
has_kids: z.coerce.number().optional(),
354355
is_smoker: z.coerce.boolean().optional(),

common/src/api/zod-types.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,8 @@ export const baseProfilesSchema = z.object({
4949
pref_gender: genderTypes,
5050
pref_age_min: z.number().min(18).max(100).optional(),
5151
pref_age_max: z.number().min(18).max(100).optional(),
52-
pref_relation_styles: z.array(
53-
z.union([
54-
z.literal('collaboration'),
55-
z.literal('friendship'),
56-
z.literal('relationship'),
57-
])
58-
),
52+
pref_relation_styles: z.array(z.string()),
53+
pref_romantic_styles: z.array(z.string()),
5954
wants_kids_strength: z.number(),
6055
looking_for_matches: z.boolean(),
6156
photo_urls: z.array(z.string()),

common/src/supabase/schema.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ export type Database = {
438438
pref_age_min: number | null
439439
pref_gender: string[]
440440
pref_relation_styles: string[]
441+
pref_romantic_styles: string[] | null
441442
referred_by_username: string | null
442443
region_code: string | null
443444
religious_belief_strength: number | null
@@ -485,6 +486,7 @@ export type Database = {
485486
pref_age_min?: number | null
486487
pref_gender: string[]
487488
pref_relation_styles: string[]
489+
pref_romantic_styles?: string[] | null
488490
referred_by_username?: string | null
489491
region_code?: string | null
490492
religious_belief_strength?: number | null
@@ -532,6 +534,7 @@ export type Database = {
532534
pref_age_min?: number | null
533535
pref_gender?: string[]
534536
pref_relation_styles?: string[]
537+
pref_romantic_styles?: string[] | null
535538
referred_by_username?: string | null
536539
region_code?: string | null
537540
religious_belief_strength?: number | null

web/components/filters/choices.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
export const RELATIONSHIP_CHOICES = {
2-
// Monogamous: 'mono',
3-
// Polyamorous: 'poly',
4-
// 'Open Relationship': 'open',
52
// Other: 'other',
63
Collaboration: 'collaboration',
74
Friendship: 'friendship',
85
Relationship: 'relationship',
96
};
107

8+
export const ROMANTIC_CHOICES = {
9+
Monogamous: 'mono',
10+
Polyamorous: 'poly',
11+
'Open Relationship': 'open',
12+
};
13+
1114
export const REVERTED_RELATIONSHIP_CHOICES = Object.fromEntries(
1215
Object.entries(RELATIONSHIP_CHOICES).map(([key, value]) => [value, key])
16+
);
17+
18+
export const REVERTED_ROMANTIC_CHOICES = Object.fromEntries(
19+
Object.entries(ROMANTIC_CHOICES).map(([key, value]) => [value, key])
1320
);

web/components/optional-profile-form.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {City, CityRow, profileToCity, useCitySearch} from "web/components/search
2828
import {AddPhotosWidget} from './widgets/add-photos'
2929
import {RadioToggleGroup} from "web/components/widgets/radio-toggle-group";
3030
import {MultipleChoiceOptions} from "common/love/multiple-choice";
31-
import {RELATIONSHIP_CHOICES} from "web/components/filters/choices";
31+
import {RELATIONSHIP_CHOICES, ROMANTIC_CHOICES} from "web/components/filters/choices";
3232
import toast from "react-hot-toast";
3333

3434
export const OptionalLoveUserForm = (props: {
@@ -42,7 +42,7 @@ export const OptionalLoveUserForm = (props: {
4242
const {profile, user, buttonLabel, setProfile, fromSignup, onSubmit} = props
4343

4444
const [isSubmitting, setIsSubmitting] = useState(false)
45-
const [lookingRelationship, setLookingRelationship] = useState(false)
45+
const [lookingRelationship, setLookingRelationship] = useState((profile.pref_relation_styles || []).includes('relationship'))
4646
const router = useRouter()
4747
const [heightFeet, setHeightFeet] = useState<number | undefined>(
4848
profile.height_in_inches
@@ -554,6 +554,17 @@ export const OptionalLoveUserForm = (props: {
554554
currentChoice={profile.wants_kids_strength ?? -1}
555555
/>
556556
</Col>
557+
558+
<Col className={clsx(colClassName)}>
559+
<label className={clsx(labelClassName)}>Relationship style</label>
560+
<MultiCheckbox
561+
choices={ROMANTIC_CHOICES}
562+
selected={profile['pref_romantic_styles'] || []}
563+
onChange={(selected) => {
564+
setProfile('pref_romantic_styles', selected)
565+
}}
566+
/>
567+
</Col>
557568
</>}
558569

559570
<Col className={clsx(colClassName)}>

web/components/profile-about.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import clsx from 'clsx'
22
import {convertRelationshipType, type RelationshipType,} from 'web/lib/util/convert-relationship-type'
33
import stringOrStringArrayToText from 'web/lib/util/string-or-string-array-to-text'
44
import {ReactNode} from 'react'
5+
import {REVERTED_ROMANTIC_CHOICES} from 'web/components/filters/choices'
56
import {BiSolidDrink} from 'react-icons/bi'
67
import {BsPersonHeart} from 'react-icons/bs'
78
import {FaChild} from 'react-icons/fa6'
@@ -126,7 +127,7 @@ function Seeking(props: { profile: Profile }) {
126127
function RelationshipType(props: { profile: Profile }) {
127128
const {profile} = props
128129
const relationshipTypes = profile.pref_relation_styles
129-
const seekingGenderText = stringOrStringArrayToText({
130+
let seekingGenderText = stringOrStringArrayToText({
130131
text: relationshipTypes.map((rel) =>
131132
convertRelationshipType(rel as RelationshipType).toLowerCase()
132133
).sort(),
@@ -138,6 +139,15 @@ function RelationshipType(props: { profile: Profile }) {
138139
asSentence: true,
139140
capitalizeFirstLetterOption: false,
140141
})
142+
if (relationshipTypes.includes('relationship')) {
143+
const romanticStyles = profile.pref_romantic_styles
144+
?.map((style) => REVERTED_ROMANTIC_CHOICES[style].toLowerCase())
145+
.filter(Boolean)
146+
if (romanticStyles && romanticStyles.length > 0) {
147+
seekingGenderText += ` (${romanticStyles.join(', ')})`
148+
}
149+
150+
}
141151
return (
142152
<AboutRow
143153
icon={<BsPersonHeart className="h-5 w-5"/>}

0 commit comments

Comments
 (0)