Skip to content

Commit 482c604

Browse files
committed
refactor(UserProfile): add fields for GitHub, LinkedIn, Twitter profiles and location
1 parent a43a803 commit 482c604

File tree

1 file changed

+84
-26
lines changed

1 file changed

+84
-26
lines changed

app/[locale]/dashboard/[entityType]/[entitySlug]/profile/userProfile.tsx

Lines changed: 84 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { UpdateUserInput } from '@/gql/generated/graphql';
77
import { useMutation } from '@tanstack/react-query';
88
import { Button, DropZone, Text, TextField, toast } from 'opub-ui';
99

10-
import { GraphQL } from '@/lib/api';
1110
import { useDashboardStore } from '@/config/store';
11+
import { GraphQL } from '@/lib/api';
1212

1313
const updateUserMutation: any = graphql(`
1414
mutation updateUser($input: UpdateUserInput!) {
@@ -26,6 +26,10 @@ const updateUserMutation: any = graphql(`
2626
url
2727
}
2828
username
29+
githubProfile
30+
linkedinProfile
31+
twitterProfile
32+
location
2933
}
3034
}
3135
}
@@ -44,6 +48,10 @@ const UserProfile = () => {
4448
email: userDetails?.me?.email,
4549
bio: userDetails?.me?.bio,
4650
profilePicture: userDetails?.me?.profilePicture,
51+
githubProfile: userDetails?.me?.githubProfile,
52+
linkedinProfile: userDetails?.me?.linkedinProfile,
53+
twitterProfile: userDetails?.me?.twitterProfile,
54+
location: userDetails?.me?.location,
4755
});
4856
}
4957
}, [userDetails]);
@@ -54,6 +62,10 @@ const UserProfile = () => {
5462
email: '',
5563
bio: '',
5664
profilePicture: null as File | null,
65+
githubProfile: '',
66+
linkedinProfile: '',
67+
twitterProfile: '',
68+
location: '',
5769
};
5870

5971
const { mutate, isLoading: editMutationLoading } = useMutation(
@@ -68,6 +80,10 @@ const UserProfile = () => {
6880
email: res?.updateUser?.email,
6981
bio: res?.updateUser?.bio,
7082
profilePicture: res?.updateUser?.profilePicture,
83+
githubProfile: res?.updateUser?.githubProfile,
84+
linkedinProfile: res?.updateUser?.linkedinProfile,
85+
twitterProfile: res?.updateUser?.twitterProfile,
86+
location: res?.updateUser?.location,
7187
});
7288
setUserDetails({
7389
...userDetails,
@@ -89,6 +105,10 @@ const UserProfile = () => {
89105
lastName: formData.lastName,
90106
bio: formData.bio,
91107
email: formData.email,
108+
githubProfile: formData.githubProfile,
109+
linkedinProfile: formData.linkedinProfile,
110+
twitterProfile: formData.twitterProfile,
111+
location: formData.location,
92112
};
93113

94114
// Only add logo if it has changed
@@ -103,25 +123,28 @@ const UserProfile = () => {
103123
<div>
104124
<Text variant="headingXl">My Profile</Text>
105125
</div>
106-
<div className=" mt-6 flex flex-col gap-6">
107-
<div className="flex flex-wrap gap-6 lg:flex-nowrap">
126+
<div className=" mt-6 flex flex-col gap-4">
127+
<div className="flex flex-wrap gap-4 lg:flex-nowrap">
108128
<div className="flex w-full flex-col flex-wrap gap-4 lg:flex-nowrap">
109-
<div className="w-full">
110-
<TextField
111-
label="First Name"
112-
name="firstName"
113-
value={formData.firstName}
114-
onChange={(e) => setFormData({ ...formData, firstName: e })}
115-
/>
116-
</div>
117-
<div className="w-full">
118-
<TextField
119-
label="Last Name"
120-
name="lastName"
121-
value={formData.lastName}
122-
onChange={(e) => setFormData({ ...formData, lastName: e })}
123-
/>
129+
<div className="flex w-full flex-wrap gap-6 md:flex-nowrap lg:flex-nowrap">
130+
<div className="w-full">
131+
<TextField
132+
label="First Name"
133+
name="firstName"
134+
value={formData.firstName}
135+
onChange={(e) => setFormData({ ...formData, firstName: e })}
136+
/>
137+
</div>
138+
<div className="w-full">
139+
<TextField
140+
label="Last Name"
141+
name="lastName"
142+
value={formData.lastName}
143+
onChange={(e) => setFormData({ ...formData, lastName: e })}
144+
/>
145+
</div>
124146
</div>
147+
125148
<div className="w-full">
126149
<TextField
127150
label="Email"
@@ -130,8 +153,49 @@ const UserProfile = () => {
130153
onChange={(e) => setFormData({ ...formData, email: e })}
131154
/>
132155
</div>
156+
<div className="w-full">
157+
<TextField
158+
label="Location"
159+
name="location"
160+
value={formData.location}
161+
onChange={(e) => setFormData({ ...formData, location: e })}
162+
/>
163+
</div>
164+
</div>
165+
<div className="flex w-full flex-col gap-4">
166+
<TextField
167+
label="Github Profile"
168+
name="githubProfile"
169+
type="url"
170+
value={formData.githubProfile}
171+
onChange={(e) => setFormData({ ...formData, githubProfile: e })}
172+
/>
173+
<TextField
174+
label="Linkedin Profile"
175+
name="linkedinProfile"
176+
type="url"
177+
value={formData.linkedinProfile}
178+
onChange={(e) => setFormData({ ...formData, linkedinProfile: e })}
179+
/>
180+
<TextField
181+
label="Twitter Profile"
182+
name="twitterProfile"
183+
type="url"
184+
value={formData.twitterProfile}
185+
onChange={(e) => setFormData({ ...formData, twitterProfile: e })}
186+
/>
187+
</div>
188+
</div>
189+
<div className="flex w-full flex-col gap-4 lg:flex-row">
190+
<div className="w-full">
191+
<TextField
192+
label="Bio"
193+
name="bio"
194+
multiline={6}
195+
value={formData.bio}
196+
onChange={(e) => setFormData({ ...formData, bio: e })}
197+
/>
133198
</div>
134-
135199
<div className="w-full">
136200
<DropZone
137201
label={'Upload Profile Picture'}
@@ -148,13 +212,7 @@ const UserProfile = () => {
148212
</DropZone>
149213
</div>
150214
</div>
151-
<TextField
152-
label="Bio"
153-
name="bio"
154-
multiline={6}
155-
value={formData.bio}
156-
onChange={(e) => setFormData({ ...formData, bio: e })}
157-
/>
215+
158216
<Button className="m-auto w-1/6" onClick={handleSave}>
159217
Save
160218
</Button>

0 commit comments

Comments
 (0)