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

Feature/working login page #3710

Open
wants to merge 2 commits into
base: develop-postgres
Choose a base branch
from

Conversation

PurnenduMIshra129th
Copy link
Contributor

@PurnenduMIshra129th PurnenduMIshra129th commented Feb 19, 2025

What kind of change does this PR introduce?

feature

Issue Number:

Fixes #3236

If relevant, did you update the documentation?
N/A
Summary
-Organization is now loading and revoke refresh token is successfully calling from frontend side

Does this PR introduce a breaking change?
N/A

Checklist

CodeRabbit AI Review

  • I have reviewed and addressed all critical issues flagged by CodeRabbit AI
  • I have implemented or provided justification for each non-critical suggestion
  • I have documented my reasoning in the PR comments where CodeRabbit AI suggestions were not implemented

Test Coverage

  • I have written tests for all new changes/features
  • I have verified that test coverage meets or exceeds 95%
  • I have run the test suite locally and all tests pass

Other information

N/A
Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • New Features / Improvements

    • Streamlined organization data now displays concise, clear details during login, making it easier to select and view organizations.
    • Enhanced logout and session management provide a smoother, more reliable sign‐out experience with improved error handling.
  • Bug Fixes

    • Addressed logout issues by enforcing proper token revocation, reducing potential sign-out errors.

Copy link
Contributor

coderabbitai bot commented Feb 19, 2025

Walkthrough

The pull request updates documentation and code across several modules. Documentation for GraphQL query variables and TypeScript interfaces now reflects new definition line numbers. The GraphQL mutation to revoke refresh tokens has been updated to require an input parameter. In addition, components handling user logout (ProfileDropdown, SignOut, and UserNavbar) now retrieve the user ID from local storage and pass it to the mutation, and organization data mapping has been adjusted. Minor changes in session management and interface structure are also included.

Changes

