Skip to content

NoMongo: Postgres Migration Support for POST in orgDashboard #3707

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

Merged

Conversation

NishantSinghhhhh
Copy link
Contributor

@NishantSinghhhhh NishantSinghhhhh commented Feb 18, 2025

What kind of change does this PR introduce?

This PR introduces a bugfix for the issues found in the OrgPost component and its related GraphQL query.

Issue Number:
Fixes : #3551

Snapshots/Videos:

Screencast.from.2025-02-19.01-57-57.webm

If relevant, did you update the documentation?

N/A

Summary

This PR addresses several issues within the OrgPost component and its GraphQL query:

  1. Corrected the GraphQL query to match the schema and ensure proper data fetching.
  2. Fixed TypeScript errors related to type assignments.
  3. Updated interface names to follow naming conventions.
  4. Removed unused imports and variables.
  5. Ensured proper handling of optional properties in the component.

Does this PR introduce a breaking change?

No

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

    • Enhanced organization posts with improved filtering, sorting, and pagination.
    • Added new queries to retrieve detailed post and user information, including GET_POSTS_BY_ORG and GET_USER_BY_ID.
    • Introduced interactive search and sorting components for a better browsing experience.
    • Added new PostsRenderer component for rendering organization posts.
    • Introduced SearchingButton component for improved search functionality.
  • Documentation

    • Updated public API documentation to reflect the latest query, mutation, and component changes.
    • Added new documentation for various interfaces and components to enhance developer understanding.
  • Refactor

    • Optimized components for smoother post creation, loading, and error handling.
    • Streamlined testing to ensure reliable behavior and quality user interactions.
    • Updated state management and data handling in components for improved clarity and maintainability.
    • Enhanced test suite for OrgPostCard and PostsRenderer components.

Copy link
Contributor

coderabbitai bot commented Feb 18, 2025

Walkthrough

This pull request includes extensive updates to documentation and source code across the project. It updates definition locations for various GraphQL query and mutation variables in both documentation and code, refactors components such as OrgPost and OrgPostCard with improved state management, and introduces new components like PostsRenderer and SearchingButton. New interfaces and tests are also added, and existing tests are refactored, ensuring consistency and improved maintainability across queries, mutations, and UI components.

Changes

File(s) Change Summary
docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/… Updated definition locations for variables like ORGANIZATION_ADMINS_LIST, ORGANIZATION_ADVERTISEMENT_LIST, ORGANIZATION_FUNDS, etc., reflecting new line numbers in src/GraphQl/Queries/OrganizationQueries.ts.
docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/… Updated definition locations for mutation variables (e.g., ADD_ADVERTISEMENT_MUTATION, DELETE_POST_MUTATION, UPDATE_POST_MUTATION, etc.) with corrected source code references.
docs/docs/auto-docs/GraphQl/Queries/Queries/variables/… Adjusted definition locations for query variables (e.g., ADMIN_LIST, MEMBERS_LIST, ORGANIZATIONS_LIST, etc.) and added new documentation for variables such as GET_POSTS_BY_ORG and GET_USER_BY_ID.
docs/docs/auto-docs/screens/OrgPost/…
docs/docs/auto-docs/components/OrgPostCard/…
Revised documentation for screen and component functions by updating definition locations, renaming parameters (e.g., from props to __namedParameters), and removing extraneous CSS strategy sections.
docs/docs/auto-docs/types/Post/interface/… Added new documentation files for post-related interfaces including InterfacePostCreator, InterfacePostNode, InterfacePageInfo, InterfacePostConnection, InterfaceOrganization, etc.
src/GraphQl/Queries/OrganizationQueries.ts
src/GraphQl/Mutations/mutations.ts
src/GraphQl/Queries/Queries.ts
src/GraphQl/Mutations/OrganizationMutations.ts
Updated GraphQL query and mutation signatures, consolidating input parameters into objects and modifying returned data structures for clarity and flexibility.
src/screens/OrgPost/OrgPost.tsx
src/screens/OrgPost/Posts.tsx
Refactored the OrgPost component (renaming and state enhancements) and introduced a new PostsRenderer component for handling post display with error, filtering, and sorting logic.
src/components/OrgPostCard/OrgPostCard.tsx
src/subComponents/SearchingButton.tsx
src/subComponents/SortingButton.tsx
Enhanced components with new interfaces, refined state and mutation handling (e.g., toggling pin status), and added attributes like data-testid for testing improvements.
src/components/OrgPostCard/OrgPostCard.spec.tsx
src/screens/OrgPost/OrgPost.spec.tsx
src/screens/OrgPost/Posts.spec.tsx
src/subComponents/SearchingButton.spec.tsx
Restructured tests to align with the refactored components, removing outdated scenarios and introducing new cases to validate rendering, interactions, and error handling.

Possibly related PRs

  • NoMongo: Postgres Migration Support for POST in orgDashboard #3715: The changes in the main PR regarding updates to the documentation for various GraphQL variables in src/GraphQl/Queries/OrganizationQueries.ts are related to the modifications in the retrieved PR, which also involves updates to the documentation for variables in the same file, specifically the addition of new variables and changes in their definition locations.
  • Fix GraphQL Queries related to OrganizationDashboard.jsx #3534: The changes in the main PR, which involve updating the documentation and definition locations of various GraphQL query variables in src/GraphQl/Queries/OrganizationQueries.ts, are related to the modifications in the retrieved PR that also introduces new queries and updates existing ones in src/GraphQl/Queries/Queries.ts, specifically concerning organization-related data.
  • fixed:Postgres Migration Support for User Portal #3730: The changes in the main PR, which involve updating the documentation for various GraphQL query variables and their definitions in the src/GraphQl/Queries/OrganizationQueries.ts file, are related to the modifications in the retrieved PR that also involve changes to GraphQL queries and their handling in the src/screens/UserPortal/Organizations/Organizations.tsx file, specifically regarding the USER_ORGANIZATION_CONNECTION variable. Both PRs deal with updates to GraphQL query structures and their associated documentation, indicating a direct connection at the code level.

Suggested labels

refactor, ignore-sensitive-files-pr

Poem

Hop along, code friends, the changes are here!
I've dug through mutations and queries so clear.
Lines shifted in docs like carrots in a row,
Refactoring our code with a smooth, steady flow.
With hops of joy and a twitch of my nose,
I'm glad our project blooms as our progress grows!
🐰✨

Tip

CodeRabbit's docstrings feature is now available as part of our Pro Plan! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


📜 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 cbcdb76 and c65ca4f.

