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

Added Event Registrants Tab under Event Management Dashboard #2804

Conversation

syedali237
Copy link
Contributor

@syedali237 syedali237 commented Dec 24, 2024

What kind of change does this PR introduce?

Feature

Issue Number:

Fixes #1750

Did you add tests for your changes?

Yes

Snapshots/Videos:

1734901891254134.mp4

If relevant, did you update the documentation?

No

Summary

Added the event registrants tab where admin can check in and add registrants of an event.

Does this PR introduce a breaking change?

No

Other information

Added a new package : @pdfme/common and changed its template schema according to the package. (This might give a formatting/linting error).

Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • New Features

    • Introduced a new component for managing and displaying event registrant information.
    • Added a GraphQL query to retrieve event attendees based on event ID.
    • Enhanced localization support for event registrants in multiple languages (English, French, Hindi, Spanish, Chinese).
  • Bug Fixes

    • Updated button labels for clarity in user interactions.
  • Documentation

    • Added mock data for testing event registration functionalities.
  • Chores

    • Updated ESLint configuration to ignore additional file types.

Copy link
Contributor

coderabbitai bot commented Dec 24, 2024

Walkthrough

This pull request introduces comprehensive changes to the event registrant management functionality in the Talawa Admin portal. The modifications include adding a new EventRegistrants component, updating localization files for multiple languages, introducing GraphQL queries for fetching registrant data, and refactoring existing components to support the new event registrant view. The changes aim to enhance the user interface and provide a more integrated approach to managing event registrations across different languages.

Changes

File Change Summary
package.json Added @pdfme/common dependency
public/locales/*/translation.json Added new eventRegistrant section with translations in English, French, Hindi, Spanish, and Chinese
src/GraphQl/Queries/Queries.ts Added new EVENT_REGISTRANTS GraphQL query
src/components/EventManagement/EventRegistrant/EventRegistrants.tsx New component for managing and displaying event registrants
src/screens/EventManagement/EventManagement.tsx Updated to render new EventRegistrants component
.eslintrc.json Added .svg to ignored file extensions

Assessment against linked issues

Objective Addressed Explanation
Redesign Event Management Registrant Tab
Club show registrant and check-ins registrant
Add registrant button functionality Toast message implementation not visible in this PR

Possibly related PRs

Suggested labels

ignore-sensitive-files-pr

Suggested reviewers

  • palisadoes

Poem

🐰 Registrants dance, a digital delight,
Tables and queries now shine so bright,
Multilingual magic, translations galore,
Event management opens a brand new door!
Hop to the rhythm of code so clean! 🎉


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bfc65ec and 63bffa7.

📒 Files selected for processing (3)
  • src/components/CheckIn/CheckInWrapper.module.css (0 hunks)
  • src/components/CheckIn/CheckInWrapper.tsx (2 hunks)
  • src/components/EventRegistrantsModal/EventRegistrantsWrapper.module.css (0 hunks)
💤 Files with no reviewable changes (2)
  • src/components/CheckIn/CheckInWrapper.module.css
  • src/components/EventRegistrantsModal/EventRegistrantsWrapper.module.css
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/CheckIn/CheckInWrapper.tsx

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

🧹 Nitpick comments (6)
src/components/CheckIn/CheckInWrapper.tsx (1)

31-37: Refine the alt text for accessibility.
Using "Sort" as the alt text in this context might be misleading since the button label is "Check In Registrants." Providing a more descriptive alt text improves accessibility.

 <img
   src="/images/svg/options-outline.svg"
-  width={30.63}
-  height={30.63}
-  alt="Sort"
-  className={styles.sortImg}
 />
+  width={30.63}
+  height={30.63}
+  alt="Check in icon"
+  className={styles.sortImg}
+/>
src/components/EventRegistrantsModal/EventRegistrantsWrapper.tsx (2)

27-33: Invoke onUpdate after state changes.
Calling onUpdate() after closing the modal ensures external components can refresh or handle post-close logic. This approach is correct.

Consider adding error handling or a safety check around onUpdate in case the callback logic fails or is asynchronous.


39-40: Testing attribute for consistent naming.
Using data-testid="filter-button" is fine, but the naming might be more descriptive, for instance data-testid="add-registrants-button". This makes tests more explicit.

<Button
-  data-testid="filter-button"
+  data-testid="add-registrants-button"
  className={`border-1 mx-4 ${style.createButton}`}
  ...
>
src/components/EventManagement/EventRegistrant/EventRegistrants.test.tsx (1)

52-65: Leverage built-in async utilities or set up wait helpers for better reliability.

Your approach ensures that table headers appear after the queries resolve. This is correct, but consider using React Testing Library’s recommended patterns (waitFor) extensively to reduce potential timing-related flakiness.

src/components/EventManagement/EventRegistrant/EventRegistrants.tsx (2)

63-71: Verify concurrency of queries.

Using useLazyQuery for both getEventRegistrants and getEventAttendees is fine, but carefully ensure that both queries resolve in tandem. Consider error handling logic for each query to maintain a robust user experience.


210-216: Provide feedback or user confirmation after adding a registrant.

You refresh the data upon onUpdate, which is good. Consider offering user-friendly feedback, such as a toast notification, acknowledging the successful addition of a new registrant. This will enhance the user experience.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 45d18b6 and d383822.

⛔ Files ignored due to path filters (3)
  • package-lock.json is excluded by !**/package-lock.json
  • public/images/svg/options-outline.svg is excluded by !**/*.svg
  • public/images/svg/organization.svg is excluded by !**/*.svg