File(s) Change Summary
docs/docs/auto-docs/GraphQl/Queries/Queries/variables/*.md Documentation updated for multiple GraphQL variables—the definition line numbers in src/GraphQl/Queries/Queries.ts have been revised.
docs/docs/auto-docs/components/SignOut/SignOut/functions/default.md Updated line number for the default() function from 19 to 20.
docs/docs/auto-docs/utils/interfaces/interfaces/*.md Numerous TypeScript interface docs now reference updated line numbers and, in some cases, modified property names/types (e.g. in InterfaceQueryOrganizationListObject).
src/GraphQl/Mutations/mutations.ts Modified the REVOKE_REFRESH_TOKEN mutation to include an $input: RevokeRefreshTokenInput! parameter.
src/GraphQl/Queries/Queries.ts Replaced the old organizations query with a new getAllOrganization query that returns a simplified field set (id, name, city, state, countryCode).
src/components/ProfileDropdown/ProfileDropdown.tsx Introduced userId from local storage and passed it to the revokeRefreshToken mutation.
src/components/SignOut/SignOut.tsx Added a dependency on useLocalStorage, retrieved userId, and updated logout logic to check for and include this ID in the mutation call.
src/components/UserPortal/UserNavbar/UserNavbar.tsx Changed handleLogout to an asynchronous function that retrieves userId, enhances error handling, and passes the ID to the mutation.
src/screens/LoginPage/LoginPage.tsx Adjusted organization mapping to access new fields (id, city, state, countryCode) replacing the old structure using _id and nested address fields.
src/utils/interfaces.ts Modified InterfaceQueryOrganizationListObject: removed properties like _id, image, etc., and added id, city, state, and countryCode.
src/utils/useSession.tsx Integrated useLocalStorage to retrieve userId and updated session timeout logic to use the retrieved value during logout.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant LS as LocalStorage
    participant S as SignOut Component
    participant API as GraphQL API

    U->>S: Initiate logout
    S->>LS: Retrieve userId
    LS-->>S: Return userId
    S->>API: Call revokeRefreshToken(input: { id: userId })
    API-->>S: Return confirmation/error
    S->>U: Process logout outcome
Loading

Possibly related PRs

Suggested labels

ignore-sensitive-files-pr

Suggested reviewers

  • palisadoes

Poem

I’m a rabbit hopping through the code,
Nibbling on docs that now brightly glow.
Line numbers danced and queries changed,
In logout flows, user IDs arranged.
With every tweak, the bugs grow light—
A carrot of progress, so fresh and bright!
🐰🥕

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Our Pull Request Approval Process

Thanks for contributing!

Testing Your Code

Remember, your PRs won't be reviewed until these criteria are met:

  1. We don't merge PRs with poor code quality.
    1. Follow coding best practices such that CodeRabbit.ai approves your PR.
  2. We don't merge PRs with failed tests.
    1. When tests fail, click on the Details link to learn more.
    2. Write sufficient tests for your changes (CodeCov Patch Test). Your testing level must be better than the target threshold of the repository
    3. Tests may fail if you edit sensitive files. Ask to add the ignore-sensitive-files-pr label if the edits are necessary.
  3. We cannot merge PRs with conflicting files. These must be fixed.

Our policies make our code better.

Reviewers

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/components/ProfileDropdown/ProfileDropdown.tsx (1)

36-49: 🛠️ Refactor suggestion

Add error handling for missing user ID.

The logout function should validate that userId exists before attempting to revoke the token, similar to other components.

 const logout = async (): Promise<void> => {
   try {
+    if (!userId) {
+      console.error('User ID is missing.');
+      return;
+    }
     await revokeRefreshToken({
       variables: {
         input: { id: userId },
🧹 Nitpick comments (4)
src/components/SignOut/SignOut.tsx (1)

52-58: Consider consolidating error handling in retry logic.

The retry logic duplicates the token revocation code but doesn't reuse the userId validation. This could lead to attempting token revocation with an invalid userId during retry.

 if (retryRevocation) {
   try {
+    if (!userId) {
+      console.error('User ID is missing.');
+      return;
+    }
     await revokeRefreshToken({
       variables: {
         input: { id: userId },
src/screens/LoginPage/LoginPage.tsx (3)

138-140: Remove debug console.log statement.

Remove the commented-out console.log statement as it's not needed in production code.

Apply this diff to remove the debug statement:

-      // console.log(orgData.getAllOrganization,'aaaaa');
🧰 Tools
🪛 Biome (1.9.4)

[error] 138-138: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


138-138: Use optional chaining for safer property access.

Use optional chaining to safely access the getAllOrganization property.

Apply this diff to use optional chaining:

-    if (orgData && orgData.getAllOrganization) {
+    if (orgData?.getAllOrganization) {
🧰 Tools
🪛 Biome (1.9.4)

[error] 138-138: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


147-149: Improve string interpolation readability.

The string interpolation can be made more readable by adding spaces between the organization details.

Apply this diff to improve readability:

-          tempObj['label'] =
-            `${org.name}(${org.city},${org.state},${org.countryCode})`;
-          tempObj['id'] = org.id;
+          tempObj['label'] = `${org.name} (${org.city}, ${org.state}, ${org.countryCode})`;
+          tempObj['id'] = org.id;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e2cdda and cb3eb0f.

📒 Files selected for processing (80)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ADMIN_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/BLOCK_PAGE_MEMBER_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_ATTENDEES.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_CHECKINS.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_DETAILS.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_FEEDBACKS.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_REGISTRANTS.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_COMMUNITY_DATA.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_COMMUNITY_DATA_PG.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_COMMUNITY_SESSION_TIMEOUT_DATA_PG.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_DATA_PG.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_EVENTS_PG.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_MEMBERS_PG.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_POSTS_COUNT_PG.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_POSTS_PG.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/MEMBERSHIP_REQUEST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/MEMBERS_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATIONS_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATIONS_MEMBER_CONNECTION_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATION_CONNECTION_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATION_DONATION_CONNECTION_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATION_EVENT_CONNECTION_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATION_EVENT_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/RECURRING_EVENTS.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/SIGNIN_QUERY.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USERS_CONNECTION_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_DETAILS.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_JOINED_ORGANIZATIONS_PG.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_LIST_FOR_TABLE.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_LIST_REQUEST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_ORGANIZATION_LIST.md (1 hunks)
  • docs/docs/auto-docs/components/SignOut/SignOut/functions/default.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceAddOnSpotAttendeeProps.md (3 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceAddress.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceAgendaItemCategoryInfo.md (2 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceAgendaItemCategoryList.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceAgendaItemInfo.md (5 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceAgendaItemList.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceCampaignInfo.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceCreateFund.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceCreatePledge.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceCreateVolunteerGroup.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceCustomFieldData.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceEventVolunteerInfo.md (3 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceFormData.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceFundInfo.md (2 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceMapType.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfacePledgeInfo.md (2 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfacePostCard.md (5 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfacePostForm.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryBlockPageMemberListItem.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryFundCampaignsPledges.md (2 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryMembershipRequestsListItem.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryOrganizationAdvertisementListItem.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryOrganizationEventListItem.md (2 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryOrganizationFundCampaigns.md (2 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryOrganizationListObject.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryOrganizationPostListItem.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryOrganizationUserTags.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryUserListItem.md (2 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryUserTagChildTags.md (2 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryUserTagsAssignedMembers.md (2 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryUserTagsMembersToAssignTo.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryVenueListItem.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceTagData.md (4 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceUserCampaign.md (1 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceUserEvents.md (3 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceVolunteerGroupInfo.md (4 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceVolunteerMembership.md (3 hunks)
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceVolunteerRank.md (1 hunks)
  • docs/docs/auto-docs/utils/useSession/functions/default.md (1 hunks)
  • src/GraphQl/Mutations/mutations.ts (1 hunks)
  • src/GraphQl/Queries/Queries.ts (1 hunks)
  • src/components/ProfileDropdown/ProfileDropdown.tsx (1 hunks)
  • src/components/SignOut/SignOut.tsx (3 hunks)
  • src/components/UserPortal/UserNavbar/UserNavbar.tsx (1 hunks)
  • src/screens/LoginPage/LoginPage.tsx (1 hunks)
  • src/utils/interfaces.ts (1 hunks)
  • src/utils/useSession.tsx (3 hunks)
✅ Files skipped from review due to trivial changes (71)
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_REGISTRANTS.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_POSTS_COUNT_PG.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_EVENTS_PG.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/BLOCK_PAGE_MEMBER_LIST.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_ATTENDEES.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_MEMBERS_PG.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_ORGANIZATION_LIST.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_DETAILS.md
  • docs/docs/auto-docs/components/SignOut/SignOut/functions/default.md
  • docs/docs/auto-docs/utils/useSession/functions/default.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATION_EVENT_LIST.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_COMMUNITY_SESSION_TIMEOUT_DATA_PG.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_JOINED_ORGANIZATIONS_PG.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_POSTS_PG.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/SIGNIN_QUERY.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_COMMUNITY_DATA.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATION_EVENT_CONNECTION_LIST.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_LIST_FOR_TABLE.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/RECURRING_EVENTS.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_LIST.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/MEMBERS_LIST.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USERS_CONNECTION_LIST.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ADMIN_LIST.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_DETAILS.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceAgendaItemInfo.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATION_DONATION_CONNECTION_LIST.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceMapType.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_CHECKINS.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_FEEDBACKS.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryOrganizationAdvertisementListItem.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryUserTagsAssignedMembers.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATIONS_MEMBER_CONNECTION_LIST.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_COMMUNITY_DATA_PG.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceAgendaItemCategoryInfo.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceAgendaItemList.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATION_CONNECTION_LIST.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryOrganizationPostListItem.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceAgendaItemCategoryList.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATIONS_LIST.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryOrganizationUserTags.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfacePledgeInfo.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryUserListItem.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceAddOnSpotAttendeeProps.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceFormData.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceVolunteerMembership.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceEventVolunteerInfo.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfacePostForm.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryUserTagChildTags.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryOrganizationEventListItem.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryVenueListItem.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceVolunteerRank.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceUserEvents.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_LIST_REQUEST.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceUserCampaign.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceCampaignInfo.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceFundInfo.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/MEMBERSHIP_REQUEST.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryBlockPageMemberListItem.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceCreateVolunteerGroup.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceCreateFund.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceCreatePledge.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryFundCampaignsPledges.md
  • docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_DATA_PG.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceTagData.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceVolunteerGroupInfo.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryOrganizationFundCampaigns.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceAddress.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryMembershipRequestsListItem.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceCustomFieldData.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfacePostCard.md
  • docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryUserTagsMembersToAssignTo.md
🧰 Additional context used
🪛 Biome (1.9.4)
src/screens/LoginPage/LoginPage.tsx

[error] 138-138: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (11)
src/components/SignOut/SignOut.tsx (1)

32-43: LGTM! Enhanced error handling for token revocation.

The changes properly validate the user ID before attempting to revoke the refresh token, improving error handling and security.

src/components/UserPortal/UserNavbar/UserNavbar.tsx (1)

55-72: LGTM! Well-structured async logout handling.

The changes properly implement:

  • Async/await pattern
  • User ID validation
  • Error handling
src/utils/useSession.tsx (1)

53-57: LGTM! Improved session timeout handling.

The changes properly handle the session timeout duration by using the server-provided value or falling back to the default.

src/GraphQl/Mutations/mutations.ts (1)

207-208:

✅ Verification successful

Verify that all callers have been updated to use the new input parameter.

The mutation signature has been updated to require a RevokeRefreshTokenInput! parameter. This is a breaking change that requires updates to all callers of this mutation.

Run the following script to verify that all callers have been updated:


🏁 Script executed:

#!/bin/bash
# Description: Search for all usages of the REVOKE_REFRESH_TOKEN mutation to ensure they pass the required input parameter.

# Test: Search for mutation calls. Expect: All calls should include input parameter.
rg -A 5 "revokeRefreshToken\(" 

Length of output: 1892


All callers are now passing the required input parameter.

The search confirms that every usage of the revokeRefreshToken mutation in the following files—src/components/ProfileDropdown/ProfileDropdown.tsx, src/components/SignOut/SignOut.tsx, src/components/UserPortal/UserNavbar/UserNavbar.tsx, and src/utils/useSession.tsx—correctly includes the input parameter:

  • variables: { input: { id: userId } }

The necessary changes have been applied consistently across the codebase.

src/GraphQl/Queries/Queries.ts (1)

42-47:

✅ Verification successful

Verify that all consumers have been updated to use the new data structure.

The query has been updated to use getAllOrganization and return a simplified data structure with only id, name, city, state, and countryCode. This is a breaking change that requires updates to all consumers of this query.

Run the following script to verify that all consumers have been updated:


🏁 Script executed:

#!/bin/bash
# Description: Search for all usages of the ORGANIZATION_LIST query to ensure they handle the new data structure.

# Test: Search for query usages. Expect: All consumers should handle the new fields.
rg -A 5 "ORGANIZATION_LIST"

Length of output: 4030


Consumers properly updated for the new data structure

The grep search confirms that all references to the ORGANIZATION_LIST query (and related USER_ORGANIZATION_LIST) across components, tests, and mocks are now using the updated getAllOrganization structure with the simplified fields (id, name, city, state, and countryCode). No outdated field references appear in the results.

  • src/GraphQl/Queries/Queries.ts: Query definitions now use the new structure.
  • src/screens/LoginPage/LoginPage.tsx & associated test files: Consumers correctly reference the updated query.
  • Mocks in OrgList and User test files: Updated to use the new query payload.

All consumers have been updated accordingly.

src/utils/interfaces.ts (1)

851-855: LGTM! Interface changes align with the query structure.

The interface has been correctly updated to match the simplified data structure returned by the getAllOrganization query.

docs/docs/auto-docs/utils/interfaces/interfaces/InterfaceQueryOrganizationListObject.md (5)

11-16: Documentation for "city" Property
The "city" property is clearly documented and linked to its definition in the source file. Although this property wasn’t flagged in the PR objectives, its inclusion is clear and the type is correctly shown as string.


19-23: Update for "countryCode" Property
The "countryCode" property now replaces the old "createdAt" field. The documentation correctly reflects the updated type as string and points to the revised source definition. Ensure that all related parts of the application now refer to countryCode instead of createdAt.


27-31: Update for "id" Property
The interface documentation now presents the "id" property, which effectively consolidates the previous _id and creator fields. The reference to its location in the source file is accurate. This update improves consistency across the data model.


35-39: Update for "name" Property
The "name" property now replaces the previously used "image" field. The documentation clearly specifies its type (string) and includes a correct source link. Verify that any components relying on the old property have been updated accordingly.


43-47: Update for "state" Property
The "state" property in the documentation replaces the earlier "members" field and now documents a simplified type of string instead of an object array. This change may have wider implications on how organization states are managed. Please verify that this design change is intentional and that any related data transformations or validations elsewhere in the application are updated accordingly.

Comment on lines +76 to +86
const { getItem } = useLocalStorage();
const userId = getItem('id');
if (!userId) {
console.error('User ID is missing.');
return;
}
await revokeRefreshToken({
variables: {
input: { id: userId },
},
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix React hooks rule violation.

The useLocalStorage hook is called inside the handleLogout function, which violates the Rules of Hooks. Hooks must be called at the top level of the component.

 const useSession = (): UseSessionReturnType => {
   const { t: tCommon } = useTranslation('common');
+  const { getItem } = useLocalStorage();
 
   let startTime: number;
   let timeoutDuration: number;
   
   const handleLogout = async (): Promise<void> => {
     try {
-      const { getItem } = useLocalStorage();
       const userId = getItem('id');
       if (!userId) {
         console.error('User ID is missing.');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { getItem } = useLocalStorage();
const userId = getItem('id');
if (!userId) {
console.error('User ID is missing.');
return;
}
await revokeRefreshToken({
variables: {
input: { id: userId },
},
});
const useSession = (): UseSessionReturnType => {
const { t: tCommon } = useTranslation('common');
const { getItem } = useLocalStorage();
let startTime: number;
let timeoutDuration: number;
const handleLogout = async (): Promise<void> => {
try {
const userId = getItem('id');
if (!userId) {
console.error('User ID is missing.');
return;
}
await revokeRefreshToken({
variables: {
input: { id: userId },
},
});
} catch (error) {
// Handle error appropriately
}
};
// ... other code in the hook
};

@palisadoes
Copy link
Contributor

  1. Please make coderabbit.ai approves your work.
  2. Make sure all tests pass and are valid.
  3. Ensure the test code coverage for your patch reaches as close to 100% as possible.

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