Feature/validation updates pr - #334
Open
ugoocreates-pixel wants to merge 7 commits into
Open
Conversation
… AddDeposit, Stake pages" This reverts commit 7c5b769.
| } | ||
| }; | ||
| const { | ||
| register, |
| import { ActionModal } from '@/components/ui/action-modal'; | ||
| import { useHealthFactor } from '@/hooks/useHealthRatio'; | ||
| import { notify } from '@/components/layout/notifier/Notifier'; | ||
| import { useForm, Controller } from 'react-hook-form'; |
| ); | ||
|
|
||
| const { | ||
| control, |
|
|
||
| const { | ||
| control, | ||
| register, |
| const { | ||
| control, | ||
| register, | ||
| handleSubmit: rhHandleSubmit, |
| control, | ||
| register, | ||
| handleSubmit: rhHandleSubmit, | ||
| formState: { errors, isValid }, |
| control, | ||
| register, | ||
| handleSubmit: rhHandleSubmit, | ||
| formState: { errors, isValid }, |
| const handleSubmit = async (e) => { | ||
| e.preventDefault(); | ||
|
|
||
| const onSubmit = async (data) => { |
…ature/validation-updates-pr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #270
This PR introduces comprehensive, real‑time client‑side validation to the four main form pages of the Quantara frontend:
Form.jsxwatch.Withdraw.jsxAddDeposit.jsxStake.jsxAll four pages now share a consistent validation approach, improving UX, preventing accidental bad submissions, and providing immediate feedback (< 200 ms) to users.
What was added / changed
Dependencies
useForm,Controllerfromreact-hook-form.zfrom Zod andzodResolverfrom@hookform/resolvers/zod.Validation Schemas
/^\d+(\.\d+)?$/.> 0).useFormwithresolver: zodResolver(schema)andmode: 'onChange'for real‑time validation.Form Integration
useStatehandling withreact-hook-formregistration (register) or controlled components viaController.errorsmapping to render<p className="text-red-500">error messages directly under each input.<Button … disabled={!isValid || loading}>) until the form passes validation.UI Adjustments
fieldprops fromController.<form onSubmit={handleSubmit(onSubmit)}>to leverage RHF submission handling.Business Logic Integration
Form.jsx, after successful validation we construct theformDataobject and callhandleTransactionas before, resetting the token amount viasetValue.AddDeposit.jsx, on success we reset both amount and selected token viasetValue.Stake.jsx, theonSubmitcurrently logs the stake action (placeholder for real integration).Accessibility & Performance
<p>elements with clear colour contrast (text-red-500) to satisfy Axe DevTools accessibility checks.Testing & Verification
Why this matters