-
-
Notifications
You must be signed in to change notification settings - Fork 888
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
NoMongo: Postgres Migration Support for POST in orgDashboard #3707
Conversation
Signed-off-by: NishantSinghhhhh <[email protected]>
WalkthroughThis 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
Possibly related PRs
Suggested labels
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Pro Plan! Simply use the command 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (18)
✨ Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (1)
src/screens/OrgPost/OrgPost.tsx (1)
72-73
: Guard or remove console logs in productionMultiple
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
📒 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 valuesChanging
$first
and$last
from aPositiveInt
type to a standardInt
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 goodUsing
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 namingThe use of
id
on both the post and thecreator
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 OrgPostCardImporting dedicated components for empty states and post rendering is a neat approach. This improves modularity.
328-329
: Pagination logic is well-structuredDisabling “Next” or “Previous” navigation based on
hasNextPage
orhasPreviousPage
helps prevent invalid pagination requests.Also applies to: 340-341
Signed-off-by: NishantSinghhhhh <[email protected]>
…in into NoMongo-Post
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
📒 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:
- Using a single input object for better type safety
- 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)
|
Sure once , I am done restoring the functionality, I will change the tests accordingly |
Signed-off-by: NishantSinghhhhh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 StructureThe 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 populatescurrentUser
and leavesunassignUserTag
asundefined
.- Case 2: Conversely, with
variables: { id: undefined; tagId: string; userId: string; }
, the response populatesunassignUserTag
(with its_id
) and setscurrentUser
toundefined
.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 HeadingThe 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 HeadingThe 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 HeadingThe 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 DetailsThe variable
ERROR_MOCK
is clearly declared with its type (object[]
) and is highlighted using markdown formatting. Consider verifying if the escape character inERROR\_MOCK
is necessary for correct rendering; it might be possible to simplify it toERROR_MOCK
.docs/docs/auto-docs/screens/MemberDetail/MemberDetail/functions/default.md (1)
12-13
: Refactor Sentence Openings for Improved ReadabilityBoth 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 SectionThe 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 DescriptionThe 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 FormattingThe 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 theresult.data.updateCurrentUser
object with type annotations and default values. The nested subsections (e.g., foraddressLine1
,avatarMimeType
,createdAt
, etc.) facilitate easy reference. As a future improvement, consider revisiting the properties typed asany
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 forMOCK_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: Insrc/screens/ManageTag/ManageTagMocks.ts
, when mocking data forUSER_TAGS_ASSIGNED_MEMBERS
andUSER_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 -->
Signed-off-by: NishantSinghhhhh <[email protected]>
…in into NoMongo-Post
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
- Add file size validation
- Use more specific error messages
- 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
📒 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)
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 |
Signed-off-by: NishantSinghhhhh <[email protected]>
…in into NoMongo-Post
Signed-off-by: NishantSinghhhhh <[email protected]>
On it , adding more tests to cover Posts |
Signed-off-by: NishantSinghhhhh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (7)
src/screens/OrgPost/OrgPost.tsx (4)
173-173
:⚠️ Potential issueRemove 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 issueReplace 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 issueImprove 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 suggestionEnhance 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 issueFix 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 issueFix 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 issueFix 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
📒 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 fromhandleAddMediaChange
. 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 themultiple
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.tsxLength 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 thehandleAddMediaChange
logic to iterate over and handle all files inevent.target.files
.src/screens/OrgPost/OrgPost.spec.tsx (5)
1507-1509
: Remove duplicate mock implementations.There are duplicate mock implementations for
errorHandler
andconvertToBase64
. 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.
Signed-off-by: NishantSinghhhhh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
src/screens/OrgPost/OrgPost.spec.tsx (2)
526-527
:⚠️ Potential issueFix 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 issueFix 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
📒 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
andhandleVideoAddMediaChange
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);
Signed-off-by: NishantSinghhhhh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (6)
src/screens/OrgPost/OrgPost.tsx (2)
246-247
: 🛠️ Refactor suggestionReplace 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 suggestionImprove 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 issueFix 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 suggestionFix 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 issueFix 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 suggestionImprove 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
andhandleVideoAddMediaChange
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
📒 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.
@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]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (2)
src/screens/OrgPost/OrgPost.tsx (2)
246-247
: 🛠️ Refactor suggestionImplement 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 suggestionImprove 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
📒 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
toOrgPost
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 fromhandleAddMediaChange
. 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
andhandlePreviousPage
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.
Signed-off-by: NishantSinghhhhh <[email protected]>
Sir, |
9934f56
into
PalisadoesFoundation:develop-postgres
@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 |
If the API changes are related, then create a PR there and reference this PR its related issue |
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:
Does this PR introduce a breaking change?
No
Checklist
CodeRabbit AI Review
Test Coverage
Other information
N/A
Have you read the contributing guide?
Yes
Summary by CodeRabbit
New Features
GET_POSTS_BY_ORG
andGET_USER_BY_ID
.PostsRenderer
component for rendering organization posts.SearchingButton
component for improved search functionality.Documentation
Refactor
OrgPostCard
andPostsRenderer
components.