-
Notifications
You must be signed in to change notification settings - Fork 208
[1단계 - 페이먼츠] - 하쿠(이동현) 미션 제출합니다. #432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
a298bb9
docs: 기능 명세 작성
ha-kuku fc8f4eb
chore: styled component 설치
ha-kuku 0fc0c15
feat: Input 컴포넌트 구현
ha-kuku 2491d57
style: input 스타일 변경
ha-kuku 38f0d57
feat: CardNumberInputs 구현
ha-kuku 3c87d9e
feat: input width 동적으로 조정
ha-kuku 6381154
feat:CardExpirationPeriodInputs 구현
ha-kuku dd03715
feat:CardCVCNumberInputs구현
ha-kuku 5940f2d
feat: SectionTitle 구현
ha-kuku 7bbf904
feat:CardNumberSection구현
ha-kuku 859f0f0
feat:CardExpirationPeriodSection 구현
ha-kuku ce0c0b7
feat:CardCVCNumberSection 구현
ha-kuku 3f77c59
feat:CardPreview UI 구현
ha-kuku 89b35a7
feat: inputProps type 삭제
ha-kuku 2f73a15
feat: 카드번호 동적 Ui로 표현
ha-kuku 96b5102
feat: cardNumberInput 유효성 검사 추가
ha-kuku 047115d
feat: cardExpirationPeriodInput 유효성 검사 추가
ha-kuku ac4a397
feat: cardExpirationPeriodInput UI 동적 표현
ha-kuku 91a1e48
feat: cardCVCNumberInput UI 동적 표현
ha-kuku b2d57e6
feat: cardPreview UI 동적 표현
ha-kuku 842e58a
fix: storybook 에러 수정
ha-kuku bea0cd5
fix: 경로 오류 수정
ha-kuku 64f29a9
style: styled component 변수명 변경
ha-kuku c9d806a
refactor: app UI 중앙 정렬
ha-kuku efc7db3
refactor: 공통 type 분리
ha-kuku 74da666
refactor: 상수화
ha-kuku 2c60150
refactor: 공통 로직 분리
ha-kuku d55a629
style: 코드 스타일 변경
ha-kuku 4eceaab
chore: chromatic workflow 추가
ha-kuku 0544ece
docs: 기능 사항 체크
ha-kuku 41f544b
feat: 페이지 배포
ha-kuku f79fc36
docs: 리팩터링 사항 추가
ha-kuku 9ed0df5
refactor: 카드 로고 동적 UI 구현 방식 변경
ha-kuku dc1aca9
refactor: validation 조건 수정
ha-kuku a8a3ce2
style: types 폴더명 앞 공백 제거
ha-kuku e9fe607
fix: 문자 입력 시 오류메시지 미로딩 오류 해결
ha-kuku 9b0b22d
refactor: 에러 처리 방식 변경
ha-kuku 1548759
refactor: input 중복 코드 줄이기
ha-kuku 0180a0f
style: 코드 포멧터 적용
ha-kuku 3a58d86
docs: 리팩터리 반영사항 체크
ha-kuku File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 45 additions & 46 deletions
91
src/components/cardCVCNumberInputs/CardCVCNumberInputs.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,58 +1,57 @@ | ||
| import Input from "../input/Input" | ||
| import { CardCVCNumberSectionProps } from "../../\btypes/index.types" | ||
| import { useState } from "react" | ||
| import { isValidLength, isValidNumber } from "../../util/validation" | ||
| import { NO_ERROR } from "../../constants/constant" | ||
| import { StyledContainer, StyledInputWrap, StyledErrorMessage } from "../../styled-component/inputs" | ||
| import Input from '../input/Input'; | ||
| import { CardCVCNumberSectionProps } from '../../types/index.types'; | ||
| import { useState } from 'react'; | ||
| import { isValidLength, isValidNumber } from '../../util/validation'; | ||
| import { NO_ERROR } from '../../constants/constant'; | ||
| import { StyledContainer, StyledInputWrap, StyledErrorMessage } from '../../styled-component/inputs'; | ||
|
|
||
| const CVC_NUMBER_LENGTH = 3; | ||
|
|
||
| const errorMessage = { | ||
| length: '3자리만 입력 가능합니다.', | ||
| number : '숫자만 입력 가능합니다.' | ||
| } | ||
| length: '3자리만 입력 가능합니다.', | ||
| number: '숫자만 입력 가능합니다.', | ||
| }; | ||
|
|
||
| function CardCVCNumberInputs({ CVCNumber, changeCVCNumber }: CardCVCNumberSectionProps) { | ||
| const [error, setError] = useState(NO_ERROR); | ||
|
|
||
| const [error, setError] = useState(NO_ERROR); | ||
|
|
||
| function checkValidation(length : number, CVCNumber: string) { | ||
| if (CVCNumber === NO_ERROR) { | ||
| setError(NO_ERROR) | ||
| return; | ||
| } | ||
|
|
||
| if (!isValidLength(CVCNumber, length)) { | ||
| setError(errorMessage.length) | ||
| return; | ||
| } | ||
| if (!isValidNumber(CVCNumber)) { | ||
| setError(errorMessage.number) | ||
| return; | ||
| } | ||
|
|
||
| setError(NO_ERROR) | ||
| function checkValidation(length: number, CVCNumber: string) { | ||
| if (CVCNumber === NO_ERROR) { | ||
| setError(NO_ERROR); | ||
| return; | ||
| } | ||
|
|
||
| if (!isValidLength(CVCNumber, length)) { | ||
| setError(errorMessage.length); | ||
| return; | ||
| } | ||
| if (!isValidNumber(CVCNumber)) { | ||
| setError(errorMessage.number); | ||
| return; | ||
| } | ||
|
|
||
| return ( | ||
| <StyledContainer> | ||
| <label htmlFor="">CVC</label> | ||
| <StyledInputWrap> | ||
| <Input | ||
| value={CVCNumber} | ||
| onChange={(e) => { | ||
| changeCVCNumber(e.target.value); | ||
| checkValidation(CVC_NUMBER_LENGTH, e.target.value); | ||
| }} | ||
| isError={error !== NO_ERROR} | ||
| width='100%' | ||
| maxLength={CVC_NUMBER_LENGTH} | ||
| placeholder='123' /> | ||
| </StyledInputWrap> | ||
| {error !== NO_ERROR ? <StyledErrorMessage>{error}</StyledErrorMessage> : null} | ||
| </StyledContainer> | ||
| ) | ||
| setError(NO_ERROR); | ||
| } | ||
|
|
||
| return ( | ||
| <StyledContainer> | ||
| <label htmlFor="">CVC</label> | ||
| <StyledInputWrap> | ||
| <Input | ||
| value={CVCNumber} | ||
| onChange={(e) => { | ||
| changeCVCNumber(e.target.value); | ||
| checkValidation(CVC_NUMBER_LENGTH, e.target.value); | ||
| }} | ||
| isError={error !== NO_ERROR} | ||
| width="100%" | ||
| maxLength={CVC_NUMBER_LENGTH} | ||
| placeholder="123" | ||
| /> | ||
| </StyledInputWrap> | ||
| {error !== NO_ERROR ? <StyledErrorMessage>{error}</StyledErrorMessage> : null} | ||
| </StyledContainer> | ||
| ); | ||
| } | ||
|
|
||
| export default CardCVCNumberInputs | ||
| export default CardCVCNumberInputs; |
38 changes: 19 additions & 19 deletions
38
src/components/cardCVCNumberSection/CardCVCNumberSection.tsx
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 모든 컴포넌트가 같은 레벨에 위치하고 있는데요. 애플리케이션 전체에 걸쳐 재사용 되는 함수와 특정 용도로 사용되는 함수를 폴더 구조를 통해 나눠보시면 좋을거 같네요 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,24 @@ | ||
| import SectionTitle from "../sectionTitle/SectionTitle" | ||
| import CardCVCNumberInputs from "../cardCVCNumberInputs/CardCVCNumberInputs" | ||
| import styled from "styled-components" | ||
| import { CardCVCNumberSectionProps } from "../../\btypes/index.types" | ||
| import SectionTitle from '../sectionTitle/SectionTitle'; | ||
| import CardCVCNumberInputs from '../cardCVCNumberInputs/CardCVCNumberInputs'; | ||
| import styled from 'styled-components'; | ||
| import { CardCVCNumberSectionProps } from '../../types/index.types'; | ||
|
|
||
| const StyledContainer = styled.div` | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: center; | ||
| align-items: flex-start; | ||
| gap: 16px; | ||
| width: 100%; | ||
| ` | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: center; | ||
| align-items: flex-start; | ||
| gap: 16px; | ||
| width: 100%; | ||
| `; | ||
|
|
||
| function CardCVCNumberSection({ CVCNumber, changeCVCNumber } : CardCVCNumberSectionProps) { | ||
| return ( | ||
| <StyledContainer> | ||
| <SectionTitle title='CVC 번호를 입력해 주세요'/> | ||
| <CardCVCNumberInputs CVCNumber={CVCNumber} changeCVCNumber={changeCVCNumber}/> | ||
| </StyledContainer> | ||
| ) | ||
| function CardCVCNumberSection({ CVCNumber, changeCVCNumber }: CardCVCNumberSectionProps) { | ||
| return ( | ||
| <StyledContainer> | ||
| <SectionTitle title="CVC 번호를 입력해 주세요" /> | ||
| <CardCVCNumberInputs CVCNumber={CVCNumber} changeCVCNumber={changeCVCNumber} /> | ||
| </StyledContainer> | ||
| ); | ||
| } | ||
|
|
||
| export default CardCVCNumberSection | ||
| export default CardCVCNumberSection; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
화살표 함수 대신 함수 선언문을 사용하신 이유가 궁금합니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어떤 이유를 가지고 선언문을 사용하지는 않았습니다..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
함수 선언문과 화살표 함수의 차이를 찾아보시고 의도에 맞는 코드를 작성하실 수 있으면 좋을거 같네요 ㅎㅎ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네! 구분해서 사용하겠습니다!