From e00f9c6ae0f4a2010836ebc9dff3c41a6062a8e0 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Mon, 20 May 2024 16:51:29 -0500 Subject: [PATCH] refactor: use Formik field wrappers as components --- .../UIPatternsComplexWizard/steps/StepOne.tsx | 7 ++- .../steps/StepThree.tsx | 16 +++++-- .../UIPatternsComplexWizard/steps/StepTwo.tsx | 13 +++-- .../app/UIPatternsWizard/steps/StepOne.tsx | 7 ++- .../app/UIPatternsWizard/steps/StepThree.tsx | 4 +- .../app/UIPatternsWizard/steps/StepTwo.tsx | 4 +- .../auth/LoginComponent/LoginComponent.tsx | 10 ++-- .../details/ProjectEdit/ProjectEditForm.tsx | 25 ++++++---- .../details/grants/ProjectGrantFormFields.tsx | 48 ++++++++++++++----- .../ProjectPublicationFormFIelds.tsx | 24 +++++++--- .../TicketCreateModal/TicketCreateForm.tsx | 46 +++++++++++++----- .../TicketDetailModal/TicketReplyForm.tsx | 6 ++- 12 files changed, 154 insertions(+), 56 deletions(-) diff --git a/apps/ui-patterns/src/app/UIPatternsComplexWizard/steps/StepOne.tsx b/apps/ui-patterns/src/app/UIPatternsComplexWizard/steps/StepOne.tsx index ef2df37d1..d5e0e8691 100644 --- a/apps/ui-patterns/src/app/UIPatternsComplexWizard/steps/StepOne.tsx +++ b/apps/ui-patterns/src/app/UIPatternsComplexWizard/steps/StepOne.tsx @@ -1,19 +1,22 @@ import { FormikInput } from '@tacc/core-components'; import * as Yup from 'yup'; import { UIWizardStep, useWizardValues, InitialValueGenerator } from '..'; +import { Field } from 'formik'; export const StepOne: React.FC = () => { const { extra } = useWizardValues(); return (

Step One: Extra value two is {extra.extraTwo}

- - = ({ note="more values inside" className={fieldArrayStyles.item} > - - = ({ title={`Field Array ${outerIndex}`} className={fieldArrayStyles.item} > - = ({ note="more values inside" className={fieldArrayStyles.item} > - - { return (

Step One

- - { return (

Step Three

- { return (

Step Two

- = ({ className }) => { // FAQ: To use inline messaging for required fields (instead of browser): // 1. Uncomment this constant definition // 2. Pass this constant to ; validationSchema={validationSchema} - // 3. Remove `required` attribute from 's + // 3. Remove `required` attribute from s // const validationSchema = Yup.object({ // username: Yup.string().required(), // password: Yup.string().required(), @@ -116,14 +116,16 @@ const LoginComponent: React.FC = ({ className }) => {
- - {({ isValid }) => ( - - - + {scienceFields.map((field) => ( ))} - - + @@ -104,8 +112,9 @@ export const ProjectAbstractEditForm: React.FC<{ : field.name} ))} - - + { const scienceFields = useProjectScienceField().data ?? []; @@ -12,33 +13,58 @@ const ProjectGrantFormFields: React.FC = () => { return ( <>
- - + +
- + - + {scienceFields.map((field) => ( ))} - - + + - - +
- - + +
- - +
- - - + + +
- { > {({ isValid }) => ( - + @@ -98,8 +103,13 @@ export const TicketCreateForm: React.FC = () => { - - +
+ @@ -115,9 +125,16 @@ export const TicketCreateForm: React.FC = () => { - - - + + { reports" /> - { />
- - { />
- { description="" /> - - -