summaryrefslogtreecommitdiff
path: root/components/additional-info/join-form.tsx
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-12-09 06:09:09 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-12-09 06:09:09 +0000
commitcf3f7cf0efa2753a401b36f6eb3a49cb9697ddce (patch)
treec5174948c8bb35171151605bbbe19f6d18c30509 /components/additional-info/join-form.tsx
parentea8aed1e1d62fb9fa6716347de73e4ef13040929 (diff)
(최겸) 구매 rfq, 기술영업 rfq drm 해제 시 결재 상신에 첨부파일 포함 로직 적용
Diffstat (limited to 'components/additional-info/join-form.tsx')
-rw-r--r--components/additional-info/join-form.tsx59
1 files changed, 54 insertions, 5 deletions
diff --git a/components/additional-info/join-form.tsx b/components/additional-info/join-form.tsx
index fe5698d8..1642962f 100644
--- a/components/additional-info/join-form.tsx
+++ b/components/additional-info/join-form.tsx
@@ -223,6 +223,8 @@ export function InfoForm() {
})
const isFormValid = form.formState.isValid
+ const watchedCountry = form.watch("country")
+ const isDomesticVendor = watchedCountry === "KR"
// Field array for contacts
const { fields: contactFields, append: addContact, remove: removeContact, replace: replaceContacts } =
@@ -369,6 +371,29 @@ export function InfoForm() {
fetchVendorData()
}, [companyId, form, replaceContacts])
+ // 도로명주소 검색 결과 수신 (내자 벤더만)
+ React.useEffect(() => {
+ if (!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()
+
+ form.setValue("postalCode", zipNo || form.getValues("postalCode") || "", { shouldDirty: true })
+ form.setValue("address", road || form.getValues("address") || "", { shouldDirty: true })
+ form.setValue("addressDetail", addrDetail || form.getValues("addressDetail") || "", { shouldDirty: true })
+ }
+
+ window.addEventListener("message", handleMessage)
+ return () => window.removeEventListener("message", handleMessage)
+ }, [isDomesticVendor, form])
+
+ const handleJusoSearch = () => {
+ if (!isDomesticVendor) return
+ window.open("/api/juso", "jusoSearch", "width=570,height=420,scrollbars=yes,resizable=yes")
+ }
+
// 컴포넌트 언마운트 시 미리보기 URL 정리 (blob URL만)
React.useEffect(() => {
return () => {
@@ -1224,11 +1249,29 @@ export function InfoForm() {
name="address"
render={({ field }) => (
<FormItem>
- <FormLabel className="after:content-['*'] after:ml-0.5 after:text-red-500">
- 주소
- </FormLabel>
+ <div className="flex items-center justify-between gap-2">
+ <FormLabel className="after:content-['*'] after:ml-0.5 after:text-red-500">
+ 주소
+ </FormLabel>
+ {isDomesticVendor && (
+ <Button
+ type="button"
+ variant="secondary"
+ size="sm"
+ onClick={handleJusoSearch}
+ disabled={isSubmitting}
+ >
+ 주소 검색
+ </Button>
+ )}
+ </div>
<FormControl>
- <Input {...field} disabled={isSubmitting} />
+ <Input
+ {...field}
+ disabled={isSubmitting}
+ readOnly={isDomesticVendor}
+ className={cn(isDomesticVendor && "bg-muted text-muted-foreground")}
+ />
</FormControl>
<FormMessage />
</FormItem>
@@ -1258,7 +1301,13 @@ export function InfoForm() {
<FormItem>
<FormLabel>우편번호</FormLabel>
<FormControl>
- <Input {...field} disabled={isSubmitting} placeholder="우편번호를 입력해주세요" />
+ <Input
+ {...field}
+ disabled={isSubmitting}
+ readOnly={isDomesticVendor}
+ className={cn(isDomesticVendor && "bg-muted text-muted-foreground")}
+ placeholder="우편번호를 입력해주세요"
+ />
</FormControl>
<FormMessage />
</FormItem>