-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fac63d6
commit 2f78de0
Showing
3 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, { useState } from "react"; | ||
import { Form, Button } from "react-bootstrap"; | ||
|
||
const ProfileForm = ({ onSubmit }) => { | ||
const [name, setName] = useState(""); | ||
const [age, setAge] = useState(""); | ||
const [occupation, setOccupation] = useState(""); | ||
const [bio, setBio] = useState(""); | ||
|
||
const handleSubmit = e => { | ||
e.preventDefault(); | ||
const profileData = { | ||
name, | ||
age, | ||
occupation, | ||
bio | ||
}; | ||
// Pass the profile data to the parent component | ||
onSubmit(profileData); | ||
}; | ||
|
||
return ( | ||
<Form onSubmit={handleSubmit}> | ||
<Form.Group controlId="formName"> | ||
<Form.Label>Name</Form.Label> | ||
<Form.Control | ||
type="text" | ||
placeholder="Enter your name" | ||
value={name} | ||
onChange={e => setName(e.target.value)} | ||
/> | ||
</Form.Group> | ||
|
||
<Form.Group controlId="formAge"> | ||
<Form.Label>Age</Form.Label> | ||
<Form.Control | ||
type="number" | ||
placeholder="Enter your age" | ||
value={age} | ||
onChange={e => setAge(e.target.value)} | ||
/> | ||
</Form.Group> | ||
|
||
<Form.Group controlId="formOccupation"> | ||
<Form.Label>Occupation</Form.Label> | ||
<Form.Control | ||
type="text" | ||
placeholder="Enter your occupation" | ||
value={occupation} | ||
onChange={e => setOccupation(e.target.value)} | ||
/> | ||
</Form.Group> | ||
|
||
<Form.Group controlId="formBio"> | ||
<Form.Label>Bio</Form.Label> | ||
<Form.Control | ||
as="textarea" | ||
rows={3} | ||
placeholder="Enter a short bio" | ||
value={bio} | ||
onChange={e => setBio(e.target.value)} | ||
/> | ||
</Form.Group> | ||
|
||
<Button variant="primary" type="submit"> | ||
Save Profile | ||
</Button> | ||
</Form> | ||
); | ||
}; | ||
|
||
export default ProfileForm; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters