Skip to content

Commit a977a95

Browse files
committed
add tags to profile
1 parent 437ca72 commit a977a95

File tree

13 files changed

+95
-19
lines changed

13 files changed

+95
-19
lines changed

src/core/adaptors/users/index.adaptors.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import {
55
addLanguage,
66
Education,
77
Experience,
8+
getUserDetails,
89
importLinkedin,
910
LanguageCode,
1011
ProjectType,
1112
reviews,
1213
updateWallet,
14+
UserDetails,
1315
} from 'src/core/api';
1416
import { getIdentityMeta } from 'src/core/utils';
1517
import { v4 as uuidv4 } from 'uuid';
@@ -146,3 +148,14 @@ export const updateWalletAdaptor = async (payload: WalletReq): Promise<AdaptorRe
146148
return { data: null, error: 'Error in updating user wallet' };
147149
}
148150
};
151+
152+
//FIXME Use this type after migrating to v3
153+
export const getUserDetailsAdaptor = async (username: string): Promise<AdaptorRes<UserDetails>> => {
154+
try {
155+
const data = await getUserDetails(username);
156+
return { data, error: null };
157+
} catch (error) {
158+
console.error('Error in getting user details: ', error);
159+
return { data: null, error: 'Error in getting user details' };
160+
}
161+
};

src/core/api/users/users.api.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
ReferReq,
2525
ImportRes,
2626
Reviews,
27+
UserDetails,
2728
} from './users.types';
2829

