Skip to content

Commit ce9c60e

Browse files
committed
feat: pay, account 관련 empty case 처리
1 parent 5466a2f commit ce9c60e

File tree

7 files changed

+102
-41
lines changed

7 files changed

+102
-41
lines changed

next.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
4+
reactStrictMode: false,
45
async rewrites() {
56
return [
67
{

src/app/(with-layout)/pay/(components)/pay-card.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import "swiper/css/effect-flip";
77
import { EffectFlip } from "swiper/modules";
88
import { Swiper, SwiperSlide } from "swiper/react";
99

10-
export default function PayCard() {
10+
interface Props {
11+
balance: number;
12+
}
13+
14+
export default function PayCard({ balance }: Props) {
1115
const [fullScreen, setFullScreen] = useState<boolean | HTMLImageElement>(
1216
false
1317
);
@@ -150,7 +154,7 @@ export default function PayCard() {
150154
<div className="flex flex-col gap-2">
151155
<div className="flex justify-between w-[200px]">
152156
<span className="text-bd3 xs:text-bd1">포인트</span>
153-
<span className="text-t4 xs:text-t3">8106원</span>
157+
<span className="text-t4 xs:text-t3">{balance}</span>
154158
</div>
155159
<div className="flex items-center justify-between w-[200px]">
156160
<span className="text-bd3 xs:text-bd1">머니</span>

src/app/(with-layout)/pay/accounts/add/page.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ export default function Page() {
4141
</Accordion.Summary>
4242
</div>
4343
<Accordion.Details>
44-
<div className="grid grid-cols-4 gap-5">
44+
<div className="grid grid-cols-4 gap-2">
4545
{bankList.map((bank) => (
4646
<button
4747
key={bank.id}
48-
className="hover:bg-shadow-800 aspect-square rounded-xl place-content-center select-none"
48+
className="hover:bg-shadow-800 p-2 aspect-square rounded-xl flex justify-center items-center select-none"
4949
onClick={() => handleBankClick(bank)}
5050
>
51-
<div className="flex flex-col gap-3 justify-center items-center">
51+
<div className="flex flex-col gap-2 justify-center items-center">
5252
<div className="bg-white rounded-xl p-2">
5353
<Image
5454
width={24}
@@ -58,7 +58,7 @@ export default function Page() {
5858
className="w-8 h-8"
5959
/>
6060
</div>
61-
<div className="text-bd1 font-bold text-center">
61+
<div className="text-bd4 xs:text-bd3 sm:text-bd1 font-bold text-center">
6262
{bank.name}
6363
</div>
6464
</div>

src/app/(with-layout)/pay/accounts/page.tsx

+33-10
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,38 @@
22
import BottomFixedButton, {
33
Button,
44
} from "@/app/(_components)/bottom-fixed-button";
5-
import Link from "next/link";
5+
import BottomSheet from "@/app/(_components)/bottom-sheet";
66
import { PATH } from "@/lib/_shared/paths";
7+
import { AccountType } from "@/types/api/pay";
8+
import getBankId from "@/utils/getBankName";
79
import Image from "next/image";
8-
import BottomSheet from "@/app/(_components)/bottom-sheet";
10+
import Link from "next/link";
911
import {
10-
useState,
1112
ChangeEventHandler,
1213
KeyboardEventHandler,
1314
useEffect,
15+
useState,
1416
} from "react";
1517

16-
const accounts = [
17-
{ id: "hana", name: "하나", accountNum: 1010102030210 },
18-
{ id: "woori", name: "우리", accountNum: 1000023366635 },
18+
const accounts: AccountType[] = [
19+
{
20+
accountId: 123,
21+
bankName: "하나",
22+
accountNum: 1010102030210,
23+
accountStatus: "ACTIVE",
24+
createdAt: new Date(),
25+
updatedAt: new Date(),
26+
accountHolder: "이채민",
27+
},
28+
{
29+
accountId: 2322,
30+
bankName: "우리",
31+
accountNum: 1000023366635,
32+
accountStatus: "ACTIVE",
33+
createdAt: new Date(),
34+
updatedAt: new Date(),
35+
accountHolder: "이채민",
36+
},
1937
];
2038

2139
const pay = 12230;
@@ -41,7 +59,12 @@ export default function AccountListPage() {
4159
<div className="flex flex-col gap-10 pt-5">
4260
<h1 className="text-t2">연결 계좌</h1>
4361
<ul className="flex flex-col ">
44-
{accounts.map(({ id, name, accountNum }) => (
62+
{accounts.length === 0 && (
63+
<div className="text-center text-shadow-500">
64+
등록된 계좌가 없습니다
65+
</div>
66+
)}
67+
{accounts.map(({ bankName, accountNum }) => (
4568
<div
4669
key={accountNum}
4770
className="flex justify-between hover:bg-shadow-800 p-5 rounded-xl"
@@ -51,12 +74,12 @@ export default function AccountListPage() {
5174
<Image
5275
width={28}
5376
height={28}
54-
src={`/icons/bank/${id}.svg`}
55-
alt={name}
77+
src={`/icons/bank/${getBankId(bankName)}.svg`}
78+
alt={bankName}
5679
/>
5780
</div>
5881
<div className="text-bd1">
59-
{name}&nbsp;
82+
{bankName}&nbsp;
6083
{accountNum.toString().slice(-4)}
6184
</div>
6285
</div>

src/app/(with-layout)/pay/page.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,27 @@ import Link from "next/link";
44
import BadgeStatus from "./(components)/badge-status";
55
import FundingProgress from "./(components)/funding-progress";
66
import GoCardBenefit from "./(components)/go-card-benefit";
7-
import PayCard from "./(components)/pay-card";
87
import PayNotice from "./(components)/pay-notice";
98
import PointMoney from "./(components)/point-money";
109

1110
export default async function HomePage() {
11+
// const { balance } = await getPay();
12+
const balance = 1000;
13+
1214
// TODO: 실제 데이터 fetching
1315
return (
1416
<div className="flex flex-col gap-5 w-full">
1517
{/** 알림 */}
1618
<PayNotice />
1719

1820
{/** 페이 */}
19-
<PayCard />
21+
<Link
22+
href={PATH.PAY_ACCOUNTS}
23+
className="card aspect-[1.6/1] w-full min-h-36 flex p-0 justify-center items-center "
24+
>
25+
페이 등록하기 +
26+
</Link>
27+
{/* <PayCard balance={balance} /> */}
2028

2129
{/** 포인트, 머니 */}
2230
<PointMoney />

src/types/api/pay.ts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { BankNameType } from "../bank";
2+
3+
export interface PayType {
4+
payNum: number;
5+
balance: number;
6+
createdAt: Date;
7+
updatedAt: Date;
8+
}
9+
10+
export interface PaymentType {
11+
userId: string;
12+
sellerId: string;
13+
orderName: string;
14+
}
15+
16+
export interface AccountType {
17+
accountId: number;
18+
accountNum: number;
19+
bankName: BankNameType;
20+
accountStatus: "ACTIVE" | "INACTIVE" | "SUSPENDED";
21+
accountHolder: string; // 계좌 주
22+
createdAt: Date;
23+
updatedAt: Date;
24+
}

src/utils/getBankName.ts

+24-23
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
// @deprecated
2-
export default function getBankName(bankId: string) {
3-
switch (bankId) {
4-
case "hana":
5-
return "하나";
6-
case "ibk":
7-
return "IBK";
8-
case "kakao":
9-
return "카카오";
10-
case "kb":
11-
return "KB";
12-
case "kbank":
13-
return "케이뱅크";
14-
case "nonghyup":
15-
return "농협";
16-
case "sc":
17-
return "SC제일";
18-
case "shinhan":
19-
return "신한";
20-
case "toss":
21-
return "토스";
22-
case "woori":
23-
return "우리";
1+
import { BankNameType } from "@/types/bank";
2+
3+
export default function getBankId(bankName: BankNameType) {
4+
switch (bankName) {
5+
case "하나":
6+
return "hana";
7+
case "IBK기업":
8+
return "ibk";
9+
case "카카오뱅크":
10+
return "kakao";
11+
case "국민":
12+
return "kb";
13+
case "케이뱅크":
14+
return "kbank";
15+
case "농협":
16+
return "nonghyup";
17+
case "SC제일":
18+
return "sc";
19+
case "신한":
20+
return "shinhan";
21+
case "토스뱅크":
22+
return "toss";
23+
case "우리":
24+
return "woori";
2425
default:
2526
return null;
2627
}

0 commit comments

Comments
 (0)