-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathCreditCard.js
More file actions
51 lines (44 loc) · 1.17 KB
/
CreditCard.js
File metadata and controls
51 lines (44 loc) · 1.17 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
import React from 'react';
import './CreditCard.css';
import mCard from '../assets/images/MasterCard.png'
import visa from '../assets/images/visa.png';
const CreditCard = ({
type,
number,
expirationMonth,
expirationYear,
bank,
owner,
bgColor,
color,
}) => {
const lastFourDigits = number.slice(-4);
const formattedMonth = expirationMonth.toString().padStart(2, "0");
const cardLogo = type === "Visa" ? visa : mCard;
return (
<div className='main'>
<div
className="credit-card"
style={{ backgroundColor: bgColor, color: color }}
>
<div className="card-logo">
<img src={cardLogo} alt={`${type} logo`} />
</div>
<div className="card-number">
<p>•••• •••• •••• {lastFourDigits}</p>
</div>
<div className="card-info">
<span className="expiration">
Expires {formattedMonth}/{expirationYear}
</span>
<span className="bank">{bank}</span>
<span className="cardholder-name">
<br />
{owner}
</span>
</div>
</div>
</div>
);
};
export default CreditCard