8000 User profile page adding Causes tab by kkatusic · Pull Request #5152 · Giveth/giveth-dapps-v2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

User profile page adding Causes tab #5152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2025
Merged

User profile page adding Causes tab #5152

merged 1 commit into from
Jul 7, 2025

Conversation

kkatusic
Copy link
Collaborator
@kkatusic kkatusic commented Jul 7, 2025

Missing this:

Screenshot 2025-07-07 at 16 25 32

and this:

Uploading Screenshot 2025-07-07 at 16.31.10.png…

Summary by CodeRabbit

  • New Features

    • Added a dedicated "My Causes" section and navigation in user profiles and menus.
    • Enhanced project and cause listings to display distinct labels, status, and statistics based on type.
    • Introduced new UI elements for causes, including total distributed funds and project counts.
  • Improvements

    • Updated localization with new labels for imp 8000 roved clarity in cause and project-related UI.
    • Project actions and navigation now adapt based on whether an item is a cause or a project.
    • Profile tabs and routes expanded to support direct access to causes.
  • Bug Fixes

    • Ensured correct routing and display for cause and project links throughout the user interface.

Copy link
vercel bot commented Jul 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
giveth-dapps-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 7, 2025 2:36pm

Copy link
Contributor
coderabbitai bot commented Jul 7, 2025

Walkthrough

This change introduces new localization labels for causes and projects, updates GraphQL queries to include project type, and adjusts UI components to differentiate between causes and projects. It adds a "My Causes" menu item, refines tab and dropdown logic, and updates routing and displ 8000 ay logic to support distinct handling of causes alongside projects.

Changes

File(s) Change Summary
lang/en.json Added new English localization labels for causes and projects.
src/apollo/gql/gqlPowerBoosting.ts Updated GraphQL query to include projectType in fetched project data.
src/lib/constants/Routes.ts Added new route and tab for "My Causes" in the profile tabs and routes.
src/components/menu/UserItems.tsx Added "My Causes" menu item to the wallet menu.
src/components/views/userProfile/ProfileContributes.tsx Tab label for causes now uses "My Causes" for the current user and displays a count badge when applicable.
src/components/views/userProfile/causesTab/ProfileCausesTab.tsx Changed React Query cache key from "dashboard-projects" to "dashboard-causes".
src/components/views/userProfile/boostedTab/BoostsTable.tsx Project title links now route differently based on project type (cause or project).
src/components/views/userProfile/projectsTab/ProjectActions.tsx Dropdown options and actions now conditionally adjust labels and navigation for causes vs. projects.
src/components/views/userProfile/projectsTab/ProjectItem.tsx Display and routing logic updated to differentiate between causes and projects, with new UI elements for causes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant GraphQL API

    User->>UI: Open Profile or Menu
    UI->>UI: Determine if viewing Causes or Projects
    UI->>GraphQL API: Fetch data (including projectType)
    GraphQL API-->>UI: Return projects/causes with projectType
    UI->>UI: Render menu/tab/routes based on type
    UI->>User: Display "My Causes" or "My Projects" with correct links and labels
Loading

Possibly related PRs

Suggested labels

Code Review

Suggested reviewers

  • divine-comedian
  • maryjaf
  • ae2079

Poem

A rabbit hopped through fields of code,
Adding labels for causes, a brand new road.
Now "My Causes" shine in the menu bright,
With routes and tabs that feel just right.
Projects and causes, side by side,
In Giveth’s garden, they now reside!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

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

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (3)
lang/en.json (2)

832-832: Align key naming with existing pattern

"label.project_listed_on_public_site" mixes “project” directly into the key instead of following the existing label.project.* dot-notation (e.g. label.project.status). For consistency, consider:

-"label.project_listed_on_public_site": "Listed on public site",
+"label.project.listed_publicly": "Listed publicly",

…and update the consuming components accordingly.


1945-1949: Remember to propagate new keys to other locale files

The five newly-added Cause keys (your_cause_has_been_published, my_causes, listed_publicly, view_cause, total_distributed) are currently English-only.
Add stubs to the other locale JSONs (lang/es.json, lang/de.json, etc.) to prevent runtime fallbacks or missing-string warnings.

src/components/views/userProfile/projectsTab/ProjectActions.tsx (1)

