fix: Enhance error handling and validation messages in form data operations
- Integrated `formatPgError` utility to provide user-friendly error messages based on PostgreSQL error codes during form data operations. - Updated error responses in `saveFormData`, `saveFormDataEnhanced`, `updateFormData`, and `updateFormDataPartial` to include specific messages based on the company context. - Improved error handling in the frontend components to display relevant error messages from the server response, ensuring users receive clear feedback on save operations. - Enhanced the required field validation by incorporating NOT NULL metadata checks across various components, improving the accuracy of form submissions. These changes improve the overall user experience by providing clearer error messages and ensuring that required fields are properly validated based on both manual settings and database constraints.
This commit is contained in:
@@ -10,6 +10,7 @@ import { useCalculation } from "./useCalculation";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { apiClient } from "@/lib/api/client";
|
||||
import { ComponentRendererProps } from "@/types/component";
|
||||
import { isColumnRequiredByMeta } from "@/lib/registry/DynamicComponentRenderer";
|
||||
|
||||
// ✅ ComponentRendererProps 상속으로 필수 props 자동 확보
|
||||
export interface ModalRepeaterTableComponentProps extends ComponentRendererProps {
|
||||
@@ -380,6 +381,15 @@ export function ModalRepeaterTableComponent({
|
||||
return [];
|
||||
}, [componentConfig?.columns, propColumns, sourceColumns]);
|
||||
|
||||
// NOT NULL 메타데이터 기반 required 보강
|
||||
const enhancedColumns = React.useMemo((): RepeaterColumnConfig[] => {
|
||||
if (!targetTable) return columns;
|
||||
return columns.map((col) => ({
|
||||
...col,
|
||||
required: col.required || isColumnRequiredByMeta(targetTable, col.field),
|
||||
}));
|
||||
}, [columns, targetTable]);
|
||||
|
||||
// 초기 props 검증
|
||||
useEffect(() => {
|
||||
if (rawSourceColumns.length !== sourceColumns.length) {
|
||||
@@ -876,7 +886,7 @@ export function ModalRepeaterTableComponent({
|
||||
|
||||
{/* Repeater 테이블 */}
|
||||
<RepeaterTable
|
||||
columns={columns}
|
||||
columns={enhancedColumns}
|
||||
data={localValue}
|
||||
onDataChange={handleChange}
|
||||
onRowChange={handleRowChange}
|
||||
|
||||
Reference in New Issue
Block a user