From 4c3de63290b75ba4731718adb85e9f231b0c0037 Mon Sep 17 00:00:00 2001 From: Wiktoria Salamon <39302106+wiktoriasalamon@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:51:01 +0200 Subject: [PATCH] refactor: use Avatar component in PeopleTable (#132) --- .../common/Avatar/Avatar.interface.ts | 3 +-- .../src/components/common/Avatar/Avatar.tsx | 17 ++++++++++------- .../src/components/modules/Topbar/Topbar.tsx | 2 +- .../People/Modules/PeopleTable/PeopleTable.tsx | 18 +++++++----------- .../PersonalDetails/PersonalDetails.tsx | 2 +- .../mySpace/MySpace/modules/Header/Header.tsx | 2 +- frontend/src/utils/index.ts | 1 + frontend/src/utils/string.ts | 6 ++++++ 8 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 frontend/src/utils/string.ts diff --git a/frontend/src/components/common/Avatar/Avatar.interface.ts b/frontend/src/components/common/Avatar/Avatar.interface.ts index bf712838..e545a0c6 100644 --- a/frontend/src/components/common/Avatar/Avatar.interface.ts +++ b/frontend/src/components/common/Avatar/Avatar.interface.ts @@ -1,7 +1,6 @@ export interface AvatarProps { variant?: AvatarVariant; - firstName: string; - lastName: string; + initials: string; imageUrl?: string | undefined; } diff --git a/frontend/src/components/common/Avatar/Avatar.tsx b/frontend/src/components/common/Avatar/Avatar.tsx index eab27758..d9b83360 100644 --- a/frontend/src/components/common/Avatar/Avatar.tsx +++ b/frontend/src/components/common/Avatar/Avatar.tsx @@ -13,21 +13,24 @@ const variants: { '320': 'w-80 h-80 text-5xl', }; -export const Avatar: React.FC = ({ firstName, lastName, imageUrl, variant = '40' }) => { +export const Avatar: React.FC = ({ initials, imageUrl, variant = '40' }) => { const avatarClass = generateClassNames( - 'rounded-full bg-blue-700 flex justify-center items-center', + 'rounded-full bg-blue-700 flex justify-center items-center object-cover', variants[variant], ); return (
{imageUrl ? ( - User avatar + User avatar ) : ( - - {firstName[0]} - {lastName[0]} - + {initials} )}
); diff --git a/frontend/src/components/modules/Topbar/Topbar.tsx b/frontend/src/components/modules/Topbar/Topbar.tsx index 09f7965c..2987ae75 100644 --- a/frontend/src/components/modules/Topbar/Topbar.tsx +++ b/frontend/src/components/modules/Topbar/Topbar.tsx @@ -45,7 +45,7 @@ export const Topbar = () => { Open user menu - + = ({ people }) => { @@ -48,16 +48,12 @@ export const PeopleTable: FC = ({ people }) => { {people?.map((person) => ( +
-
- User image -
{person.name} diff --git a/frontend/src/components/pages/ProfileSetting/modules/PersonalDetails/PersonalDetails.tsx b/frontend/src/components/pages/ProfileSetting/modules/PersonalDetails/PersonalDetails.tsx index 1b7f7026..5cc9fea4 100644 --- a/frontend/src/components/pages/ProfileSetting/modules/PersonalDetails/PersonalDetails.tsx +++ b/frontend/src/components/pages/ProfileSetting/modules/PersonalDetails/PersonalDetails.tsx @@ -32,7 +32,7 @@ export const PersonalDetails: React.FC = ({ data }) => { Profile photo - +