GETP-150 feature: 피플 정보 등록 Mock API 코드 작성 및 연동 #49
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.
✨ 구현한 기능
mocks/people/data.js
에 피플 mock data 를 작성하였습니다src/services/people/people.service.ts
의peopleService
객체에registerPeople
메서드를 작성하였습니다RegisterPeopleRequestBody
를 파라미터로 받아, 요청하는 비동기함수request
를 작성하고,react-toastify
의toast.promise
의 인자로 넘겨주어 해당 프로미스가 핸들링 되는 동안 띄울 toast 코드를 작성하였습니다이후
src/services/people/hooks/useRegisterPeople.tsx
에 피플 정보를 등록하는 커스텀 훅을@tanstack/react-query
의useMutation()
훅을 사용해 작성하였습니다.커스텀 훅 내부에서 해당 요청에 필요한 필드의 값을 얻기 위한
emailRef
,nicknameRef
,phoneNumberRef
,peopleType
,handleIndividualClick
,handleTeamClick
,handleRegisterButtonClick
을 구현하고 리턴하였습니다이후 해당 훅이 쓰이는
PeopleInfoRegisterPage
에서호출하고 리턴하는 ref 와 함수를 바인딩 해 주었습니다
📢 논의하고 싶은 내용
🎸 기타
MSW REST API 테스트 mocking 하는 법
@tanstack/react-query useMutation hook 사용법