Add profile field: religion

This commit is contained in:
MartinBraquet
2025-10-25 14:21:58 +02:00
parent 0430733b58
commit 940c1f5692
7 changed files with 45 additions and 2 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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

View File

@@ -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])
);

View File

@@ -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: {
<Col className={clsx(colClassName)}>
<label className={clsx(labelClassName)}>Religious beliefs</label>
<MultiCheckbox
choices={RELIGION_CHOICES}
selected={profile['religion'] ?? []}
onChange={(selected) => setProfile('religion', selected)}
/>
<Input
type="text"
onChange={(e) => setProfile('religious_beliefs', e.target.value)}

View File

@@ -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={<RiScales3Line className="h-5 w-5"/>}
text={profile.political_beliefs?.map(belief => REVERTED_POLITICAL_CHOICES[belief])}
/>
<AboutRow
icon={<PiHandsPrayingBold className="h-5 w-5"/>}
text={profile.religion?.map(belief => REVERTED_RELIGION_CHOICES[belief])}
/>
<AboutRow
icon={<PiHandsPrayingBold className="h-5 w-5"/>}
text={profile.religious_beliefs}

View File

@@ -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]
}