diff options
Diffstat (limited to 'lib/pq/pq-review-table-new/request-investigation-dialog.tsx')
| -rw-r--r-- | lib/pq/pq-review-table-new/request-investigation-dialog.tsx | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/lib/pq/pq-review-table-new/request-investigation-dialog.tsx b/lib/pq/pq-review-table-new/request-investigation-dialog.tsx index f5a7ff91..febc308c 100644 --- a/lib/pq/pq-review-table-new/request-investigation-dialog.tsx +++ b/lib/pq/pq-review-table-new/request-investigation-dialog.tsx @@ -83,6 +83,7 @@ interface RequestInvestigationDialogProps { investigationMethod?: string,
investigationNotes?: string
}
+ vendorCountry?: string | null
}
export function RequestInvestigationDialog({
@@ -91,7 +92,9 @@ export function RequestInvestigationDialog({ onSubmit,
selectedCount,
initialData,
+ vendorCountry,
}: RequestInvestigationDialogProps) {
+ const isDomesticVendor = vendorCountry === "KR" || vendorCountry === "한국"
const [isPending, setIsPending] = React.useState(false)
const [qmManagers, setQMManagers] = React.useState<QMUser[]>([])
const [isLoadingManagers, setIsLoadingManagers] = React.useState(false)
@@ -121,6 +124,36 @@ export function RequestInvestigationDialog({ }
}, [isOpen, initialData, form]);
+ // 도로명 주소 검색 결과 수신 및 주소 포맷팅
+ React.useEffect(() => {
+ if (!isOpen || !isDomesticVendor) 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)
+ }, [isOpen, isDomesticVendor, form])
+
+ const handleJusoSearch = () => {
+ if (!isDomesticVendor) return
+ window.open(
+ "/api/juso",
+ "jusoSearch",
+ "width=570,height=420,scrollbars=yes,resizable=yes"
+ )
+ }
+
// Dialog가 열릴 때 QM 담당자 목록 로드
React.useEffect(() => {
if (isOpen && qmManagers.length === 0) {
@@ -227,7 +260,20 @@ export function RequestInvestigationDialog({ name="investigationAddress"
render={({ field }) => (
<FormItem>
- <FormLabel>실사 장소</FormLabel>
+ <div className="flex items-center justify-between gap-2">
+ <FormLabel>실사 장소</FormLabel>
+ {isDomesticVendor && (
+ <Button
+ type="button"
+ size="sm"
+ variant="secondary"
+ onClick={handleJusoSearch}
+ disabled={isPending}
+ >
+ 도로명 주소 검색
+ </Button>
+ )}
+ </div>
<FormControl>
<Textarea
placeholder="실사가 진행될 주소를 입력하세요"
|
