Files
setrip/components/shared/profile-nudge-banner.tsx

42 lines
1.5 KiB
TypeScript

import Link from "next/link";
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
import { profileRepo } from "@/server/repositories/profile.repo";
/**
* Server component banner: muncul di atas semua halaman ketika user sudah login
* tapi profil sosialnya kosong. Menjaga janji "kenalan dulu, gabung kemudian"
* dengan mendorong user mengisi minat/kota sebelum join trip.
*/
export async function ProfileNudgeBanner() {
const session = await getServerSession(authOptions);
if (!session?.user?.id) return null;
const profile = await profileRepo.findByUserId(session.user.id);
const hasMeaningfulProfile =
!!profile &&
(!!profile.bio?.trim() ||
!!profile.city?.trim() ||
profile.interests.length > 0);
if (hasMeaningfulProfile) return null;
return (
<div className="border-b border-amber-200 bg-amber-50">
<div className="mx-auto flex max-w-6xl flex-col items-start gap-2 px-4 py-2.5 text-xs sm:flex-row sm:items-center sm:justify-between sm:text-sm">
<p className="text-amber-900">
<span className="font-semibold">Lengkapi profil sosial kamu</span>
bio, kota, dan minat. Calon teman trip akan lebih mudah kenal kamu
sebelum gabung bareng.
</p>
<Link
href="/profile"
className="shrink-0 rounded-lg bg-amber-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-amber-700"
>
Isi profil sekarang
</Link>
</div>
</div>
);
}