📒 Files selected for processing (12)
  • package.json (1 hunks)
  • public/locales/en/translation.json (1 hunks)
  • src/GraphQl/Queries/Queries.ts (1 hunks)
  • src/components/CheckIn/CheckInWrapper.tsx (2 hunks)
  • src/components/CheckIn/tagTemplate.ts (2 hunks)
  • src/components/EventManagement/EventRegistrant/EventRegistrants.module.css (1 hunks)
  • src/components/EventManagement/EventRegistrant/EventRegistrants.test.tsx (1 hunks)
  • src/components/EventManagement/EventRegistrant/EventRegistrants.tsx (1 hunks)
  • src/components/EventManagement/EventRegistrant/Registrations.mocks.ts (1 hunks)
  • src/components/EventRegistrantsModal/EventRegistrantsWrapper.test.tsx (1 hunks)
  • src/components/EventRegistrantsModal/EventRegistrantsWrapper.tsx (2 hunks)
  • src/screens/EventManagement/EventManagement.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/components/EventManagement/EventRegistrant/EventRegistrants.module.css
🔇 Additional comments (17)
src/components/CheckIn/CheckInWrapper.tsx (2)

5-5: Style import looks good.
The newly imported style object from app.module.css aligns well with the existing approach of modular CSS usage.


24-25: Testing attribute and combined styling.
Adding data-testid="stats-modal" is helpful for test reliability. The combined classes from local styles and app.module.css is consistent with the rest of the codebase.

src/components/EventRegistrantsModal/EventRegistrantsWrapper.tsx (5)

4-4: Consistent styling import.
Importing style from the global module is a good step for unified styling across components.


10-10: Optional callback prop is a good pattern.
Introducing onUpdate as an optional callback offers flexibility to handle updates after the modal is closed.


23-23: Destructure onUpdate properly.
Destructuring the new onUpdate prop is clear and consistent with the existing pattern.


46-46: Button label change is appropriate.
Renaming "Show Registrants" to "Add Registrants" clarifies the immediate action.


53-53: Explicitly referencing handleClose.
Passing handleClose directly is concise and ensures a clear flow of control when the modal closes.

src/components/EventManagement/EventRegistrant/Registrations.mocks.ts (1)

