Skip to content

Commit efade16

Browse files
committed
Wire up edit mode toggle in profile view
1 parent ef7f082 commit efade16

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

src/features/profile/Profile.tsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,10 @@ import { authUsername } from '../auth/authSlice';
2626
import { usePageTitle } from '../layout/layoutSlice';
2727
import PageNotFound from '../layout/PageNotFound';
2828
import NarrativeList from '../navigator/NarrativeList/NarrativeList';
29+
import { ProfileEditForm } from './ProfileEditForm';
2930
import classes from './Profile.module.scss';
3031
import { Affiliation, ProfileData } from './profileTypes';
3132

32-
/*
33-
* The following components are stubs due to be written in the future.
34-
* NarrativesView
35-
* ProfileInfobox
36-
* ProfileNarrativesMessage
37-
* ProfileResume
38-
* ProfileView
39-
*/
40-
4133
export const ProfileNarrativesMessage: FC<{
4234
realname: string;
4335
yours: boolean;
@@ -50,10 +42,6 @@ export const ProfileNarrativesMessage: FC<{
5042
);
5143
};
5244

53-
export const ProfileResume: FC = () => {
54-
return <div>Profile Resume</div>;
55-
};
56-
5745
export const NarrativesView: FC<{ realname: string; yours: boolean }> = ({
5846
realname,
5947
yours,
@@ -79,16 +67,14 @@ export const NarrativesView: FC<{ realname: string; yours: boolean }> = ({
7967
);
8068
};
8169

82-
export const ProfileInfobox: FC<{ realname: string }> = ({ realname }) => {
83-
return <div>Profile Infobox for {realname}.</div>;
84-
};
85-
8670
export const ProfileView: FC<{
8771
realname: string;
8872
username: string;
8973
profileData: ProfileData;
9074
viewMine: boolean;
9175
}> = ({ realname, username, profileData, viewMine }) => {
76+
const [isEditing, setIsEditing] = useState(false);
77+
9278
const gravatarHash = profileData?.synced?.gravatarHash ?? '';
9379
const gravatarDefault = profileData?.userdata?.gravatarDefault ?? 'identicon';
9480
const avatarOption = profileData?.userdata?.avatarOption ?? 'gravatar';
@@ -112,6 +98,20 @@ export const ProfileView: FC<{
11298
const location = locationParts.join(', ');
11399
const researchStatement = profileData?.userdata?.researchStatement ?? '';
114100

101+
if (isEditing) {
102+
return (
103+
<div role="tabpanel" id="profile-tabpanel" aria-labelledby="profile-tab">
104+
<ProfileEditForm
105+
profileData={profileData}
106+
username={username}
107+
realname={realname}
108+
onCancel={() => setIsEditing(false)}
109+
onSaved={() => setIsEditing(false)}
110+
/>
111+
</div>
112+
);
113+
}
114+
115115
return (
116116
<div role="tabpanel" id="profile-tabpanel" aria-labelledby="profile-tab">
117117
<Grid container spacing={2}>
@@ -150,6 +150,7 @@ export const ProfileView: FC<{
150150
<Button
151151
variant="contained"
152152
startIcon={<FontAwesomeIcon icon={faEdit} />}
153+
onClick={() => setIsEditing(true)}
153154
>
154155
Edit Profile
155156
</Button>

0 commit comments

Comments
 (0)