114 lines
3.3 KiB
TypeScript
114 lines
3.3 KiB
TypeScript
"use client";
|
|
|
|
import {
|
|
Button,
|
|
Input,
|
|
Label,
|
|
RadioGroup,
|
|
RadioGroupItem,
|
|
TableCell,
|
|
TableRow,
|
|
} from "@common/components";
|
|
|
|
import type { AcntgSeRow } from "../model/acntg/acntg-se-row-types";
|
|
import {
|
|
canAddChildRow,
|
|
formatCdLvNo,
|
|
formatTreeBranchPrefix,
|
|
} from "../model/acntg/build-acntg-display-rows";
|
|
|
|
interface AcntgSeRowProps {
|
|
row: AcntgSeRow;
|
|
depth: number;
|
|
onChange: (patch: Partial<AcntgSeRow>) => void;
|
|
onAddChild: () => void;
|
|
onDelete: () => void;
|
|
}
|
|
|
|
function AcntgSeRowComponent({ row, depth, onChange, onAddChild, onDelete }: AcntgSeRowProps) {
|
|
const levelLabel = formatCdLvNo(row.cdLvNo);
|
|
const branchPrefix = formatTreeBranchPrefix(depth);
|
|
|
|
return (
|
|
<TableRow>
|
|
<TableCell>
|
|
<div className="flex min-w-[10rem] items-center gap-1">
|
|
{branchPrefix ? (
|
|
<span className="shrink-0 font-mono text-muted">{branchPrefix}</span>
|
|
) : null}
|
|
<Input
|
|
value={row.acntgSeCd}
|
|
onChange={(e) => onChange({ acntgSeCd: e.target.value })}
|
|
placeholder="코드"
|
|
maxLength={10}
|
|
disabled={!row.isNew}
|
|
className="flex-1"
|
|
/>
|
|
</div>
|
|
</TableCell>
|
|
<TableCell>
|
|
<Input
|
|
value={row.acntgSeCdNm ?? ""}
|
|
onChange={(e) => onChange({ acntgSeCdNm: e.target.value })}
|
|
placeholder="코드명"
|
|
maxLength={100}
|
|
/>
|
|
</TableCell>
|
|
<TableCell>
|
|
<Input
|
|
value={row.expln ?? ""}
|
|
onChange={(e) => onChange({ expln: e.target.value })}
|
|
placeholder="설명"
|
|
maxLength={1000}
|
|
/>
|
|
</TableCell>
|
|
<TableCell align="center">
|
|
<RadioGroup
|
|
value={row.useYn === "N" ? "N" : "Y"}
|
|
onValueChange={(v) => onChange({ useYn: v })}
|
|
className="flex justify-center gap-4"
|
|
>
|
|
<div className="flex items-center gap-2">
|
|
<RadioGroupItem value="Y" id={`${row.rowKey}-use-y`} />
|
|
<Label htmlFor={`${row.rowKey}-use-y`}>예</Label>
|
|
</div>
|
|
<div className="flex items-center gap-2">
|
|
<RadioGroupItem value="N" id={`${row.rowKey}-use-n`} />
|
|
<Label htmlFor={`${row.rowKey}-use-n`}>아니오</Label>
|
|
</div>
|
|
</RadioGroup>
|
|
</TableCell>
|
|
<TableCell align="center">
|
|
<Input
|
|
type="number"
|
|
min={0}
|
|
value={row.sortSeq ?? ""}
|
|
onChange={(e) =>
|
|
onChange({ sortSeq: e.target.value ? Number(e.target.value) : undefined })
|
|
}
|
|
className="w-20"
|
|
/>
|
|
</TableCell>
|
|
<TableCell align="center">{levelLabel}</TableCell>
|
|
<TableCell align="center">
|
|
<div className="flex justify-center gap-2">
|
|
<Button
|
|
type="button"
|
|
size="sm"
|
|
color="white"
|
|
disabled={!canAddChildRow()}
|
|
onClick={onAddChild}
|
|
>
|
|
하위추가
|
|
</Button>
|
|
<Button type="button" size="sm" color="gray" onClick={onDelete}>
|
|
삭제
|
|
</Button>
|
|
</div>
|
|
</TableCell>
|
|
</TableRow>
|
|
);
|
|
}
|
|
|
|
export { AcntgSeRowComponent };
|