1-67: Well-structured mock data.
The mock objects for successful and error responses are well-defined, covering normal and failing scenarios for EVENT_REGISTRANTS and EVENT_ATTENDEES. This is a good practice to ensure robust testing coverage.

src/components/EventRegistrantsModal/EventRegistrantsWrapper.test.tsx (1)

80-80: Updated test reference is correct.
Changing the button label to "Add Registrants" aligns with the updated UI text and ensures the test remains accurate.

src/components/EventManagement/EventRegistrant/EventRegistrants.test.tsx (2)

1-13: Use consistent imports and remove unused ones if any.

All looks good regarding imports, especially React, Apollo, and react-testing-library. Just be cautious of any libraries or types that might not be used in the final implementation.


39-45: Avoid overshadowing or mocking react-router-dom incorrectly.

The jest.mock('react-router-dom') pattern is acceptable, but ensure it doesn't conflict with other tests or lead to unpredictable behavior if your test suite grows. Consider a specialized mock file for useParams if needed.

src/screens/EventManagement/EventManagement.tsx (1)

235-237: Great integration of the new EventRegistrants tab.

You are appropriately rendering <EventRegistrants /> under the registrants tab. Ensure that navigation to this tab is tested in a higher-level integration test so that the overall user flow is validated.

src/components/EventManagement/EventRegistrant/EventRegistrants.tsx (2)

45-60: Safeguard your type checks and handle potential undefined data.

The onCompleted callback sets registrants only if data?.getEventAttendeesByEventId is defined. Ensure that null or empty edge cases (e.g., no event attendees) are gracefully handled.


81-104: Check how you handle missing or partial attendee data.

Merging logic that depends on createdAt could break if a partial match or incomplete data is encountered. Consider a fallback for matchedAttendee to ensure no unhandled exceptions.

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

331-339: EVENT_REGISTRANTS query is well-defined.

The query is structured properly to retrieve minimal fields (userId, isRegistered, _id). Confirm if any additional fields are needed, such as user creation date, to avoid multiple queries.

public/locales/en/translation.json (1)

775-785: LGTM! Translation keys are well-structured

The added eventRegistrant translations are clear, concise and follow the established naming conventions. All necessary UI text elements for the event registrants feature are covered.

src/components/CheckIn/tagTemplate.ts (1)

Line range hint 5-19: LGTM! Schema structure simplified while maintaining functionality

The schema restructuring reduces unnecessary nesting while preserving the same name field configuration. The PDF template settings look correct.

package.json Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 24, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 24, 2024
Copy link

codecov bot commented Dec 24, 2024

Codecov Report

Attention: Patch coverage is 82.92683% with 7 lines in your changes missing coverage. Please review.

Project coverage is 87.92%. Comparing base (979d584) to head (6186002).
Report is 3 commits behind head on develop-postgres.

Files with missing lines Patch % Lines
...entManagement/EventRegistrant/EventRegistrants.tsx 85.29% 0 Missing and 5 partials ⚠️
.../EventRegistrantsModal/EventRegistrantsWrapper.tsx 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           develop-postgres    #2804       +/-   ##
=====================================================
+ Coverage             59.89%   87.92%   +28.02%     
=====================================================
  Files                   296      315       +19     
  Lines                  7373     8264      +891     
  Branches               1610     1866      +256     
=====================================================
+ Hits                   4416     7266     +2850     
+ Misses                 2711      788     -1923     
+ Partials                246      210       -36     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@syedali237
Copy link
Contributor Author

Should I raise an issue regarding the test coverage of this component as it would also require to be migrated into vitest.

@palisadoes
Copy link
Contributor

Please fix the test coverage in this PR

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: 0

🧹 Nitpick comments (4)
src/components/EventManagement/EventRegistrant/EventRegistrants.spec.tsx (3)

1-16: Use consistent import statements and group them logically.
The imports are comprehensive but mixing test utilities and library imports in a single block can reduce readability. Consider grouping them logically (e.g., React & library imports, custom utilities, mocks).


