Conversation
…e to accept onBlur and/or custom TextFieldProps props
|
Preview branch generated at https://MPDX-8678-improve-add-donation.d3dytjb8adxkk5.amplifyapp.com |
Bundle sizes [mpdx-react]Compared against f62263d No significant changes found |
wjames111
left a comment
There was a problem hiding this comment.
Looks great! thanks for improving this form. The only issue I had was getting the DateField working.
src/components/Layouts/Primary/TopBar/Items/AddMenu/Items/AddDonation/AddDonation.tsx
Outdated
Show resolved
Hide resolved
|
So right now we are essentially hacking the touched state by either leaving out the check for I think this is the best way to handle the form validation, it also works on the |
@wjames111 Is this a change that should be made on all form fields or just the DateField one? |
|
@zweatshirt Ideally all of them if possible. |
…ere onBlur is required
| useMediaQuery, | ||
| } from '@mui/material'; | ||
| import { FastField, Field, FieldProps, Form, Formik } from 'formik'; | ||
| import i18n from 'i18next'; |
There was a problem hiding this comment.
I noticed this one of Daniel's reviews, it looks like we should be importing from src/lib/i18n.
| import i18n from 'i18next'; | |
| import i18n from 'src/lib/i18n'; |
| .typeError(i18n.t('Appeal amount must be a valid number')) | ||
| .nullable() | ||
| .test( | ||
| 'Is appeal amount in valid currency format?', | ||
| 'Appeal amount must be in valid currency format', | ||
| i18n.t('Appeal amount must be in valid currency format'), | ||
| (amount) => | ||
| !amount || /\$?[0-9][0-9.,]*/.test(amount as unknown as string), | ||
| ) | ||
| .test( | ||
| 'Is positive?', | ||
| 'Must use a positive number for appeal amount', | ||
| i18n.t('Must use a positive number for appeal amount'), | ||
| (value) => !value || parseFloat(value as unknown as string) > 0, | ||
| ), | ||
| appealId: yup.string().nullable(), | ||
| currency: yup.string().required(), | ||
| designationAccountId: yup.string().required(), | ||
| donationDate: requiredDateTime(), | ||
| donorAccountId: yup.string().required(), | ||
| currency: yup.string().required(i18n.t('Currency is required')), | ||
| designationAccountId: yup | ||
| .string() | ||
| .required(i18n.t('Designation account is required')), | ||
| donationDate: requiredDateTime(i18n.t('Date is required')), | ||
| donorAccountId: yup.string().required(i18n.t('Partner Account is required')), |
There was a problem hiding this comment.
I think this will be a lot more helpful to the user!
| onChange={(e) => { | ||
| setFieldValue('amount', e.target.value); | ||
| setFieldTouched('amount', true, false); | ||
| }} | ||
| onBlur={() => setFieldTouched('amount', true)} |
There was a problem hiding this comment.
Thanks for using the setFieldTouched on these!
There was a problem hiding this comment.
Thanks for making these changes!
Description
Jira ticket
Checklist: