test
Some checks failed
deploy-on-main / deploy (push) Failing after 22s

This commit is contained in:
koreacomp5
2025-11-09 22:05:22 +09:00
parent 34e831f738
commit a007ac11ce
21 changed files with 845 additions and 112 deletions

View File

@@ -1,4 +1,5 @@
import { headers } from "next/headers";
import { redirect } from "next/navigation";
import prisma from "@/lib/prisma";
import Link from "next/link";
import { UserAvatar } from "@/app/components/UserAvatar";
@@ -6,6 +7,7 @@ import { GradeIcon, getGradeName } from "@/app/components/GradeIcon";
import { HeroBanner } from "@/app/components/HeroBanner";
import { PostList } from "@/app/components/PostList";
import ProfileLabelIcon from "@/app/svgs/profilelableicon";
import { ProfileImageEditor } from "@/app/components/ProfileImageEditor";
export default async function MyPage({ searchParams }: { searchParams: Promise<{ tab?: string; page?: string; sort?: string; q?: string }> }) {
const sp = await searchParams;
const activeTab = sp?.tab || "posts";
@@ -26,35 +28,38 @@ export default async function MyPage({ searchParams }: { searchParams: Promise<{
try {
const h = await headers();
const cookieHeader = h.get("cookie") || "";
let isAdmin = false;
const uid = cookieHeader
.split(";")
.map((s) => s.trim())
.find((pair) => pair.startsWith("uid="))
?.split("=")[1];
const isAdminVal = cookieHeader
.split(";")
.map((s) => s.trim())
.find((pair) => pair.startsWith("isAdmin="))
?.split("=")[1];
isAdmin = isAdminVal === "1";
if (!uid) {
redirect(`/login?next=/my-page`);
}
if (uid) {
const user = await prisma.user.findUnique({
where: { userId: decodeURIComponent(uid) },
select: { userId: true, nickname: true, profileImage: true, points: true, level: true, grade: true },
});
if (user) currentUser = user;
if (user) {
currentUser = { ...user, isAdmin } as any;
} else {
redirect(`/login?next=/my-page`);
}
}
} catch (e) {
// 에러 무시
}
// 로그인되지 않은 경우 어드민 사용자 가져오기
if (!currentUser) {
const admin = await prisma.user.findUnique({
where: { nickname: "admin" },
select: { userId: true, nickname: true, profileImage: true, points: true, level: true, grade: true },
});
if (admin) currentUser = admin;
}
if (!currentUser) {
return <div className="p-4"> .</div>;
}
if (!currentUser) redirect(`/login?next=/my-page`);
// 통계 정보 가져오기
const [postsCount, commentsCount, receivedMessagesCount, sentMessagesCount] = await Promise.all([
@@ -84,7 +89,12 @@ export default async function MyPage({ searchParams }: { searchParams: Promise<{
<div className="space-y-6">
{/* 히어로 배너 */}
<section>
<HeroBanner />
<HeroBanner
subItems={[
{ id: "my-page", name: "마이페이지", href: "/my-page" },
]}
activeSubId="my-page"
/>
</section>
{/* 프로필 섹션 (모바일 대응) */}
@@ -114,12 +124,25 @@ export default async function MyPage({ searchParams }: { searchParams: Promise<{
<div className="flex items-center gap-[4px]">
<span className="text-[20px] font-bold text-[#5c5c5c] truncate max-w-[200px]">{currentUser.nickname || "사용자"}</span>
<button className="w-[20px] h-[20px] shrink-0">
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.7188 3.125L13.5938 4.99999L5.3125 13.2812L3.4375 11.4062L11.7188 3.125ZM14.0625 1.5625L15.3125 2.8125C15.625 3.12499 15.625 3.62499 15.3125 3.93749L13.4375 5.81249L11.5625 3.93749L13.4375 2.06249C13.75 1.74999 14.25 1.74999 14.5625 2.06249L14.0625 1.5625ZM3.125 14.375L9.0625 12.1875L7.1875 10.3125L3.125 14.375Z" fill="#707070"/>
<svg width="20" height="20" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.05882 10.9412H1.94929L9.17506 3.71541L8.28459 2.82494L1.05882 10.0507V10.9412ZM0.638118 12C0.457294 12 0.305765 11.9388 0.183529 11.8165C0.0611764 11.6942 0 11.5427 0 11.3619V10.1389C0 9.96682 0.0330587 9.80277 0.0991764 9.64677C0.165176 9.49077 0.256118 9.35483 0.372 9.23894L9.31094 0.304058C9.41765 0.207117 9.53547 0.132235 9.66441 0.0794118C9.79347 0.0264706 9.92877 0 10.0703 0C10.2118 0 10.3489 0.025118 10.4815 0.0753533C10.6142 0.125589 10.7316 0.20547 10.8339 0.315L11.6959 1.18782C11.8055 1.29006 11.8835 1.40771 11.9301 1.54076C11.9767 1.67382 12 1.80688 12 1.93994C12 2.08194 11.9758 2.21741 11.9273 2.34635C11.8788 2.47541 11.8017 2.59329 11.6959 2.7L2.76106 11.628C2.64518 11.7439 2.50924 11.8348 2.35324 11.9008C2.19724 11.9669 2.03318 12 1.86106 12H0.638118ZM8.72206 3.27794L8.28459 2.82494L9.17506 3.71541L8.72206 3.27794Z" fill="#707070"/>
</svg>
</button>
</div>
{/* 관리자 설정 버튼 */}
{"isAdmin" in (currentUser as any) && (currentUser as any).isAdmin && (
<div className="mt-1">
<Link
href="/admin"
className="inline-flex items-center h-9 px-4 rounded-md bg-neutral-900 text-white text-sm hover:bg-neutral-800"
>
</Link>
</div>
)}
</div>
{/* 프로필 이미지 편집 */}
<ProfileImageEditor initialUrl={currentUser.profileImage || null} />
{/* 레벨/등급/포인트 정보 - 가로 배치 */}
<div className="flex gap-3 md:gap-[16px] items-center justify-center">
<div className="flex items-center gap-[4px] min-w-0">