Repository navigation
Expand file tree
/
Copy pathProfilePage.js
More file actions
65 lines (59 loc) · 1.94 KB
/
Copy pathProfilePage.js
File metadata and controls
65 lines (59 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React, { useState } from 'react';
import './ProfilePage.css';
const ProfilePage = () => {
const [profileData, setProfileData] = useState({
name: 'John Doe',
bio: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
profilePicture: 'path/to/default-profile.jpg', // Update with a default or existing profile picture
});
const [isEditing, setIsEditing] = useState(false);
const [newData, setNewData] = useState({ ...profileData });
const handleInputChange = (e) => {
const { name, value } = e.target;
setNewData({ ...newData, [name]: value });
};
const handleProfileUpdate = () => {
setProfileData(newData);
setIsEditing(false);
};
const handleEditToggle = () => {
setIsEditing(!isEditing);
};
return (
<div className="profile-page">
<div className="profile-header">
<div className="profile-picture">
<img src={profileData.profilePicture} alt="Profile" />
</div>
<div className="profile-info">
{isEditing ? (
<div className="edit-form">
<input
type="text"
name="name"
value={newData.name}
onChange={handleInputChange}
placeholder="Name"
/>
<textarea
name="bio"
value={newData.bio}
onChange={handleInputChange}
placeholder="Bio"
/>
<button onClick={handleProfileUpdate}>Save</button>
</div>
) : (
<>
<h1>{profileData.name}</h1>
<p>{profileData.bio}</p>
<button onClick={handleEditToggle}>Edit Profile</button>
</>
)}
</div>
</div>
{/* Add additional profile sections here, e.g., posts, followers, etc. */}
</div>
);
};
export default ProfilePage;