-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathCardNaming.tsx
More file actions
75 lines (69 loc) · 1.9 KB
/
Copy pathCardNaming.tsx
File metadata and controls
75 lines (69 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import styles from "./CardNaming.module.css";
import {
CardNumber,
CardType,
ExpirationDate,
TwoPasswordDigits,
} from "../CardRegister/types";
import PlasticCard from "../../component/PlaticCard/PlaticCard";
import Input from "../../../components/Input/Input";
import { ChangeEvent, useState } from "react";
export type CardQuery = {
cardNumber: CardNumber;
expiration: ExpirationDate;
cardHolder: string;
cvc: string;
cardType: CardType;
password?: TwoPasswordDigits;
};
export type NameQuery = {
cardName: string;
};
interface CardNamingProps {
card?: Omit<CardQuery, "password">;
onSubmit: (value: NameQuery) => void;
}
export default function CardNaming({
onSubmit,
card,
}: Readonly<CardNamingProps>) {
const [cardName, setCardName] = useState<string>("");
function completeRegist() {
onSubmit({ cardName: cardName ?? card?.cardType });
}
function changeCardName(event: ChangeEvent<HTMLInputElement>) {
setCardName(event.target.value);
}
return (
<div className={styles.result__container}>
<div>
<div className={styles.result__description}>
카드 등록이 완료되었습니다.
</div>
<div className={styles.result__card}>
<PlasticCard
cardNumber={card?.cardNumber}
cardType={card?.cardType}
holderName={card?.cardHolder}
expiration={card?.expiration}
/>
</div>
<div className={styles.result__name}>
<Input
maxLength={10}
placeholder="카드 별칭 (선택)"
textAlign="center"
hasUnderbar
value={cardName}
onChange={changeCardName}
/>
</div>
<div className={styles.result__check}>
<button onClick={completeRegist} className={styles.result__check_btn}>
확인
</button>
</div>
</div>
</div>
);
}