Skip to content

Implement generalized solution for cross-field validation#352

Merged
akaia-shadowfox merged 13 commits intomainfrom
fix/258-bug-inconsistent-feedback-form-donation-to-project-field
Feb 26, 2025
Merged

Implement generalized solution for cross-field validation#352
akaia-shadowfox merged 13 commits intomainfrom
fix/258-bug-inconsistent-feedback-form-donation-to-project-field

Conversation

@akaia-shadowfox
Copy link
Copy Markdown
Collaborator

@akaia-shadowfox akaia-shadowfox commented Feb 25, 2025

Summary by CodeRabbit

  • Chores
    • Reorganized the internal file structure by standardizing import paths for UI components, utilities, hooks, and styles to improve maintainability.
  • Enhancements
    • Refined form handling and validation logic with streamlined state management and updated input validation rules, ensuring more consistent error feedback.

@akaia-shadowfox akaia-shadowfox self-assigned this Feb 25, 2025
@akaia-shadowfox akaia-shadowfox linked an issue Feb 25, 2025 that may be closed by this pull request
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 25, 2025

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

Name Status Preview Comments Updated (UTC)
potlock-next-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 1:54pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 25, 2025

Walkthrough

The pull request reorganizes the project’s directory structure by changing many import paths from a general @/common/ui namespace to a more specific @/common/ui/layout namespace. In addition, CSS file paths, alias configurations, and output paths in configuration files have been updated. A constant in the shared configuration is modified from including a default token to being empty, and enhanced form hooks are introduced to streamline validation using Zod. Numerous UI component and hook import paths are updated across common, entities, pages, and layout files.

Changes

File(s) Change Summary
components.json, package.json Updated CSS paths, alias configurations, and output file paths for CSS generation scripts.
src/common/constants.ts Modified PLATFORM_LISTED_TOKEN_IDS from [NATIVE_TOKEN_ID] to an empty array.
src/common/ui/..., src/entities/..., src/layout/..., src/pages/... Reorganized UI modules: updated numerous import paths from "@/common/ui/..." to "@/common/ui/layout/..." for components, SVGs, hooks, and utilities.
src/common/ui/form/hooks/enhanced.ts, src/common/ui/form/hooks/zod-validation.ts, and related donation/pot/profile form hooks Introduced enhanced form hooks integrating Zod-based validation and simplified form state management.

Sequence Diagram(s)

sequenceDiagram
    participant Component as UI Component
    participant EFHook as EnhancedFormHook
    participant RHF as React-Hook-Form
    participant Zod as ZodResolver

    Component->>EFHook: Initialize form with schema & dependentFields
    EFHook->>RHF: Call useForm with ZodResolver
    RHF-->>EFHook: Returns form state
    EFHook->>Zod: Validate data on change/cross-field updates
    Zod-->>EFHook: Return validation results
    EFHook->>Component: Return enhanced form object and state (e.g., isUnpopulated)
Loading

Possibly related PRs

Poem

I’m a rabbit, hopping with glee,
Reorganizing code from A to Z.
Import paths now dance in a new layout hue,
CSS and hooks refreshed anew.
With Zod in our forms, we cheerfully leap,
In a world of clean code, where structure runs deep. 🐇✨

Tip

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

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

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.

…into fix/258-bug-inconsistent-feedback-form-donation-to-project-field
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/entities/pot/models/schemas.ts (1)

58-64: 🛠️ Refactor suggestion

Fix inconsistency in error message for pot_description validation.

The validation uses POT_MIN_NAME_LENGTH for the minimum length check, but the error message uses a hardcoded value of 10. This creates a maintenance issue - if the constant value changes in the future, the error message would become incorrect.

Compare with the pot_name validation on line 49 which consistently uses the constant in both places:

-    .min(POT_MIN_NAME_LENGTH, `Must be at least ${10} characters long.`)
+    .min(POT_MIN_NAME_LENGTH, `Must be at least ${POT_MIN_NAME_LENGTH} characters long.`)
🧹 Nitpick comments (6)
src/features/donation/models/schemas.ts (1)

76-77: TODO should be more specific.

The TODO comment lacks specific information about what needs to be verified and what action is required depending on the outcome.

Consider adding more details to the TODO, such as the issue number and what needs to be fixed if the issue still exists.

src/common/ui/form/hooks/zod-validation.ts (1)

51-77: Consider performance optimizations for the validation hook.

The hook runs validation on every change to any form value, which could lead to performance issues in large forms.

Consider these optimizations:

  1. Debounce the validation to avoid running it on every keystroke
  2. Only run validation when fields in dependentFields actually change, rather than any form value
  3. Add a dependency array to the useEffect that specifically tracks only the relevant fields
-  useEffect(() => {
+  // Only extract the values of dependent fields
+  const relevantValues = dependentFields.reduce((acc, field) => {
+    acc[field] = values[field];
+    return acc;
+  }, {} as Partial<Inputs>);
+
+  useEffect(() => {
     if (dependentFields.length > 0) {
       schema.parseAsync(values).catch((error?: ZodError) =>
         error?.issues.forEach(({ code, message, path }) => {
           const fieldPath = path.at(0);
 
           if (
             dependentFields.includes(fieldPath as keyof Inputs) &&
             typeof fieldPath === "string" &&
             code === "custom"
           ) {
             form.setError(fieldPath as Path<Inputs>, { message, type: code });
           }
         }),
       );
     }
-  }, [schema, form, values, dependentFields]);
+  }, [schema, form, JSON.stringify(relevantValues), dependentFields]);
src/features/profile-setup/hooks/forms.ts (2)

