수요처 등록 폼 작업중
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
"use client";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import * as z from "zod";
|
||||
import {
|
||||
Form,
|
||||
FormField,
|
||||
FormUi,
|
||||
ScrollArea,
|
||||
SelectBox,
|
||||
} from "@common/business_components/ui";
|
||||
import { Button } from "@common/components/ui";
|
||||
import { CoRegForm } from "@/components/ui/matDmd/coRegForm/component";
|
||||
import toast from "react-hot-toast";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
const formSchema = z.object({
|
||||
ctpv: z.string(),
|
||||
sgg: z.string(),
|
||||
coNm: z.string().min(1).max(20),
|
||||
bznmNo: z.string().min(1).min(9).max(12),
|
||||
addr: z.string().min(1).min(6).max(20),
|
||||
telNo: z.string().min(8).max(12),
|
||||
|
||||
});
|
||||
|
||||
export default function MyForm() {
|
||||
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const form = useForm<z.infer<typeof formSchema>>({
|
||||
resolver: zodResolver(formSchema),
|
||||
defaultValues: {
|
||||
coNm:'',
|
||||
bznmNo:'',
|
||||
addr:'',
|
||||
telNo:'',
|
||||
},
|
||||
});
|
||||
|
||||
function onSubmit(values: z.infer<typeof formSchema>) {
|
||||
try {
|
||||
console.log(values);
|
||||
toast(
|
||||
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
|
||||
<code className="text-white">{JSON.stringify(values, null, 2)}</code>
|
||||
</pre>
|
||||
);
|
||||
router.push('./dmdReg')
|
||||
// <Link href='matMng/matDmd/dmdReg'></Link>
|
||||
} catch (error) {
|
||||
console.error("Form submission error", error);
|
||||
toast.error("Failed to submit the form. Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="grid h-40 grid-cols-3 place-content-center">
|
||||
<h1 className=" col-start-2 col-span-1 text-4xl underline">
|
||||
수요처 정보입력
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-5 gap-4 overflow-hidden">
|
||||
<div className="col-span-1 "/>
|
||||
<div className="col-span-3 ">
|
||||
<div>
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
className="space-y-8 max-w-3xl mx-auto"
|
||||
>
|
||||
<CoRegForm>{form}</CoRegForm>
|
||||
|
||||
{/* <WqForm> {form}</WqForm> */}
|
||||
|
||||
<Button type="submit">수요처등록</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-span-1 " />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
"use client";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import * as z from "zod";
|
||||
import {
|
||||
Form,
|
||||
} from "@common/business_components/ui";
|
||||
import { Button } from "@common/components/ui";
|
||||
import { DmdRegForm } from "@/components/ui/matDmd/dmdRegform/component";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
const formSchema = z.object({
|
||||
dmdSel: z.string().min(1).min(0),
|
||||
dmdTmng: z.coerce.date(),
|
||||
dmdWq: z.string().min(1).optional(),
|
||||
useUsgCd: z.string(),
|
||||
wntUntprc: z.string().min(1),
|
||||
grssClfg: z.string().min(1),
|
||||
tn: z.string().min(1).optional(),
|
||||
combResdch: z.string().min(1).optional(),
|
||||
tp: z.string().min(1).optional(),
|
||||
trbt: z.string().min(1).optional(),
|
||||
ph: z.string().min(1).optional(),
|
||||
bod: z.string().min(1).optional(),
|
||||
clIonQnt: z.string().min(1).optional(),
|
||||
smll: z.string().min(1).optional(),
|
||||
cdtnv: z.string().min(1).optional(),
|
||||
crmty: z.string().min(1).optional(),
|
||||
rmrk: z.string().min(1).optional(),
|
||||
});
|
||||
|
||||
export default function MyForm() {
|
||||
const form = useForm<z.infer<typeof formSchema>>({
|
||||
resolver: zodResolver(formSchema),
|
||||
defaultValues: {
|
||||
dmdTmng: new Date(),
|
||||
dmdWq: '',
|
||||
useUsgCd: '',
|
||||
wntUntprc: '',
|
||||
grssClfg: '',
|
||||
tn: '',
|
||||
combResdch: '',
|
||||
tp: '',
|
||||
trbt:'',
|
||||
ph: '',
|
||||
bod: '',
|
||||
clIonQnt: '',
|
||||
smll: '',
|
||||
cdtnv: '',
|
||||
crmty: '',
|
||||
rmrk: '',
|
||||
},
|
||||
});
|
||||
|
||||
function onSubmit(values: z.infer<typeof formSchema>) {
|
||||
try {
|
||||
console.log(values);
|
||||
|
||||
toast(
|
||||
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
|
||||
<code className="text-white">{JSON.stringify(values, null, 2)}</code>
|
||||
</pre>
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Form submission error", error);
|
||||
// toast.error("Failed to submit the form. Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="grid h-40 grid-cols-3 place-content-center">
|
||||
<h1 className=" col-start-2 col-span-1 text-4xl underline">
|
||||
수요 신청정보입력
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-5 gap-4 overflow-hidden">
|
||||
<div className="col-span-1 "/>
|
||||
<div className="col-span-3 max-h-[78vh] overflow-y-scroll ">
|
||||
<div>
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
className="space-y-8 max-w-3xl mx-auto"
|
||||
>
|
||||
|
||||
<DmdRegForm> {form}</DmdRegForm>
|
||||
|
||||
<Button type="submit"> 수요신청</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-span-1 " />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
"use client"
|
||||
|
||||
|
||||
import {
|
||||
useForm
|
||||
} from "react-hook-form"
|
||||
import {
|
||||
zodResolver
|
||||
} from "@hookform/resolvers/zod"
|
||||
import * as z from "zod"
|
||||
|
||||
import {
|
||||
Calendar as CalendarIcon
|
||||
} from "lucide-react"
|
||||
import { Form, FormField, FormUi, ScrollArea, SelectBox } from "@common/business_components/ui"
|
||||
import { Button, Input } from "@common/components/ui"
|
||||
import { BaseForm } from "@/components/ui/matDmd/baseForm/component"
|
||||
import { WqForm } from "@/components/ui/matDmd/wqForm/component"
|
||||
|
||||
const formSchema = z.object({
|
||||
ctpv: z.string(),
|
||||
sgg: z.string(),
|
||||
coNm: z.string().min(1).min(0).max(20),
|
||||
bznmNo: z.string().min(1).min(9).max(12),
|
||||
name_5973331634: z.string().min(1).min(6).max(20),
|
||||
telNo: z.string().min(8).max(12),
|
||||
dmdSel: z.string().min(1).min(0),
|
||||
dmdTmng: z.coerce.date(),
|
||||
dmdWq: z.string().min(1).optional(),
|
||||
useUsgCd: z.string(),
|
||||
wntUntprc: z.string().min(1),
|
||||
grssClfg: z.string().min(1),
|
||||
tn: z.string().min(1).optional(),
|
||||
combResdch: z.string().min(1),
|
||||
tp: z.string().min(1),
|
||||
trbt: z.string().min(1).optional(),
|
||||
ph: z.string().min(1),
|
||||
bod: z.string().min(1).optional(),
|
||||
clIonQnt: z.string().min(1),
|
||||
smll: z.string().min(1).optional(),
|
||||
cdtnv: z.string().min(1).optional(),
|
||||
crmty: z.string().min(1).optional(),
|
||||
rmrk: z.string().min(1)
|
||||
});
|
||||
|
||||
export default function MyForm() {
|
||||
|
||||
const form = useForm < z.infer < typeof formSchema >> ({
|
||||
resolver: zodResolver(formSchema),
|
||||
defaultValues: {
|
||||
"dmdTmng": new Date()
|
||||
},
|
||||
})
|
||||
|
||||
function onSubmit(values: z.infer < typeof formSchema > ) {
|
||||
try {
|
||||
console.log(values);
|
||||
/*
|
||||
toast(
|
||||
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
|
||||
<code className="text-white">{JSON.stringify(values, null, 2)}</code>
|
||||
</pre>
|
||||
);*/
|
||||
} catch (error) {
|
||||
console.error("Form submission error", error);
|
||||
// toast.error("Failed to submit the form. Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<h1 className="pl-3 text-4xl" >수요처 정보 등록 </h1>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div>
|
||||
<h1 className="space-y-8 max-w-3xl mx-auto py-1 text-2xl" >정보입력 </h1>
|
||||
</div>
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8 max-w-3xl mx-auto py-10">
|
||||
|
||||
<ScrollArea>
|
||||
<BaseForm >{form} </BaseForm>
|
||||
|
||||
|
||||
<WqForm> {form}</WqForm>
|
||||
|
||||
<Button type="submit">Submit</Button>
|
||||
</ScrollArea>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -18,7 +18,7 @@ export default function Home() {
|
||||
</Button>
|
||||
|
||||
<Button className='place-self-auto'>
|
||||
<Link href="matMng/matDmd">수요처 등록</Link>
|
||||
<Link href="matMng/matDmd/coReg">수요처 등록</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -10,7 +10,6 @@ import { useWrStore } from '../../../store';
|
||||
export default function PublicReuseFaciltyInsert() {
|
||||
const {pubFac} = useWrStore((state) => state);
|
||||
const { pubFacHeadList, publicReuseFacilityData, selectLabel} = pubFac;
|
||||
console.log(pubFacHeadList)
|
||||
const searchDiv = '하수재이용시설 '
|
||||
const selectBox = [{ text: '서울하수처리시설', val: "1" }, { text: '서울1하수처리시설', val: "2" }, { text: '서울2하수처리시설', val: "3" }]
|
||||
const headName = () => {
|
||||
|
||||
@@ -5,12 +5,12 @@ import type { selectArray } from "../rainReuseFacilityInsert";
|
||||
const selectSido = [
|
||||
{ text: '서울', val: "1" },
|
||||
{ text: "인천", val: "2" },
|
||||
{ text: "부산", val: "2" },
|
||||
{ text: "부산", val: "3" },
|
||||
];
|
||||
const selectSgg = [
|
||||
{ text: '종로구', val: "1" },
|
||||
{ text: "성북구", val: "2" },
|
||||
{ text: "강남구", val: "2" },
|
||||
{ text: "강남구", val: "3" },
|
||||
];
|
||||
const selectUsg = [
|
||||
{ text: '민간', val: "1" },
|
||||
|
||||
@@ -85,6 +85,8 @@ export type selectArray ={
|
||||
val:string
|
||||
|
||||
}
|
||||
|
||||
export const selectClass ="w-full h-full text-2xl";
|
||||
const selectHomeWater = [
|
||||
{ text: '집수면', val: "1" },
|
||||
{ text: "종류", val: "2" },
|
||||
|
||||
Reference in New Issue
Block a user