27-39: Isolate MockedProvider usage for repeated tests.
The renderEventRegistrants function is well-structured; however, if multiple tests use the same setup, consider extracting shared code to a test utility function to reduce repetition and potential maintenance overhead.


41-57: Mocking react-router-dom for each test could be optimized.
Re-mocking react-router-dom inside each describe or test may lead to overhead if used frequently across test files. If useParams is consistently returning the same values, consider a centralized mock approach for better maintainability.

public/locales/sp/translation.json (1)

1087-1098: LGTM! The Spanish translations for event registrants look good.

The translations are grammatically correct and use appropriate Spanish terminology for the event registration context. The section is well-structured and provides all necessary translations for the feature.

Consider adding a period at the end of "No se encontraron registrados" to match the punctuation style used in other similar messages in the file, like "No se encontraron voluntarios!" on line 1087:

-    "noRegistrantsFound": "No se encontraron registrados"
+    "noRegistrantsFound": "No se encontraron registrados."
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d24162b and bfc65ec.

📒 Files selected for processing (5)
  • public/locales/fr/translation.json (1 hunks)
  • public/locales/hi/translation.json (1 hunks)
  • public/locales/sp/translation.json (1 hunks)
  • public/locales/zh/translation.json (1 hunks)
  • src/components/EventManagement/EventRegistrant/EventRegistrants.spec.tsx (1 hunks)
🔇 Additional comments (7)
src/components/EventManagement/EventRegistrant/EventRegistrants.spec.tsx (4)

17-25: Validate unused helper function usage or rename it.
The wait function is an extra layer around waitFor but does not appear to be used beyond line 21. Decide if this helper is necessary to maintain readability or remove it to keep the test suite lean.


58-126: Ensure coverage for success/error handling.
The test scenarios appear comprehensive for table headers, empty scenario, and button presence, but confirm that potential error states (e.g., failed network requests) are also covered or will be covered in future tests.


128-197: Thorough scenario coverage for data merging.
The test for combining registrant and attendee data is nicely handled. Please ensure special cases, like partial merges or repeated user entries, are also tested to prevent edge-case regressions.


198-264: Fallback logic testing is well-structured.
The test validates missing attendee data rendering. This robust approach ensures consistent UX. Keeping the fallback logic minimal and clear is advisable to avoid confusion when scaling up the component features.

public/locales/zh/translation.json (1)

1085-1095: Translations align with established naming.
The newly added eventRegistrant keys mirror the structure used elsewhere, promoting consistency. Double-check for typos or missing context in these newly added translations for "注册者" or "未找到注册者".

public/locales/hi/translation.json (1)

1085-1095: Maintain continuous localization parity.
These Hindi translations for eventRegistrant appear correct. Ensure that similar keys have no mismatch in other locales, preserving the same terminology (“पंजीकृत व्यक्ति”) across the UI.

public/locales/fr/translation.json (1)

1085-1095: Check for accent consistency and spacing.
The French strings for eventRegistrant, such as “Enregistré le”, match the format used throughout the file. Just verify accents and punctuation in the UI for complete fluidity.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 25, 2024
@syedali237
Copy link
Contributor Author

@palisadoes increased the test coverage.

Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

Please move all your CSS to this stylesheet:

It will help us implement a light/dark mode in future, and possibly centralized overrides

@syedali237
Copy link
Contributor Author

@palisadoes, I am already using all the CSS properties from that file only. The CSS file for this component is only present if in case an individual file is required in the future.

@palisadoes
Copy link
Contributor

In that case please delete all the CSS files in the directories where the files you have edited reside.

Make sure there are no references to the local CSS files

@palisadoes palisadoes added the ignore-sensitive-files-pr The contributor has a legitimate reason for editiing protected files label Dec 25, 2024
@palisadoes palisadoes merged commit 3209a18 into PalisadoesFoundation:develop-postgres Dec 26, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore-sensitive-files-pr The contributor has a legitimate reason for editiing protected files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants