후보지 선택

This commit is contained in:
yschoi
2025-07-28 04:38:09 +09:00
parent 0f9d7a115f
commit 16b204f83b
18 changed files with 442 additions and 441 deletions
@@ -23,11 +23,11 @@ export function AccessibleFormField<T extends FieldValues>({
<FormUi label={labelText}>
<div>
{inputComponent}
{error?.message && Array.from(new Set(error.message.split('\n'))).map((msg, idx) => (
{/* {error?.message && Array.from(new Set(error.message.split('\n'))).map((msg, idx) => (
<p key={idx} className="text-red-500 text-sm mt-1" role="alert">
{msg}
</p>
))}
))} */}
</div>
</FormUi>
);
@@ -15,11 +15,9 @@ import { Button } from "@common/components/ui";
import { useSearchParams } from "next/navigation";
import { useCallback, useEffect, useState } from "react";
import { AccessibleFormField } from "./AccessibleFormField";
import type { ControllerRenderProps, UseFormReturn } from "react-hook-form";
import type { ControllerRenderProps, UseFormReturn, FieldError } from "react-hook-form";
import SearchInputText from "../common/searhDemandInput/component";
import type { DemandCompType } from "@/app/store/sdmMng";
import NewWindowPortal from "@/app/(popup-layout)/map/popup/windowPotal";
import Map from "@/app/(popup-layout)/map/popup/sdmInfoMap";
export interface SdmInfoRegFormProps {
form: UseFormReturn<FormData>;
@@ -47,7 +45,6 @@ export function SdmInfoRegForm({
const [isSimilarCase, setIsSimilarCase] = useState(false);
const [key, setKey] = useState(0);
// 후보지 팝업 오픈 상태
const [isCandidatePopup, setIsCandidatePopup] = useState(false);
//모달 조회에 필요한 데이터
const [sply, setSply] = useState<number>(0);
@@ -58,11 +55,9 @@ export function SdmInfoRegForm({
initializeCommonData();
}, [initializeCommonData]);
useEffect(() =>{
console.log('candidateTitle ', form.getValues("candidateTitle"))
},[form.getValues("candidateTitle") ])
useEffect(() => {
console.log("candidateTitle ", form.getValues("candidateTitle"));
}, [form.getValues("candidateTitle")]);
useEffect(() => {
if (useTypesData && useTypesData.length > 0) {
setTimeout(() => {
@@ -87,17 +82,20 @@ export function SdmInfoRegForm({
}
}, [searchParams, form]);
const handleCandidateClose = useCallback(
() => setIsCandidatePopup(false),
[]
);
const searchCandidate = (e: React.MouseEvent) => {
e.preventDefault();
e.stopPropagation();
//setIsCandidatePopup(true);
const popupOptions = `width=1920,height=1080,resizable='y',scrollbars='y'`;
window.open("/map/popup", "candidatePopup", popupOptions);
const dmdInfoId = JSON.parse(
sessionStorage.getItem("user") || "{}"
)?.dmdInfoId?.toString();
const url = `/map/popup?dmdInfoId=${encodeURIComponent(dmdInfoId)}`;
const width = window.screen.availWidth;
const height = window.screen.availHeight;
const left = 0;
const top = 0;
const popupOptions = `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`;
window.open(url, "candidatePopup", popupOptions);
};
const searchSimilarCase = (e: React.MouseEvent) => {
@@ -219,32 +217,24 @@ export function SdmInfoRegForm({
formIndex: 0,
required: true,
component: (field) => (
<AccessibleFormField
field={field}
label="희망단가(원/㎥)"
required={true}
error={form.formState.errors.money}
inputComponent={
<FormUi
onCheckboxChange={handleCheckboxChange}
isDisabled={isBznmTotNoDisabled}
>
<Input
placeholder="희망단가(원/㎥)을 입력하세요"
type="text"
className="!text-xl text-gray-600"
value={field.value as string}
onChange={(e) => {
field.onChange(e);
setMoney(Number(e.target.value));
}}
onBlur={field.onBlur}
name={field.name}
ref={field.ref}
/>
</FormUi>
}
/>
<FormUi
onCheckboxChange={handleCheckboxChange}
isDisabled={isBznmTotNoDisabled}
>
<Input
placeholder="희망단가(원/㎥)을 입력하세요"
type="text"
className="!text-xl text-gray-600"
value={field.value as string}
onChange={(e) => {
field.onChange(e);
setMoney(Number(e.target.value));
}}
onBlur={field.onBlur}
name={field.name}
ref={field.ref}
/>
</FormUi>
),
},
{
@@ -484,16 +474,18 @@ export function SdmInfoRegForm({
</Button>
</div>
<div className="flex justify-center gap-10 mt-5">
{(form.getValues("candidateTitle") || []).map((candidate: any, index: number) => (
<Input
key={index}
placeholder={`후보지${index + 1}`}
type="text"
className="!text-xl w-[130px] text-gray-600"
value={candidate.ruseUtztnFcltNm}
readOnly
/>
))}
{(form.getValues("candidateTitle") || []).map(
(candidate: any, index: number) => (
<Input
key={index}
placeholder={`후보지${index + 1}`}
type="text"
className="!text-xl w-[130px] text-gray-600"
value={candidate.ruseUtztnFcltNm}
readOnly
/>
)
)}
</div>
</div>
),
@@ -529,7 +521,11 @@ export function SdmInfoRegForm({
field={field}
label={label}
required={required}
error={form.formState.errors[name]}
error={
typeof form.formState.errors[name]?.message === 'string'
? (form.formState.errors[name] as FieldError)
: undefined
}
inputComponent={component(field)}
/>
)
@@ -555,7 +551,11 @@ export function SdmInfoRegForm({
field={field}
label={label}
required={required}
error={form.formState.errors[name]}
error={
typeof form.formState.errors[name]?.message === 'string'
? (form.formState.errors[name] as FieldError)
: undefined
}
inputComponent={component?.(field)}
/>
)}
@@ -580,7 +580,11 @@ export function SdmInfoRegForm({
field={field}
label={label}
required={required}
error={form.formState.errors[name]}
error={
typeof form.formState.errors[name]?.message === 'string'
? (form.formState.errors[name] as FieldError)
: undefined
}
inputComponent={component?.(field)}
/>
)}
@@ -600,7 +604,6 @@ export function SdmInfoRegForm({
noFooterYn="Y"
/>
)}
</>
);
}