Implement generalized solution for cross-field validation#352
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe pull request reorganizes the project’s directory structure by changing many import paths from a general Changes
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)
Possibly related PRs
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Pro Plan! Simply use the command ✨ Finishing Touches
🪧 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
CodeRabbit Configuration File (
|
…into fix/258-bug-inconsistent-feedback-form-donation-to-project-field
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
src/entities/pot/models/schemas.ts (1)
58-64: 🛠️ Refactor suggestionFix inconsistency in error message for pot_description validation.
The validation uses
POT_MIN_NAME_LENGTHfor 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_namevalidation 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:
- Debounce the validation to avoid running it on every keystroke
- Only run validation when fields in
dependentFieldsactually change, rather than any form value- 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
useFormanduseEnhancedFormin the same file. This can be confusing unless both are strictly necessary. Consider using onlyuseEnhancedFormif 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-forminstance is returned while elsewhereuseEnhancedFormis 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 WIPsuggests 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
⛔ Files ignored due to path filters (7)
src/common/ui/layout/svg/cart.svgis excluded by!**/*.svgsrc/common/ui/layout/svg/chef-hat.svgis excluded by!**/*.svgsrc/common/ui/layout/svg/layers.svgis excluded by!**/*.svgsrc/common/ui/layout/svg/near.svgis excluded by!**/*.svgsrc/common/ui/layout/svg/pen.svgis excluded by!**/*.svgsrc/common/ui/layout/svg/radio-active.svgis excluded by!**/*.svgsrc/common/ui/layout/svg/radio-inactive.svgis 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/componentsand 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 structureThis 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 structureThe component imports have been updated from
@/common/ui/componentsto@/common/ui/layout/components, consistent with the project's directory restructuring.src/pages/_document.tsx (1)
26-26: Simplification of body element, removed style attributeThe 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/uiLength of output: 106
Action: Verify the CSS output directory in the new structure
- The
"generate:css"script inpackage.jsonnow 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/uidid 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
NearIconandcnhave 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
isAccountIdensures 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
referrerAccountIdis 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 3Length 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 3Attention: Verify Native Token Removal
The constant
PLATFORM_LISTED_TOKEN_IDSis 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 10Length 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
--pcre2flag).- 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
useTokenAllowlisthas been updated to accept a configuration object with anenabledflag. 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 tsLength of output: 71
Action: Verify Dependent Component Usages
The API for
useTokenAllowlistnow accepts a configuration object with anenabledflag. 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 tsyielded 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
useTokenAllowlistin your codebase correctly uses the new signature.src/features/donation/models/schemas.ts (1)
88-88:Details
❓ Verification inconclusive
Variable renamed for improved semantics.
donationCrossFieldValidationTargetshas been renamed todonationDependentFieldsto 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 tsLength 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
donationCrossFieldValidationTargetshas been updated todonationDependentFieldsto 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
useEnhancedFormcan simplify validation logic. No issues spotted here.
60-66: Verify potential overrides withfollowDefaultValues.
followDefaultValuesbeing 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: selfkeeps 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
tokenis 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.isEnabledflag 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: truecontinually updates the form ifdefaultValueschange. Confirm this is desired, especially if external data arrives mid-edit.
107-107: Readability is good.The
isDisabledlogic is straightforward and aligns with typical form patterns.
109-115: Check for unhandled no-wallet case.
minAmountErroronly triggers ifviewer.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: selfis 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
FungibleTokenMetadatalooks fine. Ensure that other parts of the codebase also reference the correct path to avoidts(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 totokenClient.viewfollow 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.viewcalls, I confirmed that all invocations using anaccount_idargument consistently follow the{ args: { account_id: ... } }structure. The calls handlingft_metadataandstorage_balance_boundsuse 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
zodResolveris a best practice for integrating Zod with react-hook-form. This setup is clear and concise.
13-25: Well-defined EnhancedFormProps type.Including
schemaand optionalfollowDefaultValuesclarifies usage. This explicit design encourages strong type safety and clarity in form configurations.
27-34: Useful binding metadata.Exposing
isUnpopulatedhelps 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
useFormwith Zod and cross-field validation is a solid example of composition. TheisUnpopulatedlogic 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'sinferkeeps the code more concise and strongly typed.
24-25: Nicely modular cross-field definitions.Using
potDeploymentDependentFieldsandpotSettingsDependentFieldsclarifies which fields must be mutually validated, improving maintainability.
51-53: Memoized hydrating check.Storing
isHydratingin a memo is readable and prevents unwanted re-renders. Confirm that all references toisHydratingremain accurate after asynchronous loads.
86-88: Effective use of the enhanced form hook.Switching to
useEnhancedFormwith schema validation and conditional dependent fields is a clean pattern. Dynamically controllingfollowDefaultValuesbased on the pot’s existing state is flexible. Great work.Also applies to: 91-91
114-117: Administrator updates handled properly.Using
useCallbackto 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
formhelps keep the rest of the component code consistent with react-hook-form patterns.
* 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>
Summary by CodeRabbit