-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 계정정보수정 (봉사자, 보호소) msw 연결 (#167)
* feat(shelter): 계정정보수정 msw mock 데이터 * fix(shelter): 보호소 정보 msw handler shelterImageUrl 수정 * feat(shelter): shelterInfo 수정 타입 추가 * fix(shelter): 계정정보수정API request 타입 수정 * feat(shelter): 보호소계정정보 useQuery 추가 * feat(shelter): 보호소 계정정보 조회 msw 연결 * feat(shelter): 계정정보 수정 mutation 추가 * fix(shelter): msw 계정정보수정 handler HttpResponse 수정 * design(shelter): button 의 hover, active background 수정 * fix(volunteer): api MyInfoResponse, UpdateUserInfoParams 타입 수정 * feat(volunteer): 봉사자계정정보 fetch hook 추가 * feat(volunteer): get 봉사자정보 msw handler 추가 * feat(volunteer): 봉사자 계정정보 조회 msw 연결 * design(volunteer): button 태그 hover, active 일때 background 제거 * fix(volunteer): volunteergender 타입 수정 * feat(volunteer): 계정정보수정 useMutation 추가 * feat(volunteer): 계정정보수정 patch msw 추가 * fix(volunteer): 계정정보조회 useQuery 의 select 메소드 타입 지정
- Loading branch information
Showing
10 changed files
with
239 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -22,7 +22,7 @@ export const handlers = [ | |
shelterId: 1, | ||
shelterEmail: '[email protected]', | ||
shelterName: '양천구 보호소', | ||
imageUrl: null, | ||
shelterImageUrl: 'https://source.unsplash.com/random/?animal', | ||
shelterAddress: '서울특별시 양천구', | ||
shelterAddressDetail: '서울특별시 양천구 신월동 동자빌딩', | ||
shelterPhoneNumber: '010-1234-5678', | ||
|
@@ -49,4 +49,8 @@ export const handlers = [ | |
{ status: 200 }, | ||
); | ||
}), | ||
http.patch('/shelters/me', async () => { | ||
await delay(200); | ||
return new HttpResponse(null, { status: 204 }); | ||
}), | ||
]; |
35 changes: 35 additions & 0 deletions
35
apps/shelter/src/pages/settings/account/_hooks/useFetchShelterAccount.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { getShelterInfoAPI } from '@/apis/shelter'; | ||
|
||
const useFethShelterAccount = () => { | ||
return useQuery({ | ||
queryKey: ['shelter', 'account'], | ||
queryFn: async () => (await getShelterInfoAPI()).data, | ||
select: (data) => { | ||
return { | ||
imageUrl: data.shelterImageUrl, | ||
email: data.shelterEmail, | ||
name: data.shelterName, | ||
address: data.shelterAddress, | ||
addressDetail: data.shelterAddressDetail, | ||
phoneNumber: data.shelterPhoneNumber, | ||
sparePhoneNumber: data.shelterSparePhoneNumber, | ||
isOpenedAddress: data.shelterIsOpenedAddress, | ||
}; | ||
}, | ||
initialData: { | ||
shelterId: 1, | ||
shelterImageUrl: '', | ||
shelterEmail: '', | ||
shelterName: '', | ||
shelterAddress: '', | ||
shelterAddressDetail: '', | ||
shelterPhoneNumber: '', | ||
shelterSparePhoneNumber: '', | ||
shelterIsOpenedAddress: false, | ||
}, | ||
}); | ||
}; | ||
|
||
export default useFethShelterAccount; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { delay, http, HttpResponse } from 'msw'; | ||
|
||
export const handlers = [ | ||
http.get('/volunteers/me', async () => { | ||
await delay(200); | ||
return HttpResponse.json({ | ||
volunteerId: 1, | ||
volunteerEmail: '[email protected]', | ||
volunteerName: '김프롱', | ||
volunteerBirthDate: '2023-03-16', | ||
volunteerPhoneNumber: '010-1234-5678', | ||
volunteerTemperature: 32, | ||
completedVolunteerCount: 3, | ||
volunteerImageUrl: 'https://source.unsplash.com/random', | ||
volunteerGender: 'FEMALE', | ||
}); | ||
}), | ||
http.patch('/volunteers/me', async ({ request }) => { | ||
const updateVolunteer = await request.json(); | ||
console.log(updateVolunteer); | ||
return new HttpResponse(null, { status: 204 }); | ||
}), | ||
]; |
32 changes: 32 additions & 0 deletions
32
apps/volunteer/src/pages/settings/account/_hooks/useFetchAccount.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { getMyVolunteerInfo, MyInfoResponse } from '@/apis/volunteer'; | ||
|
||
const useFetchAccount = () => | ||
useQuery({ | ||
queryKey: ['volunteer', 'account'], | ||
queryFn: async () => (await getMyVolunteerInfo()).data, | ||
select: (data: MyInfoResponse) => { | ||
return { | ||
imageUrl: data.volunteerImageUrl, | ||
email: data.volunteerEmail, | ||
name: data.volunteerName, | ||
birthDate: data.volunteerBirthDate, | ||
phoneNumber: data.volunteerPhoneNumber, | ||
gender: data.volunteerGender, | ||
}; | ||
}, | ||
initialData: { | ||
volunteerId: 1, | ||
volunteerEmail: '', | ||
volunteerName: '', | ||
volunteerBirthDate: '', | ||
volunteerPhoneNumber: '', | ||
volunteerTemperture: 36, | ||
volunteerCount: 0, | ||
volunteerImageUrl: '', | ||
volunteerGender: 'MALE', | ||
}, | ||
}); | ||
|
||
export default useFetchAccount; |
Oops, something went wrong.