Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide the Follow button for logged-out users #1669

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Rashid-123
Copy link

Summary

The "Follow" button is now correctly hidden for logged-out users.

Steps to test/reproduce

1 . Test with Logged-out User:
- Open the bill detail page (e.g., https://maple-dev.vercel.app/bills/193/H3259).
-Ensure you are logged out.
-Verify that the "Follow" button is not visible on the page.

2 . Test with Logged-in User:
-Log in as an authenticated user.
-Navigate to the same bill detail page.
-Verify that the "Follow" button is visible and can be interacted with.

Copy link

vercel bot commented Jan 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
maple-dev ❌ Failed (Inspect) Jan 8, 2025 7:28pm

Copy link
Collaborator

@Mephistic Mephistic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Rashid - thanks for your interest in contributing to MAPLE! I left some notes on how you can fix the build so we can get this merged.

@@ -34,7 +34,8 @@ const StyledImage = styled(Image)`
export const BillDetails = ({ bill }: BillProps) => {
const { t } = useTranslation("common")

const isPendingUpgrade = useAuth().claims?.role === "pendingUpgrade"
const { user } = useAuth() // Get the logged-in user (adjust according to your auth logic)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work because user isn't the root of the state returned by useAuth() (see https://github.com/codeforboston/maple/blob/main/components/auth/redux.ts#L17 for the structure of the auth state). The auth state has both user and claims as top-level keys, so trying to get claims from user instead in the isPendingUpdate check breaks the build.

This could be adjusted to work correctly by destructuring both user and claims from useAuth() (e.g. const { user, claims } = useAuth()

@@ -34,7 +34,8 @@ const StyledImage = styled(Image)`
export const BillDetails = ({ bill }: BillProps) => {
const { t } = useTranslation("common")

const isPendingUpgrade = useAuth().claims?.role === "pendingUpgrade"
const { user } = useAuth() // Get the logged-in user (adjust according to your auth logic)
const isPendingUpgrade = user?.claims?.role === "pendingUpgrade" // Ensure the role check is based on the authenticated user
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I feel like the comments here are unnecessary - your code seems pretty self-explanatory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants