-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 새 가게 등록 API 연동 #59
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 all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e411560
refactor: 사업자 인증 단계 리팩토링 (스키마 분리 및 개업일자 검증 추가)
dew102938 0d6b599
feat: 사업자 인증 API 연동
dew102938 601ac82
refactor: 스웨거 맞춰 스키마, ui 수정 / 이미 인증된 사업자도 식당 등록 단계 진행되도록 개선
dew102938 5d2c2b9
refactor: 스웨거 맞춰 메뉴 등록 스키마, ui 수정
dew102938 27132a9
feat: 식당 등록 API 연동, 데이터 변환 로직 구현
dew102938 48468e9
feat: 식당 대표 이미지 등록 API 연동
dew102938 5c40104
feat: 메뉴 등록 API 연동, 사장 인증 후 권한 갱신을 위한 로그아웃 로직 추가
dew102938 772fa14
Merge branch 'develop' into feat/StoreRegistration-api
dew102938 d339ee3
Merge branch 'develop' into feat/StoreRegistration-api
dew102938 9d8143e
refactor: CategoryEnum 명칭 중복 방지를 위해 Menu/Store용으로 각각 분리
dew102938 e0f0ccf
refactor: getValues() 사용, input id 연결
dew102938 f7bfdb3
refactor: 영업 시간 변환 유틸 함수의 암묵적 기본값 제거, 필수값 검증 로직 추가
dew102938 ba24842
refactor: 가게 등록 로직을 mutateAsync, try-catch 패턴으로 변경하여 에러 처리 강화
dew102938 6a04145
fix: 메뉴 가격 유효성 검사 정규식 수정 (0 허용, 불필요한 선행 0 차단)
dew102938 06d24e7
fix: 가게 대표 이미지 유효성 검사 강화
dew102938 d3ba4d4
docs: TODO 주석 추가
dew102938 0273c11
refactor: 지오코딩 실패 시 등록 차단 로직 구현
dew102938 bf6266f
refactor: 정기 휴무일 접근성 개선
dew102938 bf8a781
feat: ESC키 핸들러 추가, 모달에 role, aria-modal 등 속성 추가
dew102938 27579a1
fix: 주소 데이터 변환 시 발생할 수 있는 문자열 결합 오류 방지
dew102938 532842c
refactor: 불필요한 any 타입 캐스팅 제거
dew102938 f6bddc9
Merge branch 'develop' into feat/StoreRegistration-api
dew102938 0edc8c0
fix: 코드래빗 수정사항 반영
dew102938 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,34 @@ | ||
| import type { ApiResponse } from "@/types/api"; | ||
| import type { | ||
| RequestMenuCreateDto, | ||
| RequestMenuImageDto, | ||
| ResponseMenuCreateDto, | ||
| ResponseMenuImageDto, | ||
| } from "@/types/menus"; | ||
| import { api } from "./axios"; | ||
|
|
||
| export const postMenuCreate = async ( | ||
| storeId: number, | ||
| body: RequestMenuCreateDto, | ||
| ): Promise<ResponseMenuCreateDto> => { | ||
| const { data } = await api.post<ApiResponse<ResponseMenuCreateDto>>( | ||
| `/api/v1/stores/${storeId}/menus`, | ||
| body, | ||
| ); | ||
| return data.result; | ||
| }; | ||
|
|
||
| export const postMenuImage = async ( | ||
| storeId: number, | ||
| body: RequestMenuImageDto, | ||
| ): Promise<ResponseMenuImageDto> => { | ||
| const formData = new FormData(); | ||
|
|
||
| formData.append("image", body.image); | ||
|
|
||
| const { data } = await api.post<ApiResponse<ResponseMenuImageDto>>( | ||
| `/api/v1/stores/${storeId}/menus/images`, | ||
| formData, | ||
| ); | ||
| return data.result; | ||
| }; |
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,33 @@ | ||
| import type { | ||
| RequestMainImageDto, | ||
| RequestStoreCreateDto, | ||
| ResponseMainImageDto, | ||
| ResponseStoreCreateDto, | ||
| } from "@/types/store"; | ||
| import { api } from "./axios"; | ||
| import type { ApiResponse } from "@/types/api"; | ||
|
|
||
| export const postRegisterStore = async ( | ||
| body: RequestStoreCreateDto, | ||
| ): Promise<ResponseStoreCreateDto> => { | ||
| const { data } = await api.post<ApiResponse<ResponseStoreCreateDto>>( | ||
| "/api/v1/stores", | ||
| body, | ||
| ); | ||
| return data.result; | ||
| }; | ||
|
|
||
| export const postMainImage = async ( | ||
| storeId: number, | ||
| body: RequestMainImageDto, | ||
| ): Promise<ResponseMainImageDto> => { | ||
| const formData = new FormData(); | ||
|
|
||
| formData.append("mainImage", body.mainImage); | ||
|
|
||
| const { data } = await api.post<ApiResponse<ResponseMainImageDto>>( | ||
| `/api/v1/stores/${storeId}/main-image`, | ||
| formData, | ||
| ); | ||
| return data.result; | ||
| }; | ||
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,38 @@ | ||
| import z from "zod"; | ||
|
|
||
| export const BusinessAuthSchema = z.object({ | ||
| businessNumber: z | ||
| .string() | ||
| .regex(/^[0-9]+$/, "숫자만 입력해주세요.") | ||
| .length(10, "1234567890 형식의 10자리 숫자를 입력해주세요."), | ||
| startDate: z | ||
| .string() | ||
| .regex(/^[0-9]+$/, "숫자만 입력해주세요.") | ||
| .length(8, "YYYYMMDD 형식의 8자리 숫자를 입력해주세요.") | ||
| .refine( | ||
| (val) => { | ||
| const year = parseInt(val.substring(0, 4)); | ||
| const month = parseInt(val.substring(4, 6)); | ||
| const day = parseInt(val.substring(6, 8)); | ||
|
|
||
| if (month < 1 || month > 12) return false; | ||
|
|
||
| const date = new Date(year, month - 1, day); | ||
|
|
||
| if ( | ||
| date.getFullYear() !== year || | ||
| date.getMonth() !== month - 1 || | ||
| date.getDate() !== day | ||
| ) { | ||
| return false; | ||
| } | ||
|
|
||
| if (date > new Date()) return false; | ||
|
|
||
| return true; | ||
| }, | ||
| { message: "유효하지 않은 날짜입니다. (예: 20240101)" }, | ||
| ), | ||
| }); | ||
|
|
||
| export type BusinessAuthFormValues = z.infer<typeof BusinessAuthSchema>; |
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 |
|---|---|---|
| @@ -1,19 +1,46 @@ | ||
| import { z } from "zod"; | ||
|
|
||
| export const MenuCategoryEnum = z.enum(["MAIN", "SIDE", "BEVERAGE", "ALCOHOL"]); | ||
|
|
||
| const MAX_FILE_SIZE = 1 * 1024 * 1024; | ||
|
|
||
| const ACCEPTED_IMAGE_TYPES = ["image/jpeg", "image/png"]; | ||
|
|
||
| export const MenuSchema = z.object({ | ||
| menus: z | ||
| .array( | ||
| z.object({ | ||
| menuName: z.string().min(1, "메뉴명을 입력하세요."), | ||
| price: z | ||
| .string() | ||
| .min(1, "가격을 입력하세요.") | ||
| .regex(/^\d+$/, "숫자만 입력해주세요."), | ||
| description: z.string().optional(), | ||
| image: z.any().optional(), | ||
| }), | ||
| ) | ||
| .optional(), | ||
| menus: z.array( | ||
| z.object({ | ||
| name: z.string().min(1, "메뉴명을 입력하세요."), | ||
| description: z.string().max(500, "500자 이내로 입력하세요.").optional(), | ||
| price: z | ||
| .string() | ||
| .min(1, "가격을 입력하세요.") | ||
| .regex(/^(0|[1-9]\d*)$/, "0 이상의 올바른 숫자를 입력하세요."), | ||
| category: MenuCategoryEnum, | ||
| imageKey: z | ||
| .any() | ||
| .optional() | ||
| .refine( | ||
| (file) => { | ||
| if (!file || typeof file === "string") return true; | ||
| return file instanceof File ? file.size <= MAX_FILE_SIZE : true; | ||
| }, | ||
| { | ||
| message: "이미지 크기는 1MB 이하여야 합니다.", | ||
| }, | ||
| ) | ||
| .refine( | ||
| (file) => { | ||
| if (!file || typeof file === "string") return true; | ||
| return file instanceof File | ||
| ? ACCEPTED_IMAGE_TYPES.includes(file.type) | ||
| : true; | ||
| }, | ||
| { | ||
| message: ".jpg, .png 형식의 이미지만 업로드 가능합니다.", | ||
| }, | ||
| ), | ||
| }), | ||
| ), | ||
| }); | ||
|
|
||
| export type MenuFormValues = z.infer<typeof MenuSchema>; |
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.