From 2beda89dc1bb4da5b9c9da403709592ac02747ed Mon Sep 17 00:00:00 2001 From: Jihoo Kang Date: Mon, 16 Jun 2025 18:56:03 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EC=8B=A4=EC=A0=84=EC=BD=94?= =?UTF-8?q?=EB=94=A9=20=EA=B3=BC=EC=A0=9C=201~3=20=EC=99=84=EB=A3=8C=20(20?= =?UTF-8?q?2302522=20=EA=B0=95=EC=A7=80=ED=9B=84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 ++++++++ .idea/cnu-next.iml | 9 +++++++++ .idea/inspectionProfiles/Project_Default.xml | 6 ++++++ .idea/misc.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ 6 files changed, 43 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/cnu-next.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..c3f502a --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/cnu-next.iml b/.idea/cnu-next.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/cnu-next.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..03d9549 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..07115cd --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..388d1ac --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 3f286fea9f3de63e73832439ea5a7a9a1bbd0e16 Mon Sep 17 00:00:00 2001 From: Jihoo Kang Date: Wed, 25 Jun 2025 19:27:23 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=EC=A0=9C=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- next.config.ts | 4 +-- package-lock.json | 4 +-- src/app/checkout/page.tsx | 47 +++++++++++++++++++++++--- src/app/layout.tsx | 13 ++++--- src/app/mypage/page.tsx | 20 ++++++++++- src/app/search/page.tsx | 43 ++++++++++++++++++++--- src/component/layout/Footer.tsx | 3 +- src/component/layout/Header.tsx | 11 +++--- src/component/search/SearchInput.tsx | 42 +++++++++++++++++------ src/component/shopping/CartList.tsx | 46 ++++++++++++++++++++++--- src/component/shopping/ProductCart.tsx | 21 +++++------- src/context/SearchContext.tsx | 31 +++++++---------- src/context/UserContext.tsx | 42 ++++++++++++----------- 13 files changed, 235 insertions(+), 92 deletions(-) diff --git a/next.config.ts b/next.config.ts index 5b0285a..25a4053 100644 --- a/next.config.ts +++ b/next.config.ts @@ -3,8 +3,8 @@ import type { NextConfig } from "next"; const nextConfig = { reactStrictMode: false, images: { - domains: ["shopping-phinf.pstatic.net"], - }, + domains: ["shopping-phinf.pstatic.net", "via.placeholder.com"], + } }; module.exports = nextConfig; diff --git a/package-lock.json b/package-lock.json index 22c80ad..0b88957 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "cnu-next-week02", + "name": "cnu-next", "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "cnu-next-week02", + "name": "cnu-next", "version": "0.1.0", "dependencies": { "next": "15.3.3", diff --git a/src/app/checkout/page.tsx b/src/app/checkout/page.tsx index 0d40153..7ef1495 100644 --- a/src/app/checkout/page.tsx +++ b/src/app/checkout/page.tsx @@ -1,21 +1,58 @@ +"use client"; // CheckoutPage -import { useState } from "react"; +import { useState, useEffect } from "react"; +import { useRouter } from "next/navigation"; import { ProductItem } from "@/types/Product"; -interface CheckoutItem { - product: ProductItem; +interface CheckoutItem extends ProductItem { quantity: number; } // 과제 3 export default function CheckoutPage() { const [items, setItems] = useState([]); - // 3.1. 결제하기 구현 + const router = useRouter(); + + useEffect(() => { + const storedItems = localStorage.getItem("checkoutItems"); + if (storedItems) { + setItems(JSON.parse(storedItems)); + localStorage.removeItem("checkoutItems"); + } + }, []); + return (

✅ 결제가 완료되었습니다!

{/* 3.1. 결제하기 구현 */} -
+ {items.length === 0 ? ( +

결제된 아이템이 없습니다

+ ) : ( +
+ {items.map((item, index) => ( +
+

상품명: {item.title}

+

가격: {item.lprice}

+

수량: {item.quantity}

+
+ ))} +

+ 총 금액:{" "} + {items.reduce( + (sum, item) => sum + Number(item.lprice) * item.quantity, + 0 + ).toLocaleString()}원 +

+
+ )} {/* 3.2. 홈으로 가기 버튼 구현 */} +
+ +
); } diff --git a/src/app/layout.tsx b/src/app/layout.tsx index f7fa87e..9366181 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,3 +1,6 @@ +import { UserProvider } from "@/context/UserContext"; +import Header from "@/component/layout/Header"; +import Footer from "@/component/layout/Footer"; import type { Metadata } from "next"; import { Geist, Geist_Mono } from "next/font/google"; import "./globals.css"; @@ -24,10 +27,12 @@ export default function RootLayout({ }>) { return ( - - {children} + + +
+
{children}
+