📒 Files selected for processing (2)
  • docs/docs/auto-docs/screens/OrgPost/OrgPost/functions/default.md (1 hunks)
  • src/screens/OrgPost/OrgPost.tsx (11 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test Application
  • GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (18)
docs/docs/auto-docs/screens/OrgPost/OrgPost/functions/default.md (1)

9-12: Documentation has been accurately updated to reflect the new implementation.

The definition location and component description have been appropriately updated to match the new implementation in src/screens/OrgPost/OrgPost.tsx. The concise description accurately reflects the component's responsibility.

src/screens/OrgPost/OrgPost.tsx (17)

4-27: Imports and interfaces have been properly organized.

The component now properly imports the new GET_POSTS_BY_ORG query and imports interfaces from a centralized type definition file, improving type safety and code organization.


29-34: JSDoc has been added to address pipeline failure.

The component now has proper JSDoc documentation, addressing the previous pipeline failure mentioned in the past review comments.


51-67: State management has been improved with appropriate type definitions.

The component now uses properly typed state variables for handling pagination, sorting, and filtering of posts, which enhances type safety and maintainability.


68-80: Updated query to use the new GET_POSTS_BY_ORG endpoint.

The component now uses the new query with proper variables structure and network-only fetch policy to ensure fresh data is retrieved.


103-111: Added proper type definition for GraphQL query response.

The component now uses the InterfaceOrganizationPostListData interface for typing the query response, improving type safety.


119-150: Improved error checking and input validation for post creation.

The function now properly validates required fields and constructs a typed input object for post creation, improving reliability.


174-233: Refactor duplicate media handling logic.

The handleAddMediaChange and handleVideoAddMediaChange functions contain similar logic that could be refactored into a single function to reduce duplication.

-const handleAddMediaChange = async (
-  e: React.ChangeEvent<HTMLInputElement>,
-): Promise<void> => {
-  const selectedFile = e.target.files?.[0];
-
-  if (selectedFile) {
-    // Validate file type
-    if (
-      !selectedFile.type.startsWith('image/') &&
-      !selectedFile.type.startsWith('video/')
-    ) {
-      toast.error('Please select an image or video file');
-      return;
-    }
-
-    if (filteredPosts.length === 0) {
-      console.log('No filtered posts found');
-    }
-
-    setFile(selectedFile);
-
-    try {
-      const base64 = await convertToBase64(selectedFile);
-      setPostFormState((prev) => ({
-        ...prev,
-        addMedia: base64,
-      }));
-    } catch {
-      toast.error('Could not generate preview');
-    }
-  } else {
-    setFile(null);
-    setPostFormState((prev) => ({
-      ...prev,
-      addMedia: '',
-    }));
-  }
-};
-
-const handleVideoAddMediaChange = async (
-  e: React.ChangeEvent<HTMLInputElement>,
-): Promise<void> => {
-  const selectedFile = e.target.files?.[0];
-  if (selectedFile) {
-    if (!selectedFile.type.startsWith('video/')) {
-      toast.error('Please select a video file');
-      return;
-    }
-    setVideoFile(selectedFile);
-    try {
-      const base64 = await convertToBase64(selectedFile);
-      setVideoPreview(base64);
-    } catch {
-      toast.error('Could not generate video preview');
-    }
-  } else {
-    setVideoFile(null);
-    setVideoPreview('');
-  }
-};
+const handleMediaChange = async (
+  e: React.ChangeEvent<HTMLInputElement>,
+  mediaType: 'all' | 'video',
+): Promise<void> => {
+  const selectedFile = e.target.files?.[0];
+  
+  if (!selectedFile) {
+    if (mediaType === 'all') {
+      setFile(null);
+      setPostFormState((prev) => ({
+        ...prev,
+        addMedia: '',
+      }));
+    } else {
+      setVideoFile(null);
+      setVideoPreview('');
+    }
+    return;
+  }
+  
+  // Validate file type
+  if (mediaType === 'all') {
+    if (!selectedFile.type.startsWith('image/') && !selectedFile.type.startsWith('video/')) {
+      toast.error('Please select an image or video file');
+      return;
+    }
+    setFile(selectedFile);
+  } else {
+    if (!selectedFile.type.startsWith('video/')) {
+      toast.error('Please select a video file');
+      return;
+    }
+    setVideoFile(selectedFile);
+  }
+  
+  // Create preview
+  try {
+    const base64 = await convertToBase64(selectedFile);
+    if (mediaType === 'all') {
+      setPostFormState((prev) => ({
+        ...prev,
+        addMedia: base64,
+      }));
+    } else {
+      setVideoPreview(base64);
+    }
+  } catch {
+    toast.error(`Could not generate ${mediaType === 'all' ? '' : 'video '}preview`);
+  }
+};
+
+const handleAddMediaChange = (e: React.ChangeEvent<HTMLInputElement>): Promise<void> => 
+  handleMediaChange(e, 'all');
+
+const handleVideoAddMediaChange = (e: React.ChangeEvent<HTMLInputElement>): Promise<void> => 
+  handleMediaChange(e, 'video');

235-264: Added proper pagination and sorting logic.

The component now correctly handles pagination and sorting of posts with appropriate useEffect dependencies.


270-287: Extracted post rendering logic to a separate component.

The component now uses a PostsRenderer component for rendering posts, which improves code organization and maintainability.


288-317: Added robust sorting logic with appropriate state management.

The sorting function now properly updates state variables and handles the "None" option correctly.


319-347: Improved search functionality.

The search function now properly filters posts based on the search term and handles errors appropriately.


349-385: Improved pagination logic for different sorting states.

The component now correctly handles pagination for both server-side pagination (when sortingOption is 'None') and client-side pagination (when sorting is applied).


388-404: Added proper previous page handling.

The component now correctly handles the previous page button for both server-side and client-side pagination.


450-470: Updated pagination UI with proper disabled states.

The pagination buttons are now properly disabled based on the availability of next/previous pages.


536-545: Added separate video upload input.

A separate input for video uploads has been added, improving the user experience by clearly distinguishing between different types of media uploads.


582-608: Added preview functionality for video uploads.

The component now provides a preview for video uploads with proper controls for removing the preview, enhancing the user experience.


530-531: 💡 Verification agent

🧩 Analysis chain

Corrected multiple attribute on file input.

The multiple attribute has been set to false, addressing the previous issue where multiple files were allowed but only the first one was processed.


🏁 Script executed:

#!/bin/bash
# Check for other file inputs that might need the same correction
rg "multiple={true}" src/

Length of output: 135


Verified: Corrected multiple attribute on file input in OrgPost.tsx
The changes on lines 530-531 have been confirmed. The re-run search (with escaped braces) produced no instances of file inputs using "multiple={true}", demonstrating that the issue has been addressed across the codebase.


🏁 Script executed:

[run_scripts]
#!/bin/bash
# Correctly search for file inputs that still use multiple={true} (with proper escaping)
rg "multiple=\{true\}" src/

Length of output: 333


Multiple File Input Attribute Correction – Further Verification Needed

  • OrgPost.tsx (lines 530-531): The file input now correctly uses multiple={false}, which stops the issue where multiple files were allowed but only the first one was processed.
  • Additional Instances Found:
    • src/components/AgendaItems/Create/AgendaItemsCreateModal.tsx still has multiple={true}
    • src/components/AgendaItems/Update/AgendaItemsUpdateModal.tsx still has multiple={true}

Please verify whether the AgendaItems modal components are intended to allow multiple file uploads or if they should be revised similarly to OrgPost.tsx to ensure consistency and correct file processing.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
  • @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: 4

🧹 Nitpick comments (1)
src/screens/OrgPost/OrgPost.tsx (1)

72-73: Guard or remove console logs in production

Multiple console.log statements are helpful for debugging but can clutter production logs. Consider removing or conditionally wrapping them in a debug flag to keep console output clean.

Also applies to: 83-84, 86-87, 90-91, 99-100, 103-104, 129-130, 137-137, 155-156

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 055f54a and 55cdf39.

📒 Files selected for processing (12)
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_ADMINS_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_ADVERTISEMENT_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_FUNDS.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_POST_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_USER_TAGS_LIST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/USER_CREATED_ORGANIZATIONS.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/USER_JOINED_ORGANIZATIONS.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/USER_ORGANIZATION_CONNECTION.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/VENUE_LIST.md (1 hunks)
  • docs/docs/auto-docs/screens/OrgPost/OrgPost/functions/default.md (1 hunks)
  • src/GraphQl/Queries/OrganizationQueries.ts (1 hunks)
  • src/screens/OrgPost/OrgPost.tsx (11 hunks)
✅ Files skipped from review due to trivial changes (10)
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/VENUE_LIST.md
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_FUNDS.md
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/USER_CREATED_ORGANIZATIONS.md
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_ADMINS_LIST.md
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/USER_ORGANIZATION_CONNECTION.md
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/USER_JOINED_ORGANIZATIONS.md
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_POST_LIST.md
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_USER_TAGS_LIST.md
  • docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_ADVERTISEMENT_LIST.md
  • docs/docs/auto-docs/screens/OrgPost/OrgPost/functions/default.md
🧰 Additional context used
🧠 Learnings (1)
src/GraphQl/Queries/OrganizationQueries.ts (1)
Learnt from: hustlernik
PR: PalisadoesFoundation/talawa-admin#3534
File: src/GraphQl/Queries/Queries.ts:388-395
Timestamp: 2025-02-07T13:00:35.500Z
Learning: The `GET_ORGANIZATION_POSTS_PG` query is designed to fetch only a few recent posts using the `first` parameter, and pagination is intentionally omitted as it's not required for this use case.
🪛 GitHub Actions: PR Workflow
src/screens/OrgPost/OrgPost.tsx

[error] 1-1: No TSDoc comment found in file.

🔇 Additional comments (5)
src/GraphQl/Queries/OrganizationQueries.ts (3)

21-22: Validate acceptance of negative or zero values

Changing $first and $last from a PositiveInt type to a standard Int can allow negative or zero values, potentially causing errors or unexpected behavior. Ensure validation is handled, possibly on the server or in your resolver logic, to safeguard against invalid input.


24-25: Looks good

Using organization(input: $input) aligns with the updated schema. This is a clear and extensible way to handle query parameters in a single input object.


29-32: Consistent field naming

The use of id on both the post and the creator entity is generally fine in GraphQL, as each field is namespaced by its parent object. No issues here.

src/screens/OrgPost/OrgPost.tsx (2)

5-7: Added imports for NotFound and OrgPostCard

Importing dedicated components for empty states and post rendering is a neat approach. This improves modularity.


328-329: Pagination logic is well-structured

Disabling “Next” or “Previous” navigation based on hasNextPage or hasPreviousPage helps prevent invalid pagination requests.

Also applies to: 340-341

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 18, 2025
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 (2)
src/screens/OrgPost/OrgPost.tsx (2)

73-109: Add return value documentation to component JSDoc.

The component's JSDoc is comprehensive but lacks information about the return value. Consider adding a @returns tag.

 /**
  * OrgPost Component
  *
  * This component is responsible for rendering and managing organization posts.
  * It allows users to create, view, and navigate through posts associated with an organization.
  *
  * Features:
  * - Fetches and displays organization posts using GraphQL queries.
  * - Supports creating new posts with image/video uploads.
  * - Pagination for navigating between post pages.
  * - Search functionality for filtering posts by title or text.
  * - Sorting options to view the latest or oldest posts.
  * - Allows pinning posts for priority display.
  *
  * Dependencies:
  * - Apollo Client for GraphQL queries and mutations.
  * - React Bootstrap for styling and UI components.
  * - react-toastify for success and error notifications.
  * - i18next for internationalization.
  * - Utility functions like convertToBase64 and errorHandler.
  *
  * Props: None
  *
  * State:
  * - postmodalisOpen: boolean - Controls the visibility of the create post modal.
  * - postformState: object - Stores post form data (title, info, media, pinPost).
  * - sortingOption: string - Stores the current sorting option ('latest', 'oldest').
  * - file: File | null - Stores the selected media file.
  * - after, before: string | null | undefined - Cursor values for pagination.
  * - first, last: number | null - Number of posts to fetch for pagination.
  * - showTitle: boolean - Controls whether to search by title or text.
  *
  * GraphQL Queries:
  * - ORGANIZATION_POST_LIST: Fetches organization posts with pagination.
  * - CREATE_POST_MUTATION: Creates a new post for the organization.
+ *
+ * @returns A JSX element representing the organization posts page with post management functionality.
  */

118-118: Remove debug console.log statements.

Debug console.log statements should not be in production code. Consider using a proper logging framework or removing them.

-  console.log('Page title set to:', t('title'));
-  console.log('Initial post form state:', postformState);
-  console.log('Initial sorting option:', sortingOption);
-  console.log('Current organization ID:', currentUrl);
-  console.log('Opening post modal');
-  console.log('Closing post modal');
-  console.log('Fetched organization posts:', orgPostListData);
-  console.log('Creating post with form state:', postformState);
-  console.log('Post creation response:', data);

Also applies to: 129-129, 132-132, 136-136, 145-145, 150-150, 176-176, 183-183, 212-212

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 55cdf39 and eb9a909.

📒 Files selected for processing (21)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/ADD_ADVERTISEMENT_MUTATION.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/ADD_PLUGIN_MUTATION.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DELETE_ADVERTISEMENT_BY_ID.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DELETE_POST_MUTATION.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DONATE_TO_ORGANIZATION.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/FORGOT_PASSWORD_MUTATION.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/GENERATE_OTP_MUTATION.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/LIKE_POST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/REGISTER_EVENT.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/RESET_COMMUNITY.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UNLIKE_POST.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_ADVERTISEMENT_MUTATION.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_COMMUNITY_PG.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_EVENT_MUTATION.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_INSTALL_STATUS_PLUGIN_MUTATION.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_ORG_STATUS_PLUGIN_MUTATION.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_POST_MUTATION.md (1 hunks)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_SESSION_TIMEOUT_PG.md (1 hunks)
  • docs/docs/auto-docs/screens/OrgPost/OrgPost/functions/default.md (1 hunks)
  • src/GraphQl/Mutations/mutations.ts (1 hunks)
  • src/screens/OrgPost/OrgPost.tsx (9 hunks)
✅ Files skipped from review due to trivial changes (18)
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DELETE_ADVERTISEMENT_BY_ID.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/LIKE_POST.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DELETE_POST_MUTATION.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/ADD_ADVERTISEMENT_MUTATION.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/RESET_COMMUNITY.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_COMMUNITY_PG.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_INSTALL_STATUS_PLUGIN_MUTATION.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/ADD_PLUGIN_MUTATION.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_EVENT_MUTATION.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/FORGOT_PASSWORD_MUTATION.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UNLIKE_POST.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_POST_MUTATION.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_ADVERTISEMENT_MUTATION.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/REGISTER_EVENT.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_SESSION_TIMEOUT_PG.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DONATE_TO_ORGANIZATION.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_ORG_STATUS_PLUGIN_MUTATION.md
  • docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/GENERATE_OTP_MUTATION.md
🧰 Additional context used
🪛 LanguageTool
docs/docs/auto-docs/screens/OrgPost/OrgPost/functions/default.md

[grammar] ~34-~34: The word ‘create’ is a verb. Did you mean the noun “creation”?
Context: ...oolean - Controls the visibility of the create post modal. - postformState: object - S...

(PREPOSITION_VERB)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test Application
  • GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (4)
src/screens/OrgPost/OrgPost.tsx (2)

22-71: Add TSDoc to interfaces.

The interfaces are well-structured but lack documentation. Consider adding TSDoc to improve code maintainability and clarity.

Example:

+/**
+ * Represents a post creator with basic user information.
+ */
 interface InterfacePostCreator {
   id: string;
   firstName?: string;
   lastName?: string;
 }

+/**
+ * Represents a post node with all post-related information.
+ */
 interface InterfacePostNode {
   id: string;
   caption: string;
   text?: string;
   imageUrl?: string | null;
   videoUrl?: string | null;
   creator?: InterfacePostCreator;
   pinned?: boolean;
 }

381-400: Remove unused postID prop.

The postID prop is always passed as an empty string and appears to be unused.

-                    <OrgPostCard
-                      key={post.id}
-                      id={post.id}
-                      postTitle={post.caption}
-                      postInfo={post.text || ''}
-                      postAuthor={`${post.creator?.firstName || ''} ${post.creator?.lastName || ''}`}
-                      postPhoto={post.imageUrl || null}
-                      postVideo={post.videoUrl || null}
-                      pinned={post.pinned || false}
-                      postID={''}
-                    />
+                    <OrgPostCard
+                      key={post.id}
+                      id={post.id}
+                      postTitle={post.caption}
+                      postInfo={post.text || ''}
+                      postAuthor={`${post.creator?.firstName || ''} ${post.creator?.lastName || ''}`}
+                      postPhoto={post.imageUrl || null}
+                      postVideo={post.videoUrl || null}
+                      pinned={post.pinned || false}
+                    />
src/GraphQl/Mutations/mutations.ts (1)

417-429: LGTM! Improved mutation structure.

The updated CREATE_POST_MUTATION follows GraphQL best practices by:

  1. Using a single input object for better type safety
  2. Returning comprehensive post data including attachments
docs/docs/auto-docs/screens/OrgPost/OrgPost/functions/default.md (1)

1-49: LGTM! Comprehensive documentation.

The documentation is well-structured and provides detailed information about the component's features, dependencies, state management, and GraphQL operations.

🧰 Tools
🪛 LanguageTool

[grammar] ~34-~34: The word ‘create’ is a verb. Did you mean the noun “creation”?
Context: ...oolean - Controls the visibility of the create post modal. - postformState: object - S...

(PREPOSITION_VERB)

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 18, 2025
@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.

@NishantSinghhhhh
Copy link
Contributor Author

  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.

Sure once , I am done restoring the functionality, I will change the tests accordingly

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 (12)
docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/MOCKS1.md (1)

7-7: Clarify and Document the Union Type Structure

The updated declaration for MOCKS1 now uses a union type to express two distinct payloads. Please verify that these cases accurately represent the intended GraphQL response variations:

  • Case 1: When querying with variables: { id: string; tagId: undefined; userId: undefined; }, the response populates currentUser and leaves unassignUserTag as undefined.
  • Case 2: Conversely, with variables: { id: undefined; tagId: string; userId: string; }, the response populates unassignUserTag (with its _id) and sets currentUser to undefined.

If this distinction is intended, it would be beneficial to add inline comments or consider creating type aliases to improve readability and future maintainability. This can help future developers understand why these two distinct cases exist and how each should be handled in tests.

docs/docs/auto-docs/components/OrgPostCard/OrgPostCard/interfaces/InterfacePostFormNew.md (3)

9-9: Remove Trailing Punctuation in Heading

The heading on this line ends with a colon, which is flagged by markdownlint (MD026). Consider removing the trailing punctuation to comply with style guidelines.

-## CSS Strategy Explanation:
+## CSS Strategy Explanation
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

9-9: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


16-16: Eliminate Trailing Colon in Benefits Heading

The heading "### Benefits:" ends with a colon. Removing this trailing punctuation can improve consistency with markdown style guidelines.

-### Benefits:
+### Benefits
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

16-16: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


21-21: Correct Trailing Punctuation in Global CSS Classes Heading

The heading "### Global CSS Classes used:" includes a trailing colon. Please remove it to align with markdownlint recommendations.

-### Global CSS Classes used:
+### Global CSS Classes used
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

21-21: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/ERROR_MOCK.md (1)

5-7: Variable Declaration Details

The variable ERROR_MOCK is clearly declared with its type (object[]) and is highlighted using markdown formatting. Consider verifying if the escape character in ERROR\_MOCK is necessary for correct rendering; it might be possible to simplify it to ERROR_MOCK.

docs/docs/auto-docs/screens/MemberDetail/MemberDetail/functions/default.md (1)

12-13: Refactor Sentence Openings for Improved Readability

Both lines 12 and 13 start consecutive sentences with "It". Rephrasing these sentences can enhance the readability of the documentation. For example, you could merge or vary the sentence openings, such as:

-It also allows the user to update the details. It uses the UPDATE_CURRENT_USER_MUTATION to update the user details.
-It uses the CURRENT_USER query to get the user details. It uses the useLocalStorage hook to store the user details in the local storage.
+This component not only displays user details but also enables updates using the UPDATE_CURRENT_USER_MUTATION. Additionally, it retrieves the user information via the CURRENT_USER query and persists these details in local storage through the useLocalStorage hook.

This change helps reduce repetitive sentence structures.

🧰 Tools
🪛 LanguageTool

[style] ~12-~12: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ER_MUTATION to update the user details. It uses the CURRENT_USER query to get the ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~13-~13: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ENT_USER query to get the user details. It uses the useLocalStorage hook to store ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

docs/docs/auto-docs/screens/UserPortal/Settings/ProfileHeader/ProfileHeader/functions/default.md (3)

1-4: Document Header & Introductory Section

The file starts with a clear link ([Admin Docs](/)) and a simple separator. For enhanced clarity, consider including a more descriptive title (for example, “ProfileHeader Default Function Documentation”) to immediately convey the file’s purpose to new readers.


11-19: Component Overview and Layout Description

The overview efficiently explains the purpose of the component along with its layout details. One minor suggestion: for consistency in the bullet lists (specifically, the item “- A profile dropdown menu on the right side”), consider ending the bullet text with a period.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~15-~15: A period might be missing here.
Context: ... - A profile dropdown menu on the right side The layout uses flexbox for proper ali...

(AI_EN_LECTOR_MISSING_PUNCTUATION_PERIOD)


20-35: Parameters & Deprecation Notice Formatting

The parameters are well-described with their types, and the deprecation notice for deprecatedLegacyContext is clearly indicated. However, static analysis flagged that using emphatic markers (e.g., Deprecated and See) as stand-alone headings might not be ideal (MD036). Consider replacing them with proper Markdown headings (for example, ### Deprecated) or stylistically integrating them into the text for better consistency and accessibility.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

30-30: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)


32-32: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/UPDATE_MOCK.md (2)

5-10: Variable Declaration and Source Link
The section clearly documents the variable name (UPDATE_MOCK) along with its type (object[]) and provides a direct link to its definition in the source file. Consider verifying whether the escape for the underscore (i.e. UPDATE\_MOCK) is intentional for formatting purposes.


33-144: Result Type Declaration Section
This section is comprehensive and methodically lists all properties of the result.data.updateCurrentUser object with type annotations and default values. The nested subsections (e.g., for addressLine1, avatarMimeType, createdAt, etc.) facilitate easy reference. As a future improvement, consider revisiting the properties typed as any if the schema becomes more stable to provide stronger type safety.

docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/MOCK_FILE.md (1)

7-7: Improve Readability of Complex Type Definition
The complex type structure for MOCK_FILE is presented within a single blockquote, which can affect readability. Consider refactoring this block into a fenced code block with multi-line formatting. For example:

- > `const` **MOCK_FILE**: ({ `request`: { `query`: `DocumentNode`; `variables`: { `id`: `string`; `tagId`: `undefined`; `userId`: `undefined`; }; }; `result`: { `data`: { `currentUser`: { ... }; `unassignUserTag`: `undefined`; }; }; } | { `request`: { `query`: `DocumentNode`; `variables`: { `id`: `undefined`; `tagId`: `string`; `userId`: `string`; }; }; `result`: { `data`: { `currentUser`: `undefined`; `unassignUserTag`: { `_id`: `string`; }; }; }; })[]
+ ```typescript
+ const MOCK_FILE: ({
+   request: { 
+     query: DocumentNode; 
+     variables: { id: string; tagId: undefined; userId: undefined; };
+   };
+   result: {
+     data: {
+       currentUser: { /* detailed properties */ };
+       unassignUserTag: undefined;
+     };
+   };
+ } | {
+   request: {
+     query: DocumentNode;
+     variables: { id: undefined; tagId: string; userId: string; };
+   };
+   result: {
+     data: {
+       currentUser: undefined;
+       unassignUserTag: { _id: string; };
+     };
+   };
+ })[];
+ ```
This change will enable proper syntax highlighting and easier maintenance.

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

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

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between eb9a909aed880cd0f5ccf1c9b04dd11ba052a54d and c5453818f9f407542de91bade808bfc4c9d37dee.

</details>

<details>
<summary>⛔ Files ignored due to path filters (1)</summary>

* `package-lock.json` is excluded by `!**/package-lock.json`

</details>

<details>
<summary>📒 Files selected for processing (107)</summary>

* `docs/docs/auto-docs/GraphQl/Mutations/OrganizationMutations/variables/ADD_CUSTOM_FIELD.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/OrganizationMutations/variables/CANCEL_MEMBERSHIP_REQUEST.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/OrganizationMutations/variables/JOIN_PUBLIC_ORGANIZATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/OrganizationMutations/variables/REMOVE_CUSTOM_FIELD.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/OrganizationMutations/variables/SEND_MEMBERSHIP_REQUEST.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/ADD_ADMIN_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/ADD_ADVERTISEMENT_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/ADD_MEMBER_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/ADD_PLUGIN_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/CREATE_EVENT_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/CREATE_ORGANIZATION_MEMBERSHIP_MUTATION_PG.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/CREATE_ORGANIZATION_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/CREATE_ORGANIZATION_MUTATION_PG.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/CREATE_POST_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DELETE_ADVERTISEMENT_BY_ID.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DELETE_EVENT_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DELETE_ORGANIZATION_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DELETE_POST_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DONATE_TO_ORGANIZATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/FORGOT_PASSWORD_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/GENERATE_OTP_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/LIKE_POST.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/RECAPTCHA_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/REFRESH_TOKEN_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/REGISTER_EVENT.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/REMOVE_ADMIN_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/REMOVE_MEMBER_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/RESET_COMMUNITY.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/REVOKE_REFRESH_TOKEN.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/SIGNUP_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UNLIKE_POST.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_ADVERTISEMENT_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_COMMUNITY_PG.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_CURRENT_USER_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_EVENT_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_INSTALL_STATUS_PLUGIN_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_ORG_STATUS_PLUGIN_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_POST_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_SESSION_TIMEOUT_PG.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_USER_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_USER_PASSWORD_MUTATION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/FILTERED_ORGANIZATION_POSTS.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_ADMINS_LIST.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_ADVERTISEMENT_LIST.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_FUNDS.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_USER_TAGS_LIST.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/USER_CREATED_ORGANIZATIONS.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/USER_JOINED_ORGANIZATIONS.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/USER_ORGANIZATION_CONNECTION.md` (1 hunks)
* `docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/VENUE_LIST.md` (1 hunks)
* `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/CURRENT_USER.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/ORGANIZATION_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/ChangeLanguageDropdown/ChangeLanguageDropDown/functions/default.md` (1 hunks)
* `docs/docs/auto-docs/components/OrgPostCard/OrgPostCard/functions/default.md` (1 hunks)
* `docs/docs/auto-docs/components/OrgPostCard/OrgPostCard/interfaces/InterfacePostFormNew.md` (1 hunks)
* `docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks/variables/CHAT_BY_ID_QUERY_MOCK.md` (1 hunks)
* `docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks/variables/GROUP_CHAT_BY_USER_ID_QUERY_MOCK.md` (1 hunks)
* `docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks/variables/MESSAGE_SENT_TO_CHAT_MOCK.md` (1 hunks)
* `docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks/variables/UNREAD_CHAT_LIST_QUERY_MOCK.md` (1 hunks)
* `docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks/variables/UserConnectionListMock.md` (1 hunks)
* `docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks2/variables/CHATS_LIST_MOCK.md` (1 hunks)
* `docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks2/variables/CREATE_CHAT_MUTATION_MOCK.md` (1 hunks)
* `docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks2/variables/GROUP_CHAT_BY_ID_QUERY_MOCK.md` (1 hunks)
* `docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks2/variables/MARK_CHAT_MESSAGES_AS_READ_MOCK.md` (1 hunks)
* `docs/docs/auto-docs/components/UserPortal/UserProfile/UserAddressFields/functions/UserAddressFields.md` (2 hunks)
* `docs/docs/auto-docs/screens/MemberDetail/MemberDetail/functions/default.md` (1 hunks)
* `docs/docs/auto-docs/screens/MemberDetail/MemberDetail/functions/getLanguageName.md` (1 hunks)
* `docs/docs/auto-docs/screens/MemberDetail/MemberDetail/functions/prettyDate.md` (1 hunks)
* `docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/ERROR_MOCK.md` (1 hunks)
* `docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/MOCKS1.md` (1 hunks)
* `docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/MOCKS2.md` (3 hunks)
* `docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/MOCKS3.md` (3 hunks)
* `docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/MOCK_FILE.md` (1 hunks)
* `docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/UPDATE_MOCK.md` (1 hunks)
* `docs/docs/auto-docs/screens/UserPortal/Settings/ProfileHeader/ProfileHeader/functions/default.md` (1 hunks)

</details>

<details>
<summary>⛔ Files not processed due to max files limit (21)</summary>

* docs/docs/auto-docs/screens/UserPortal/Settings/ProfileImageSection/ProfileImageSection/functions/default.md
* docs/docs/auto-docs/screens/UserPortal/Settings/Settings/functions/default.md
* docs/docs/auto-docs/screens/UserPortal/Settings/SettingsMocks/variables/MOCKS.md
* docs/docs/auto-docs/screens/UserPortal/Settings/SettingsMocks/variables/MOCKS1.md
* docs/docs/auto-docs/screens/UserPortal/Settings/SettingsMocks/variables/MOCKS2.md
* docs/docs/auto-docs/screens/UserPortal/Settings/SettingsMocks/variables/UPDATE_MOCK.md
* docs/docs/auto-docs/screens/UserPortal/Settings/SettingsMocks/variables/errorMock.md
* docs/docs/auto-docs/screens/UserPortal/Settings/SideToggle/SideToggle/functions/default.md
* docs/docs/auto-docs/screens/UserPortal/Settings/UserDetails/UserDetails/functions/default.md
* docs/docs/auto-docs/utils/formEnumFields/variables/educationGradeEnum.md
* docs/docs/auto-docs/utils/formEnumFields/variables/employmentStatusEnum.md
* docs/docs/auto-docs/utils/formEnumFields/variables/genderEnum.md
* docs/docs/auto-docs/utils/formEnumFields/variables/maritalStatusEnum.md
* docs/docs/auto-docs/utils/passwordValidator/functions/validatePassword.md
* docs/docs/auto-docs/utils/sanitizeAvatar/functions/sanitizeAvatars.md
* docs/docs/auto-docs/utils/urlToFile/functions/urlToFile.md
* src/GraphQl/Mutations/OrganizationMutations.ts
* src/GraphQl/Mutations/mutations.ts
* src/GraphQl/Queries/OrganizationQueries.ts
* src/components/OrgPostCard/OrgPostCard.tsx
* src/screens/OrgPost/OrgPost.tsx

</details>

<details>
<summary>✅ Files skipped from review due to trivial changes (72)</summary>

* docs/docs/auto-docs/GraphQl/Mutations/OrganizationMutations/variables/SEND_MEMBERSHIP_REQUEST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DELETE_EVENT_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_ATTENDEES.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_DETAILS.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/REFRESH_TOKEN_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_MEMBERS_PG.md
* docs/docs/auto-docs/GraphQl/Mutations/OrganizationMutations/variables/ADD_CUSTOM_FIELD.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_FEEDBACKS.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATION_DONATION_CONNECTION_LIST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_USER_MUTATION.md
* docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks/variables/UserConnectionListMock.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_JOINED_ORGANIZATIONS_PG.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_LIST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/ADD_MEMBER_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_COMMUNITY_SESSION_TIMEOUT_DATA_PG.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/BLOCK_PAGE_MEMBER_LIST.md
* docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks/variables/CHAT_BY_ID_QUERY_MOCK.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/REVOKE_REFRESH_TOKEN.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/CREATE_ORGANIZATION_MUTATION_PG.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/SIGNUP_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_LIST_REQUEST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_USER_PASSWORD_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_COMMUNITY_DATA.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ADMIN_LIST.md
* docs/docs/auto-docs/GraphQl/Mutations/OrganizationMutations/variables/JOIN_PUBLIC_ORGANIZATION.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/SIGNIN_QUERY.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_DATA_PG.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DELETE_ORGANIZATION_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/CURRENT_USER.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USERS_CONNECTION_LIST.md
* docs/docs/auto-docs/components/ChangeLanguageDropdown/ChangeLanguageDropDown/functions/default.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/MEMBERSHIP_REQUEST.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATION_EVENT_LIST.md
* docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks2/variables/CHATS_LIST_MOCK.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_REGISTRANTS.md
* docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks2/variables/MARK_CHAT_MESSAGES_AS_READ_MOCK.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/RECURRING_EVENTS.md
* docs/docs/auto-docs/screens/MemberDetail/MemberDetail/functions/getLanguageName.md
* docs/docs/auto-docs/GraphQl/Mutations/OrganizationMutations/variables/REMOVE_CUSTOM_FIELD.md
* docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks/variables/UNREAD_CHAT_LIST_QUERY_MOCK.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/MEMBERS_LIST.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/EVENT_CHECKINS.md
* docs/docs/auto-docs/screens/MemberDetail/MemberDetail/functions/prettyDate.md
* docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/FILTERED_ORGANIZATION_POSTS.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_DETAILS.md
* docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks2/variables/GROUP_CHAT_BY_ID_QUERY_MOCK.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_EVENTS_PG.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_CURRENT_USER_MUTATION.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/REMOVE_MEMBER_MUTATION.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/CREATE_ORGANIZATION_MEMBERSHIP_MUTATION_PG.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/CREATE_POST_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_POSTS_PG.md
* docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks/variables/GROUP_CHAT_BY_USER_ID_QUERY_MOCK.md
* docs/docs/auto-docs/GraphQl/Mutations/OrganizationMutations/variables/CANCEL_MEMBERSHIP_REQUEST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/REMOVE_ADMIN_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATION_EVENT_CONNECTION_LIST.md
* docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks/variables/MESSAGE_SENT_TO_CHAT_MOCK.md
* docs/docs/auto-docs/components/OrgPostCard/OrgPostCard/functions/default.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_ORGANIZATION_POSTS_COUNT_PG.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/CREATE_ORGANIZATION_MUTATION.md
* docs/docs/auto-docs/components/UserPortal/CreateDirectChat/CreateDirectChatMocks2/variables/CREATE_CHAT_MUTATION_MOCK.md
* docs/docs/auto-docs/components/UserPortal/UserProfile/UserAddressFields/functions/UserAddressFields.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_ORGANIZATION_LIST.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATIONS_LIST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/ADD_ADMIN_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATION_LIST.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/GET_COMMUNITY_DATA_PG.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATION_CONNECTION_LIST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/RECAPTCHA_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/USER_LIST_FOR_TABLE.md
* docs/docs/auto-docs/GraphQl/Queries/Queries/variables/ORGANIZATIONS_MEMBER_CONNECTION_LIST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/CREATE_EVENT_MUTATION.md

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (26)</summary>

* docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/USER_CREATED_ORGANIZATIONS.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DELETE_POST_MUTATION.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_COMMUNITY_PG.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DELETE_ADVERTISEMENT_BY_ID.md
* docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/USER_JOINED_ORGANIZATIONS.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/ADD_ADVERTISEMENT_MUTATION.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/RESET_COMMUNITY.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_SESSION_TIMEOUT_PG.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UNLIKE_POST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/FORGOT_PASSWORD_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/USER_ORGANIZATION_CONNECTION.md
* docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_ADMINS_LIST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/LIKE_POST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/ADD_PLUGIN_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_USER_TAGS_LIST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_EVENT_MUTATION.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/GENERATE_OTP_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_FUNDS.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_INSTALL_STATUS_PLUGIN_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/ORGANIZATION_ADVERTISEMENT_LIST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_POST_MUTATION.md
* docs/docs/auto-docs/GraphQl/Queries/OrganizationQueries/variables/VENUE_LIST.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_ORG_STATUS_PLUGIN_MUTATION.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/UPDATE_ADVERTISEMENT_MUTATION.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/DONATE_TO_ORGANIZATION.md
* docs/docs/auto-docs/GraphQl/Mutations/mutations/variables/REGISTER_EVENT.md

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧠 Learnings (1)</summary>

<details>
<summary>docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/MOCKS1.md (1)</summary>

Learnt from: meetulr
PR: #2355
File: src/screens/ManageTag/ManageTagMocks.ts:187-269
Timestamp: 2024-11-12T10:40:58.654Z
Learning: In src/screens/ManageTag/ManageTagMocks.ts, when mocking data for USER_TAGS_ASSIGNED_MEMBERS and USER_TAGS_MEMBERS_TO_ASSIGN_TO, it's acceptable for user IDs to overlap because the queries serve different purposes and the overlapping IDs can represent realistic scenarios in tests.


</details>

</details><details>
<summary>🪛 LanguageTool</summary>

<details>
<summary>docs/docs/auto-docs/screens/MemberDetail/MemberDetail/functions/default.md</summary>

[style] ~12-~12: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ER_MUTATION to update the user details. It uses the CURRENT_USER query to get the ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

---

[style] ~13-~13: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ENT_USER query to get the user details. It uses the useLocalStorage hook to store ...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

</details>
<details>
<summary>docs/docs/auto-docs/screens/UserPortal/Settings/ProfileHeader/ProfileHeader/functions/default.md</summary>

[uncategorized] ~15-~15: A period might be missing here.
Context: ... - A profile dropdown menu on the right side  The layout uses flexbox for proper ali...

(AI_EN_LECTOR_MISSING_PUNCTUATION_PERIOD)

</details>
<details>
<summary>docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/MOCK_FILE.md</summary>

[typographical] ~1-~1: Ikke parret symbol: "]" ser ud til at mangle
Context: [Admin Docs](/)  ***  # Variable: MOCK\_F...

(UNPAIRED_BRACKETS)

</details>

</details>
<details>
<summary>🪛 markdownlint-cli2 (0.17.2)</summary>

<details>
<summary>docs/docs/auto-docs/screens/UserPortal/Settings/ProfileHeader/ProfileHeader/functions/default.md</summary>

30-30: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

---

32-32: Emphasis used instead of a heading
null

(MD036, no-emphasis-as-heading)

</details>
<details>
<summary>docs/docs/auto-docs/components/OrgPostCard/OrgPostCard/interfaces/InterfacePostFormNew.md</summary>

9-9: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

---

16-16: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

---

21-21: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

</details>

</details>

</details>

<details>
<summary>🔇 Additional comments (54)</summary><blockquote>

<details>
<summary>docs/docs/auto-docs/components/OrgPostCard/OrgPostCard/interfaces/InterfacePostFormNew.md (1)</summary>

`1-84`: **Overall Documentation Quality and Clarity**

The new documentation file for `InterfacePostFormNew` is well structured and highly informative. The headings, property descriptions, and direct links to the source code greatly improve clarity and ease of navigation for future developers. Keep up the good work!

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 markdownlint-cli2 (0.17.2)</summary>

9-9: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

---

16-16: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

---

21-21: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

</details>

</details>

</details>
<details>
<summary>docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/ERROR_MOCK.md (10)</summary>

`1-2`: **Documentation Header and Admin Docs Link**

The header link provides quick navigation to the Admin Docs. Ensure that the relative link (`/`) resolves correctly in all deployment contexts.

---

`3-4`: **Separator Formatting**

The horizontal rule (`***`) is used effectively to separate the header from the content, enhancing readability.

---

`9-10`: **Definition Location Link**

The link that points to the source definition at `src/screens/MemberDetail/MemberDetailMocks.ts:193` is very helpful. Make sure it remains updated if the source file path or line number changes.

---

`11-12`: **Type Declaration Section**

The section clearly labels the type declaration, which organizes the subsequent details in a structured manner.

---

`13-16`: **Error Property Documentation**

The `error` property is documented succinctly as type `Error`. This clear declaration helps in understanding the expected structure of the `ERROR_MOCK` variable.

---

`17-20`: **Request Property Documentation**

The documentation specifies that `request` is of type `object`, setting a good foundation for the nested properties. If the complexity of the structure increases in the future, consider providing additional details.

---

`21-24`: **Request Query Documentation**

The `request.query` property is clearly documented with its type (`DocumentNode`) and its initialization with `UPDATE_CURRENT_USER_MUTATION`. This precise detail aligns well with expected usage in the source code.

---

`25-28`: **Request Variables Documentation**

The property `request.variables` is defined as an `object`. The concise declaration is clear; however, if the variables object grows in complexity, expanding the documentation to include sub-properties might be beneficial.

---

`29-32`: **Input Object Documentation**

The `request.variables.input` property is documented as an object. The nested documentation reinforces the intended structure of the data, which is good for maintainability.

---

`33-35`: **Input Name Property Documentation**

The documentation for `request.variables.input.name` is clear, indicating its type as `string` along with the default value `'Test User'`. This helps in understanding both the type and the initial value.

</details>
<details>
<summary>docs/docs/auto-docs/screens/MemberDetail/MemberDetail/functions/default.md (1)</summary>

`9-9`: **Verify Updated Source Reference**

The "Defined in:" link now correctly points to `src/screens/MemberDetail/MemberDetail.tsx:44`, reflecting the updated location of the function definition. Please double‐check that the target file and line number are correct.

</details>
<details>
<summary>docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/MOCKS3.md (3)</summary>

`9-9`: **Confirm Updated Definition Reference**

The "Defined in:" link has been updated to point to `src/screens/MemberDetail/MemberDetailMocks.ts:106`, which aligns with the reorganization in the source file. Please verify that the revised marker accurately reflects the current file structure.

---

`19-19`: **Ensure Correct Query Documentation**

The request object now documents the query as `DocumentNode` with a value of `CURRENT_USER` on line 19. This update is consistent with the PR objectives.

---

`37-143`: **Validate Updated Mock Data Structure for currentUser**

The entire block defining `result.data.currentUser` (from line 37 through line 143) has been comprehensively updated. The renaming from previous user data fields to `currentUser` and the inclusion of new attributes (such as `addressLine1`, `avatarMimeType`, `emailAddress`, etc.) are clear and consistent. Please ensure that these documented fields match the actual GraphQL schema and serve the intended purpose in tests.

</details>
<details>
<summary>docs/docs/auto-docs/screens/UserPortal/Settings/ProfileHeader/ProfileHeader/functions/default.md (4)</summary>

`5-10`: **Function Signature Documentation Clarity**

The documentation clearly presents the function signature (using the blockquote) along with a link to its location in the source code. This format helps developers quickly find the implementation.

---

`36-39`: **Return Type Documentation**

The return type `ReactNode` is clearly listed and easy to understand. No changes are necessary here.

---

`40-46`: **Remarks Section Review**

The remarks section effectively outlines the Bootstrap classes used for layout and styling, which aids in understanding how the component is visually structured. This section is concise and useful.

---

`47-58`: **Example Usage Clarity**

The examples provided for basic usage and usage with translated text are well-formatted using proper code blocks and language markers (`tsx`). These examples will assist developers in quickly implementing the component.

</details>
<details>
<summary>docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/UPDATE_MOCK.md (2)</summary>

`1-4`: **General Documentation Header**  
The header with the “[Admin Docs](/)” link and horizontal rule is clear and provides a good starting point for the document.

---

`11-32`: **Request Type Declaration Section**  
The breakdown of the request object—including its properties like `query` (correctly assigned to `UPDATE_CURRENT_USER_MUTATION`) and the nested `variables.input.name` (with its default value)—is structured well. This clear hierarchical presentation should help users quickly understand the expected input format for the GraphQL mutation.

</details>
<details>
<summary>docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/MOCK_FILE.md (4)</summary>

`1-2`: **Markdown Link Verification**  
The markdown link `[Admin Docs](/)` is correctly formed. The static analysis warning regarding an unpaired bracket appears to be a false positive.

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 LanguageTool</summary>

[typographical] ~1-~1: Ikke parret symbol: "]" ser ud til at mangle
Context: [Admin Docs](/)  ***  # Variable: MOCK\_F...

(UNPAIRED_BRACKETS)

</details>

</details>

---

`3-4`: **Horizontal Rule Confirmation**  
The horizontal rule (`***`) is used appropriately to separate content in the document.

---

`5-6`: **Header and Title Formatting**  
The header `# Variable: MOCK\_FILE` is clear and well-formatted with proper escaping to display the underscore.

---

`9-10`: **Source Reference Link Clarity**  
The reference link to the source file (`src/screens/MemberDetail/MemberDetailMocks.ts:207`) is clear and correctly formatted. Ensure this link is updated if the file path changes in the future.

</details>
<details>
<summary>docs/docs/auto-docs/screens/MemberDetail/MemberDetailMocks/variables/MOCKS2.md (29)</summary>

`9-9`: **Source Link Update**  
The reference now clearly indicates that `MOCKS2` is defined at line 64 in `MemberDetailMocks.ts`. This link improves traceability between the docs and the actual implementation.

---

`19-19`: **GraphQL Query Update**  
The `request.query` now correctly uses `CURRENT_USER`, aligning the mock with the updated GraphQL schema. Ensure that other parts of the system consuming this mock data are updated accordingly.

---

`37-39`: **Result Data Restructure**  
The mock has been updated to use `currentUser` instead of the former nested `user` property. This enhances consistency with the backend response structure.

---

`41-43`: **Typename Definition**  
Defining `__typename` as `'User'` for `currentUser` is in line with GraphQL best practices. Confirm that this value remains consistent across similar queries.

---

`45-47`: **Address Line 1 Field Update**  
The `addressLine1` property is now explicitly defined with the placeholder `'Line 1'`. Verify that this conforms to the expected structure from the backend.

---

`49-51`: **Address Line 2 Field Update**  
The `addressLine2` property has been updated appropriately to `'Line 2'`, matching the new data schema.

---

`53-55`: **Avatar MIME Type Update**  
The `avatarMimeType` field is now included with a sample value `'image/jpeg'`, ensuring consistency in representing media types.

---

`57-59`: **Avatar URL Field**  
The `avatarURL` now points to a placeholder URL. Ensure that this value is updated in real scenarios or tests where an actual URL is needed.

---

`61-63`: **Birth Date Format**  
The `birthDate` field now uses the ISO date string `'2000-01-01'`. Confirm that all date fields across the application adhere to this or an agreed-upon standard format.

---

`65-67`: **City Field Update**  
The property `city` is now set to `'nyc'`. Verify that this shorthand is intentional and consistent with other representations of city names in the system.

---

`69-71`: **Country Code Field**  
The `countryCode` is updated to `'bb'`. Please double-check that this code is correct and not a typographical error.

---

`73-75`: **CreatedAt Timestamp Update**  
The `createdAt` field is now provided with a specific timestamp. Ensure that the format and example value align with production expectations.

---

`77-79`: **Description Field Update**  
The `description` field now includes a placeholder `'This is a description'`. This update should help clarify the intended structure for current user data in mocks.

---

`81-83`: **Education Grade Update**  
The `educationGrade` field is defined with the value `'grade_8'`. Confirm that this sample value is representative and consistent with schema definitions.

---

`85-87`: **Email Address Field**  
The email field now uses `'[email protected]'` as a placeholder. Make sure this is acceptable for testing purpose and does not conflict with any validation rules in the system.

---

`89-91`: **Employment Status Field**  
The `employmentStatus` is updated to `'employed'` to reflect a concrete example test value. Verify that this status is part of the allowed enumeration in the system.

---

`93-95`: **Home Phone Number Update**  
The `homePhoneNumber` field now holds `'+9999999998'`. Confirm that this format matches the expected format across other mock datasets.

---

`97-99`: **User ID Field Update**  
The `id` for `currentUser` has been updated to a UUID-like string. Ensure consistency with how user IDs are represented in the production database.

---

`101-103`: **Email Verification Flag**  
The boolean flag `isEmailAddressVerified` is set to `false`, which is typically the expected default for user creation states.

---

`105-107`: **Marital Status Field**  
The `maritalStatus` field is now defined as `'engaged'`, which should be cross-checked with valid status values in the application.

---

`109-111`: **Mobile Phone Number Update**  
The `mobilePhoneNumber` has been updated to use a consistent phone number format.

---

`113-115`: **Name Field Update**  
The `name` property is set to `'Rishav Jha'`, matching the intended test data. Consider introducing variability in test data if needed for robustness.

---

`117-119`: **Natal Sex Field Update**  
The `natalSex` field is now provided as `'male'`. Confirm that this sample is in line with related components’ expectations.

---

`121-123`: **Natural Language Code**  
The `naturalLanguageCode` is now assigned `'en'`. This aligns with common usage for English and should be validated in integration tests.

---

`125-127`: **Postal Code Field**  
The `postalCode` is updated to a string `'111111'`. Verify that this placeholder format is adequate for the intended locale or is replaced in production.

---

`129-131`: **User Role Field**  
The `role` property is now declared as `'regular'`. Ensure that this designation is consistent with the roles defined in the backend.

---

`133-135`: **State Field Update**  
The `state` field now holds `'State1'`. Confirm that this representative state name meets testing or illustrative purposes.

---

`137-139`: **UpdatedAt Timestamp Field**  
The `updatedAt` field has been provided with a current timestamp string. Verify that such timestamps are correctly processed by date handlers in the application.

---

`141-143`: **Work Phone Number Update**  
The `workPhoneNumber` field now uses a similar format to other phone numbers. Consistency checks against overall data formatting are recommended.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 19, 2025
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: 4

🧹 Nitpick comments (2)
src/screens/OrgPost/OrgPost.tsx (1)

246-288: Improve error handling in handleAddMediaChange.

The error handling in the file upload function could be improved:

  1. Add file size validation
  2. Use more specific error messages
  3. Handle file type validation more robustly
 const handleAddMediaChange = async (
   e: React.ChangeEvent<HTMLInputElement>,
 ): Promise<void> => {
   const selectedFile = e.target.files?.[0];

   if (selectedFile) {
-    console.log('Selected file:', {
-      name: selectedFile.name,
-      type: selectedFile.type,
-      size: selectedFile.size,
-    });

+    // Validate file size (e.g., 5MB limit)
+    const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
+    if (selectedFile.size > MAX_FILE_SIZE) {
+      toast.error('File size exceeds 5MB limit');
+      return;
+    }

     // Validate file type
+    const ALLOWED_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'video/mp4', 'video/webm'];
     if (
-      !selectedFile.type.startsWith('image/') &&
-      !selectedFile.type.startsWith('video/')
+      !ALLOWED_TYPES.includes(selectedFile.type)
     ) {
-      toast.error('Please select an image or video file');
+      toast.error('Please select a valid image (JPEG, PNG, GIF) or video (MP4, WebM) file');
       return;
     }

     // Store the raw file
     setFile(selectedFile);

     // Create preview
     try {
       const base64 = await convertToBase64(selectedFile);
       setPostFormState((prev) => ({
         ...prev,
         addMedia: base64,
       }));
     } catch (error) {
-      console.error('Preview generation error:', error);
       toast.error('Could not generate preview');
     }
   } else {
     setFile(null);
     setPostFormState((prev) => ({
       ...prev,
       addMedia: '',
     }));
   }
 };
