Skip to content

Commit a360f80

Browse files
committed
Add warning message about short bio
1 parent 0cc7549 commit a360f80

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

web/components/bio/profile-bio.tsx

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,52 @@
1-
import { Profile } from 'common/love/profile'
2-
import { useState } from 'react'
3-
import { Col } from 'web/components/layout/col'
4-
import { Subtitle } from '../widgets/profile-subtitle'
5-
import { BioBlock } from './profile-bio-block'
1+
import {Profile} from 'common/love/profile'
2+
import {useEffect, useState} from 'react'
3+
import {Col} from 'web/components/layout/col'
4+
import {Subtitle} from '../widgets/profile-subtitle'
5+
import {BioBlock} from './profile-bio-block'
6+
import {MAX_INT, MIN_BIO_LENGTH} from "common/constants";
7+
import {useTextEditor} from "web/components/widgets/editor";
8+
import {JSONContent} from "@tiptap/core"
69

710
export function ProfileBio(props: {
811
isCurrentUser: boolean
912
profile: Profile
1013
refreshProfile: () => void
1114
fromProfilePage?: Profile
1215
}) {
13-
const { isCurrentUser, profile, refreshProfile, fromProfilePage } = props
16+
const {isCurrentUser, profile, refreshProfile, fromProfilePage} = props
1417
const [edit, setEdit] = useState(false)
1518

1619
if (!isCurrentUser && !profile.bio) return null
1720
if (fromProfilePage && !profile.bio) return null
1821

22+
const editor = useTextEditor({defaultValue: ''})
23+
const [textLength, setTextLength] = useState(editor?.getText().length ?? MAX_INT)
24+
25+
useEffect(() => {
26+
if (!editor) return
27+
editor.commands.setContent(profile.bio as JSONContent)
28+
setTextLength(editor.getText().length)
29+
}, [profile.bio, editor])
30+
1931
return (
2032
<Col>
33+
{textLength < MIN_BIO_LENGTH && !edit && (
34+
<div className="group relative inline-block">
35+
<p className="text-red-600 cursor-help flex items-center gap-1">
36+
Bio too short. Profile may be filtered from search results.
37+
<span className="text-xs border border-red-600 rounded px-1 animate-pulse">
38+
Hover for details
39+
</span>
40+
</p>
41+
<div
42+
className="invisible group-hover:visible absolute left-0 top-full mt-2 p-3 bg-canvas-50 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 w-72 z-10">
43+
<p className="text-sm">
44+
Since your bio is too short, Compass' algorithm filters out your profile from search results (unless
45+
"Include short bios" is selected). This ensures searches show meaningful profiles.
46+
</p>
47+
</div>
48+
</div>
49+
)}
2150
<Subtitle className="mb-4">About Me</Subtitle>
2251
<BioBlock
2352
isCurrentUser={isCurrentUser}

0 commit comments

Comments
 (0)