selectbox로 변경
This commit is contained in:
@@ -32,7 +32,7 @@ export default function PublicReuseFaciltyInsert() {
|
||||
|
||||
const [searchTxt, setSearchTxt] = useState<string>();
|
||||
const [bdstTable, setbdstTable] = useState<customPbnst[]>();
|
||||
const [selectBdst, setSelectBdst] = useState<customPbnst | null>(null);
|
||||
const [selectBdst, setSelectBdst] = useState<customPbnst[] | null>(null);
|
||||
const [selectedRow, setSelectedRow] = useState<customPbnst | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -59,6 +59,7 @@ useEffect(() => {
|
||||
if (val === undefined) return;
|
||||
console.log("pbnstRes", pbnstRes)
|
||||
const selectRow = pbnstHasuRes?.[val];
|
||||
|
||||
setSelectedRow(selectRow);
|
||||
console.log("아제발", selectRow)
|
||||
if (pbnstRes === null){
|
||||
|
||||
@@ -36,7 +36,7 @@ export type pubFacState = {
|
||||
pbnstMngUpHeadList: TableUpperProps[];
|
||||
pbnstMngNm: chHeadType[];
|
||||
pbnstHasuRes: pubHasuType[];
|
||||
pbnstRes: customPbnst | null; // 배열에서 단일 객체 또는 null로 변경
|
||||
pbnstRes: customPbnst[] | null; // 배열에서 단일 객체 또는 null로 변경
|
||||
pbnstBizCycle: SelectDataType[];
|
||||
selectLabel: SelectDataType[];
|
||||
pbnstOrgwtHeadList: TableUpperProps[];
|
||||
@@ -146,7 +146,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
...state,
|
||||
pbnst: {
|
||||
...state.pbnst,
|
||||
pbnstRes: pbnstRes,
|
||||
pbnstRes: [pbnstRes],
|
||||
pbnstBizCycle: pbnstBizCycle,
|
||||
isInit: false,
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { FileUpload, FormUi } from "@common/business_components/ui";
|
||||
import { FileUpload, FormUi, SelectBox } from "@common/business_components/ui";
|
||||
import { Form, FormField } from "@common/business_components/ui/form";
|
||||
import { Button, Input } from "@common/components";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
@@ -22,19 +22,22 @@ import {
|
||||
type customPbnst,
|
||||
type operType,
|
||||
type ruseFcltType,
|
||||
type selectLabel,
|
||||
} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
|
||||
import { Label } from "@common/business_components/ui/form/lib/label";
|
||||
export type FilesType = {
|
||||
atflCd: String;
|
||||
file: File;
|
||||
};
|
||||
|
||||
export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
export function PbnstMngForm({ data }: { data: customPbnst[] }) {
|
||||
const { pbnst, pbnstUpdate } = useWrStore((state) => state);
|
||||
const { pbnstMngUpHeadList } = pbnst;
|
||||
const [ruseOperData, setRuseOperData] = useState<operType[]>();
|
||||
const [planFiles, setPlanFiles] = useState<File[] | null>(null);
|
||||
const [relationfiles, setRelationFiles] = useState<FilesType[] | null>(null);
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
const [fcltNm, setFcltNm] = useState<selectLabel[]>()
|
||||
|
||||
const [upload, setUpload] = useState<Upload | null>(null);
|
||||
const [progress, setProgress] = useState(0);
|
||||
@@ -43,7 +46,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
setProgress(Number(percentage));
|
||||
};
|
||||
|
||||
const ref = useRef<operType[] | null>(data?.fcOpers ?? null);
|
||||
const ref = useRef<operType[] | null>(data[0]?.fcOpers ?? null);
|
||||
const form = useForm<z.infer<typeof pbnstRegZod>>({
|
||||
resolver: zodResolver(pbnstRegZod),
|
||||
defaultValues: pbnstRegZod.parse({}),
|
||||
@@ -80,14 +83,21 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
selectedIdxs.reverse().forEach((idx) => remove(idx));
|
||||
};
|
||||
|
||||
const onSelectValue = (val: string) => {};
|
||||
|
||||
useEffect(() => {
|
||||
if (!data) return;
|
||||
form.reset(data);
|
||||
setRuseOperData(data.fcOpers);
|
||||
//form.reset(data);
|
||||
const fcltNmList = data.map((item, index) => ({
|
||||
text: item.ruseUtztnFcltNm,
|
||||
val: String(index)
|
||||
}))
|
||||
setFcltNm(fcltNmList)
|
||||
}, [data]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!fcltNm || fcltNm.length === 0) return;
|
||||
// Default to the first item in data when fcltNm changes
|
||||
form.reset(data[0]);
|
||||
console.log("fcltNm", fcltNm)
|
||||
}, [fcltNm, data]);
|
||||
// 2. Define a submit handler.
|
||||
function onSubmit(values: z.infer<typeof pbnstRegZod>) {
|
||||
console.log("submit", values);
|
||||
@@ -142,6 +152,9 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
console.log("relationfiles changed:", relationfiles);
|
||||
}, [relationfiles]);
|
||||
|
||||
|
||||
|
||||
|
||||
const testFile = () => {
|
||||
// if (relationfiles && relationfiles[0])
|
||||
// TusClientUpload(relationfiles[0], setUpload, {
|
||||
@@ -169,14 +182,23 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
|
||||
<form onSubmit={form.handleSubmit(onSubmit)}>
|
||||
<div className="flex justify-between items-center mx-3 mb-3">
|
||||
<div className="col-span-2 flex items-top">
|
||||
<h2 className={formTableName + "pr-3 col-span-10 "}>
|
||||
{/* <h2 className={formTableName + "pr-3 col-span-10 "}>
|
||||
재이용 시설명
|
||||
</h2>
|
||||
<span className="mt-4 ml-2">
|
||||
</h2> */}
|
||||
{/* <span className="mt-4 ml-2">
|
||||
{form.getValues("ruseUtztnFcltNm")
|
||||
? ": " + form.getValues("ruseUtztnFcltNm")
|
||||
: ""}
|
||||
</span>
|
||||
</span> */}
|
||||
<Label className={formTableName + "pr-3 col-span-2 "}>재이용 시설명</Label>
|
||||
<SelectBox
|
||||
label=""
|
||||
className="mt-4 ml-2"
|
||||
selectClass={undefined}
|
||||
selectArray={fcltNm ?? []}
|
||||
onSelectValue={(val) => {console.log("val", val)}}
|
||||
value={""}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Button type="submit" size={commonButonSize}>
|
||||
|
||||
Reference in New Issue
Block a user