@@ -23,6 +23,7 @@ import {VisibilityConfirmationModal} from './visibility-confirmation-modal'
2323import { deleteAccount } from "web/lib/util/delete" ;
2424import toast from "react-hot-toast" ;
2525import { StarButton } from "web/components/widgets/star-button" ;
26+ import { disableProfile } from "web/lib/util/disable" ;
2627
2728export default function ProfileHeader ( props : {
2829 user : User
@@ -47,12 +48,14 @@ export default function ProfileHeader(props: {
4748 const currentUser = useUser ( )
4849 const isCurrentUser = currentUser ?. id === user . id
4950 const [ showVisibilityModal , setShowVisibilityModal ] = useState ( false )
51+ const disabled = profile . disabled
5052
5153 console . debug ( 'ProfileProfileHeader' , { user, profile, userActivity, currentUser} )
5254
5355 return (
5456 < Col className = "w-full" >
5557 < Row className = { clsx ( 'flex-wrap justify-between gap-2 py-1' ) } >
58+ { currentUser && isCurrentUser && disabled && < div className = "text-red-500" > You disabled your profile, so no one else can access it.</ div > }
5659 < Row className = "items-center gap-1" >
5760 < Col className = "gap-1" >
5861 < Row className = "items-center gap-1 text-xl" >
@@ -135,6 +138,33 @@ export default function ProfileHeader(props: {
135138 }
136139 } ,
137140 } ,
141+ {
142+ name : disabled ? 'Enable profile' : 'Disable profile' ,
143+ icon : null ,
144+ onClick : async ( ) => {
145+ const confirmed = true // confirm(
146+ // 'Are you sure you want to disable your profile? This will hide your profile from searches and listings..'
147+ // )
148+ if ( confirmed ) {
149+ toast
150+ . promise ( disableProfile ( ! disabled ) , {
151+ loading : disabled ? 'Enabling profile...' : 'Disabling profile...' ,
152+ success : ( ) => {
153+ return `Profile ${ disabled ? 'enabled' : 'disabled' } `
154+ } ,
155+ error : ( ) => {
156+ return `Failed to ${ disabled ? 'enable' : 'disable' } profile`
157+ } ,
158+ } )
159+ . then ( ( ) => {
160+ refreshProfile ( )
161+ } )
162+ . catch ( ( ) => {
163+ // return false
164+ } )
165+ }
166+ } ,
167+ } ,
138168 ] }
139169 />
140170 </ Row >
0 commit comments