-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathCreditCard.js
More file actions
39 lines (32 loc) · 883 Bytes
/
CreditCard.js
File metadata and controls
39 lines (32 loc) · 883 Bytes
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
import "./CreditCard.css";
function CreditCard({
type,
number,
expirationMonth,
expirationYear,
bank,
owner,
bgColor,
color,
}) {
const cardTypeImg =
type === "Visa"
? "/assets/images/visa.png"
: "/assets/images/master-card.svg";
const maskedNumber = "•••• •••• •••• " + number.slice(-4);
return (
<div className="credit-card" style={{ backgroundColor: bgColor, color }}>
<img className="card-logo" src={cardTypeImg} alt={type} />
<div className="card-number">{maskedNumber}</div>
<div className="exp-bank">
<span>
Expires {String(expirationMonth).padStart(2, "0")}/
{String(expirationYear).slice(-2)}
</span>
<span className="bank">{bank}</span>
</div>
<div className="owner">{owner}</div>
</div>
);
}
export default CreditCard;