docs/docs/auto-docs/screens/OrgPost/OrgPost/functions/default.md (1)

34-34: Fix grammar in state description.

Change "create post modal" to "creation post modal" or "post creation modal" for better grammar.

-postmodalisOpen: boolean - Controls the visibility of the create post modal.
+postmodalisOpen: boolean - Controls the visibility of the post creation modal.
🧰 Tools
🪛 LanguageTool

[grammar] ~34-~34: The word ‘create’ is a verb. Did you mean the noun “creation”?
Context: ...oolean - Controls the visibility of the create post modal. - postformState: object - S...

(PREPOSITION_VERB)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 221ab61 and 99c155f.

📒 Files selected for processing (3)
  • docs/docs/auto-docs/components/OrgPostCard/OrgPostCard/functions/default.md (1 hunks)
  • docs/docs/auto-docs/screens/OrgPost/OrgPost/functions/default.md (1 hunks)
  • src/screens/OrgPost/OrgPost.tsx (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/docs/auto-docs/components/OrgPostCard/OrgPostCard/functions/default.md
🧰 Additional context used
🪛 LanguageTool
docs/docs/auto-docs/screens/OrgPost/OrgPost/functions/default.md

[grammar] ~34-~34: The word ‘create’ is a verb. Did you mean the noun “creation”?
Context: ...oolean - Controls the visibility of the create post modal. - postformState: object - S...

(PREPOSITION_VERB)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test Application
🔇 Additional comments (2)
src/screens/OrgPost/OrgPost.tsx (1)

80-116: LGTM! Comprehensive component documentation.

The TSDoc for the OrgPost component is well-structured and provides clear information about the component's features, dependencies, state management, and GraphQL operations.

docs/docs/auto-docs/screens/OrgPost/OrgPost/functions/default.md (1)

11-44: LGTM! Well-structured documentation.

The documentation is comprehensive and clearly describes the component's features, dependencies, state management, and GraphQL operations. The structure makes it easy for developers to understand the component's functionality.

🧰 Tools
🪛 LanguageTool

[grammar] ~34-~34: The word ‘create’ is a verb. Did you mean the noun “creation”?
Context: ...oolean - Controls the visibility of the create post modal. - postformState: object - S...

(PREPOSITION_VERB)

@NishantSinghhhhh
Copy link
Contributor Author

NishantSinghhhhh commented Feb 20, 2025

@palisadoes,

I wanted to inquire whether it is necessary to include the author's name in the posts. I noticed that the query for posts in the talwa-api does not contain a field for creatorId. Could you please provide guidance on this matter?

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 20, 2025
Signed-off-by: NishantSinghhhhh <[email protected]>
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 25, 2025
@NishantSinghhhhh
Copy link
Contributor Author

  1. Try to get the test code coverage as close to 100% as possible.
  2. Posts have been broken for a long time and we can't afford for them to break again.

On it , adding more tests to cover Posts

Signed-off-by: NishantSinghhhhh <[email protected]>
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

♻️ Duplicate comments (7)
src/screens/OrgPost/OrgPost.tsx (4)

173-173: ⚠️ Potential issue

Remove debug console.log statement.

This console.log statement should be removed as it appears to be debugging code that serves no purpose in production.

-console.log(setShowTitle);

248-249: ⚠️ Potential issue

Replace console.error with proper error handling.

Use proper error handling instead of console logging.

-console.error('Organization post list error:', orgPostListError);
-// Add proper error handling here
+toast.error('Failed to fetch organization posts');

349-351: ⚠️ Potential issue

Improve error handling in search function.

Replace console.error with more informative user feedback.

-      console.error('Search error:', error);
-      toast.error('Error searching posts');
+      toast.error(`Error searching posts: ${error instanceof Error ? error.message : 'Unknown error'}`);

174-213: 🛠️ Refactor suggestion

Enhance file validation in handleAddMediaChange.

Add file size validation to prevent large file uploads.

 const handleAddMediaChange = async (
   e: React.ChangeEvent<HTMLInputElement>,
 ): Promise<void> => {
   const selectedFile = e.target.files?.[0];

   if (selectedFile) {
+    // Validate file size (e.g., 5MB limit)
+    const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
+    if (selectedFile.size > MAX_FILE_SIZE) {
+      toast.error('File size exceeds 5MB limit');
+      return;
+    }
+
     // Validate file type
     if (
       !selectedFile.type.startsWith('image/') &&
       !selectedFile.type.startsWith('video/')
     ) {
       toast.error('Please select an image or video file');
       return;
     }

-    if (filteredPosts.length === 0) {
-      console.log('No filtered posts found');
-    }

     // Store the raw file
     setFile(selectedFile);

     // Create preview
     try {
       const base64 = await convertToBase64(selectedFile);
       setPostFormState((prev) => ({
         ...prev,
         addMedia: base64,
       }));
     } catch {
       toast.error('Could not generate preview');
     }
   } else {
     setFile(null);
     setPostFormState((prev) => ({
       ...prev,
       addMedia: '',
     }));
   }
 };
src/screens/OrgPost/OrgPost.spec.tsx (3)

507-533: ⚠️ Potential issue

Fix incorrect file attachment in createPostSuccessMock.

The mock includes a raw File object in the variables, but GraphQL can't serialize File objects directly. This doesn't match how the component would actually send attachments and might lead to misleading test results.

const createPostSuccessMock: MockedResponse = {
  request: {
    query: CREATE_POST_MUTATION,
    variables: {
      input: {
        caption: 'Test Post Title',
        organizationId: '123',
        isPinned: false,
-       attachments: [file],
+       attachments: [expect.any(File)], // Use expect.any() for testing since actual values can't be directly compared
      },
    },
  },
  result: {
    data: {
      createPost: {
        id: '3',
        caption: 'Test Post Title',
        pinnedAt: null,
        attachments: [{ url: 'base64String' }],
        createdAt: new Date().toISOString(),
        updatedAt: new Date().toISOString(),
      },
    },
  },
};

1132-1134: ⚠️ Potential issue

Fix ambiguous assertion in sorting test.

The assertion expect([0, 2]).toContain(captionsNow.length) is ambiguous - it's checking that the length is either 0 or 2 without a clear expectation. This makes the test less reliable.

await waitFor(
  () => {
    const captionsNow = screen.queryAllByTestId('post-caption');
-   expect([0, 2]).toContain(captionsNow.length);
+   expect(captionsNow.length).toBe(2);
  },
  { timeout: 300 },
);

1171-1173: ⚠️ Potential issue

Fix inaccurate assertion in Latest sorting test.

The test for "Latest" sorting option is asserting the same order as for "Oldest" sorting, which is incorrect. The sort order should be reversed for "Latest".

await waitFor(() => {
  const postCaptions = screen
    .getAllByTestId('post-caption')
    .map((el) => el.textContent || '');
-  expect(postCaptions[0]).toContain('Early Post');
-  expect(postCaptions[1]).toContain('Later Post');
+  expect(postCaptions[0]).toContain('Later Post');
+  expect(postCaptions[1]).toContain('Early Post');
});
🧹 Nitpick comments (3)
src/screens/OrgPost/OrgPost.tsx (1)

426-431: Remove commented-out code.

This commented-out code for the SearchingButton component should be removed as it clutters the codebase.

-                {/* <SearchingButton
-                  text="Search" 
-                  dataTestIdPrefix="sort-button"
-                  type="sort" 
-                  className={`${styles.dropdown} `}
-                /> */}
src/screens/OrgPost/OrgPost.spec.tsx (2)

589-614: Reduce timeout values in tests for faster execution.

The timeout values in waitFor calls are unnecessarily high (5000ms). Reducing these timeouts will make the tests run faster without sacrificing reliability.

await waitFor(
  () => {
    expect(
      screen.getByTestId('modalOrganizationHeader'),
    ).toBeInTheDocument();
  },
- { timeout: 5000 },
+ { timeout: 1000 },
);

22-25: Add JSDoc to the test file.

Adding a JSDoc comment to describe the purpose of the test file would improve documentation and make it easier for other developers to understand the test suite.

+/**
+ * Tests for the OrgPost component
+ * 
+ * These tests verify the functionality of the OrgPost component
+ * including post creation, sorting, filtering, and pagination.
+ */
import type { RenderResult } from '@testing-library/react';
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 78c97e6 and 944c2d4.

📒 Files selected for processing (2)
  • src/screens/OrgPost/OrgPost.spec.tsx (2 hunks)
  • src/screens/OrgPost/OrgPost.tsx (10 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test Application
🔇 Additional comments (13)
src/screens/OrgPost/OrgPost.tsx (8)

215-235: Reduce duplication in media handling functions.

The handleVideoAddMediaChange function duplicates much of the logic from handleAddMediaChange. Consider refactoring both into a single function that handles both media types.

+const handleMediaChange = async (
+  e: React.ChangeEvent<HTMLInputElement>,
+  mediaType: 'all' | 'video',
+): Promise<void> => {
+  const selectedFile = e.target.files?.[0];
+  
+  if (!selectedFile) {
+    if (mediaType === 'all') {
+      setFile(null);
+      setPostFormState((prev) => ({
+        ...prev,
+        addMedia: '',
+      }));
+    } else {
+      setVideoFile(null);
+      setVideoPreview('');
+    }
+    return;
+  }
+  
+  // Validate file size
+  const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
+  if (selectedFile.size > MAX_FILE_SIZE) {
+    toast.error('File size exceeds 5MB limit');
+    return;
+  }
+  
+  // Validate file type
+  if (mediaType === 'all') {
+    if (!selectedFile.type.startsWith('image/') && !selectedFile.type.startsWith('video/')) {
+      toast.error('Please select an image or video file');
+      return;
+    }
+    setFile(selectedFile);
+  } else {
+    if (!selectedFile.type.startsWith('video/')) {
+      toast.error('Please select a video file');
+      return;
+    }
+    setVideoFile(selectedFile);
+  }
+  
+  // Create preview
+  try {
+    const base64 = await convertToBase64(selectedFile);
+    if (mediaType === 'all') {
+      setPostFormState((prev) => ({
+        ...prev,
+        addMedia: base64,
+      }));
+    } else {
+      setVideoPreview(base64);
+    }
+  } catch {
+    toast.error(`Could not generate ${mediaType === 'all' ? '' : 'video '}preview`);
+  }
+};
+
+const handleAddMediaChange = (e: React.ChangeEvent<HTMLInputElement>): Promise<void> => 
+  handleMediaChange(e, 'all');
+
+const handleVideoAddMediaChange = (e: React.ChangeEvent<HTMLInputElement>): Promise<void> => 
+  handleMediaChange(e, 'video');

377-410: Streamline pagination logic for different sorting options.

Currently, the pagination logic for sortingOption === 'None' and other sorting options is duplicated and differs significantly, making the code more complex and potentially introducing bugs. Consider centralizing this logic.


272-289: Reduce duplication in post rendering with PostsRenderer component.

The implementation of PostsRenderer to handle various display states is a good improvement, providing consistent rendering of posts across different filtering and sorting states.


129-139: Improved type safety with InterfaceMutationCreatePostInput.

The use of a typed input object for the mutation provides better type safety and documentation of the expected parameters. This is a good improvement over the previous implementation.


68-80: Query implementation aligned with GraphQL schema.

The implementation of the GET_POSTS_BY_ORG query with appropriate input structure and fetchPolicy is correct and follows best practices for GraphQL queries.


119-127: Improved input validation for form submission.

The addition of input validation to check for empty title and valid organization ID before submission helps prevent invalid data from being sent to the server.


324-353: Well-structured search implementation.

The search implementation is well-structured with proper error handling, filtering logic, and user feedback.


537-553:

❓ Verification inconclusive

Ensure file input accepts multiple files.

The multiple={true} attribute is set on the file input, but the handling logic only processes the first file. Either remove the multiple attribute or update the logic to handle multiple files.


🏁 Script executed:

#!/bin/bash
# Check if the mutation supports multiple file uploads

# Look for the mutation definition in the GraphQL mutations file
rg -A 10 "CREATE_POST_MUTATION" src/GraphQl/Mutations/mutations.ts

# Check if there's any code handling multiple files in the component
rg -A 5 "files\.length" src/screens/OrgPost/OrgPost.tsx
rg -A 5 "forEach.*files" src/screens/OrgPost/OrgPost.tsx

Length of output: 424


Action: Update Media File Handler for Accurate Multiple File Support

  • In src/screens/OrgPost/OrgPost.tsx (lines 537–553), the media file input includes multiple={true}, which implies the intent to allow multiple file selection.
  • However, evidence from our searches indicates that the current implementation of the handleAddMediaChange handler does not process more than one file.
  • Please either remove the multiple attribute from the input or update the handleAddMediaChange logic to iterate over and handle all files in event.target.files.
src/screens/OrgPost/OrgPost.spec.tsx (5)

1507-1509: Remove duplicate mock implementations.

There are duplicate mock implementations for errorHandler and convertToBase64. These should be consolidated to avoid confusion and potential inconsistencies.

Since the first implementation of these mocks appears much earlier in the file (lines 29-75), you should remove these duplicate implementations.

Also applies to: 1511-1514


616-637: Enhance test coverage for form submission.

The test case should verify that the mutation is called with the correct variables, the form state is reset after submission, and that the refetch function is called to update the post list.

it('submits the create post form successfully', async () => {
  renderComponent();
  await act(() => new Promise((resolve) => setTimeout(resolve, 0)));
  const openModalBtn = await screen.findByTestId(
    'createPostModalBtn',
    {},
-   { timeout: 5000 },
+   { timeout: 1000 },
  );
  fireEvent.click(openModalBtn);
  const titleInput = screen.getByTestId('modalTitle');
  const infoInput = screen.getByTestId('modalinfo');
  fireEvent.change(titleInput, { target: { value: 'Test Post Title' } });
  fireEvent.change(infoInput, { target: { value: 'Test Post Information' } });
  const submitBtn = screen.getByTestId('createPostBtn');
  fireEvent.click(submitBtn);
  await waitFor(
    () => {
      expect(toast.success).toHaveBeenCalled();
+     // Verify mutation was called with correct variables
+     expect(create).toHaveBeenCalledWith({
+       variables: {
+         input: {
+           caption: 'Test Post Title',
+           organizationId: '123',
+           isPinned: false,
+         },
+       },
+       context: {
+         headers: {
+           'Apollo-Require-Preflight': 'true',
+         },
+       },
+     });
+     // Verify form state was reset
+     expect(titleInput).toHaveValue('');
+     expect(infoInput).toHaveValue('');
+     // Verify refetch was called
+     expect(refetch).toHaveBeenCalled();
    },
-   { timeout: 5000 },
+   { timeout: 1000 },
  );
});

77-86: Good use of data generation for consistent test data.

Creating an array of test posts with a consistent structure is a good practice for test data generation. This makes the tests more maintainable and easier to understand.


1296-1410: Well-structured pagination tests.

The pagination tests are well structured and comprehensive, testing both "None" and custom sorting options, as well as next and previous page functionality. This ensures the pagination feature works correctly across all states.


1412-1505: Thorough search functionality tests.

The search functionality tests cover important aspects like case-insensitive search, integration with PostsRenderer, and proper filtering of results. This is a good example of comprehensive testing.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 25, 2025
Signed-off-by: NishantSinghhhhh <[email protected]>
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

♻️ Duplicate comments (2)
src/screens/OrgPost/OrgPost.spec.tsx (2)

526-527: ⚠️ Potential issue

Fix incorrect file attachment in createPostSuccessMock.

The mock includes a raw File object in the variables, but GraphQL can't serialize File objects directly. This should match how the component actually sends attachments.

      input: {
        caption: 'Test Post Title',
        organizationId: '123',
        isPinned: false,
-       attachments: [file],
+       // This should match how your component sends attachments in the actual implementation
+       // For example, if you're using Apollo Upload Client, you might need special handling
+       attachments: [expect.any(File)],
      },

1171-1183: ⚠️ Potential issue

Fix inaccurate assertion in Latest sorting test.

The test for "Latest" sorting option is asserting the same order as for "Oldest" sorting, which appears to be incorrect. For "Latest" sorting, the most recent posts should appear first.

  it('sorts posts in descending order when "Latest" is selected', async () => {
    const toggleButton = screen.getByTestId('sortpost-toggle');
    userEvent.click(toggleButton);
    const latestOption = await screen.findByText('Latest');
    userEvent.click(latestOption);
    await waitFor(() => {
      const postCaptions = screen
        .getAllByTestId('post-caption')
        .map((el) => el.textContent || '');
-      expect(postCaptions[0]).toContain('Early Post');
-      expect(postCaptions[1]).toContain('Later Post');
+      expect(postCaptions[0]).toContain('Later Post');
+      expect(postCaptions[1]).toContain('Early Post');
    });
  });
🧹 Nitpick comments (3)
src/screens/OrgPost/OrgPost.tsx (2)

173-173: Remove debug console.log statement.

Debug statements should not be present in production code.

-console.log(setShowTitle);

290-323: Simplify sorting logic to avoid code duplication.

The sorting logic is duplicated between this function and the useEffect on lines 253-266. Consider extracting the sorting logic into a reusable function.

+const sortPostsByDate = (posts: InterfacePost[], option: string): InterfacePost[] => {
+  return [...posts].sort((a, b) => {
+    const dateA = new Date(a.createdAt).getTime();
+    const dateB = new Date(b.createdAt).getTime();
+    return option === 'oldest' ? dateA - dateB : dateB - dateA;
+  });
+};

 const handleSorting = (option: string): void => {
   setCurrentPage(1);
   setSortingOption(option);

   if (option === 'None') {
     setDisplayPosts([]);

     refetchPosts({
       input: {
         organizationId: currentUrl,
       },
     });
     return;
   }
   if (!['latest', 'oldest'].includes(option)) {
     return;
   }

   if (loading || error || !data?.postsByOrganization) {
     return;
   }

-  const posts = [...data.postsByOrganization];
-  const sorted = posts.sort((a, b) => {
-    const dateA = new Date(a.createdAt).getTime();
-    const dateB = new Date(b.createdAt).getTime();
-    return option === 'oldest' ? dateA - dateB : dateB - dateA;
-  });
+  const sorted = sortPostsByDate(data.postsByOrganization, option);

   setSortedPosts(sorted);

   const initialPosts = sorted.slice(0, postsPerPage);
   setDisplayPosts(initialPosts);
 };

And in the useEffect:

 useEffect(() => {
   if (data?.postsByOrganization) {
-    const posts = [...data.postsByOrganization];
-
-    // Sort posts based on the selected option
-    const sorted = posts.sort((a, b) => {
-      const dateA = new Date(a.createdAt).getTime();
-      const dateB = new Date(b.createdAt).getTime();
-      return sortingOption === 'oldest' ? dateA - dateB : dateB - dateA;
-    });
+    const sorted = sortPostsByDate(data.postsByOrganization, sortingOption);

     setSortedPosts(sorted);
   }
 }, [data, sortingOption]);
src/screens/OrgPost/OrgPost.spec.tsx (1)

81-84: Remove duplicate mock for convertToBase64.

The convertToBase64 mock is defined twice (first at lines 44-47). Remove this duplicate definition.

-vi.mock('utils/convertToBase64', () => ({
-  default: vi.fn().mockResolvedValue('base64String'),
-}));
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 944c2d4 and 7ac2485.

📒 Files selected for processing (2)
  • src/screens/OrgPost/OrgPost.spec.tsx (2 hunks)
  • src/screens/OrgPost/OrgPost.tsx (10 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test Application
🔇 Additional comments (6)
src/screens/OrgPost/OrgPost.tsx (5)

189-191: Remove unnecessary console logging and conditional logic.

This check and logging statement is unnecessary and should be removed.

-      if (filteredPosts.length === 0) {
-        console.log('No filtered posts found');
-      }

248-249: Remove console.log statement and implement proper error handling.

Replace console.error with proper error handling.

-      console.error('Organization post list error:', orgPostListError);
-      // Add proper error handling here
+      toast.error('Failed to fetch organization posts');

349-351: Improve error handling in search function.

Replace console.error with more informative user feedback.

-      console.error('Search error:', error);
-      toast.error('Error searching posts');
+      toast.error(`Error searching posts: ${error instanceof Error ? error.message : 'Unknown error'}`);
       setIsFiltering(false);

174-213: Reduce duplication between media handling functions.

The handleAddMediaChange and handleVideoAddMediaChange functions duplicate much of the same logic. Consider refactoring these into a single function that handles both media types.

-const handleAddMediaChange = async (
-  e: React.ChangeEvent<HTMLInputElement>,
-): Promise<void> => {
-  const selectedFile = e.target.files?.[0];
-
-  if (selectedFile) {
-    // Validate file type
-    if (
-      !selectedFile.type.startsWith('image/') &&
-      !selectedFile.type.startsWith('video/')
-    ) {
-      toast.error('Please select an image or video file');
-      return;
-    }
-
-    if (filteredPosts.length === 0) {
-      console.log('No filtered posts found');
-    }
-
-    // Store the raw file
-    setFile(selectedFile);
-
-    // Create preview
-    try {
-      const base64 = await convertToBase64(selectedFile);
-      setPostFormState((prev) => ({
-        ...prev,
-        addMedia: base64,
-      }));
-    } catch {
-      toast.error('Could not generate preview');
-    }
-  } else {
-    setFile(null);
-    setPostFormState((prev) => ({
-      ...prev,
-      addMedia: '',
-    }));
-  }
-};
-
-const handleVideoAddMediaChange = async (
-  e: React.ChangeEvent<HTMLInputElement>,
-): Promise<void> => {
-  const selectedFile = e.target.files?.[0];
-  if (selectedFile) {
-    if (!selectedFile.type.startsWith('video/')) {
-      toast.error('Please select a video file');
-      return;
-    }
-    setVideoFile(selectedFile);
-    try {
-      const base64 = await convertToBase64(selectedFile);
-      setVideoPreview(base64);
-    } catch {
-      toast.error('Could not generate video preview');
-    }
-  } else {
-    setVideoFile(null);
-    setVideoPreview('');
-  }
-};
+const handleMediaChange = async (
+  e: React.ChangeEvent<HTMLInputElement>,
+  mediaType: 'all' | 'video',
+): Promise<void> => {
+  const selectedFile = e.target.files?.[0];
+  
+  if (!selectedFile) {
+    if (mediaType === 'all') {
+      setFile(null);
+      setPostFormState((prev) => ({
+        ...prev,
+        addMedia: '',
+      }));
+    } else {
+      setVideoFile(null);
+      setVideoPreview('');
+    }
+    return;
+  }
+  
+  // Validate file size
+  const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
+  if (selectedFile.size > MAX_FILE_SIZE) {
+    toast.error('File size exceeds 5MB limit');
+    return;
+  }
+  
+  // Validate file type
+  if (mediaType === 'all') {
+    if (!selectedFile.type.startsWith('image/') && !selectedFile.type.startsWith('video/')) {
+      toast.error('Please select an image or video file');
+      return;
+    }
+    setFile(selectedFile);
+  } else {
+    if (!selectedFile.type.startsWith('video/')) {
+      toast.error('Please select a video file');
+      return;
+    }
+    setVideoFile(selectedFile);
+  }
+  
+  // Create preview
+  try {
+    const base64 = await convertToBase64(selectedFile);
+    if (mediaType === 'all') {
+      setPostFormState((prev) => ({
+        ...prev,
+        addMedia: base64,
+      }));
+    } else {
+      setVideoPreview(base64);
+    }
+  } catch {
+    toast.error(`Could not generate ${mediaType === 'all' ? '' : 'video '}preview`);
+  }
+};
+
+const handleAddMediaChange = (e: React.ChangeEvent<HTMLInputElement>): Promise<void> => 
+  handleMediaChange(e, 'all');
+
+const handleVideoAddMediaChange = (e: React.ChangeEvent<HTMLInputElement>): Promise<void> => 
+  handleMediaChange(e, 'video');

Also applies to: 215-235


536-536: Consider removing multiple attribute or handle multiple files properly.

The multiple attribute is set to true, but the code only processes the first selected file. Either remove the attribute or update the file handling logic to support multiple files.

-              multiple={true}
+              multiple={false}
src/screens/OrgPost/OrgPost.spec.tsx (1)

1142-1143: Fix ambiguous assertion in sorting test.

The assertion is ambiguous - it's checking that the length is either 0 or 2 without a clear expectation.

-        expect([0, 2]).toContain(captionsNow.length);
+        expect(captionsNow.length).toBe(2);

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 25, 2025
Signed-off-by: NishantSinghhhhh <[email protected]>
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

♻️ Duplicate comments (6)
src/screens/OrgPost/OrgPost.tsx (2)

246-247: 🛠️ Refactor suggestion

Replace console.error with proper error handling.

Replace the console.error statement with proper error handling to provide feedback to the user.

-console.error('Organization post list error:', orgPostListError);
-// Add proper error handling here
+toast.error('Failed to fetch organization posts');

347-349: 🛠️ Refactor suggestion

Improve error handling in search function.

Replace console.error with more informative user feedback.

-console.error('Search error:', error);
-toast.error('Error searching posts');
+toast.error(`Error searching posts: ${error instanceof Error ? error.message : 'Unknown error'}`);
src/screens/OrgPost/OrgPost.spec.tsx (4)

560-569: ⚠️ Potential issue

Fix incorrect file attachment handling in test mock.

The mock is passing a raw File object to GraphQL mutation, but GraphQL can't directly serialize a File object. This should match how your component actually sends files.

A GraphQL mutation cannot directly accept a File object. The implementation should match how your application actually handles file uploads, typically using a multipart form or base64 encoding.

const createPostSuccessMock: MockedResponse = {
  request: {
    query: CREATE_POST_MUTATION,
    variables: {
      input: {
        caption: 'Test Post Title',
        organizationId: '123',
        isPinned: false,
-       attachments: [file],
+       // Match how your application actually handles file uploads
+       attachments: ['base64String'], // If using base64 encoding
      },
    },
  },
  // ...
};

Consider reviewing how file uploads are actually handled in your application.


1240-1242: 🛠️ Refactor suggestion

Fix ambiguous assertion in sorting test.

The assertion expect([0, 2]).toContain(captionsNow.length) is ambiguous - it's checking that the length is either 0 or 2 without a clear expectation.

await waitFor(
  () => {
    const captionsNow = screen.queryAllByTestId('post-caption');
-   expect([0, 2]).toContain(captionsNow.length);
+   // Be more specific about what you expect
+   expect(captionsNow.length).toBe(2);
  },
  { timeout: 300 },
);

1270-1282: ⚠️ Potential issue

Fix incorrect post sorting assertion in "Latest" sort test.

The test for "Latest" sorting is checking the same order as "Oldest" sorting, which is incorrect. Latest posts should appear first.

it('sorts posts in descending order when "Latest" is selected', async () => {
  const toggleButton = screen.getByTestId('sortpost-toggle');
  userEvent.click(toggleButton);
  const latestOption = await screen.findByText('Latest');
  userEvent.click(latestOption);
  await waitFor(() => {
    const postCaptions = screen
      .getAllByTestId('post-caption')
      .map((el) => el.textContent || '');
-    expect(postCaptions[0]).toContain('Early Post');
-    expect(postCaptions[1]).toContain('Later Post');
+    expect(postCaptions[0]).toContain('Later Post');
+    expect(postCaptions[1]).toContain('Early Post');
  });
});

1284-1292: 🛠️ Refactor suggestion

Improve the invalid sorting option test.

The current test for ignoring invalid sorting options doesn't actually test an invalid option - it only checks the initial state without attempting to set an invalid option.

it('ignores invalid sorting options and leaves posts order unchanged', async () => {
+  // Save initial post order
+  let initialOrder: string[] = [];
+  await waitFor(() => {
+    initialOrder = screen
+      .getAllByTestId('post-caption')
+      .map((el) => el.textContent || '');
+  });
+  
+  // Simulate an invalid sort option by manipulating the component's state
+  const toggleButton = screen.getByTestId('sortpost-toggle');
+  userEvent.click(toggleButton);
+  // Instead of selecting a valid option, click elsewhere to close dropdown
+  fireEvent.click(document.body);
+  
  await waitFor(() => {
    const postCaptions = screen
      .getAllByTestId('post-caption')
      .map((el) => el.textContent || '');
-    expect(postCaptions[0]).toContain('Early Post');
-    expect(postCaptions[1]).toContain('Later Post');
+    // Verify posts remain in the original order
+    expect(postCaptions).toEqual(initialOrder);
  });
});
🧹 Nitpick comments (4)
src/screens/OrgPost/OrgPost.tsx (3)

173-173: Remove debug console.log statement.

Debug console.log statements should not be present in production code.

-console.log(setShowTitle);

174-233: Reduce duplication between media handling functions.

The handleAddMediaChange and handleVideoAddMediaChange functions share significant logic. Consider refactoring them into a single function with a mediaType parameter.

-const handleAddMediaChange = async (
-  e: React.ChangeEvent<HTMLInputElement>,
-): Promise<void> => {
-  const selectedFile = e.target.files?.[0];
-
-  if (selectedFile) {
-    // Validate file type
-    if (
-      !selectedFile.type.startsWith('image/') &&
-      !selectedFile.type.startsWith('video/')
-    ) {
-      toast.error('Please select an image or video file');
-      return;
-    }
-
-    if (filteredPosts.length === 0) {
-      console.log('No filtered posts found');
-    }
-
-    // Store the raw file
-    setFile(selectedFile);
-
-    // Create preview
-    try {
-      const base64 = await convertToBase64(selectedFile);
-      setPostFormState((prev) => ({
-        ...prev,
-        addMedia: base64,
-      }));
-    } catch {
-      toast.error('Could not generate preview');
-    }
-  } else {
-    setFile(null);
-    setPostFormState((prev) => ({
-      ...prev,
-      addMedia: '',
-    }));
-  }
-};
-
-const handleVideoAddMediaChange = async (
-  e: React.ChangeEvent<HTMLInputElement>,
-): Promise<void> => {
-  const selectedFile = e.target.files?.[0];
-  if (selectedFile) {
-    if (!selectedFile.type.startsWith('video/')) {
-      toast.error('Please select a video file');
-      return;
-    }
-    setVideoFile(selectedFile);
-    try {
-      const base64 = await convertToBase64(selectedFile);
-      setVideoPreview(base64);
-    } catch {
-      toast.error('Could not generate video preview');
-    }
-  } else {
-    setVideoFile(null);
-    setVideoPreview('');
-  }
-};
+const handleMediaChange = async (
+  e: React.ChangeEvent<HTMLInputElement>,
+  isVideo = false,
+): Promise<void> => {
+  const selectedFile = e.target.files?.[0];
+  
+  if (!selectedFile) {
+    if (isVideo) {
+      setVideoFile(null);
+      setVideoPreview('');
+    } else {
+      setFile(null);
+      setPostFormState((prev) => ({
+        ...prev,
+        addMedia: '',
+      }));
+    }
+    return;
+  }
+  
+  // Validate file type
+  if (isVideo) {
+    if (!selectedFile.type.startsWith('video/')) {
+      toast.error('Please select a video file');
+      return;
+    }
+    setVideoFile(selectedFile);
+  } else {
+    if (!selectedFile.type.startsWith('image/') && !selectedFile.type.startsWith('video/')) {
+      toast.error('Please select an image or video file');
+      return;
+    }
+    setFile(selectedFile);
+  }
+  
+  // Create preview
+  try {
+    const base64 = await convertToBase64(selectedFile);
+    if (isVideo) {
+      setVideoPreview(base64);
+    } else {
+      setPostFormState((prev) => ({
+        ...prev,
+        addMedia: base64,
+      }));
+    }
+  } catch {
+    toast.error(isVideo ? 'Could not generate video preview' : 'Could not generate preview');
+  }
+};
+
+const handleAddMediaChange = (e: React.ChangeEvent<HTMLInputElement>): Promise<void> => 
+  handleMediaChange(e, false);
+
+const handleVideoAddMediaChange = (e: React.ChangeEvent<HTMLInputElement>): Promise<void> => 
+  handleMediaChange(e, true);

189-191: Remove unnecessary console logging and conditional check.

This check for empty filtered posts and the console logging is unnecessary and should be removed.

-if (filteredPosts.length === 0) {
-  console.log('No filtered posts found');
-}
src/screens/OrgPost/OrgPost.spec.tsx (1)

644-665: Enhance test coverage for form submission.

The form submission test should verify that the mutation is called with correct variables, form state is reset, and the posts list is refetched.

it('submits the create post form successfully', async () => {
  renderComponent();
  await act(() => new Promise((resolve) => setTimeout(resolve, 0)));
  const openModalBtn = await screen.findByTestId(
    'createPostModalBtn',
    {},
    { timeout: 5000 },
  );
  fireEvent.click(openModalBtn);
  const titleInput = screen.getByTestId('modalTitle');
  const infoInput = screen.getByTestId('modalinfo');
  fireEvent.change(titleInput, { target: { value: 'Test Post Title' } });
  fireEvent.change(infoInput, { target: { value: 'Test Post Information' } });
  const submitBtn = screen.getByTestId('createPostBtn');
  fireEvent.click(submitBtn);
  await waitFor(
    () => {
      expect(toast.success).toHaveBeenCalled();
+     
+     // Verify form is reset
+     expect(titleInput).toHaveValue('');
+     expect(infoInput).toHaveValue('');
+     
+     // Verify modal is closed
+     expect(screen.queryByTestId('modalOrganizationHeader')).not.toBeInTheDocument();
    },
    { timeout: 5000 },
  );
});
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7ac2485 and a893427.

📒 Files selected for processing (2)
  • src/screens/OrgPost/OrgPost.spec.tsx (2 hunks)
  • src/screens/OrgPost/OrgPost.tsx (10 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test Application
  • GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (1)
src/screens/OrgPost/OrgPost.tsx (1)

534-549: Consider consolidating media upload inputs.

Having separate file inputs for general media and video could confuse users since the general media input already accepts videos. Consider consolidating these or clearly differentiating their purposes in the UI.

Do you intend to have two separate upload controls for media (images/videos) and videos specifically? If this is intentional, consider adding clearer labels or instructions to explain the difference between these inputs to users.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 25, 2025
@NishantSinghhhhh
Copy link
Contributor Author

NishantSinghhhhh commented Feb 25, 2025

Screenshot from 2025-02-26 04-12-54
Screenshot from 2025-02-26 04-13-02

@palisadoes Sir only these 2 chunk of codes are left I will try adding code around afternoon and make the coverage above 90%

Signed-off-by: NishantSinghhhhh <[email protected]>
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

♻️ Duplicate comments (2)
src/screens/OrgPost/OrgPost.tsx (2)

246-247: 🛠️ Refactor suggestion

Implement proper error handling.

Replace the console.error with proper user feedback for organization post list errors.

-console.error('Organization post list error:', orgPostListError);
-// Add proper error handling here
+toast.error('Failed to fetch organization posts');

319-347: 🛠️ Refactor suggestion

Improve error handling in search function.

The current implementation logs errors to console. Consider providing more informative user feedback.

-      console.error('Search error:', error);
-      toast.error('Error searching posts');
+      toast.error(`Error searching posts: ${error instanceof Error ? error.message : 'Unknown error'}`);
🧹 Nitpick comments (1)
src/screens/OrgPost/OrgPost.tsx (1)

582-608: Duplicate preview handling logic.

The video preview handling duplicates much of the logic from the general media preview handling. Consider consolidating these into a reusable component or function.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a893427 and cbcdb76.

📒 Files selected for processing (2)
  • docs/docs/auto-docs/screens/OrgPost/OrgPost/functions/default.md (1 hunks)
  • src/screens/OrgPost/OrgPost.tsx (10 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test Application
  • GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (18)
docs/docs/auto-docs/screens/OrgPost/OrgPost/functions/default.md (2)

9-9: Documentation correctly updated with new function definition location.

The file path has been updated to reflect the new location of the OrgPost component function at line 36 in the source file.


11-12: Clear component description added.

The added description appropriately explains the component's purpose in a concise manner, improving documentation quality.

src/screens/OrgPost/OrgPost.tsx (16)

22-27: Interfaces properly imported from dedicated type file.

Moving the interfaces to a separate type file and importing them follows good TypeScript practices for code organization and reusability.


29-32: JSDoc added to resolve previous TSDoc issue.

The added JSDoc comment resolves the pipeline warning mentioned in previous reviews about missing documentation.


34-34: Component name appropriately changed to follow React conventions.

Renaming from orgPost to OrgPost follows React component naming conventions (PascalCase).


51-67: Comprehensive state management added for pagination and filtering.

The addition of state variables for sorting, pagination, filtering, and search improves component functionality and user experience.


68-80: New query implementation for fetching organization posts.

The implementation of GET_POSTS_BY_ORG with proper variables structure and network-only fetch policy ensures fresh data is retrieved when needed.


119-139: Improved error handling and type safety in createPost function.

The enhanced validation for title and organizationId, along with properly typed input object, improves reliability and type safety.


173-173: Remove debug console.log statement.

This debug statement should be removed from production code.

-console.log(setShowTitle);

174-211: Enhance file validation in handleAddMediaChange.

The current implementation validates file type but lacks size validation, which could lead to performance issues with large files.

const handleAddMediaChange = async (
  e: React.ChangeEvent<HTMLInputElement>,
): Promise<void> => {
  const selectedFile = e.target.files?.[0];

  if (selectedFile) {
+    // Validate file size (e.g., 5MB limit)
+    const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
+    if (selectedFile.size > MAX_FILE_SIZE) {
+      toast.error('File size exceeds 5MB limit');
+      return;
+    }

    // Validate file type
    if (
      !selectedFile.type.startsWith('image/') &&
      !selectedFile.type.startsWith('video/')
    ) {
      toast.error('Please select an image or video file');
      return;
    }

-    if (filteredPosts.length === 0) {
-      console.log('No filtered posts found');
-    }

    // Store the raw file
    setFile(selectedFile);

213-233: Reduce duplication between media handling functions.

The handleVideoAddMediaChange function duplicates much of the logic from handleAddMediaChange. Consider consolidating these into a single function with a media type parameter.


235-242: Appropriate useEffect for pagination.

This effect correctly handles pagination when sorting is active, ensuring the proper subset of posts is displayed.


251-264: Well-structured sorting effect.

The effect for sorting posts is well-structured and efficiently handles different sorting options.


270-287: Component extraction for post rendering.

Extracting the post rendering logic to a separate component improves code organization and maintainability.


288-317: Comprehensive sorting implementation.

The sorting implementation is well-structured, providing a clear way to handle different sorting options and update the displayed posts accordingly.


349-365: Well-structured pagination state management.

The pagination state management correctly handles different sorting states, ensuring consistent behavior regardless of the active sorting option.


369-386: Comprehensive pagination handlers.

Both handleNextPage and handlePreviousPage functions correctly handle pagination for different sorting states, properly updating cursors and page states.

Also applies to: 388-404


536-545: Review video upload field duplication.

There are two separate file upload fields - one for all media and one specifically for videos. Consider whether this duplication is necessary or if a single field with appropriate type validation would suffice.

Is there a specific requirement for having separate upload fields for general media and videos? This might cause confusion for users.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 26, 2025
Signed-off-by: NishantSinghhhhh <[email protected]>
@NishantSinghhhhh
Copy link
Contributor Author

@palisadoes,

Sir,
I've maximized the test coverage as much as possible at this point. I've attempted to add tests for the two problematic code sections, but they still aren't getting covered. Could you please review and merge this PR?

@github-project-automation github-project-automation bot moved this from In review to Ready in NoMongo: Talawa-Admin Feb 27, 2025
@palisadoes palisadoes merged commit 9934f56 into PalisadoesFoundation:develop-postgres Feb 27, 2025
19 checks passed
@github-project-automation github-project-automation bot moved this from Ready to Done in NoMongo: Talawa-Admin Feb 27, 2025
@NishantSinghhhhh
Copy link
Contributor Author

@palisadoes , I will be raising 1 more PR in Talawa-api, as I have added some queries there , should I raise 1 issue for it First pr should I directly make a PR

@palisadoes
Copy link
Contributor

If the API changes are related, then create a PR there and reference this PR its related issue

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

Successfully merging this pull request may close these issues.

2 participants