feat: 모든 숫자에 천 단위 콤마 자동 표시

- InteractiveDataTable: number/decimal 타입 셀에 천 단위 콤마 적용
- FlowWidget: 스텝 카운트, 데이터 셀, 페이지 정보에 천 단위 콤마 적용
- formatValue 함수로 숫자 자동 감지 및 포맷팅
- 문자열로 저장된 숫자도 자동으로 포맷팅 처리
- toLocaleString('ko-KR') 사용으로 한국식 숫자 표기
This commit is contained in:
kjs 2025-11-03 10:00:16 +09:00
parent 2ddda380f2
commit c9eacb8f4a
2 changed files with 31 additions and 16 deletions

View File

@ -1775,8 +1775,11 @@ export const InteractiveDataTable: React.FC<InteractiveDataTableProps> = ({
case "number":
case "decimal":
if (typeof value === "number") {
return value.toLocaleString();
if (value !== null && value !== undefined && value !== "") {
const numValue = typeof value === "string" ? parseFloat(value) : value;
if (!isNaN(numValue)) {
return numValue.toLocaleString("ko-KR");
}
}
break;

View File

@ -58,6 +58,28 @@ export function FlowWidget({
const { isPreviewMode } = useScreenPreview(); // 프리뷰 모드 확인
const { user } = useAuth(); // 사용자 정보 가져오기
// 숫자 포맷팅 함수
const formatValue = (value: any): string => {
if (value === null || value === undefined || value === "") {
return "-";
}
// 숫자 타입이거나 숫자로 변환 가능한 문자열인 경우 포맷팅
if (typeof value === "number") {
return value.toLocaleString("ko-KR");
}
if (typeof value === "string") {
const numValue = parseFloat(value);
// 숫자로 변환 가능하고, 변환 후 원래 값과 같은 경우에만 포맷팅
if (!isNaN(numValue) && numValue.toString() === value.trim()) {
return numValue.toLocaleString("ko-KR");
}
}
return String(value);
};
// 🆕 전역 상태 관리
const setSelectedStep = useFlowStepStore((state) => state.setSelectedStep);
const resetFlow = useFlowStepStore((state) => state.resetFlow);
@ -698,7 +720,7 @@ export function FlowWidget({
}`}
>
<span className="text-sm font-medium sm:text-base">
{stepCounts[step.id] || 0}
{(stepCounts[step.id] || 0).toLocaleString("ko-KR")}
</span>
<span className="text-xs font-normal sm:text-sm"></span>
</div>
@ -884,13 +906,7 @@ export function FlowWidget({
{stepDataColumns.map((col) => (
<div key={col} className="flex justify-between gap-2 text-xs">
<span className="text-muted-foreground font-medium">{columnLabels[col] || col}:</span>
<span className="text-foreground truncate">
{row[col] !== null && row[col] !== undefined ? (
String(row[col])
) : (
<span className="text-muted-foreground">-</span>
)}
</span>
<span className="text-foreground truncate">{formatValue(row[col])}</span>
</div>
))}
</div>
@ -941,11 +957,7 @@ export function FlowWidget({
)}
{stepDataColumns.map((col) => (
<TableCell key={col} className="h-16 border-b px-6 py-3 text-sm whitespace-nowrap">
{row[col] !== null && row[col] !== undefined ? (
String(row[col])
) : (
<span className="text-muted-foreground">-</span>
)}
{formatValue(row[col])}
</TableCell>
))}
</TableRow>
@ -964,7 +976,7 @@ export function FlowWidget({
{/* 왼쪽: 페이지 정보 + 페이지 크기 선택 */}
<div className="flex flex-col items-center gap-2 sm:flex-row sm:gap-4">
<div className="text-muted-foreground text-xs sm:text-sm">
{stepDataPage} / {totalStepDataPages} ( {stepData.length})
{stepDataPage} / {totalStepDataPages} ( {stepData.length.toLocaleString("ko-KR")})
</div>
<div className="flex items-center gap-2">
<span className="text-muted-foreground text-xs"> :</span>