Skip to content

Commit

Permalink
Follow btn individual users (#1654)
Browse files Browse the repository at this point in the history
* feat: follow buttons for individual users

* fix: remove second follow user button

* fix: user cannot follow their own testimony hit

* fix: rn prettier
  • Loading branch information
aaerhart authored Dec 18, 2024
1 parent e29d5cb commit fafe412
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
35 changes: 21 additions & 14 deletions components/ProfilePage/ProfileButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,17 @@ export const EditProfileButton = ({ className }: { className?: string }) => {

export function ProfileButtonsUser({
isProfilePublic,
onProfilePublicityChanged
onProfilePublicityChanged,
isUser,
profileId
}: {
isProfilePublic: boolean | undefined
onProfilePublicityChanged: (isPublic: boolean) => void
isUser: boolean
profileId: string
}) {
const { t } = useTranslation("editProfile")
const { user } = useAuth()

const actions = useProfile()

Expand All @@ -76,16 +81,20 @@ export function ProfileButtonsUser({
onProfilePublicityChanged(!isProfilePublic)
}
return (
<div className={`d-grid gap-2 col-12 m-3`}>
<EditProfileButton className={`py-1`} />
<ToggleButton
toggleState={isProfilePublic || false}
stateTrueLabel={t("forms.makePrivate")}
stateFalseLabel={t("forms.makePublic")}
onClick={handleSave}
className={`py-1`}
/>
</div>
<>
{isUser ? (
<div className={`d-grid gap-2 col-12 m-3`}>
<EditProfileButton className={`py-1`} />
<ToggleButton
toggleState={isProfilePublic || false}
stateTrueLabel={t("forms.makePrivate")}
stateFalseLabel={t("forms.makePublic")}
onClick={handleSave}
className={`py-1`}
/>
</div>
) : null}
</>
)
}

Expand All @@ -100,9 +109,7 @@ export function ProfileButtonsOrg({
const { user } = useAuth()
return (
<>
{isUser ? (
<EditProfileButton />
) : followOrg && user ? (
{followOrg && user && !isUser ? (
<FollowOrgButton profileId={profileId} />
) : null}
</>
Expand Down
6 changes: 4 additions & 2 deletions components/ProfilePage/ProfileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ export const ProfileHeader = ({
<div className="col-12 col-md-2 d-flex justify-content-center justify-content-md-end align-items-center ms-md-auto ">
{isOrg ? (
<OrgContactInfo profile={profile} />
) : isUser ? (
) : (
<ProfileButtonsUser
isProfilePublic={isProfilePublic}
onProfilePublicityChanged={onProfilePublicityChanged}
isUser={isUser}
profileId={profileId}
/>
) : null}
)}
</div>
</Header>
)
Expand Down
3 changes: 2 additions & 1 deletion components/search/testimony/TestimonyHit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const TestimonyResult = ({ hit }: { hit: Hit<Testimony> }) => {
)
const { user } = useAuth()
const { followOrg } = useFlags()
const isCurrentUser = user?.uid === hit.authorUid

return (
<div
Expand Down Expand Up @@ -70,7 +71,7 @@ const TestimonyResult = ({ hit }: { hit: Hit<Testimony> }) => {
<span style={{ flexGrow: 1 }}>
<b>Written by {writtenBy}</b>
</span>
{followOrg && isOrg && user && (
{!isCurrentUser && followOrg && user && (
<FollowOrgButton profileId={hit.authorUid} />
)}
</div>
Expand Down

0 comments on commit fafe412

Please sign in to comment.