141-159: Verify array splice indices for option insertion

The code uses hardcoded splice indices to insert options. This approach could be brittle if the base options array structure changes.

Consider using a more robust approach like:

-if (!isCause) {
-	options.splice(1, 0, {
-		label: formatMessage({ id: 'label.add_update' }),
-		icon: <IconUpdate16 />,
-		cb: () =>
-			router.push(slugToProjectView(project.slug) + '?tab=updates'),
-	});
-
-	options.splice(3, 0, {
-		label: capitalizeAllWords(
-			formatMessage({ id: 'label.manage_addresses' }),
-		),
-		icon: <IconWalletOutline16 />,
-		cb: () => {
-			setSelectedProject(project);
-			setShowAddressModal(true);
-		},
-	});
-}
+// Insert after edit option
+if (!isCause) {
+	const editIndex = options.findIndex(opt => opt.icon?.type === IconEdit16);
+	options.splice(editIndex + 1, 0, {
+		label: formatMessage({ id: 'label.add_update' }),
+		icon: <IconUpdate16 />,
+		cb: () =>
+			router.push(slugToProjectView(project.slug) + '?tab=updates'),
+	});
+
+	// Insert after activate/deactivate option
+	const activateIndex = options.findIndex(opt => opt.icon?.type === IconArchiving);
+	options.splice(activateIndex + 1, 0, {
+		label: capitalizeAllWords(
+			formatMessage({ id: 'label.manage_addresses' }),
+		),
+		icon: <IconWalletOutline16 />,
+		cb: () => {
+			setSelectedProject(project);
+			setShowAddressModal(true);
+		},
+	});
+}

Or alternatively, build the options array conditionally from the start.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68103a6 and f0d5c4b.

📒 Files selected for processing (9)
  • lang/en.json (3 hunks)
  • src/apollo/gql/gqlPowerBoosting.ts (1 hunks)
  • src/components/menu/UserItems.tsx (1 hunks)
  • src/components/views/userProfile/ProfileContributes.tsx (1 hunks)
  • src/components/views/userProfile/boostedTab/BoostsTable.tsx (2 hunks)
  • src/components/views/userProfile/causesTab/ProfileCausesTab.tsx (1 hunks)
  • src/components/views/userProfile/projectsTab/ProjectActions.tsx (7 hunks)
  • src/components/views/userProfile/projectsTab/ProjectItem.tsx (7 hunks)
  • src/lib/constants/Routes.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
src/components/views/userProfile/causesTab/ProfileCausesTab.tsx (1)
src/components/views/userProfile/projectsTab/constants.ts (1)
  • projectsOrder (6-9)
src/components/views/userProfile/boostedTab/BoostsTable.tsx (1)
src/lib/routeCreators.ts (2)
  • slugToCauseView (42-42)
  • slugToProjectView (3-5)
src/components/views/userProfile/projectsTab/ProjectItem.tsx (1)
src/helpers/number.ts (1)
  • formatDonation (53-75)
src/components/views/userProfile/projectsTab/ProjectActions.tsx (2)
src/lib/routeCreators.ts (4)
  • slugToCauseView (42-42)
  • slugToProjectView (3-5)
  • idToCauseEdit (27-29)
  • idToProjectEdit (23-25)
src/lib/helpers.ts (1)
  • capitalizeAllWords (331-333)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (21)
src/lib/constants/Routes.ts (2)

14-14: LGTM: Consistent with existing tab patterns

The new causes tab follows the same naming convention and structure as existing profile tabs.


74-74: LGTM: Route construction follows established pattern

The MyCauses route is constructed consistently with other profile routes like MyProjects and MyDonations.

src/components/menu/UserItems.tsx (1)

151-155: LGTM: Menu item follows established pattern

The new "My Causes" menu item is properly structured with the correct properties and logical placement in the menu array.

src/components/views/userProfile/causesTab/ProfileCausesTab.tsx (1)

29-29: LGTM: Query key change ensures proper data isolation

Changing the query key from 'dashboard-projects' to 'dashboard-causes' is appropriate for the causes tab and prevents cache conflicts between projects and causes data.

src/apollo/gql/gqlPowerBoosting.ts (1)

