diff --git a/web/components/profile-grid.tsx b/web/components/profile-grid.tsx
index 725e6d4..dde371a 100644
--- a/web/components/profile-grid.tsx
+++ b/web/components/profile-grid.tsx
@@ -13,10 +13,7 @@ import {useUser} from "web/hooks/use-user";
import {useT} from "web/lib/locale";
import {useAllChoices} from "web/hooks/use-choices";
import {getSeekingGenderText} from "web/lib/profile/seeking";
-import {Tooltip} from 'web/components/widgets/tooltip'
-import {EyeOffIcon} from '@heroicons/react/outline'
-import {useState} from 'react'
-import {api} from 'web/lib/api'
+import HideProfileButton from 'web/components/widgets/hide-profile-button'
export const ProfileGrid = (props: {
profiles: Profile[]
@@ -95,7 +92,6 @@ function ProfilePreview(props: {
const choicesIdsToLabels = useAllChoices()
const t = useT()
// const currentUser = useUser()
- const [hiding, setHiding] = useState(false)
const bio = profile.bio as JSONContent;
@@ -170,26 +166,13 @@ function ProfilePreview(props: {
)}
{/* Hide profile button */}
{onHide && (
-
-
-
+
)}
diff --git a/web/components/profile/profile-header.tsx b/web/components/profile/profile-header.tsx
index 8115ca8..05a4ede 100644
--- a/web/components/profile/profile-header.tsx
+++ b/web/components/profile/profile-header.tsx
@@ -23,6 +23,7 @@ import {StarButton} from "web/components/widgets/star-button";
import {disableProfile} from "web/lib/util/disable";
import {useT} from 'web/lib/locale'
import {Tooltip} from "web/components/widgets/tooltip";
+import HideProfileButton from 'web/components/widgets/hide-profile-button'
export default function ProfileHeader(props: {
user: User
@@ -153,8 +154,9 @@ export default function ProfileHeader(props: {
) : (
- {/*TODO: Add score to profile page once we can efficiently compute it (i.e., not recomputing it for every profile)*/}
- {/**/}
+ {currentUser && !isCurrentUser && (
+
+ )}
void
+ className?: string
+ iconClassName?: string
+ tooltip?: string
+ ariaLabel?: string
+ stopPropagation?: boolean
+ suppressToast?: boolean
+}
+
+export function HideProfileButton(props: HideProfileButtonProps) {
+ const {
+ hiddenUserId,
+ onHidden,
+ className,
+ iconClassName,
+ tooltip,
+ ariaLabel,
+ stopPropagation,
+ suppressToast,
+ } = props
+
+ const t = useT()
+ const [submitting, setSubmitting] = useState(false)
+
+ const onClick = async (e: React.MouseEvent) => {
+ e.preventDefault()
+ if (stopPropagation) e.stopPropagation()
+ if (submitting) return
+ setSubmitting(true)
+ try {
+ await api('hide-profile', {hiddenUserId})
+ onHidden?.(hiddenUserId)
+ if (!suppressToast)
+ toast.success(
+ t(
+ 'profiles.hidden_success',
+ 'Profile hidden. You will no longer see this person in search results.'
+ )
+ )
+ } finally {
+ setSubmitting(false)
+ }
+ }
+
+ return (
+
+
+
+ )
+}
+
+export default HideProfileButton