diff options
Diffstat (limited to 'components')
| -rw-r--r-- | components/additional-info/join-form.tsx | 59 | ||||
| -rw-r--r-- | components/pq-input/pq-input-tabs.tsx | 4 |
2 files changed, 56 insertions, 7 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> diff --git a/components/pq-input/pq-input-tabs.tsx b/components/pq-input/pq-input-tabs.tsx index 6c9a1254..6ffd637a 100644 --- a/components/pq-input/pq-input-tabs.tsx +++ b/components/pq-input/pq-input-tabs.tsx @@ -651,8 +651,8 @@ export function PQInputTabs({ if (result.ok) { toast({ - title: "PQ Submitted", - description: "Your PQ information has been submitted successfully", + title: "PQ 제출 완료", + description: "PQ 정보가 성공적으로 제출되었습니다", }); // 제출 후 PQ 목록 페이지로 리디렉션 window.location.href = "/partners/pq_new"; |