74-74: LGTM: projectType field addition enables cause/project differentiation

Adding the projectType field to the GraphQL query is necessary for components to conditionally handle projects and causes differently.

src/components/views/userProfile/boostedTab/BoostsTable.tsx (1)

34-34: LGTM: Appropriate imports for new functionality

The imports for slugToCauseView and EProjectType are correctly added to support the conditional routing logic.

Also applies to: 42-42

src/components/views/userProfile/ProfileContributes.tsx (1)

131-140: Verify causes count data source

The badge in ProfileContributes.tsx (lines 131–140) currently uses user?.projectsCount, which represents total projects rather than causes. Our type definitions don’t include a causesCount field. Please confirm one of the following:

  • There is a dedicated causes count on the user object (e.g. user.causesCount) and update this badge accordingly.
  • Using projectsCount here is intentional (i.e. projects ≡ causes), or adjust the API/schema to expose a proper causes count.

File to review:

  • src/components/views/userProfile/ProfileContributes.tsx (lines 131–140)
src/components/views/userProfile/projectsTab/ProjectItem.tsx (4)

126-143: Verify intentional exclusion of verification status for causes.

The verification status section is only rendered for projects of type PROJECT, not for causes. Please confirm this is intentional behavior.


62-68: LGTM: Conditional routing logic is correct.

The conditional routing based on project type appropriately directs causes to /cause/[slug] and projects to /project/[slug].


85-91: LGTM: Conditional labeling implemented correctly.

The conditional labeling logic properly differentiates between causes and projects using appropriate localization keys.

Also applies to: 97-105


182-198: Confirm the correct data source for “Total Distributed”
I didn’t find a separate totalDistributed (or similarly named) field on the project type, yet the UI uses project.totalDonations for both “Total Raised” and “Total Distributed.” Please verify with the backend/GraphQL schema whether:

  • There is a distinct field for distributed funds that should be used here, or
  • project.totalDonations is indeed intended to represent both values.

• File: src/components/views/userProfile/projectsTab/ProjectItem.tsx
• Lines: 182–198

lang/en.json (1)

1927-1927: Redundant qualifier in key

cause_status_small duplicates cause_status while only changing visual size. This leaks presentation concerns into i18n keys.
If the string is identical to label.cause.cause_status, reuse that key; otherwise, rename with a semantic suffix (e.g. .short or .abbr) that reflects the content, not styling.

src/components/views/userProfile/projectsTab/ProjectActions.tsx (9)

20-20: LGTM: Import addition for project type enum

The import of EProjectType is necessary for the type checking logic introduced later in the component.


23-25: LGTM: Import additions for cause-specific routes

The new route creator imports (idToCauseEdit, slugToCauseView) are properly imported and will be used for cause-specific navigation.


65-65: LGTM: Clean type-based boolean derivation

The isCause boolean is clearly derived from the project type, providing a clean way to conditionally handle causes throughout the component.


104-111: LGTM: Conditional view option with proper routing

The view option correctly uses different labels and routes based on whether the item is a cause or project, maintaining consistent user experience.


114-122: LGTM: Conditional edit option with proper routing

The edit option correctly uses different labels and routes based on whether the item is a cause or project, maintaining consistency with the view option.


127-132: LGTM: Conditional activate/deactivate labels

The activate/deactivate option correctly uses different labels based on whether the item is a cause or project, providing appropriate terminology for each type.


179-180: LGTM: Proper restriction of verification to projects only

The verification logic correctly restricts verification options to projects only (project.projectType === EProjectType.PROJECT), which makes sense as causes likely don't need the same verification process.


237-237: LGTM: Consistent localization usage

The dropdown label now uses the localization system consistently with other labels in the component.


246-246: LGTM: Modal prop updated for cause support

The DeactivateProjectModal now receives the isCause prop, allowing the modal to handle causes appropriately.

Copy link
Collaborator
@CarlosQ96 CarlosQ96 left a comment

Choose a reason for hiding this comment

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

LGTM!

@kkatusic kkatusic merged commit 998fe04 into develop Jul 7, 2025
4 checks passed
@kkatusic kkatusic deleted the user_profile_cause branch July 7, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: QA
Development

Successfully merging this pull request may close these issues.

2 participants
0