feat(gift): 받을 주소 관리 및 카카오 주소 검색 추가

This commit is contained in:
Yu Sung
2026-10-01 23:40:11 +09:00
parent 00e6ba90f6
commit 013a694b2a
7 changed files with 604 additions and 2 deletions
+28
View File
@@ -0,0 +1,28 @@
let loading
export function loadPostcode() {
if (window.daum && window.daum.Postcode) return Promise.resolve(window.daum.Postcode)
if (loading) return loading
loading = new Promise((resolve, reject) => {
const script = document.createElement('script')
const finish = error => {
clearTimeout(timer)
script.onload = null
script.onerror = null
if (error) {
script.remove()
loading = null
reject(error)
} else {
resolve(window.daum.Postcode)
}
}
const timer = setTimeout(() => finish(new Error('주소 검색을 불러오지 못했습니다. 다시 시도해주세요.')), 15000)
script.src = 'https://t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js'
script.async = true
script.onload = () => finish(window.daum && window.daum.Postcode ? null : new Error('주소 검색을 불러오지 못했습니다. 다시 시도해주세요.'))
script.onerror = () => finish(new Error('주소 검색을 불러오지 못했습니다. 다시 시도해주세요.'))
document.head.appendChild(script)
})
return loading
}