Skip to content

Commit

Permalink
formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
itstolexy committed Jul 20, 2024
1 parent 17c448b commit 08475fe
Showing 1 changed file with 36 additions and 37 deletions.
73 changes: 36 additions & 37 deletions app/components/bio/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,40 @@ import { defaultFormState, defaultFormError, FormField } from "../constant";
import TextAreaField from "../textarea";

export default function Bio() {
const [formState, setFormState] = useState(defaultFormState);
const [formError, setFormError] = useState(defaultFormError);

const updateFormData = (key: string, value: string) => {
if (value.length > 64) {
setFormError({
...formError,
[key]: "Your bio cannot exceed 64 characters",
});
} else {
setFormError({
...formError,
[key]: null,
});
}

setFormState({
...formState,
[key]: value,
const [formState, setFormState] = useState(defaultFormState);
const [formError, setFormError] = useState(defaultFormError);

const updateFormData = (key: string, value: string) => {
if (value.length > 64) {
setFormError({
...formError,
[key]: "Your bio cannot exceed 64 characters",
});
} else {
setFormError({
...formError,
[key]: null,
});
};

return (
<div className="font-sans p-6">
<TextAreaField
label="Bio"
placeholder="A seasoned front-end developer with fulfilling duties."
name={FormField.bio}
value={formState[FormField.bio]}
error={formError[FormField.bio]}
handleChange={(e: React.ChangeEvent<HTMLTextAreaElement>) =>
updateFormData(FormField.bio, e.target.value)
}
/>
</div>
);
}

}

setFormState({
...formState,
[key]: value,
});
};

return (
<div className="font-sans p-6">
<TextAreaField
label="Bio"
placeholder="A seasoned front-end developer with fulfilling duties."
name={FormField.bio}
value={formState[FormField.bio]}
error={formError[FormField.bio]}
handleChange={(e: React.ChangeEvent<HTMLTextAreaElement>) =>
updateFormData(FormField.bio, e.target.value)
}
/>
</div>
);
}

0 comments on commit 08475fe

Please sign in to comment.