summaryrefslogtreecommitdiff
path: root/lib/vendor-investigation/table/investigation-progress-sheet.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vendor-investigation/table/investigation-progress-sheet.tsx')
-rw-r--r--lib/vendor-investigation/table/investigation-progress-sheet.tsx47
1 files changed, 46 insertions, 1 deletions
diff --git a/lib/vendor-investigation/table/investigation-progress-sheet.tsx b/lib/vendor-investigation/table/investigation-progress-sheet.tsx
index a9fbdfdb..6b040ad7 100644
--- a/lib/vendor-investigation/table/investigation-progress-sheet.tsx
+++ b/lib/vendor-investigation/table/investigation-progress-sheet.tsx
@@ -96,6 +96,38 @@ export function InvestigationProgressSheet({
}
}, [investigation, form])
+ // 도로명 주소 검색 결과 수신 및 주소 포맷팅
+ React.useEffect(() => {
+ const isDomestic = investigation?.vendorCountry === "KR" || investigation?.vendorCountry === "한국"
+ if (!props.open || !isDomestic) return
+
+ const handleMessage = (event: MessageEvent) => {
+ if (!event.data || event.data.type !== "JUSO_SELECTED") return
+ const { zipNo, roadAddrPart1, roadAddrPart2, addrDetail } = event.data.payload || {}
+ const road = [roadAddrPart1, roadAddrPart2].filter(Boolean).join(" ").trim()
+ const baseAddress = [zipNo ? `(${zipNo})` : "", road].filter(Boolean).join(" ").trim()
+ const detail = (addrDetail || "").trim()
+ const formatted = detail ? `${baseAddress}, ${detail}` : baseAddress
+
+ if (formatted) {
+ form.setValue("investigationAddress", formatted, { shouldDirty: true })
+ }
+ }
+
+ window.addEventListener("message", handleMessage)
+ return () => window.removeEventListener("message", handleMessage)
+ }, [props.open, investigation?.vendorCountry, form])
+
+ const handleJusoSearch = () => {
+ const isDomestic = investigation?.vendorCountry === "KR" || investigation?.vendorCountry === "한국"
+ if (!isDomestic) return
+ window.open(
+ "/api/juso",
+ "jusoSearch",
+ "width=570,height=420,scrollbars=yes,resizable=yes"
+ )
+ }
+
// Submit handler
async function onSubmit(values: UpdateVendorInvestigationProgressSchema) {
console.log("실사 진행 관리 onSubmit 호출됨:", values)
@@ -193,7 +225,20 @@ export function InvestigationProgressSheet({
name="investigationAddress"
render={({ field }) => (
<FormItem>
- <FormLabel>실사 주소</FormLabel>
+ <div className="flex items-center justify-between gap-2">
+ <FormLabel>실사 주소</FormLabel>
+ { (investigation?.vendorCountry === "KR" || investigation?.vendorCountry === "한국") && (
+ <Button
+ type="button"
+ size="sm"
+ variant="secondary"
+ onClick={handleJusoSearch}
+ disabled={isPending}
+ >
+ 도로명 주소 검색
+ </Button>
+ )}
+ </div>
<FormControl>
<Textarea
placeholder="실사가 진행될 주소를 입력하세요..."