중복 타입 제거 및 실적등록 완료
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
"use client";
|
||||
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import type {
|
||||
} from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
|
||||
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { InputTableBody } from "@/components/lib/func/TableData";
|
||||
import {
|
||||
Input,
|
||||
Table,
|
||||
@@ -12,7 +13,7 @@ import {
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@common/components/ui";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useState, type Dispatch, type SetStateAction } from "react";
|
||||
|
||||
export function GuideDetailsTable({
|
||||
chgRes,
|
||||
@@ -26,80 +27,26 @@ export function GuideDetailsTable({
|
||||
setChGuidData: (chgRes: any[]) => void;
|
||||
}) {
|
||||
const { code, rainChkgdn } = useWrStore((state) => state);
|
||||
const [guidData, setGuidData] = useState<any[]>();
|
||||
const [inputData, setInputData] = useState<any[]>();
|
||||
|
||||
|
||||
const handleChange = (
|
||||
rowIndex: number,
|
||||
field: any,
|
||||
value: string | number
|
||||
) => {
|
||||
if(Number(value) < 0 ||! Number(value)){
|
||||
value = 0;
|
||||
}else{
|
||||
value = Number(value);
|
||||
}
|
||||
setGuidData((prevData) =>
|
||||
prevData?.map((row, index) => {
|
||||
if (index === rowIndex) {
|
||||
return {
|
||||
...row,
|
||||
[field as any]: value,
|
||||
};
|
||||
}
|
||||
return row;
|
||||
})
|
||||
);
|
||||
};
|
||||
const tableBody = (chgRes: any[] | []) => {
|
||||
return (
|
||||
<>
|
||||
{chgRes.map((data, dataIndex) => (
|
||||
<TableRow key={dataIndex + "row"}>
|
||||
{headList.map((head, headIndex) => (
|
||||
<TableCell key={head.id + headIndex} className="w-36" >
|
||||
{head.edit ===true && data.edit !==false?
|
||||
<Input
|
||||
className={`${head.id !== "utztnUsgCd" ? "text-right" : "text-center"} !text-xl h-10 w-full`}
|
||||
onChange={(e) =>
|
||||
handleChange(dataIndex, head.id, e.target.value)
|
||||
}
|
||||
value={data[head.id as keyof any] ?? ""}
|
||||
/> : (
|
||||
<div
|
||||
className={`
|
||||
${head.id !== "utztnUsgCd" ? "text-right" : "text-center"}
|
||||
!text-xl w-full h-10
|
||||
`}
|
||||
>
|
||||
{data[head.id as keyof any] ?? ""}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</TableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
};
|
||||
useEffect(() => {
|
||||
setGuidData(chgRes);
|
||||
setInputData(chgRes);
|
||||
}, [chgRes]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setChGuidData(guidData??[] );
|
||||
setChGuidData(inputData??[] );
|
||||
|
||||
}, [guidData]);
|
||||
}, [inputData]);
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={`card !m-[1.2rem] !p-0r `}>
|
||||
<Table variant="secondary">
|
||||
<TableHeader className="font-bold">{headMakeprfmnc(headList, rainChkgdn?.rainHeadNm)}</TableHeader>
|
||||
<TableBody >
|
||||
{tableBody(guidData ?? [])}
|
||||
{InputTableBody(inputData ?? [],headList, setInputData) }
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"
|
||||
import { useWrStore } from "@/app/store";
|
||||
import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
|
||||
import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
|
||||
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import { tableData } from "@/components/lib/func/commom";
|
||||
import {
|
||||
chRowspanTable,
|
||||
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
rswtChkZodType,
|
||||
rswtrChkDetailsZodType,
|
||||
} from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
|
||||
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import { tableData } from "@/components/lib/func/commom";
|
||||
import {
|
||||
chRowspanTable,
|
||||
|
||||
Reference in New Issue
Block a user