Skip to content

feat(web-ui): improve profile page #795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions services/web-ui/public/locales/en/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"placeholder": "Describe yourself in a few words"
},
"header": "Profile",
"links": {
"blog": "Blog"
},
"save": "Save",
"update": {
"error": "There was an error when trying to update your profile",
Expand Down
3 changes: 3 additions & 0 deletions services/web-ui/public/locales/sv/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"placeholder": "Beskriv dig i ord"
},
"header": "Profil",
"links": {
"blog": "Blog"
},
"save": "Spara",
"update": {
"error": "Något gick fel när din profil skulle uppdateras",
Expand Down
3 changes: 3 additions & 0 deletions services/web-ui/public/locales/zh/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"placeholder": "简单描述一下自己"
},
"header": "个人资料",
"links": {
"blog": "博客"
},
"save": "保存",
"update": {
"error": "尝试更新您的个人资料时出错",
Expand Down
15 changes: 8 additions & 7 deletions services/web-ui/src/pages/ProfilePage/ProfilePage.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Avatar, Typography } from "@mui/material";

import { ProfileDetails } from "src/api";
import { Center } from "src/components/ui/Center";
import { useTranslation } from "src/core/i18n";

export interface ProfilePageComponentProps {
profile: ProfileDetails;
Expand All @@ -13,19 +12,21 @@ export interface ProfilePageComponentProps {
export function ProfilePageComponent({
profile,
}: ProfilePageComponentProps): ReactElement {
const { t } = useTranslation("profile");

return (
<>
<Center>
<Avatar src={profile.photo?.url} sx={{ height: 150, width: 150 }} />
</Center>

<Typography gutterBottom sx={{ paddingTop: 2 }} variant="h5">
{t("description.title")}
</Typography>
<Center>
<Typography gutterBottom sx={{ paddingTop: 2 }} variant="h5">
{profile.name}
</Typography>
</Center>

<Typography>{profile.description}</Typography>
<Center>
<Typography>{profile.description}</Typography>
</Center>
</>
);
}
24 changes: 9 additions & 15 deletions services/web-ui/src/pages/ProfilePage/ProfilePage.container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CacheKeysConstants, useQuery } from "src/core/query";
import { ErrorView } from "src/views/ErrorView";

import { ProfilePageComponent } from "./ProfilePage.component";
import { ProfilePageHeader } from "./ProfilePage.header";
import { ProfilePageNav } from "./ProfilePage.nav";
import { ProfilePageSkeleton } from "./ProfilePage.skeleton";

export function ProfilePageContainer(): ReactElement {
Expand All @@ -21,37 +21,31 @@ export function ProfilePageContainer(): ReactElement {

if (error) {
return (
<>
<ProfilePageHeader />
<ProfilePageNav>
<ErrorView error={error} />
</>
</ProfilePageNav>
);
}

if (isPending) {
return (
<>
<ProfilePageHeader />
<ProfilePageNav>
<ProfilePageSkeleton />
</>
</ProfilePageNav>
);
}

if (!data) {
return (
<>
<ProfilePageHeader />

<ProfilePageNav>
<Typography>Nothing found</Typography>
</>
</ProfilePageNav>
);
}

return (
<>
<ProfilePageHeader />

<ProfilePageNav>
<ProfilePageComponent profile={data} />
</>
</ProfilePageNav>
);
}
17 changes: 0 additions & 17 deletions services/web-ui/src/pages/ProfilePage/ProfilePage.header.tsx

This file was deleted.

22 changes: 22 additions & 0 deletions services/web-ui/src/pages/ProfilePage/ProfilePage.nav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ReactElement } from "react";

import { Box } from "@mui/material";

import { NavLayout } from "src/components/layout";
import { useTranslation } from "src/core/i18n";

interface ProfilePageNavProps {
children: ReactElement;
}

export function ProfilePageNav({
children,
}: ProfilePageNavProps): ReactElement {
const { t } = useTranslation("profile");

return (
<NavLayout linkText={t("links.blog")} to="/">
<Box sx={{ pt: 1 }}>{children}</Box>
</NavLayout>
);
}
Loading