Skip to content
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

Improve profile page #1973

Merged
merged 1 commit into from
Jan 29, 2025
Merged
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
14 changes: 7 additions & 7 deletions apps/web/app/[language]/profile/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LinkButton } from '@gw2treasures/ui/components/Form/Button';
import { FormatDate } from '@/components/Format/FormatDate';
import { Headline } from '@gw2treasures/ui/components/Headline/Headline';
import { HeroLayout } from '@/components/Layout/HeroLayout';
Expand All @@ -8,11 +7,12 @@ import { db } from '@/lib/prisma';
import type { Metadata } from 'next';
import { redirect } from 'next/navigation';
import { Suspense, cache } from 'react';
import { FlexRow } from '@gw2treasures/ui/components/Layout/FlexRow';
import { Accounts } from './accounts';
import { Skeleton } from '@/components/Skeleton/Skeleton';
import { revalidatePath } from 'next/cache';
import { SubmitButton } from '@gw2treasures/ui/components/Form/Buttons/SubmitButton';
import { ExternalLink } from '@gw2treasures/ui/components/Link/ExternalLink';
import { pageView } from '@/lib/pageView';

const getUserData = cache(async () => {
const session = await getUser();
Expand Down Expand Up @@ -41,13 +41,13 @@ const getUserData = cache(async () => {

export default async function ProfilePage() {
const { sessionId, user } = await getUserData();
await pageView('profile');

return (
<HeroLayout hero={<Headline id="profile">{user.name}</Headline>} toc>
<FlexRow>
<LinkButton external href="/logout" icon="logout">Logout</LinkButton>
{user.roles.includes('Admin') && <LinkButton href="/admin/users">Admin</LinkButton>}
</FlexRow>
<p>
You can change your username on your <ExternalLink href="https://gw2.me/profile">gw2.me Profile</ExternalLink>.
</p>

<Headline id="accounts">Accounts</Headline>
<Suspense fallback={<Skeleton/>}>
Expand All @@ -68,7 +68,7 @@ export default async function ProfilePage() {
<tr key={session.id}>
<td>{session.info}{session.id === sessionId && ' (Current Session)'}</td>
<td><FormatDate relative date={session.createdAt}/></td>
<td><FormatDate relative date={session.lastUsed}/></td>
<td>{session.id === sessionId ? 'now' : <FormatDate relative date={session.lastUsed}/>}</td>
</tr>
))}
</tbody>
Expand Down
Loading