Fix age rendering

This commit is contained in:
MartinBraquet
2025-10-02 14:14:24 +02:00
parent ce1305d8ae
commit bfee7ff09d
3 changed files with 10 additions and 7 deletions

View File

@@ -65,6 +65,7 @@ export const OptionalLoveUserForm = (props: {
const handleSubmit = async () => {
setIsSubmitting(true)
const {bio: _, ...otherProfileProps} = profile
console.log('otherProfileProps', removeNullOrUndefinedProps(otherProfileProps))
const {error} = await tryCatch(
updateProfile(removeNullOrUndefinedProps(otherProfileProps) as any)
)
@@ -198,7 +199,7 @@ export const OptionalLoveUserForm = (props: {
value={profile['age'] ?? undefined}
min={18}
max={100}
onChange={(e) => setProfile('age', Number(e.target.value))}
onChange={(e) => setProfile('age', e.target.value ? Number(e.target.value) : null)}
/>
</Col>
@@ -238,7 +239,7 @@ export const OptionalLoveUserForm = (props: {
<Select
value={profile['pref_age_min'] ?? ''}
onChange={(e) =>
setProfile('pref_age_min', Number(e.target.value))
setProfile('pref_age_min', e.target.value ? Number(e.target.value) : 18)
}
className={'w-18 border-ink-300 rounded-md'}
>
@@ -255,7 +256,7 @@ export const OptionalLoveUserForm = (props: {
<Select
value={profile['pref_age_max'] ?? ''}
onChange={(e) =>
setProfile('pref_age_max', Number(e.target.value))
setProfile('pref_age_max', e.target.value ? Number(e.target.value) : 100)
}
className={'w-18 border-ink-300 rounded-md'}
>

View File

@@ -107,12 +107,14 @@ function Seeking(props: { profile: Profile }) {
})
const ageRangeText =
min == 18 && max == 100
min == 18 && max == 100 || min == undefined && max == undefined
? 'of any age'
: min == max
? `exactly ${min} years old`
: max == 100
? `${min} or older`
: max == 100 || max == undefined
? `older than ${min}`
: min == 18 || min == undefined
? `younger than ${max}`
: `between ${min} - ${max} years old`
if (!prefGender || prefGender.length < 1) {

View File

@@ -23,8 +23,8 @@ export function ProfileInfo(props: {
fromProfilePage?: Profile
fromSignup?: boolean
}) {
console.log('Rendering ProfileProfile for ', props)
const {profile, user, refreshProfile, fromProfilePage, fromSignup} = props
console.log('Rendering Profile for', user.username, user.name, props)
const currentUser = useUser()
// const currentProfile = useProfile()