-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat/#106] 사장님 가게 등록 관련 API 연동 #111
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
5 commits
Select commit
Hold shift + click to select a range
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
68 changes: 68 additions & 0 deletions
68
apps/owner/src/app/signup/register/_apis/searchAddressBykakao.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,68 @@ | ||
| "use client"; | ||
|
|
||
| import type { AddressSearchItem } from "../_types/address-search"; | ||
|
|
||
| export function searchAddressByKakao( | ||
| keyword: string, | ||
| size = 10, | ||
| ): Promise<AddressSearchItem[]> { | ||
| return new Promise((resolve, reject) => { | ||
| const trimmedKeyword = keyword.trim(); | ||
|
|
||
| if (!trimmedKeyword) { | ||
| resolve([]); | ||
| return; | ||
| } | ||
|
|
||
| if ( | ||
| typeof window === "undefined" || | ||
| !window.kakao?.maps?.services | ||
| ) { | ||
| reject(new Error("Kakao services library is not loaded.")); | ||
| return; | ||
| } | ||
|
|
||
| const geocoder = new window.kakao.maps.services.Geocoder(); | ||
|
|
||
| geocoder.addressSearch( | ||
| trimmedKeyword, | ||
| (result: KakaoAddressSearchResult[], status: string) => { | ||
| const { kakao } = window; | ||
|
|
||
| if (status === kakao.maps.services.Status.ZERO_RESULT) { | ||
| resolve([]); | ||
| return; | ||
| } | ||
|
|
||
| if (status !== kakao.maps.services.Status.OK) { | ||
| reject(new Error("주소 검색 중 오류가 발생했습니다.")); | ||
| return; | ||
| } | ||
|
|
||
| const mapped = result.slice(0, size).map((item, index) => { | ||
| const lotNumberAddress = | ||
| item.address?.address_name || item.address_name || ""; | ||
|
|
||
| const roadAddress = | ||
| item.road_address?.address_name || item.address_name || ""; | ||
|
|
||
| return { | ||
| id: `${item.x}-${item.y}-${index}`, | ||
| label: roadAddress || lotNumberAddress, | ||
| lotNumberAddress, | ||
| roadAddress, | ||
| longitude: Number(item.x), | ||
| latitude: Number(item.y), | ||
| }; | ||
| }); | ||
|
|
||
| resolve(mapped); | ||
| }, | ||
| { | ||
| page: 1, | ||
| size, | ||
| analyze_type: window.kakao.maps.services.AnalyzeType.SIMILAR, | ||
| }, | ||
| ); | ||
| }); | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존 계좌 정보가 초기화되지 않아 저장 시 값이 지워집니다.
이 effect에서
bankType,depositor,bankAccount를 로컬 상태로 옮기지 않고 있어서 수정 화면이 빈 값으로 열립니다. 사용자가 해당 필드를 건드리지 않고 저장하면 기존 계좌 정보가""/undefined로 덮일 수 있습니다.🔧 수정 예시
useEffect(() => { if (!myStore) return; setStoreName(myStore.storeName ?? ""); setStoreEmail(myStore.storeEmail ?? ""); setInputAddress(myStore.inputAddress ?? ""); + setBankType(myStore.bankType ?? ""); + setDepositor(myStore.depositor ?? ""); + setBankAccount(myStore.bankAccount ?? ""); setBusinessHours(parseBusinessHours(myStore.businessHours)); if (myStore.tag) { setSelectedTag(reverseTagMap[myStore.tag as StoreTag] ?? ""); } }, [myStore]);🤖 Prompt for AI Agents