-
Notifications
You must be signed in to change notification settings - Fork 1
[Feature/#199] 나의 푸드트럭 등록 / 수정 api / 리뷰 XXXX #214
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
Closed
Closed
Changes from 14 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
7872e07
feat: 기존 데이터가 있다면 폼 데이터 초기화
holdn2 1698113
feat: 메뉴 목록 조회 api를 이용하여 있다면 폼 데이터의 menu가 true 가 되도록 함
holdn2 35eb0e1
refactor: 다른 페이지 이동 시 getNavigateState 사용하도록 다시 롤백
holdn2 1d3d9f2
Merge branch 'develop' into feature/#199/food-truck-form-api
holdn2 535d2a3
code review: zod 스키마에서 수량, 전기, 결제 관련 유효성 검증 기본 string에서 enum으로 수정
holdn2 93eeb76
code review: normalizeEnumValue의 undefined 반환 처리
holdn2 017fe67
refactor: 활동가능지역 관련 로직 수정 및 오류 해결 / 가독성 및 유지보수를 위해 resetFoodTruckForm…
holdn2 ac68c43
code review: 코드 리뷰 반영
holdn2 102fed4
refactor: 푸드트럭 사진 관련 로직 수정
holdn2 a7613d7
code review: 코드리뷰 반영. 에러 방지 코드 추가
holdn2 9e6d4d0
chore: 스웨거 관련 명령어 수정 및 스웨거 업데이트
holdn2 75372e4
code review: UploadFoodTruckImages에서 훅 호출 전 foodTruckId 유효성 검증
holdn2 549542b
feat: 나의 푸드트럭 등록 및 수정 api 함수 구현 및 관련 훅 구현
holdn2 048c595
fix: 메뉴 등록 페이지로 갔다 돌아올 때도 state를 적절히 추가해서 에러가 생기지 않도록 수정함
holdn2 2f282ed
fix: 메뉴 등록 페이지로 갔다 돌아올 때도 state를 적절히 추가해서 에러가 생기지 않도록 수정함
holdn2 812888c
feat: 나의푸드트럭 등록/수정 api 연동 완료. 서버와의 오류 해결 필요
holdn2 a981621
refactor: 서버에서 받는 날짜 형식이 달라도 동일한 반환값을 내도록 함수 수정
holdn2 328eea5
fix: 서버에서 요청한데로 지역코드가 아닌 id로 보내도록 수정
holdn2 527735e
code review: formdata가 없을 때의 예외처리 추가
holdn2 cb80f29
feat: 닉네임 중복 검증 추가
holdn2 f8016bf
refactor: 이름 관련 유효성 검증 알맞게 수정
holdn2 695b746
refactor: 운영정보 및 기타에 대해서 null이 오면 빈 string으로 변환하도록 수정
holdn2 7d3aafc
code review: early return 추가 및 객체 안전성을 위한 스키마 수정(z.nativeEnum 사용)
holdn2 e2cb925
fix: 타입 단언으로 빌드오류 수정
holdn2 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
Some comments aren't visible on the classic Files Changed page.
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
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
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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import type { | ||
| BaseResponseFoodTruckIdResponse, | ||
| UpdateFoodTruckInfoRequest, | ||
| } from 'apis/data-contracts'; | ||
| import { apiRequest } from '@api/apiRequest'; | ||
|
|
||
| export const updateMyFoodTruckInfoApi = async ( | ||
| foodTruckId: number, | ||
| data: UpdateFoodTruckInfoRequest | ||
| ) => { | ||
| const response = await apiRequest<BaseResponseFoodTruckIdResponse>({ | ||
| endPoint: `/food-trucks/${foodTruckId}`, | ||
| method: 'PUT', | ||
| data, | ||
| }); | ||
| return response.data; | ||
| }; | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
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
36 changes: 36 additions & 0 deletions
36
src/pages/@owner/food-truck-form/hooks/use-mutation-food-truck-form.ts
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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { useNavigate } from 'react-router-dom'; | ||
| import type { UpdateFoodTruckInfoRequest } from 'apis/data-contracts'; | ||
| import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
|
|
||
| import useToast from '@hooks/use-toast'; | ||
| import { updateMyFoodTruckInfoApi } from '@pages/@owner/food-truck-form/api'; | ||
| import { ROUTES } from '@router/constant/routes'; | ||
| import { FOOD_TRUCKS_QUERY_KEY } from '@shared/querykey/food-trucks'; | ||
|
|
||
| export const useMutationFoodTruckForm = () => { | ||
| const navigate = useNavigate(); | ||
| const toast = useToast(); | ||
| const queryClient = useQueryClient(); | ||
|
|
||
| const { mutate: updateFoodTruckInfo } = useMutation({ | ||
| mutationFn: ({ | ||
| foodTruckId, | ||
| data, | ||
| }: { | ||
| foodTruckId: number; | ||
| data: UpdateFoodTruckInfoRequest; | ||
| }) => updateMyFoodTruckInfoApi(foodTruckId, data), | ||
| onSuccess: () => { | ||
| toast.success('푸드트럭 정보가 업데이트 되었습니다.'); | ||
| queryClient.invalidateQueries({ queryKey: FOOD_TRUCKS_QUERY_KEY.ALL }); | ||
| navigate(ROUTES.FOOD_TRUCK_MANAGEMENT); | ||
| }, | ||
| onError: error => { | ||
| toast.error(`업데이트 실패 : ${error.message}`); | ||
| }, | ||
|
Comment on lines
+30
to
+32
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. 에러 메시지 노출을 제한하세요.
🔎 안전한 에러 처리 제안 onError: error => {
- toast.error(`업데이트 실패 : ${error.message}`);
+ const errorMessage =
+ error instanceof ApiRequestError
+ ? '푸드트럭 정보 업데이트에 실패했습니다. 다시 시도해주세요.'
+ : '네트워크 오류가 발생했습니다.';
+ toast.error(errorMessage);
+ console.error('Food truck update error:', error);
},또는 에러 타입별로 다른 메시지를 제공할 수 있습니다.
🤖 Prompt for AI Agents |
||
| }); | ||
|
|
||
| return { | ||
| updateFoodTruckInfo, | ||
| }; | ||
| }; | ||
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
57 changes: 57 additions & 0 deletions
57
src/pages/@owner/food-truck-form/utils/reset-food-truck-form-value.ts
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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import type { | ||
| FoodTruckDetailResponse, | ||
| MyFoodTruckMenuResponse, | ||
| } from 'apis/data-contracts'; | ||
|
|
||
| import { normalizeEnumValue } from '@utils/normalize-enum-value'; | ||
| import { AVAILABLE_QUANTITY } from '@constant/available-quantity'; | ||
| import { NEED_ELECTRICITY } from '@constant/need-electricity'; | ||
| import { PAYMENT_METHOD } from '@constant/payment-method'; | ||
| import { formatStringDatesToAvailableDates } from '@utils/date'; | ||
|
|
||
| export const resetFoodTruckFormValue = ( | ||
| foodTruckDetailData: FoodTruckDetailResponse, | ||
| menus?: MyFoodTruckMenuResponse[] | ||
| ) => { | ||
| const availableQuantity = normalizeEnumValue( | ||
| AVAILABLE_QUANTITY, | ||
| foodTruckDetailData.availableQuantity | ||
| ); | ||
| const needElectricity = normalizeEnumValue( | ||
| NEED_ELECTRICITY, | ||
| foodTruckDetailData.needElectricity | ||
| ); | ||
| const payment = normalizeEnumValue( | ||
| PAYMENT_METHOD, | ||
| foodTruckDetailData.paymentMethod | ||
| ); | ||
| if (!availableQuantity || !needElectricity || !payment) { | ||
| return { | ||
| isError: true, | ||
| }; | ||
| } | ||
|
|
||
| return { | ||
| isError: false, | ||
| values: { | ||
| name: foodTruckDetailData.name, | ||
| nameDuplicate: true, | ||
| description: foodTruckDetailData.description, | ||
| phoneNumber: foodTruckDetailData.phoneNumber, | ||
| regionCodes: foodTruckDetailData.regionCodes, | ||
| availableQuantity: availableQuantity, | ||
| needElectricity: needElectricity, | ||
| paymentMethod: payment, | ||
| menuCategories: foodTruckDetailData.menuCategories, | ||
| photoUrls: foodTruckDetailData.photoUrl, | ||
| operatingInfo: foodTruckDetailData.operatingInfo, | ||
| option: foodTruckDetailData.option, | ||
| availableDates: formatStringDatesToAvailableDates( | ||
| foodTruckDetailData.availableDates ?? [] | ||
| ), | ||
| activeTime: foodTruckDetailData.activeTime, | ||
| timeDiscussRequired: foodTruckDetailData.timeDiscussRequired, | ||
| menus: menus && menus.length > 0, | ||
| }, | ||
| }; | ||
| }; |
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.
Uh oh!
There was an error while loading. Please reload this page.