Skip to content

Commit

Permalink
Resolve merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
chalabi2 committed Sep 4, 2024
1 parent 0e9cdfd commit aca7ad3
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 130 deletions.
158 changes: 78 additions & 80 deletions components/groups/forms/groups/MemberInfoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -103,95 +103,92 @@ export default function MemberInfoForm({
validateOnChange={true}
validateOnBlur={true}
>
{({ values, isValid, errors, setFieldValue }) => {
return (
<Form className="min-h-[330px]">
<div className="overflow-y-scroll max-h-[550px] min-h-[330px]">
{errors.members && <div className="text-red-500"></div>}
<FieldArray name="members">
{() => (
<>
{values.members.map((member, index) => (
<div key={index} className="grid grid-cols-3 gap-4 mb-4 p-1">
<div className="relative">
<TextInput
name={`members.${index}.address`}
label="Address"
placeholder="manifest1..."
value={member.address}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
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 && (
<button
type="button"
onClick={() => {
setFieldValue(`members.${index}.address`, address);
dispatch({
type: 'UPDATE_MEMBER',
index,
field: 'address',
value: address,
});
}}
aria-label="Paste address"
className="btn btn-primary rounded-tr-lg rounded-br-lg rounded-bl-none rounded-tl-none"
>
<PiAddressBook className="w-6 h-6" />
</button>
)}
</div>
{({ values, isValid, dirty, setFieldValue }) => (
<Form className="min-h-[330px]">
<div className="overflow-y-scroll max-h-[550px] min-h-[330px]">
<FieldArray name="members">
{() => (
<>
{values.members.map((member, index) => (
<div key={index} className="grid grid-cols-3 gap-4 mb-4 p-1">
<div className="relative">
<TextInput
name={`members.${index}.name`}
label="Name"
placeholder="Alice"
value={member.name}
name={`members.${index}.address`}
label="Address"
placeholder="manifest1..."
value={member.address}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
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"
/>
<NumberInput
name={`members.${index}.weight`}
label="Weight"
placeholder="1"
value={member.weight}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
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 && (
<button
type="button"
onClick={() => {
setFieldValue(`members.${index}.address`, address);
dispatch({
type: 'UPDATE_MEMBER',
index,
field: 'address',
value: address,
});
}}
aria-label="Paste address"
className="btn btn-primary rounded-tr-lg rounded-br-lg rounded-bl-none rounded-tl-none"
>
<PiAddressBook className="w-6 h-6" />
</button>
)}
</div>
))}
</>
)}
</FieldArray>
</div>

<TextInput
name={`members.${index}.name`}
label="Name"
placeholder="Alice"
value={member.name}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
setFieldValue(`members.${index}.name`, e.target.value);
dispatch({
type: 'UPDATE_MEMBER',
index,
field: 'name',
value: e.target.value,
});
}}
className="input input-bordered w-full"
/>
<NumberInput
name={`members.${index}.weight`}
label="Weight"
placeholder="1"
value={member.weight}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
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"
/>
</div>
))}
</>
)}
</FieldArray>
</div>

<button
type="submit"
Expand All @@ -204,6 +201,7 @@ export default function MemberInfoForm({
</Form>
)}
</Formik>

<div className="flex space-x-3 ga-4 mt-6">
<button
onClick={prevStep}
Expand Down
90 changes: 40 additions & 50 deletions components/groups/forms/proposals/ProposalDetailsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function ProposalDetails({
const updateField = (field: keyof ProposalFormData, value: any) => {
dispatch({ type: 'UPDATE_FIELD', field, value });
};
console.log(formData);
return (
<section className="">
<div className="lg:flex mx-auto">
Expand All @@ -46,63 +47,52 @@ export default function ProposalDetails({
onSubmit={nextStep}
validateOnChange={true}
>
{({ isValid, dirty, errors, setFieldValue }) => {
return (
<Form className="min-h-[330px]">
<div className="grid gap-5 my-6 sm:grid-cols-2">
{({ isValid, dirty, setFieldValue }) => (
<Form className="min-h-[330px]">
<div className="grid gap-5 my-6 sm:grid-cols-2">
<TextInput
label="Proposal Title"
name="title"
placeholder="Title"
value={formData.title}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
updateField('title', e.target.value);
setFieldValue('title', e.target.value);
}}
/>
<div className="flex flex-row items-center justify-start">
<TextInput
label="Proposal Title"
name="title"
placeholder="Title"
value={formData.title}
label="Proposer"
name="proposers"
placeholder="List of authors"
value={formData.proposers}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
updateField('title', e.target.value);
setFieldValue('title', e.target.value);
updateField('proposers', e.target.value);
setFieldValue('proposers', e.target.value);
}}
className="rounded-tr-none rounded-br-none"
/>
<div className="flex flex-row items-center justify-start">
<TextInput
label="Proposer"
name="proposers"
placeholder="List of authors"
value={formData.proposers}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
updateField('proposers', e.target.value);
setFieldValue('proposers', e.target.value);
}}
className="rounded-tr-none rounded-br-none"
/>
<button
type="button"
aria-label="address-btn"
onClick={() => {
setFieldValue('proposers', address);
updateField('proposers', address);
}}
className="btn btn-primary rounded-tr-lg rounded-br-lg rounded-bl-none rounded-tl-none"
>
<PiAddressBook className="w-6 h-6" />
</button>
</div>
<TextArea
label="Summary"
name="summary"
placeholder="Short Bio"
value={formData.summary}
onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {
updateField('summary', e.target.value);
setFieldValue('summary', e.target.value);
<button
type="button"
aria-label="address-btn"
onClick={() => {
setFieldValue('proposers', address);
updateField('proposers', address);
}}
/>
className="btn btn-primary rounded-tr-lg rounded-br-lg rounded-bl-none rounded-tl-none"
>
<PiAddressBook className="w-6 h-6" />
</button>
</div>
<button
type="submit"
className="w-full mt-4 btn px-5 py-2.5 sm:py-3.5 btn-primary"
disabled={!isValid || !dirty}
onClick={() => {
nextStep();
<TextArea
label="Summary"
name="summary"
placeholder="Short Bio"
value={formData.summary}
onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {
updateField('summary', e.target.value);
setFieldValue('summary', e.target.value);
}}

/>
</div>
<button
Expand Down

0 comments on commit aca7ad3

Please sign in to comment.