forked from woowacourse/react-payments
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCVCInput.jsx
More file actions
46 lines (42 loc) · 1.04 KB
/
CVCInput.jsx
File metadata and controls
46 lines (42 loc) · 1.04 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
import React from "react";
import { RULE_INPUT } from "constants/constants";
import {
FlexWrapper,
InputBasic,
InputBox,
InputTitle,
InputContainer,
TipButton,
} from "components/common";
export const CVCInput = ({
isValid,
handleCardCVCCheck,
handleModalVisible,
}) => {
const handleCVCChange = (e) => {
if (isNaN(e.target.value)) {
e.target.value = e.target.value.slice(0, e.target.value.length - 1);
return;
}
handleCardCVCCheck(e.target.value.length === 3);
};
return (
<InputContainer>
<InputTitle htmlFor="input_CVC" isValid={isValid}>
보안카드(CVC/CVV)
</InputTitle>
<FlexWrapper alignItems="baseline" gap="10px">
<InputBox width="25%">
<InputBasic
type="password"
id="input_CVC"
maxLength="3"
pattern={RULE_INPUT.CVC_RULE}
onChange={handleCVCChange}
/>
</InputBox>
<TipButton onClick={handleModalVisible} contents="?" />
</FlexWrapper>
</InputContainer>
);
};