재이용시설 등록 데이터 구조 변경

This commit is contained in:
leedj312
2025-05-30 09:17:17 +09:00
parent 41df013bb3
commit a5d816e221
7 changed files with 605 additions and 347 deletions
@@ -1,19 +1,64 @@
import React from "react";
import React, { useCallback, useState } from "react";
import { FormControl, FormItem, FormLabel, FormMessage } from "../form";
import { Button, Checkbox } from "@common/components/ui";
const FormUi = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> & {label:string|undefined}
>(({children, label},ref)=>{
export const BZNM_TOT_NO = '총사업자등록번호';
export const CANDIDATE = '공급처 후보지 선택(필수아님)';
interface FormUiProps extends React.HTMLAttributes<HTMLDivElement> {
label?: string;
onCheckboxChange?: (checked: boolean) => void;
isDisabled?: boolean;
}
interface FormElementProps extends React.HTMLAttributes<HTMLElement> {
disabled?: boolean;
}
const FormUi = React.forwardRef<HTMLDivElement, FormUiProps>(
({ children, label, onCheckboxChange, isDisabled }, ref) => {
const [isChecked, setIsChecked] = useState(false);
const handleCheckboxChange = useCallback((checked: boolean) => {
setIsChecked(checked);
onCheckboxChange?.(checked);
}, [onCheckboxChange]);
console.log(children);
return (
<FormItem ref={ref}>
{label?<FormLabel className="text-xl">{label}</FormLabel>:<></>}
<FormControl>
{children}
</FormControl>
<FormMessage />
</FormItem>
)
})
<FormItem ref={ref}>
{label && <FormLabel className="text-xl">{label}</FormLabel>}
{label === BZNM_TOT_NO && (
<div className="float-right">
<div className="flex items-center gap-2">
<Checkbox
id="check"
checked={isChecked}
onCheckedChange={handleCheckboxChange}
/>
<label className="w-20 text-xl text-gray-600" htmlFor="check">해당없음</label>
</div>
</div>
)}
{label === CANDIDATE && (
<FormControl>
{children}
</FormControl>
)}
{label !== BZNM_TOT_NO && label !== CANDIDATE && (
<FormControl>
{React.isValidElement(children) && isDisabled
? React.cloneElement(children, {
disabled: true,
...(children.props as FormElementProps)
})
: children}
</FormControl>
)}
<FormMessage />
</FormItem>
);
}
);
FormUi.displayName = 'FormUi';
export { FormUi };
export { FormUi };