93 lines
2.6 KiB
TypeScript
93 lines
2.6 KiB
TypeScript
import { rainRegExcel } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
|
|
import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
|
import {
|
|
DatePicker,
|
|
FileUpload,
|
|
Form,
|
|
FormField,
|
|
FormUi,
|
|
Title,
|
|
} from "@common/business_components/ui";
|
|
import { Button } from "@common/components/ui";
|
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
import { useState } from "react";
|
|
import { useForm } from "react-hook-form";
|
|
import type { z } from "zod";
|
|
|
|
export default function ChkgdExcel({ type }: { type: string }) {
|
|
const [files, setFiles] = useState(null);
|
|
|
|
const [dmdDate, setDmdDate] = useState(new Date());
|
|
|
|
const defaultValues: z.infer<typeof rainRegExcel> = rainRegExcel.parse({});
|
|
|
|
const form = useForm<z.infer<typeof rainRegExcel>>({
|
|
resolver: zodResolver(rainRegExcel),
|
|
defaultValues: defaultValues,
|
|
});
|
|
|
|
const onChangeDate = (val: Date | undefined) => {
|
|
if (val) setDmdDate(val);
|
|
};
|
|
return (
|
|
<>
|
|
<div>
|
|
<Form {...form}>
|
|
<div>
|
|
<Title
|
|
title={
|
|
type === "RNB"
|
|
? "빗물 이용시설"
|
|
: "중수도 이용시설" + "점검 결과등록"
|
|
}
|
|
></Title>
|
|
</div>
|
|
<div className="flex justify-between">
|
|
<h3 className="text-2xl font-bold text-gray-900">
|
|
{"○점검정보 입력"}
|
|
</h3>
|
|
|
|
<Button className="">저장</Button>
|
|
</div>
|
|
|
|
<div>
|
|
<FormField
|
|
control={form.control}
|
|
name="chckYmd"
|
|
render={({ field }) => (
|
|
<FormUi label="점검일자">
|
|
<DatePicker
|
|
mode="single"
|
|
field={{
|
|
value:
|
|
field.value && !isNaN(new Date(field.value).getTime())
|
|
? new Date(field.value)
|
|
: new Date(), // Provide a default Date value
|
|
onChange: (date) => field.onChange(date),
|
|
}}
|
|
selectClass={selectClass}
|
|
/>
|
|
</FormUi>
|
|
)}
|
|
/>
|
|
|
|
<FormField
|
|
control={form.control}
|
|
name="file"
|
|
render={({ field }) => (
|
|
<FormUi label="점검결과 파일">
|
|
<FileUpload
|
|
files={field.value}
|
|
setFiles={setFiles}
|
|
fileTypes="excel"
|
|
></FileUpload>
|
|
</FormUi>
|
|
)}
|
|
/>
|
|
</div>
|
|
</Form>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|