-
Notifications
You must be signed in to change notification settings - Fork 1
[Feature/#199] 나의 푸드트럭 등록 / 수정 api #215
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
base: develop
Are you sure you want to change the base?
Changes from all commits
7872e07
1698113
35eb0e1
1d3d9f2
535d2a3
93eeb76
017fe67
ac68c43
102fed4
a7613d7
9e6d4d0
75372e4
549542b
048c595
2f282ed
812888c
a981621
328eea5
527735e
cb80f29
f8016bf
695b746
7d3aafc
e2cb925
bdc5066
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
| "storybook": "storybook dev -p 6006", | ||
| "build-storybook": "storybook build", | ||
| "chromatic": "npx chromatic --project-token=chpt_b45a4ae4e58f49f", | ||
| "swagger-typescript-api": "swagger-typescript-api generate -p http://52.79.221.101:8000/v3/api-docs -r -o ./apis --modular -d --extract-request-body --extract-response-body --extract-response-error --axios --clean-output", | ||
| "swagger-typescript-api": "swagger-typescript-api generate -p http://13.125.207.84:8000/v3/api-docs -r -o ./apis --modular -d --extract-request-body --extract-response-body --extract-response-error --axios --clean-output", | ||
holdn2 marked this conversation as resolved.
Show resolved
Hide resolved
Collaborator
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. 직접 수정을 해보니 package.json에서 환경변수를 써서 처리하는 건 여러 방식 중 하나로 하면 가능한데 생성된 http-client.ts 같은 파일에서는 여전히 노출되는 문제가 있습니다. |
||
| "update-icon-ids": "tsx src/shared/utils/extract-icon-ids.ts" | ||
| }, | ||
| "dependencies": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,9 @@ import { FormProvider } from 'react-hook-form'; | |
| import Navigation from '@layout/navigation/Navigation'; | ||
| import { Icon } from '@icon/Icon'; | ||
| import Button from '@ui/button/Button'; | ||
| import { ROUTES } from '@router/constant/routes'; | ||
| import useToast from '@hooks/use-toast'; | ||
|
|
||
| import { | ||
| FoodTruckName, | ||
| FoodTruckDescription, | ||
|
|
@@ -12,7 +15,6 @@ import { | |
| FoodTruckOption, | ||
| FoodTruckPhoto, | ||
| } from '@pages/@owner/food-truck-form/@section/basic-info-section/index'; | ||
|
|
||
| import { | ||
| AvailableQuantity, | ||
| NeedElectricity, | ||
|
|
@@ -30,8 +32,6 @@ import { | |
| } from '@pages/@owner/food-truck-form/constants/food-truck'; | ||
| import ActiveTime from '@components/active-time/ActiveTime'; | ||
| import ActiveDate from '@components/active-date/ActiveDate'; | ||
| import useFoodTruckDetail from '@pages/food-truck-detail/hooks/use-food-truck-detail'; | ||
| import { ROUTES } from '@router/constant/routes'; | ||
|
|
||
| // 메인 컴포넌트 | ||
| export default function FoodTruckForm() { | ||
|
|
@@ -40,9 +40,10 @@ export default function FoodTruckForm() { | |
|
|
||
| const navigate = useNavigate(); | ||
| const location = useLocation(); | ||
| const toast = useToast(); | ||
|
|
||
| // TODO: id 값이 있을 시 푸드트럭 정보 가져오기 | ||
| const { methods, reset, isFormValid, handleSubmit } = useFoodTruckForm(); | ||
| const { isEdit, methods, reset, isFormValid, handleSubmit, previousName } = | ||
| useFoodTruckForm(foodTruckIdNumber); | ||
|
Collaborator
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. 프론트 측 문제는 아니지만, url을 바꾸면 푸드트럭 주인이 아니더라도 그 내용이 조회가 가능한 문제가 있습니다. 서버 측에서 적절한 사용자인지 확인을 하는 로직이 추가로 있기 + 임의 문자열로 보이게 하는 처리가 병행되면 좋을 것 같습니다. |
||
|
|
||
| const { | ||
| formActiveTime, | ||
|
|
@@ -58,30 +59,32 @@ export default function FoodTruckForm() { | |
| handleActiveDateSetValue, | ||
| handleActiveDateError, | ||
| } = useFoodTruckFormDate(methods); | ||
| // 서버에서 활동 가능 지역은 지역코드로 받아야함 | ||
| const { foodTruckDetailData } = useFoodTruckDetail(foodTruckIdNumber); | ||
|
|
||
| useEffect(() => { | ||
| if (location.state?.formData && location.state?.from) { | ||
| reset(location.state.formData); | ||
| } | ||
| }, [location.state, reset]); | ||
|
|
||
| if (!foodTruckId || isNaN(foodTruckIdNumber)) { | ||
| toast.error('잘못된 접근입니다.'); | ||
| navigate(ROUTES.FOOD_TRUCK_MANAGEMENT); | ||
| return null; | ||
| } | ||
|
|
||
| const handleNavigateBack = () => { | ||
| navigate(ROUTES.FOOD_TRUCK_MANAGEMENT); | ||
| }; | ||
|
|
||
| return ( | ||
| <FormProvider {...methods}> | ||
| <Navigation | ||
| centerContent={ | ||
| foodTruckDetailData ? '나의 푸드트럭 수정' : '나의 푸드트럭 등록' | ||
| } | ||
| centerContent={isEdit ? '나의 푸드트럭 수정' : '나의 푸드트럭 등록'} | ||
| leftIcon={<Icon name='ic_back' />} | ||
| handleLeftClick={handleNavigateBack} | ||
| /> | ||
| <div className='flex flex-col px-[2rem] pb-[12rem]'> | ||
| <FoodTruckName /> | ||
| <FoodTruckName previousName={previousName} /> | ||
| <FoodTruckDescription /> | ||
| <FoodTruckPhoneNumber /> | ||
| <ActiveTime | ||
|
|
@@ -91,7 +94,7 @@ export default function FoodTruckForm() { | |
| handleActiveTimeSetValue={handleActiveTimeSetValue} | ||
| handleTimeDiscussRequiredSetValue={handleTimeDiscussRequiredSetValue} | ||
| /> | ||
| <RegionSection /> | ||
| <RegionSection foodTruckId={foodTruckId} /> | ||
| <MenuCategory /> | ||
| <AvailableQuantity /> | ||
| <NeedElectricity /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import type { BaseResponseFoodTruckIdResponse } from 'apis/data-contracts'; | ||
| import { apiRequest } from '@api/apiRequest'; | ||
|
|
||
| export interface UpdateFoodTruckInfoApiRequest { | ||
| name: string; | ||
| description: string; | ||
| phoneNumber: string; | ||
| activeTime: string; | ||
| timeDiscussRequired: boolean; | ||
| foodTruckServiceAreas: number[]; | ||
| menuCategories: string[]; | ||
| availableQuantity: string; | ||
| needElectricity: string; | ||
| paymentMethod: string; | ||
| availableDates: string[]; | ||
| photoUrls: string[]; | ||
| operatingInfo?: string; | ||
| option?: string; | ||
| } | ||
| export const updateMyFoodTruckInfoApi = async ( | ||
| foodTruckId: number, | ||
| data: UpdateFoodTruckInfoApiRequest | ||
| ) => { | ||
| 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
|
||
Uh oh!
There was an error while loading. Please reload this page.