빗물이용시설 등록 수정 및 공통코드 api 추가
This commit is contained in:
@@ -7,18 +7,18 @@ import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
import { FormUi } from "@common/business_components";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { selectClass, type rainRuseType } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { useEffect } from "react";
|
||||
|
||||
const formSchema = z
|
||||
.object({
|
||||
facilityName: z.string().min(2).max(50),
|
||||
instlCmptnDt: z.string(),
|
||||
instlCst: z.string(),
|
||||
chmaraKndCd: z.string(),
|
||||
chmaraSz: z.string(),
|
||||
chmaraYn: z.string(),
|
||||
chmaraCpct: z.string(),
|
||||
chmaraProcs: z.string(),
|
||||
instlCmptnDt: z.date(),
|
||||
instlCst: z.number(),
|
||||
pntfColKnd: z.string(),
|
||||
pntfColArea: z.number(),
|
||||
filtrTrtmfctPrs: z.string(),
|
||||
filtrTrtmfctYn: z.string(),
|
||||
filtrTrtmfctCpct: z.string(),
|
||||
instlCstSprtYn: z.string(),
|
||||
instlCstSprtAmt: z.string(),
|
||||
grntchCstSprtYn: z.string(),
|
||||
@@ -28,22 +28,27 @@ const formSchema = z
|
||||
grntchBdstCertNo: z.string(),
|
||||
grntchBdstCertGrd: z.string(),
|
||||
})
|
||||
.readonly();
|
||||
|
||||
export function RainRegForm() {
|
||||
const { rain } = useWrStore((state) => state);
|
||||
export function RainRegForm({data}:{data:rainRuseType[]} ) {
|
||||
const { rain ,code} = useWrStore((state) => state);
|
||||
const {rainFcltCd } = code
|
||||
useEffect(() => {
|
||||
console.log(data);
|
||||
if (data && data.length > 0) {
|
||||
form.reset(data[0]); // Assuming the first item matches the form schema
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
const form = useForm<z.infer<typeof formSchema>>({
|
||||
resolver: zodResolver(formSchema),
|
||||
defaultValues: {
|
||||
facilityName: "",
|
||||
instlCmptnDt: "",
|
||||
instlCst: "",
|
||||
chmaraKndCd: "",
|
||||
chmaraYn: "",
|
||||
chmaraSz: "",
|
||||
chmaraCpct: "",
|
||||
chmaraProcs: "",
|
||||
instlCmptnDt: new Date(),
|
||||
instlCst: 0,
|
||||
pntfColKnd: "",
|
||||
pntfColArea: 0,
|
||||
filtrTrtmfctYn: "N",
|
||||
filtrTrtmfctCpct: "",
|
||||
filtrTrtmfctPrs: "",
|
||||
instlCstSprtYn: "",
|
||||
instlCstSprtAmt: "",
|
||||
grntchCstSprtYn: "",
|
||||
@@ -87,9 +92,9 @@ export function RainRegForm() {
|
||||
<FormUi label="설치완료일">
|
||||
<Input
|
||||
className=""
|
||||
placeholder="1,000,000"
|
||||
type=""
|
||||
{...field}
|
||||
type="date"
|
||||
onChange={(e) => field.onChange(e.target.value ? new Date(e.target.value) : undefined)}
|
||||
value={field.value ? field.value.toISOString().split('T')[0] : ""}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -125,14 +130,14 @@ export function RainRegForm() {
|
||||
<div className="col-span-5 pl-6">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="chmaraKndCd"
|
||||
name="pntfColKnd"
|
||||
render={({ field }) => (
|
||||
<FormUi label="종류">
|
||||
<SelectBox
|
||||
className={""}
|
||||
selectClass={selectClass}
|
||||
label={""}
|
||||
selectArray={rain.selectYN}
|
||||
selectArray={rainFcltCd}
|
||||
onSelectValue={onSelectValue}
|
||||
{...field}
|
||||
/>
|
||||
@@ -143,7 +148,7 @@ export function RainRegForm() {
|
||||
<div className="col-span-5">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="chmaraSz"
|
||||
name="pntfColArea"
|
||||
render={({ field }) => (
|
||||
<FormUi label="면적(m³)">
|
||||
<Input
|
||||
@@ -165,7 +170,7 @@ export function RainRegForm() {
|
||||
<div className="col-span-4 pl-6">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="chmaraYn"
|
||||
name="filtrTrtmfctYn"
|
||||
render={({ field }) => (
|
||||
<FormUi label="유무">
|
||||
<SelectBox
|
||||
@@ -183,7 +188,7 @@ export function RainRegForm() {
|
||||
<div className="col-span-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="chmaraCpct"
|
||||
name="filtrTrtmfctCpct"
|
||||
render={({ field }) => (
|
||||
<FormUi label="용량(m³/일)">
|
||||
<Input
|
||||
@@ -199,7 +204,7 @@ export function RainRegForm() {
|
||||
<div className="col-span-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="chmaraProcs"
|
||||
name="filtrTrtmfctPrs"
|
||||
render={({ field }) => (
|
||||
<FormUi label="처리공정">
|
||||
<Input
|
||||
|
||||
Reference in New Issue
Block a user