diff --git a/components/groups/forms/groups/MemberInfoForm.tsx b/components/groups/forms/groups/MemberInfoForm.tsx index 920683a9..a9d53709 100644 --- a/components/groups/forms/groups/MemberInfoForm.tsx +++ b/components/groups/forms/groups/MemberInfoForm.tsx @@ -15,7 +15,6 @@ const MemberSchema = Yup.object().shape({ const MemberInfoSchema = Yup.object().shape({ members: Yup.array().of(MemberSchema).min(1, 'At least one member is required'), }); - export default function MemberInfoForm({ formData, dispatch, @@ -30,6 +29,7 @@ export default function MemberInfoForm({ address: string; }>) { const [numberOfMembers, setNumberOfMembers] = useState(formData.members.length); + console.log('formData', formData); const updateMembers = () => { const currentLength = formData.members.length; if (numberOfMembers > currentLength) { @@ -103,95 +103,92 @@ export default function MemberInfoForm({ validateOnChange={true} validateOnBlur={true} > - {({ values, isValid, errors, setFieldValue }) => { - return ( -
-
- {errors.members &&
} - - {() => ( - <> - {values.members.map((member, index) => ( -
-
- ) => { - setFieldValue(`members.${index}.address`, e.target.value); - dispatch({ - type: 'UPDATE_MEMBER', - index, - field: 'address', - value: e.target.value, - }); - }} - className={`input input-bordered w-full ${ - index === 0 ? 'rounded-tr-none rounded-br-none' : '' - }`} - /> - {index === 0 && ( - - )} -
+ {({ values, isValid, dirty, setFieldValue }) => ( + +
+ + {() => ( + <> + {values.members.map((member, index) => ( +
+
) => { - setFieldValue(`members.${index}.name`, e.target.value); + setFieldValue(`members.${index}.address`, e.target.value); dispatch({ type: 'UPDATE_MEMBER', index, - field: 'name', + field: 'address', value: e.target.value, }); }} - className="input input-bordered w-full" - /> - ) => { - const value = Math.max(1, parseInt(e.target.value) || 1); - setFieldValue(`members.${index}.weight`, value); - dispatch({ - type: 'UPDATE_MEMBER', - index, - field: 'weight', - value: value.toString(), - }); - }} - min={1} - className="input input-bordered w-full" + className={`input input-bordered w-full ${ + index === 0 ? 'rounded-tr-none rounded-br-none' : '' + }`} /> + {index === 0 && ( + + )}
- ))} - - )} - -
- + ) => { + setFieldValue(`members.${index}.name`, e.target.value); + dispatch({ + type: 'UPDATE_MEMBER', + index, + field: 'name', + value: e.target.value, + }); + }} + className="input input-bordered w-full" + /> + ) => { + const value = Math.max(1, parseInt(e.target.value) || 1); + setFieldValue(`members.${index}.weight`, value); + dispatch({ + type: 'UPDATE_MEMBER', + index, + field: 'weight', + value: value.toString(), + }); + }} + min={1} + className="input input-bordered w-full" + /> +
+ ))} + + )} + +
-
-