import Image from 'next/image'; import Link from 'next/link'; import { notFound, redirect } from 'next/navigation'; import { Trans } from '@lingui/macro'; import { FileIcon } from 'lucide-react'; import { DateTime } from 'luxon'; import { setupI18nSSR } from '@documenso/lib/client-only/providers/i18n.server'; import { NEXT_PUBLIC_WEBAPP_URL } from '@documenso/lib/constants/app'; import { getServerComponentSession } from '@documenso/lib/next-auth/get-server-component-session'; import { getPublicProfileByUrl } from '@documenso/lib/server-only/profile/get-public-profile-by-url'; import { extractInitials } from '@documenso/lib/utils/recipient-formatter'; import { formatDirectTemplatePath } from '@documenso/lib/utils/templates'; import { Avatar, AvatarFallback, AvatarImage } from '@documenso/ui/primitives/avatar'; import { Button } from '@documenso/ui/primitives/button'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@documenso/ui/primitives/table'; import { Tooltip, TooltipContent, TooltipTrigger } from '@documenso/ui/primitives/tooltip'; export type PublicProfilePageProps = { params: { url: string; }; }; const BADGE_DATA = { Premium: { imageSrc: '/static/premium-user-badge.svg', name: 'Premium', }, EarlySupporter: { imageSrc: '/static/early-supporter-badge.svg', name: 'Early supporter', }, }; export default async function PublicProfilePage({ params }: PublicProfilePageProps) { setupI18nSSR(); const { url: profileUrl } = params; if (!profileUrl) { redirect('/'); } const publicProfile = await getPublicProfileByUrl({ profileUrl, }).catch(() => null); if (!publicProfile || !publicProfile.profile.enabled) { notFound(); } const { user } = await getServerComponentSession(); const { profile, templates } = publicProfile; return (
{publicProfile.avatarImageId && ( )} {extractInitials(publicProfile.name)}

{publicProfile.name}

{publicProfile.badge && ( Profile badge Profile badge

{BADGE_DATA[publicProfile.badge.type].name}

Since {DateTime.fromJSDate(publicProfile.badge.since).toFormat('LLL ‘yy')}

)}
{(profile.bio ?? '').split('\n').map((line, index) => (

{line}

))}
{templates.length === 0 && (

It looks like {publicProfile.name} hasn't added any documents to their profile yet. {' '} {!user?.id && ( While waiting for them to do so you can create your own Documenso account and get started with document signing right away. )} {'userId' in profile && user?.id === profile.userId && ( Go to your{' '} public profile settings {' '} to add documents. )}

)} {templates.length > 0 && (
Documents {templates.map((template) => (

{template.publicTitle}

{template.publicDescription}

))}
)}
); }