From c81fba3535f654674ef3c21c1c3edfd2f7de3e6b Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Thu, 19 Sep 2024 20:10:01 +0600 Subject: [PATCH] feat: update public profile --- src/components/Dashboard/DashboardPage.tsx | 3 +- .../Dashboard/PersonalDashboard.tsx | 86 ++++++++++++++----- .../UpdateProfile/UpdatePublicProfileForm.tsx | 33 +++++++ .../UserPublicProfileHeader.tsx | 18 +++- 4 files changed, 114 insertions(+), 26 deletions(-) diff --git a/src/components/Dashboard/DashboardPage.tsx b/src/components/Dashboard/DashboardPage.tsx index 9bf8e37cf..3284ab58e 100644 --- a/src/components/Dashboard/DashboardPage.tsx +++ b/src/components/Dashboard/DashboardPage.tsx @@ -54,13 +54,14 @@ export function DashboardPage(props: DashboardPageProps) { return (
-
+
setSelectedTeamId(undefined)} avatar={userAvatar} /> + {isLoading && ( <> diff --git a/src/components/Dashboard/PersonalDashboard.tsx b/src/components/Dashboard/PersonalDashboard.tsx index 421228817..0b75b8778 100644 --- a/src/components/Dashboard/PersonalDashboard.tsx +++ b/src/components/Dashboard/PersonalDashboard.tsx @@ -14,6 +14,9 @@ import { CheckEmoji } from '../ReactIcons/CheckEmoji.tsx'; import { ConstructionEmoji } from '../ReactIcons/ConstructionEmoji.tsx'; import { BookEmoji } from '../ReactIcons/BookEmoji.tsx'; import { DashboardAiRoadmaps } from './DashboardAiRoadmaps.tsx'; +import type { AllowedProfileVisibility } from '../../api/user.ts'; +import { PencilIcon, type LucideIcon } from 'lucide-react'; +import { cn } from '../../lib/classname.ts'; type UserDashboardResponse = { name: string; @@ -21,6 +24,7 @@ type UserDashboardResponse = { avatar: string; headline: string; username: string; + profileVisibility: AllowedProfileVisibility; progresses: UserProgress[]; projects: ProjectStatusDocument[]; aiRoadmaps: { @@ -222,18 +226,20 @@ export function PersonalDashboard(props: PersonalDashboardProps) { return 0; }); + const { username } = personalDashboardDetails || {}; + return (
{isLoading ? (
) : ( -
+

Hi {name}, good {getCurrentPeriod()}!

Visit Homepage @@ -253,8 +259,16 @@ export function PersonalDashboard(props: PersonalDashboardProps) { - {Icon && ( -
- -
+
+ + {Icon && ( +
+ +
+ )} + + {imgUrl && ( +
+ {title} +
+ )} - {imgUrl && ( -
- {title} +
+

{title}

+

{description}

+
+ + {externalLinkHref && ( + + {ExternalLinkIcon && } + {externalLinkText} + )} - -
-

{title}

-

{description}

-
- +
); } diff --git a/src/components/UpdateProfile/UpdatePublicProfileForm.tsx b/src/components/UpdateProfile/UpdatePublicProfileForm.tsx index 9162082b5..406e7177d 100644 --- a/src/components/UpdateProfile/UpdatePublicProfileForm.tsx +++ b/src/components/UpdateProfile/UpdatePublicProfileForm.tsx @@ -71,6 +71,7 @@ export function UpdatePublicProfileForm() { const [profileRoadmaps, setProfileRoadmaps] = useState([]); const [isLoading, setIsLoading] = useState(false); + const [isProfileUpdated, setIsProfileUpdated] = useState(false); const { isCopied, copyText } = useCopyText(); @@ -109,6 +110,7 @@ export function UpdatePublicProfileForm() { await loadProfileSettings(); toast.success('Profile updated successfully'); + setIsProfileUpdated(true); }; const loadProfileSettings = async () => { @@ -593,6 +595,37 @@ export function UpdatePublicProfileForm() { > {isLoading ? 'Please wait..' : 'Save Profile'} + {isProfileUpdated && publicProfileUrl && ( +
+ + + + View Profile + +
+ )}
); diff --git a/src/components/UserPublicProfile/UserPublicProfileHeader.tsx b/src/components/UserPublicProfile/UserPublicProfileHeader.tsx index 81c3f5646..794e8abca 100644 --- a/src/components/UserPublicProfile/UserPublicProfileHeader.tsx +++ b/src/components/UserPublicProfile/UserPublicProfileHeader.tsx @@ -3,6 +3,7 @@ import { Globe, LinkedinIcon, Mail, + Pencil, Twitter, } from 'lucide-react'; import type { GetPublicProfileResponse } from '../../api/user'; @@ -15,11 +16,12 @@ type UserPublicProfileHeaderProps = { export function UserPublicProfileHeader(props: UserPublicProfileHeaderProps) { const { userDetails } = props; - const { name, links, publicConfig, avatar, email } = userDetails; + const { name, links, publicConfig, avatar, email, isOwnProfile } = + userDetails; const { headline, isAvailableForHire, isEmailVisible } = publicConfig!; return ( -
+
{name}
@@ -51,6 +53,16 @@ export function UserPublicProfileHeader(props: UserPublicProfileHeaderProps) { {isEmailVisible && }
+ + {isOwnProfile && ( + + + Edit Profile + + )}
); }