From 940c1f5692f63bf72ddccd4ec3b00b1443801682 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Sat, 25 Oct 2025 14:21:58 +0200 Subject: [PATCH] Add profile field: religion --- backend/email/emails/functions/mock.ts | 2 ++ backend/supabase/profiles.sql | 1 + common/src/supabase/schema.ts | 3 +++ web/components/filters/choices.tsx | 22 ++++++++++++++++++++++ web/components/optional-profile-form.tsx | 7 ++++++- web/components/profile-about.tsx | 6 +++++- web/lib/util/convert-types.ts | 6 ++++++ 7 files changed, 45 insertions(+), 2 deletions(-) diff --git a/backend/email/emails/functions/mock.ts b/backend/email/emails/functions/mock.ts index d5528a1..7616992 100644 --- a/backend/email/emails/functions/mock.ts +++ b/backend/email/emails/functions/mock.ts @@ -36,6 +36,7 @@ export const sinclairProfile: ProfileRow = { pref_gender: ['female', 'trans-female'], pref_age_min: 18, pref_age_max: 21, + religion: [], pref_relation_styles: ['friendship'], pref_romantic_styles: ['poly', 'open', 'mono'], wants_kids_strength: 3, @@ -137,6 +138,7 @@ export const jamesProfile: ProfileRow = { pref_gender: ['female'], pref_age_min: 22, pref_age_max: 32, + religion: [], pref_relation_styles: ['friendship'], pref_romantic_styles: ['poly', 'open', 'mono'], wants_kids_strength: 4, diff --git a/backend/supabase/profiles.sql b/backend/supabase/profiles.sql index 3098d6f..3ac9211 100644 --- a/backend/supabase/profiles.sql +++ b/backend/supabase/profiles.sql @@ -45,6 +45,7 @@ CREATE TABLE IF NOT EXISTS profiles ( region_code TEXT, religious_belief_strength INTEGER, religious_beliefs TEXT, + religion TEXT[], twitter TEXT, university TEXT, user_id TEXT NOT NULL, diff --git a/common/src/supabase/schema.ts b/common/src/supabase/schema.ts index bd3a687..05bf5cb 100644 --- a/common/src/supabase/schema.ts +++ b/common/src/supabase/schema.ts @@ -565,6 +565,7 @@ export type Database = { pref_romantic_styles: string[] | null referred_by_username: string | null region_code: string | null + religion: string[] | null religious_belief_strength: number | null religious_beliefs: string | null twitter: string | null @@ -613,6 +614,7 @@ export type Database = { pref_romantic_styles?: string[] | null referred_by_username?: string | null region_code?: string | null + religion?: string[] | null religious_belief_strength?: number | null religious_beliefs?: string | null twitter?: string | null @@ -661,6 +663,7 @@ export type Database = { pref_romantic_styles?: string[] | null referred_by_username?: string | null region_code?: string | null + religion?: string[] | null religious_belief_strength?: number | null religious_beliefs?: string | null twitter?: string | null diff --git a/web/components/filters/choices.tsx b/web/components/filters/choices.tsx index 0dd83da..f597564 100644 --- a/web/components/filters/choices.tsx +++ b/web/components/filters/choices.tsx @@ -45,6 +45,24 @@ export const EDUCATION_CHOICES = { PhD: 'doctorate', } +export const RELIGION_CHOICES = { + 'Atheist': 'atheist', + 'Agnostic': 'agnostic', + 'Spiritual': 'spiritual', + 'Christian': 'christian', + 'Muslim': 'muslim', + 'Jewish': 'jewish', + 'Hindu': 'hindu', + 'Buddhist': 'buddhist', + 'Sikh': 'sikh', + 'Taoist': 'taoist', + 'Jain': 'jain', + 'Shinto': 'shinto', + 'Zoroastrian': 'zoroastrian', + 'Unitarian Universalist': 'unitarian_universalist', + 'Other': 'other', +} + export const REVERTED_RELATIONSHIP_CHOICES = Object.fromEntries( Object.entries(RELATIONSHIP_CHOICES).map(([key, value]) => [value, key]) ); @@ -63,4 +81,8 @@ export const REVERTED_DIET_CHOICES = Object.fromEntries( export const REVERTED_EDUCATION_CHOICES = Object.fromEntries( Object.entries(EDUCATION_CHOICES).map(([key, value]) => [value, key]) +); + +export const REVERTED_RELIGION_CHOICES = Object.fromEntries( + Object.entries(RELIGION_CHOICES).map(([key, value]) => [value, key]) ); \ No newline at end of file diff --git a/web/components/optional-profile-form.tsx b/web/components/optional-profile-form.tsx index ae2a545..6131492 100644 --- a/web/components/optional-profile-form.tsx +++ b/web/components/optional-profile-form.tsx @@ -32,7 +32,7 @@ import { DIET_CHOICES, EDUCATION_CHOICES, POLITICAL_CHOICES, - RELATIONSHIP_CHOICES, + RELATIONSHIP_CHOICES, RELIGION_CHOICES, ROMANTIC_CHOICES } from "web/components/filters/choices"; import toast from "react-hot-toast"; @@ -407,6 +407,11 @@ export const OptionalProfileUserForm = (props: { + setProfile('religion', selected)} + /> setProfile('religious_beliefs', e.target.value)} diff --git a/web/components/profile-about.tsx b/web/components/profile-about.tsx index 1e489e6..7effe74 100644 --- a/web/components/profile-about.tsx +++ b/web/components/profile-about.tsx @@ -4,7 +4,7 @@ import stringOrStringArrayToText from 'web/lib/util/string-or-string-array-to-te import {ReactNode} from 'react' import { REVERTED_DIET_CHOICES, REVERTED_EDUCATION_CHOICES, - REVERTED_POLITICAL_CHOICES, + REVERTED_POLITICAL_CHOICES, REVERTED_RELIGION_CHOICES, REVERTED_ROMANTIC_CHOICES } from 'web/components/filters/choices' import {BiSolidDrink} from 'react-icons/bi' @@ -69,6 +69,10 @@ export default function ProfileAbout(props: { icon={} text={profile.political_beliefs?.map(belief => REVERTED_POLITICAL_CHOICES[belief])} /> + } + text={profile.religion?.map(belief => REVERTED_RELIGION_CHOICES[belief])} + /> } text={profile.religious_beliefs} diff --git a/web/lib/util/convert-types.ts b/web/lib/util/convert-types.ts index d670107..db4bb1c 100644 --- a/web/lib/util/convert-types.ts +++ b/web/lib/util/convert-types.ts @@ -3,6 +3,7 @@ import { REVERTED_EDUCATION_CHOICES, REVERTED_POLITICAL_CHOICES, REVERTED_RELATIONSHIP_CHOICES, + REVERTED_RELIGION_CHOICES, REVERTED_ROMANTIC_CHOICES } from "web/components/filters/choices"; @@ -11,6 +12,7 @@ export type RomanticType = keyof typeof REVERTED_ROMANTIC_CHOICES export type DietType = keyof typeof REVERTED_DIET_CHOICES export type PoliticalType = keyof typeof REVERTED_POLITICAL_CHOICES export type EducationType = keyof typeof REVERTED_EDUCATION_CHOICES +export type ReligionType = keyof typeof REVERTED_RELIGION_CHOICES export function convertRelationshipType(relationshipType: RelationshipType) { return REVERTED_RELATIONSHIP_CHOICES[relationshipType] @@ -31,3 +33,7 @@ export function convertPoliticalTypes(politicalType: PoliticalType) { export function convertEducationTypes(educationType: EducationType) { return REVERTED_EDUCATION_CHOICES[educationType] } + +export function convertReligionTypes(religionType: ReligionType) { + return REVERTED_RELIGION_CHOICES[religionType] +}