4-4: Consider standardizing form hooks.

You’re importing useForm and useEnhancedForm in the same file. This can be confusing unless both are strictly necessary. Consider using only useEnhancedForm if all validations are handled by enhanced capabilities, or document why both are needed.


195-195: Inconsistent usage of multiple form hooks.

Here, a plain react-hook-form instance is returned while elsewhere useEnhancedForm is used. This is acceptable if separate logic is required, but consider aligning for consistency.

src/entities/_shared/token/components/TokenSelector.tsx (1)

45-46: Enhance native token display.

Using NATIVE_TOKEN_ID.toUpperCase() may be cryptic if the ID is something like "near". Consider providing a more user-friendly label (e.g., "NEAR" if that’s the native token).

src/features/donation/models/effects.ts (1)

234-234: Remove or address the TS error comment.

The // @ts-expect-error WIP suggests an unfinished state. Either resolve the TypeScript error or add a clarifying comment if it's intentionally ignored.

Would you like help resolving the underlying type error?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fad62f6 and d44c8bc.

⛔ Files ignored due to path filters (7)
  • src/common/ui/layout/svg/cart.svg is excluded by !**/*.svg
  • src/common/ui/layout/svg/chef-hat.svg is excluded by !**/*.svg
  • src/common/ui/layout/svg/layers.svg is excluded by !**/*.svg
  • src/common/ui/layout/svg/near.svg is excluded by !**/*.svg
  • src/common/ui/layout/svg/pen.svg is excluded by !**/*.svg
  • src/common/ui/layout/svg/radio-active.svg is excluded by !**/*.svg
  • src/common/ui/layout/svg/radio-inactive.svg is excluded by !**/*.svg
📒 Files selected for processing (168)
  • components.json (1 hunks)
  • package.json (1 hunks)
  • src/common/constants.ts (1 hunks)
  • src/common/ui/form/components/checkbox.tsx (1 hunks)
  • src/common/ui/form/components/select.tsx (1 hunks)
  • src/common/ui/form/components/text.tsx (1 hunks)
  • src/common/ui/form/components/textarea.tsx (3 hunks)
  • src/common/ui/form/hooks/enhanced.ts (1 hunks)
  • src/common/ui/form/hooks/index.ts (1 hunks)
  • src/common/ui/form/hooks/zod-validation.ts (1 hunks)
  • src/common/ui/layout/components/atoms/badge.tsx (1 hunks)
  • src/common/ui/layout/components/atoms/hover-card.tsx (1 hunks)
  • src/common/ui/layout/components/atoms/scroll-area.tsx (1 hunks)
  • src/common/ui/layout/components/atoms/splash-screen.tsx (1 hunks)
  • src/common/ui/layout/components/atoms/table.tsx (1 hunks)
  • src/common/ui/layout/components/atoms/tooltip.tsx (1 hunks)
  • src/common/ui/layout/components/molecules/clipboard-copy-button.tsx (1 hunks)
  • src/common/ui/layout/components/molecules/radio-group.tsx (1 hunks)
  • src/common/ui/layout/components/molecules/social-share.tsx (1 hunks)
  • src/common/ui/layout/components/molecules/toaster.tsx (1 hunks)
  • src/common/wallet/hooks.ts (3 hunks)
  • src/entities/_shared/account/components/AccountFollowButton.tsx (1 hunks)
  • src/entities/_shared/account/components/AccountGroup.tsx (1 hunks)
  • src/entities/_shared/account/components/AccountGroupEditModal.tsx (2 hunks)
  • src/entities/_shared/account/components/AccountHandle.tsx (1 hunks)
  • src/entities/_shared/account/components/AccountListItem.tsx (1 hunks)
  • src/entities/_shared/account/components/AccountProfileLink.tsx (1 hunks)
  • src/entities/_shared/account/components/AccountProfileLinktree.tsx (1 hunks)
  • src/entities/_shared/account/components/AccountSummaryPopup.tsx (1 hunks)
  • src/entities/_shared/account/components/card-skeleton.tsx (1 hunks)
  • src/entities/_shared/account/components/card.tsx (1 hunks)
  • src/entities/_shared/account/components/profile-images.tsx (1 hunks)
  • src/entities/_shared/account/components/smart-contracts.tsx (1 hunks)
  • src/entities/_shared/token/components/TokenIcon.tsx (1 hunks)
  • src/entities/_shared/token/components/TokenSelector.tsx (4 hunks)
  • src/entities/_shared/token/components/TokenTotalValue.tsx (1 hunks)
  • src/entities/_shared/token/components/inputs.tsx (1 hunks)
  • src/entities/_shared/token/hooks/data.ts (1 hunks)
  • src/entities/campaign/components/CampaignBanner.tsx (1 hunks)
  • src/entities/campaign/components/CampaignCard.tsx (1 hunks)
  • src/entities/campaign/components/CampaignCarouselItem.tsx (1 hunks)
  • src/entities/campaign/components/CampaignDonorsTable.tsx (1 hunks)
  • src/entities/campaign/components/CampaignFinishModal.tsx (1 hunks)
  • src/entities/campaign/components/CampaignForm.tsx (1 hunks)
  • src/entities/campaign/components/CampaignProgressBar.tsx (1 hunks)
  • src/entities/campaign/components/CampaignSettings.tsx (1 hunks)
  • src/entities/campaign/components/CampaignsList.tsx (1 hunks)
  • src/entities/campaign/components/SuccessCampaignModal.tsx (1 hunks)
  • src/entities/campaign/hooks/forms.ts (1 hunks)
  • src/entities/cart/components/CartBreakdown.tsx (1 hunks)
  • src/entities/cart/components/CartLink.tsx (1 hunks)
  • src/entities/cart/components/CartWidget.tsx (1 hunks)
  • src/entities/list/components/AccountCard.tsx (1 hunks)
  • src/entities/list/components/ApplyToListModal.tsx (1 hunks)
  • src/entities/list/components/DonationSuccess.tsx (1 hunks)
  • src/entities/list/components/ListAccounts.tsx (1 hunks)
  • src/entities/list/components/ListCard.tsx (1 hunks)
  • src/entities/list/components/ListCardSkeleton.tsx (1 hunks)
  • src/entities/list/components/ListConfirmationModals.tsx (1 hunks)
  • src/entities/list/components/ListDetails.tsx (1 hunks)
  • src/entities/list/components/ListFormDetails.tsx (1 hunks)
  • src/entities/list/components/ListHero.tsx (1 hunks)
  • src/entities/list/components/ListsOverview.tsx (1 hunks)
  • src/entities/list/components/NoListItem.tsx (1 hunks)
  • src/entities/list/components/listActionsModal.tsx (1 hunks)
  • src/entities/list/hooks/redirects.ts (1 hunks)
  • src/entities/post/components/PostActions.tsx (1 hunks)
  • src/entities/post/components/PostEditor.tsx (1 hunks)
  • src/entities/pot/components/ActivePots.tsx (1 hunks)
  • src/entities/pot/components/ChallengeModal.tsx (1 hunks)
  • src/entities/pot/components/ChallengeResolveModal.tsx (1 hunks)
  • src/entities/pot/components/PotDonationStats.tsx (1 hunks)
  • src/entities/pot/components/PotPayoutChallenges.tsx (1 hunks)
  • src/entities/pot/components/PotSponsorsTable.tsx (1 hunks)
  • src/entities/pot/components/PotTimeline.tsx (1 hunks)
  • src/entities/pot/components/progress.tsx (1 hunks)
  • src/entities/pot/models/schemas.ts (1 hunks)
  • src/entities/voting-round/components/CandidateRow.tsx (1 hunks)
  • src/entities/voting-round/components/CandidateTable.tsx (1 hunks)
  • src/entities/voting-round/components/ResultsTable.tsx (1 hunks)
  • src/entities/voting-round/components/RuleList.tsx (1 hunks)
  • src/entities/voting-round/components/VoteRow.tsx (1 hunks)
  • src/entities/voting-round/components/VoteWeightBreakdown.tsx (1 hunks)
  • src/entities/voting-round/components/WinnerRow.tsx (1 hunks)
  • src/entities/voting-round/components/badges.tsx (1 hunks)
  • src/entities/voting-round/components/leaderboard.tsx (1 hunks)
  • src/entities/voting-round/hooks/candidates.ts (1 hunks)
  • src/features/donation/components/DonationConfirmation.tsx (2 hunks)
  • src/features/donation/components/DonationDirectAllocation.tsx (2 hunks)
  • src/features/donation/components/DonationFlow.tsx (1 hunks)
  • src/features/donation/components/DonationGroupAllocation.tsx (2 hunks)
  • src/features/donation/components/DonationModal.tsx (1 hunks)
  • src/features/donation/components/DonationRecipientShares.tsx (1 hunks)
  • src/features/donation/components/DonationSuccess.tsx (1 hunks)
  • src/features/donation/components/DonationSybilWarning.tsx (1 hunks)
  • src/features/donation/components/DonationTokenBalance.tsx (1 hunks)
  • src/features/donation/components/breakdowns.tsx (1 hunks)
  • src/features/donation/components/buttons.tsx (1 hunks)
  • src/features/donation/hooks/forms.ts (4 hunks)
  • src/features/donation/models/effects.ts (3 hunks)
  • src/features/donation/models/schemas.ts (2 hunks)
  • src/features/matching-pool-contribution/components/MatchingPoolContributionModal.tsx (1 hunks)
  • src/features/pot-application/components/PotApplicationCard.tsx (1 hunks)
  • src/features/pot-application/components/PotApplicationCardSkeleton.tsx (1 hunks)
  • src/features/pot-application/components/PotApplicationModal.tsx (1 hunks)
  • src/features/pot-application/components/PotApplicationReviewModal.tsx (1 hunks)
  • src/features/pot-configuration/components/editor.tsx (2 hunks)
  • src/features/pot-configuration/components/error.tsx (1 hunks)
  • src/features/pot-configuration/components/preview.tsx (1 hunks)
  • src/features/pot-configuration/components/success-modal.tsx (1 hunks)
  • src/features/pot-configuration/hooks/forms.ts (6 hunks)
  • src/features/pot-configuration/model/schemas.ts (4 hunks)
  • src/features/pot-deployment/components/buttons.tsx (1 hunks)
  • src/features/profile-setup/components/AddFundingSourceModal.tsx (1 hunks)
  • src/features/profile-setup/components/contract-modal.tsx (1 hunks)
  • src/features/profile-setup/components/contracts-section.tsx (1 hunks)
  • src/features/profile-setup/components/dao-progress.tsx (1 hunks)
  • src/features/profile-setup/components/form-elements.tsx (1 hunks)
  • src/features/profile-setup/components/form.tsx (1 hunks)
  • src/features/profile-setup/components/funding-sources.tsx (1 hunks)
  • src/features/profile-setup/components/image-upload.tsx (1 hunks)
  • src/features/profile-setup/hooks/forms.ts (4 hunks)
  • src/features/proportional-funding/components/actions.tsx (1 hunks)
  • src/features/proportional-funding/components/configurator.tsx (1 hunks)
  • src/features/proportional-funding/components/payout-manager.tsx (1 hunks)
  • src/layout/campaign/components/layout.tsx (1 hunks)
  • src/layout/components/app-bar.tsx (1 hunks)
  • src/layout/components/dao-auth.tsx (1 hunks)
  • src/layout/components/project-discovery.tsx (1 hunks)
  • src/layout/components/user-dropdown.tsx (1 hunks)
  • src/layout/pot/_deprecated/ErrorModal.tsx (1 hunks)
  • src/layout/pot/_deprecated/SuccessModal.tsx (1 hunks)
  • src/layout/pot/components/layout-hero.tsx (1 hunks)
  • src/layout/pot/components/layout.tsx (1 hunks)
  • src/layout/pot/hooks/tab-navigation.ts (1 hunks)
  • src/layout/profile/_deprecated/FundingTable.tsx (1 hunks)
  • src/layout/profile/components/header.tsx (1 hunks)
  • src/layout/profile/components/hero.tsx (1 hunks)
  • src/layout/profile/components/layout.tsx (1 hunks)
  • src/layout/profile/components/summary.tsx (1 hunks)
  • src/pages/_app.tsx (2 hunks)
  • src/pages/_document.tsx (1 hunks)
  • src/pages/campaign/create.tsx (1 hunks)
  • src/pages/campaigns.tsx (1 hunks)
  • src/pages/deploy.tsx (1 hunks)
  • src/pages/feed/index.tsx (1 hunks)
  • src/pages/index.tsx (1 hunks)
  • src/pages/list/[id]/index.tsx (1 hunks)
  • src/pages/list/create/index.tsx (1 hunks)
  • src/pages/list/duplicate/[id].tsx (1 hunks)
  • src/pages/list/edit/[id]/index.tsx (1 hunks)
  • src/pages/lists.tsx (1 hunks)
  • src/pages/pot/[potId]/applications.tsx (1 hunks)
  • src/pages/pot/[potId]/donations.tsx (1 hunks)
  • src/pages/pot/[potId]/feed.tsx (1 hunks)
  • src/pages/pot/[potId]/history.tsx (1 hunks)
  • src/pages/pot/[potId]/index.tsx (1 hunks)
  • src/pages/pot/[potId]/payouts.tsx (1 hunks)
  • src/pages/pot/[potId]/projects.tsx (1 hunks)
  • src/pages/pot/[potId]/sponsors.tsx (1 hunks)
  • src/pages/pot/[potId]/votes.tsx (1 hunks)
  • src/pages/pots.tsx (1 hunks)
  • src/pages/profile/[accountId]/campaigns.tsx (1 hunks)
  • src/pages/profile/[accountId]/edit.tsx (1 hunks)
  • src/pages/profile/[accountId]/feed.tsx (1 hunks)
  • src/pages/profile/[accountId]/funding-raised.tsx (1 hunks)
  • src/pages/profile/[accountId]/lists.tsx (1 hunks)
  • src/pages/register.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (148)
  • src/features/profile-setup/components/AddFundingSourceModal.tsx
  • src/entities/list/components/DonationSuccess.tsx
  • src/common/ui/layout/components/atoms/badge.tsx
  • src/entities/pot/components/ChallengeModal.tsx
  • src/common/ui/layout/components/atoms/table.tsx
  • src/entities/list/components/ListAccounts.tsx
  • src/entities/campaign/components/CampaignBanner.tsx
  • src/common/ui/layout/components/molecules/toaster.tsx
  • src/entities/list/components/ListsOverview.tsx
  • src/entities/_shared/account/components/AccountSummaryPopup.tsx
  • src/entities/_shared/account/components/card.tsx
  • src/entities/list/components/ListFormDetails.tsx
  • src/pages/profile/[accountId]/lists.tsx
  • src/entities/voting-round/components/VoteRow.tsx
  • src/common/ui/form/components/select.tsx
  • src/entities/voting-round/components/ResultsTable.tsx
  • src/entities/campaign/components/CampaignProgressBar.tsx
  • src/pages/campaigns.tsx
  • src/features/pot-configuration/components/success-modal.tsx
  • src/pages/list/[id]/index.tsx
  • src/entities/_shared/account/components/AccountHandle.tsx
  • src/pages/lists.tsx
  • src/features/profile-setup/components/funding-sources.tsx
  • src/entities/campaign/components/CampaignCarouselItem.tsx
  • src/features/donation/components/DonationTokenBalance.tsx
  • src/common/ui/form/components/text.tsx
  • src/pages/list/create/index.tsx
  • src/entities/_shared/account/components/smart-contracts.tsx
  • src/features/donation/components/breakdowns.tsx
  • src/pages/feed/index.tsx
  • src/pages/pot/[potId]/donations.tsx
  • src/pages/pot/[potId]/projects.tsx
  • src/entities/pot/components/PotTimeline.tsx
  • src/features/proportional-funding/components/payout-manager.tsx
  • src/layout/pot/_deprecated/SuccessModal.tsx
  • src/pages/pot/[potId]/sponsors.tsx
  • src/entities/pot/components/PotSponsorsTable.tsx
  • src/entities/list/components/NoListItem.tsx
  • src/common/ui/layout/components/atoms/hover-card.tsx
  • src/features/pot-application/components/PotApplicationReviewModal.tsx
  • src/pages/pot/[potId]/index.tsx
  • src/pages/pot/[potId]/history.tsx
  • src/pages/list/edit/[id]/index.tsx
  • src/features/donation/components/buttons.tsx
  • src/layout/components/dao-auth.tsx
  • src/pages/profile/[accountId]/feed.tsx
  • src/entities/_shared/account/components/AccountListItem.tsx
  • src/layout/profile/components/header.tsx
  • src/entities/post/components/PostEditor.tsx
  • src/layout/components/user-dropdown.tsx
  • src/entities/cart/components/CartWidget.tsx
  • src/entities/pot/components/PotDonationStats.tsx
  • src/entities/campaign/components/CampaignCard.tsx
  • src/pages/profile/[accountId]/campaigns.tsx
  • src/pages/campaign/create.tsx
  • src/common/ui/layout/components/molecules/clipboard-copy-button.tsx
  • src/common/ui/layout/components/atoms/splash-screen.tsx
  • src/entities/list/hooks/redirects.ts
  • src/entities/campaign/components/SuccessCampaignModal.tsx
  • src/features/pot-configuration/components/error.tsx
  • src/pages/pot/[potId]/payouts.tsx
  • src/entities/voting-round/components/VoteWeightBreakdown.tsx
  • src/entities/_shared/account/components/AccountFollowButton.tsx
  • src/common/ui/form/hooks/index.ts
  • src/pages/list/duplicate/[id].tsx
  • src/entities/voting-round/components/leaderboard.tsx
  • src/features/pot-configuration/components/preview.tsx
  • src/entities/voting-round/components/CandidateTable.tsx
  • src/features/profile-setup/components/dao-progress.tsx
  • src/entities/post/components/PostActions.tsx
  • src/entities/_shared/token/components/inputs.tsx
  • src/entities/voting-round/components/badges.tsx
  • src/features/donation/components/DonationModal.tsx
  • src/entities/list/components/ListConfirmationModals.tsx
  • src/entities/campaign/components/CampaignFinishModal.tsx
  • src/features/profile-setup/components/form-elements.tsx
  • src/layout/pot/components/layout.tsx
  • src/entities/cart/components/CartLink.tsx
  • src/common/ui/layout/components/molecules/radio-group.tsx
  • src/layout/pot/components/layout-hero.tsx
  • src/entities/campaign/components/CampaignsList.tsx
  • src/entities/campaign/components/CampaignSettings.tsx
  • src/entities/_shared/account/components/AccountProfileLink.tsx
  • src/common/ui/form/components/checkbox.tsx
  • src/layout/pot/_deprecated/ErrorModal.tsx
  • src/entities/campaign/components/CampaignForm.tsx
  • src/layout/profile/components/summary.tsx
  • src/entities/voting-round/hooks/candidates.ts
  • src/features/pot-application/components/PotApplicationCard.tsx
  • src/entities/cart/components/CartBreakdown.tsx
  • src/features/donation/components/DonationFlow.tsx
  • src/entities/campaign/hooks/forms.ts
  • src/layout/components/app-bar.tsx
  • src/entities/voting-round/components/WinnerRow.tsx
  • src/features/donation/components/DonationSybilWarning.tsx
  • src/pages/pot/[potId]/feed.tsx
  • src/features/pot-configuration/model/schemas.ts
  • src/entities/_shared/account/components/AccountProfileLinktree.tsx
  • src/pages/pot/[potId]/votes.tsx
  • src/pages/profile/[accountId]/edit.tsx
  • src/features/profile-setup/components/form.tsx
  • src/entities/_shared/account/components/card-skeleton.tsx
  • src/features/profile-setup/components/contracts-section.tsx
  • src/layout/campaign/components/layout.tsx
  • src/features/proportional-funding/components/configurator.tsx
  • src/layout/profile/_deprecated/FundingTable.tsx
  • src/entities/pot/components/PotPayoutChallenges.tsx
  • src/features/donation/components/DonationDirectAllocation.tsx
  • src/features/pot-configuration/components/editor.tsx
  • src/layout/pot/hooks/tab-navigation.ts
  • src/layout/components/project-discovery.tsx
  • src/features/proportional-funding/components/actions.tsx
  • src/pages/register.tsx
  • src/features/pot-deployment/components/buttons.tsx
  • src/features/matching-pool-contribution/components/MatchingPoolContributionModal.tsx
  • src/entities/list/components/AccountCard.tsx
  • src/pages/profile/[accountId]/funding-raised.tsx
  • src/features/donation/components/DonationGroupAllocation.tsx
  • src/entities/pot/components/ActivePots.tsx
  • src/pages/pots.tsx
  • src/features/pot-application/components/PotApplicationCardSkeleton.tsx
  • src/entities/pot/components/ChallengeResolveModal.tsx
  • src/entities/list/components/listActionsModal.tsx
  • src/common/ui/layout/components/atoms/scroll-area.tsx
  • src/pages/pot/[potId]/applications.tsx
  • src/features/donation/components/DonationSuccess.tsx
  • src/layout/profile/components/hero.tsx
  • src/common/ui/layout/components/molecules/social-share.tsx
  • src/entities/pot/components/progress.tsx
  • src/features/profile-setup/components/image-upload.tsx
  • src/entities/_shared/account/components/AccountGroup.tsx
  • src/pages/deploy.tsx
  • src/entities/list/components/ApplyToListModal.tsx
  • src/entities/list/components/ListCardSkeleton.tsx
  • src/entities/_shared/account/components/AccountGroupEditModal.tsx
  • src/common/ui/layout/components/atoms/tooltip.tsx
  • src/features/donation/components/DonationConfirmation.tsx
  • src/entities/list/components/ListHero.tsx
  • src/entities/voting-round/components/RuleList.tsx
  • src/pages/_app.tsx
  • src/entities/voting-round/components/CandidateRow.tsx
  • src/pages/index.tsx
  • src/layout/profile/components/layout.tsx
  • src/entities/list/components/ListCard.tsx
  • src/entities/list/components/ListDetails.tsx
  • src/entities/_shared/account/components/profile-images.tsx
  • src/entities/campaign/components/CampaignDonorsTable.tsx
  • src/features/pot-application/components/PotApplicationModal.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Fleek - broad-haze-5260
🔇 Additional comments (38)
src/features/donation/components/DonationRecipientShares.tsx (1)

4-6: Import paths correctly updated as part of project restructuring.

The import paths have been updated to reflect the new directory structure, where form-related components are now imported from @/common/ui/form/components and layout-related components from @/common/ui/layout/components. This aligns with the PR objective of fixing inconsistencies in the project structure.

src/entities/_shared/token/components/TokenTotalValue.tsx (1)

4-5: Import paths updated to match new layout directory structure

This change is part of the larger reorganization mentioned in the PR objective, where UI components are moved from general UI namespace to layout-specific paths.

src/features/profile-setup/components/contract-modal.tsx (1)

7-13: Import paths updated to new layout directory structure

The component imports have been updated from @/common/ui/components to @/common/ui/layout/components, consistent with the project's directory restructuring.

src/pages/_document.tsx (1)

26-26: Simplification of body element, removed style attribute

The body element has been simplified to only have a className. Note that the DEBUG styling is still applied at the HTML element level (line 7), so the conditional styling functionality appears to be preserved.

package.json (1)

14-14:

Details

❓ Verification inconclusive

Updated output path for generated CSS

The output file path for the CSS generation script has been updated to match the new directory structure, ensuring CSS files are generated in the layout directory.


🏁 Script executed:

#!/bin/bash
# Verify CSS directories exist
echo "Checking for CSS directory..."
fd -t d "layout/styles" src/common/ui

Length of output: 106


Action: Verify the CSS output directory in the new structure

  • The "generate:css" script in package.json now writes to:
    src/common/ui/layout/styles/uno.generated.css
    which aligns with the updated directory structure.
  • However, our verification using fd -t d "layout/styles" src/common/ui did not return any matching directory. Please ensure that the directory either exists in the repository or is created automatically during the build process.
src/entities/_shared/token/components/TokenIcon.tsx (1)

5-6: Import paths updated to reflect new directory structure.

The paths for NearIcon and cn have been updated from general UI paths to more specific layout paths, which aligns with the overall directory restructuring in this PR.

src/common/wallet/hooks.ts (2)

53-53: Good validation improvement for referrerAccountId.

Adding validation with isAccountId ensures only valid account IDs are used, preventing potential runtime issues with invalid data.


67-67: Consistent handling of referrerAccountId in all states.

The improved handling of referrerAccountId is now consistent across all states of the wallet.

Also applies to: 81-81

src/common/constants.ts (1)

117-117:

Details

❓ Verification inconclusive

Verify the impact of removing NATIVE_TOKEN_ID from PLATFORM_LISTED_TOKEN_IDS.

The constant has been changed from including the native token to being empty. Make sure this doesn't break any functionality that relies on this array having at least one token.


🏁 Script executed:

#!/bin/bash
# Check for any usage of PLATFORM_LISTED_TOKEN_IDS that might expect it to contain items
rg "PLATFORM_LISTED_TOKEN_IDS\." --type=ts --type=tsx -A 3 -B 3
rg "PLATFORM_LISTED_TOKEN_IDS\[" --type=ts --type=tsx -A 3 -B 3
rg "PLATFORM_LISTED_TOKEN_IDS.*length" --type=ts --type=tsx -A 3 -B 3

Length of output: 287


#!/bin/bash
# Revised search for any usage of PLATFORM_LISTED_TOKEN_IDS that might expect it to contain items,
# using file glob patterns for both .ts and .tsx files.
rg "PLATFORM_LISTED_TOKEN_IDS" -g "*.ts" -g "*.tsx" -A 3 -B 3

Attention: Verify Native Token Removal

The constant PLATFORM_LISTED_TOKEN_IDS is now an empty array and no usages were found in the repository (via an updated search using file globbing) that explicitly expect this array to contain tokens. However, please perform a manual review to ensure that no functionality relies on the presence of the native token in this list (e.g., checks on array length or direct index accesses).

components.json (1)

8-8:

Details

❓ Verification inconclusive

Updated paths for CSS and aliases to reflect new directory structure.

The configuration has been updated to point to the new layout-specific paths, which is consistent with the directory restructuring in this PR.

Make sure all related files have been moved to the new locations to avoid any broken imports or missing styles.

Also applies to: 14-16


🏁 Script executed:

#!/bin/bash
# Check if the CSS file exists at the new location
if [ -f "src/common/ui/layout/styles/theme.css" ]; then
  echo "✅ Theme CSS file exists at the new location"
else
  echo "❌ Theme CSS file NOT found at the new location"
fi

# Check for common component import patterns that might still use the old paths
rg "from \"@/common/ui/((?!layout).)*\"" --type=ts --type=tsx | head -n 10

Length of output: 478


CSS Path Update Verified, But Regex Verification Requires Adjustment

  • The updated CSS path is correct—the theme file exists at src/common/ui/layout/styles/theme.css.
  • However, the regex used to check for outdated import paths fails due to unsupported look-around. To properly scan for old import patterns, please update the command to enable PCRE2 (for example, by adding the --pcre2 flag).
  • This recommendation also applies to the check on lines 14-16.
src/common/ui/form/components/textarea.tsx (3)

11-12: Import paths are updated.

The component import paths have been updated from a more general namespace to a more specific layout directory, which aligns with the project reorganization mentioned in the PR summary.


33-35: LGTM: Required indicator styling improved.

The required field indicator is now rendered as a block-level element with appropriate styling, making it more visible and consistent.


53-63: UI structure improvement.

The form description and message are now properly organized in a flex container with justified spacing between elements. This improves the visual layout of the component and ensures proper alignment of the hint text and character count.

src/entities/_shared/token/hooks/data.ts (1)

33-36:

Details

❓ Verification inconclusive

API change: Verify dependent components.

The function signature for useTokenAllowlist has been updated to accept a configuration object with an enabled flag. This provides more flexibility but could impact components that depend on this hook.


🏁 Script executed:

#!/bin/bash
# Find all usages of useTokenAllowlist to verify they work with the new signature
rg "useTokenAllowlist" --type tsx --type ts

Length of output: 71


Action: Verify Dependent Component Usages

The API for useTokenAllowlist now accepts a configuration object with an enabled flag. While this change adds flexibility, it might impact existing components that call this hook. Our initial attempt to verify usages using:

rg "useTokenAllowlist" --type tsx --type ts

yielded an error due to the unrecognized file type "tsx". This means we couldn’t automatically confirm whether all usages have been updated appropriately.

Next Steps:

  • Please run a revised search to include TSX files, for example:
    rg "useTokenAllowlist" -g "*.ts" -g "*.tsx"
  • Verify manually that every instance of useTokenAllowlist in your codebase correctly uses the new signature.
src/features/donation/models/schemas.ts (1)

88-88:

Details

❓ Verification inconclusive

Variable renamed for improved semantics.

donationCrossFieldValidationTargets has been renamed to donationDependentFields to better align with the new cross-field validation hook pattern introduced elsewhere in this PR.


🏁 Script executed:

#!/bin/bash
# Check if there are any remaining references to the old variable name
rg "donationCrossFieldValidationTargets" --type tsx --type ts

Length of output: 89


Below is a revised review comment. However, before finalizing this review comment, please run the following additional verification script to ensure that no remaining references to the old variable name exist in either *.ts or *.tsx files:

#!/bin/bash
# Re-run the search to check if there are any lingering references to donationCrossFieldValidationTargets
rg -g "*.ts" -g "*.tsx" "donationCrossFieldValidationTargets"

Once you’ve confirmed that this search returns no results, you can consider the renaming complete. The updated variable name aligns with the new cross-field validation hook pattern.

Rewritten Review Comment:

The variable has been renamed for improved clarity. The old identifier donationCrossFieldValidationTargets has been updated to donationDependentFields to better reflect its purpose within the new cross-field validation hook pattern. Please ensure that no references to the old identifier remain across both TypeScript (.ts) and TSX (.tsx) files.

  • File: src/features/donation/models/schemas.ts (line 88)
  • Updated snippet:
    export const donationDependentFields: (keyof DonationInputs)[] = ["amount", "potAccountId"];
src/common/ui/form/hooks/zod-validation.ts (1)

1-50: Well-documented hook for cross-field validation.

This custom hook provides a well-documented solution for handling complex form validation scenarios where the validity of one field depends on others - a limitation in react-hook-form's standard validation.

src/features/profile-setup/hooks/forms.ts (3)

8-8: Import addition looks good.

Using useEnhancedForm can simplify validation logic. No issues spotted here.


60-66: Verify potential overrides with followDefaultValues.

followDefaultValues being tied to the snapshot availability may inadvertently overwrite user inputs if the snapshot loads after the user already started editing. Ensure this is the intended behavior.


145-145: Return shape is clear.

Exposing form: self keeps naming concise internally. Looks fine.

src/entities/_shared/token/components/TokenSelector.tsx (2)

17-20: Clarify zero-balance handling.

There's a TODO to render null if the user’s balance is zero, yet the current check only returns null when token is falsy. Ensure you also handle tokens that exist but have zero balance if that's required.


29-31: Feature toggle usage.

The enabled: FEATURE_REGISTRY.DirectFtDonation.isEnabled flag is a good feature toggle approach. Confirm it’s properly toggled in all deployment environments.

src/features/donation/hooks/forms.ts (4)

87-94: Watch out for overwriting user input.

followDefaultValues: true continually updates the form if defaultValues change. Confirm this is desired, especially if external data arrives mid-edit.


107-107: Readability is good.

The isDisabled logic is straightforward and aligns with typical form patterns.


109-115: Check for unhandled no-wallet case.

minAmountError only triggers if viewer.hasWalletReady === true. If the wallet isn’t ready, no error is shown. Confirm that’s correct or consider a separate error for missing wallet.


139-139: Clear return naming.

Returning form: self is consistent with the rest of the code and improves clarity.

src/features/donation/models/effects.ts (2)

19-19: Confirm updated import path.

The updated import path for FungibleTokenMetadata looks fine. Ensure that other parts of the codebase also reference the correct path to avoid ts(2307) or runtime resolution issues.


111-123:

Details

✅ Verification successful

Ensure consistency in argument passing.

The simplification to { args: { account_id: ... } } is more concise and consistent. Verify that all calls to tokenClient.view follow the same argument structure and that no call sites are overlooked.


🏁 Script executed:

#!/bin/bash
# Search the entire repository for 'tokenClient.view' calls to confirm consistent usage
rg "tokenClient\.view"

Length of output: 761


Verified Consistency:

After a repository-wide search for tokenClient.view calls, I confirmed that all invocations using an account_id argument consistently follow the { args: { account_id: ... } } structure. The calls handling ft_metadata and storage_balance_bounds use their expected argument structure. No overlooked call sites or inconsistencies were found.

src/common/ui/form/hooks/enhanced.ts (5)

1-12: Imports and resolver usage look good.

Using zodResolver is a best practice for integrating Zod with react-hook-form. This setup is clear and concise.


13-25: Well-defined EnhancedFormProps type.

Including schema and optional followDefaultValues clarifies usage. This explicit design encourages strong type safety and clarity in form configurations.


27-34: Useful binding metadata.

Exposing isUnpopulated helps manage dynamic default values smoothly, ensuring the form can rehydrate itself if needed.


36-80: Comprehensive documentation is commendable.

The extensive JSDoc provides a solid reference for consumers of this hook, making it user-friendly and self-explanatory.


81-111: Cross-field validation integration is well-structured.

The approach of wrapping useForm with Zod and cross-field validation is a solid example of composition. The isUnpopulated logic is straightforward, though ensure performance is acceptable for large forms. Otherwise, this is a neat pattern.

src/features/pot-configuration/hooks/forms.ts (6)

1-6: Updated imports reflect best practices.

Bringing in useCallback, useEffect, useMemo, useWatch, and Zod's infer keeps the code more concise and strongly typed.


24-25: Nicely modular cross-field definitions.

Using potDeploymentDependentFields and potSettingsDependentFields clarifies which fields must be mutually validated, improving maintainability.


51-53: Memoized hydrating check.

Storing isHydrating in a memo is readable and prevents unwanted re-renders. Confirm that all references to isHydrating remain accurate after asynchronous loads.


86-88: Effective use of the enhanced form hook.

Switching to useEnhancedForm with schema validation and conditional dependent fields is a clean pattern. Dynamically controlling followDefaultValues based on the pot’s existing state is flexible. Great work.

Also applies to: 91-91


114-117: Administrator updates handled properly.

Using useCallback to manage changes to admin accounts is concise and avoids excessive re-renders. This ensures the form state remains consistent.


140-140: Exposing form instance looks good.

Returning form helps keep the rest of the component code consistent with react-hook-form patterns.

Comment thread src/features/pot-configuration/hooks/forms.ts
@akaia-shadowfox akaia-shadowfox changed the title Fix/258 bug inconsistent feedback form donation to project field Implement generalized solution for cross-field validation Feb 26, 2025
@akaia-shadowfox akaia-shadowfox merged commit fbd4009 into main Feb 26, 2025
@akaia-shadowfox akaia-shadowfox deleted the fix/258-bug-inconsistent-feedback-form-donation-to-project-field branch February 26, 2025 14:16
Ebube111 added a commit that referenced this pull request Feb 27, 2025
* Implement generalized solution for cross-field validation (#352)

* Fix referrer account id handling issues (#355)

* Campaign Fixes (#354)

* fixed issue with start date

* es lint fix

* change field to number field

* es lint fix

---------

Co-authored-by: Carina Akaia <cvo.akaia@gmail.com>

---------

Co-authored-by: Carina.Akaia.org <cvo.akaia@gmail.com>
@coderabbitai coderabbitai Bot mentioned this pull request Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Inconsistent feedback form donation to project field

1 participant