-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this 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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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.