@@ -3,6 +3,8 @@ import { notFound } from 'next/navigation';
33import type { Metadata } from 'next' ;
44import { getOrderDetail } from '@/app/actions/order' ;
55import Image from 'next/image' ;
6+ import { auth } from '/auth' ;
7+ import { redirect } from 'next/navigation' ;
68
79export const metadata : Metadata = {
810 title : '주문 완료 - 온길' ,
@@ -13,12 +15,12 @@ interface PageProps {
1315}
1416
1517export default async function OrderCompletePage ( { searchParams } : PageProps ) {
18+ const session = await auth ( ) ;
19+ if ( ! session ) redirect ( '/login' ) ;
1620 const { orderId } = await searchParams ;
17-
1821 if ( ! orderId || isNaN ( Number ( orderId ) ) ) {
1922 notFound ( ) ;
2023 }
21-
2224 const order = await getOrderDetail ( Number ( orderId ) ) ;
2325
2426 return (
@@ -36,7 +38,7 @@ export default async function OrderCompletePage({ searchParams }: PageProps) {
3638 주문번호: < span className = "" > { order . orderNumber } </ span >
3739 </ p >
3840
39- < div className = "mt-5 grid max-w-sm grid-cols-2 gap-3 text-xl font-medium text-white" >
41+ < div className = "mx-auto mt-5 grid max-w-sm grid-cols-2 gap-3 text-xl font-medium text-white" >
4042 < Link
4143 href = { `/orders/${ order . id } ` }
4244 className = "bg-ongil-teal flex items-center justify-center rounded-md px-6 py-2"
@@ -87,7 +89,7 @@ export default async function OrderCompletePage({ searchParams }: PageProps) {
8789 < div className = "mt-4 flex items-center justify-between pt-3 text-lg font-bold" >
8890 < span > 총 결제금액</ span >
8991 < span className = "text-xl text-blue-600" >
90- { order . totalAmount . toLocaleString ( ) } 원
92+ { ( order . totalAmount ?? 0 ) . toLocaleString ( ) } 원
9193 </ span >
9294 </ div >
9395 </ div >
0 commit comments