2930
const overwrittenConfigV3 = {
@@ -165,3 +166,7 @@ export async function importLinkedin(file: File): Promise<ImportRes> {
165166
export async function reviews(params: PaginateReq, filters?: FilterReq): Promise<Reviews> {
166167
return (await get<Reviews>('user/reviews', { params }, filters)).data;
167168
}
169+
170+
export async function getUserDetails(username: string): Promise<UserDetails> {
171+
return (await get<UserDetails>(`users/by-username/${username}`, { ...overwrittenConfigV3 })).data;
172+
}

src/core/api/users/users.types.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,27 @@ export interface Review {
280280
export interface Reviews extends PaginateRes {
281281
items: Review[];
282282
}
283+
284+
//FIXME Use this type after migrating to v3
285+
export interface UserDetails {
286+
id: string;
287+
first_name: string;
288+
last_name: string;
289+
username: string;
290+
mission: string | null;
291+
impact_points: number;
292+
social_causes: string[];
293+
followers: number;
294+
followings: number;
295+
skills: string[];
296+
open_to_work: boolean;
297+
open_to_volunteer: boolean;
298+
identity_verified: boolean;
299+
events: string[];
300+
tags: string[];
301+
avatar_id: string | null;
302+
avatar: Media | null;
303+
cover_id: string | null;
304+
cover: Media | null;
305+
created_at: string;
306+
}

src/core/router/router.blueprint.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import FallBack from 'src/pages/error/fallback/fallback';
4040
import { NotFound } from 'src/pages/error/notFound';
4141
import { RootState } from 'src/store';
4242

43-
import { getReviewsAdaptor } from '../adaptors/users/index.adaptors';
43+
import { getReviewsAdaptor, getUserDetailsAdaptor } from '../adaptors/users/index.adaptors';
4444
import { DeepLinks } from '../deepLinks';
4545
import { checkSearchFilters } from '../utils';
4646

@@ -84,12 +84,14 @@ export const blueprint: RouteObject[] = [
8484
kind: 'SERVICE',
8585
});
8686
const reviews = await getReviewsAdaptor(1, 5);
87+
const userDetails = await getUserDetailsAdaptor(params.id);
8788
// Keep this, it might be needed in the future
8889
// const [userBadges, missions] = await Promise.all([badges(user.id), userMissions(user.id)]);
8990
return {
9091
user,
9192
services: services.data,
9293
reviews: reviews.data,
94+
userTags: userDetails.data?.tags || [],
9395
// badges: userBadges,
9496
// missions,
9597
};

src/core/translation/locales/en/profile.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"request-sent": "Request sent",
1717
"connect": "Connect",
1818
"message": "Message"
19-
}
19+
},
20+
"available-for-work": "Available for work",
21+
"hiring": "Hiring"
2022
},
2123
"main-info": {
2224
"connections": "connections",

src/core/translation/locales/es/profile.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"request-sent": "Solicitud enviada",
1717
"connect": "Conectar",
1818
"message": "Mensaje"
19-
}
19+
},
20+
"available-for-work": "Disponible para trabajar",
21+
"hiring": "Contratando"
2022
},
2123
"main-info": {
2224
"connections": "conexiones",

src/core/translation/locales/jp/profile.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"request-sent": "リクエスト送信済み",
1717
"connect": "接続",
1818
"message": "メッセージ"
19-
}
19+
},
20+
"available-for-work": "仕事を探しています",
21+
"hiring": "採用中"
2022
},
2123
"main-info": {
2224
"connections": "つながり",

src/core/translation/locales/kr/profile.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"request-sent": "요청 전송됨",
1717
"connect": "연결",
1818
"message": "메시지"
19-
}
19+
},
20+
"available-for-work": "구직 중",
21+
"hiring": "채용 중"
2022
},
2123
"main-info": {
2224
"connections": "연결",

src/modules/userProfile/components/profileHeader/desktopHeader.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { ConnectStatus, Organization, User } from 'src/core/api';
3-
import { getIdentityMeta } from 'src/core/utils';
3+
import { getIdentityMeta, translate } from 'src/core/utils';
44
import { ThreeDotsButton } from 'src/modules/connections/threeDotsButton';
55
import { AvatarProfile } from 'src/modules/general/components/avatarProfile';
66
import { Button } from 'src/modules/general/components/Button';
@@ -26,11 +26,11 @@ interface DesktopHeaderProps {
2626
displayConnectButton: () => boolean;
2727
displayMessageButton: () => boolean;
2828
displayThreeDotsButton: () => boolean;
29+
userTags: string[];
2930
}
3031
export const DesktopHeader: React.FC<DesktopHeaderProps> = ({
3132
identity,
3233
myProfile,
33-
isLoggedIn,
3434
connectStatus,
3535
handleOpenEditInfoModal,
3636
handleOpenQRCodeModal,
@@ -41,6 +41,7 @@ export const DesktopHeader: React.FC<DesktopHeaderProps> = ({
4141
displayConnectButton,
4242
displayMessageButton,
4343
displayThreeDotsButton,
44+
userTags,
4445
}) => {
4546
const { username, name, profileImage } = getIdentityMeta(identity);
4647

@@ -59,7 +60,7 @@ export const DesktopHeader: React.FC<DesktopHeaderProps> = ({
5960
<div className="text-2xl md:text-3xl font-semibold text-Gray-light-mode-900">{name}</div>
6061
{type === 'users' && (identity as User).open_to_work && (
6162
<Chip
62-
label="Available for work"
63+
label={translate('profile-header.available-for-work')}
6364
size="lg"
6465
theme="secondary"
6566
startIcon={<Dot color={variables.color_success_500} size="small" shadow={false} />}
@@ -69,13 +70,16 @@ export const DesktopHeader: React.FC<DesktopHeaderProps> = ({
6970

7071
{type === 'organizations' && (identity as Organization).hiring && (
7172
<Chip
72-
label="Hiring"
73+
label={translate('profile-header.hiring')}
7374
size="lg"
7475
theme="secondary"
7576
startIcon={<Dot color={variables.color_success_500} size="small" shadow={false} />}
7677
shape="sharp"
7778
/>
7879
)}
80+
81+
{type === 'users' &&
82+
userTags.map(tag => <Chip key={tag} label={tag} size="lg" theme="secondary" shape="sharp" />)}
7983
</div>
8084
<div className="text-base font-normal text-Gray-light-mode-500">{username}</div>
8185
</div>
@@ -88,7 +92,7 @@ export const DesktopHeader: React.FC<DesktopHeaderProps> = ({
8892
onClick={handleOpenQRCodeModal}
8993
>
9094
<Icon fontSize={20} name="share-01" color={variables.color_grey_700} />
91-
Share
95+
{translate('profile-header.actions.share')}
9296
</Button>
9397
{displayMessageButton() && (
9498
<Button
@@ -97,7 +101,7 @@ export const DesktopHeader: React.FC<DesktopHeaderProps> = ({
97101
style={{ height: '40px', fontSize: '14px' }}
98102
onClick={handleMessage}
99103
>
100-
Message
104+
{translate('profile-header.actions.message')}
101105
</Button>
102106
)}
103107
{displayConnectButton() && (
@@ -108,7 +112,9 @@ export const DesktopHeader: React.FC<DesktopHeaderProps> = ({
108112
style={{ height: '40px', fontSize: '14px' }}
109113
onClick={() => setOpenConnectRequest(true)}
110114
>
111-
{connectStatus === 'PENDING' ? 'Request sent' : 'Connect'}
115+
{connectStatus === 'PENDING'
116+
? translate('profile-header.actions.request-sent')
117+
: translate('profile-header.actions.connect')}
112118
</Button>
113119
)}
114120
{displayThreeDotsButton() && <ThreeDotsButton otherIdentityId={identity?.id || ''} />}

src/modules/userProfile/components/profileHeader/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ import { EditImageModal } from '../../containers/editImage';
1616
import { EditInfoOrgModal } from '../../containers/editInfoOrg';
1717
import { ShareProfile } from '../../containers/shareProfile';
1818

19-
export const ProfileHeader = () => {
19+
interface ProfileHeaderProps {
20+
userTags?: string[];
21+
}
22+
23+
export const ProfileHeader = ({ userTags = [] }: ProfileHeaderProps) => {
2024
const {
2125
identity,
2226
identityType,
@@ -100,13 +104,15 @@ export const ProfileHeader = () => {
100104
displayConnectButton={displayConnectButton}
101105
displayMessageButton={displayMessageButton}
102106
displayThreeDotsButton={displayThreeDotsButton}
107+
userTags={userTags}
103108
/>
104109
<MobileHeader
105110
identity={identity}
106111
type={identityType}
107112
myProfile={myProfile}
108113
handleOpenEditInfoModal={handleOpenEditInfoModal}
109114
handleOpenEditAvatar={handleOpenEditAvatar}
115+
userTags={userTags}
110116
/>
111117
</div>
112118
<div className="md:hidden">

0 commit comments

Comments
 (0)