fix(WEB): 폼 컴포넌트 DatePicker 적용 및 코드 정리
- ExpectedExpenseManagement DatePicker 적용 및 간소화 - BoardForm 날짜 필드 개선 - AttendanceInfoDialog, ReasonInfoDialog 코드 정리 - ReceivingDetail 기능 보강 - ShipmentCreate/Edit DatePicker 적용 - VehicleDispatchEdit 수정 - WorkOrderCreate 개선 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -166,8 +166,8 @@ export function BoardForm({ mode, initialData }: BoardFormProps) {
|
||||
}, [boardCode, title, content]);
|
||||
|
||||
// ===== 저장 핸들러 =====
|
||||
const handleSubmit = useCallback(async () => {
|
||||
if (!validate()) return;
|
||||
const handleSubmit = useCallback(async (): Promise<{ success: boolean; error?: string }> => {
|
||||
if (!validate()) return { success: false, error: '' };
|
||||
|
||||
setIsSubmitting(true);
|
||||
try {
|
||||
@@ -186,20 +186,19 @@ export function BoardForm({ mode, initialData }: BoardFormProps) {
|
||||
result = await updatePost(boardCode, initialData.id, postData);
|
||||
}
|
||||
|
||||
if (result?.success) {
|
||||
toast.success(mode === 'create' ? '게시글이 등록되었습니다.' : '게시글이 수정되었습니다.');
|
||||
router.push('/ko/board');
|
||||
} else {
|
||||
toast.error(result?.error || '게시글 저장에 실패했습니다.');
|
||||
if (!result?.success) {
|
||||
return { success: false, error: result?.error || '게시글 저장에 실패했습니다.' };
|
||||
}
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
if (isNextRedirectError(error)) throw error;
|
||||
console.error('게시글 저장 오류:', error);
|
||||
toast.error('게시글 저장에 실패했습니다.');
|
||||
const errorMessage = error instanceof Error ? error.message : '게시글 저장에 실패했습니다.';
|
||||
return { success: false, error: errorMessage };
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
}, [boardCode, title, content, isPinned, mode, initialData, router, validate]);
|
||||
}, [boardCode, title, content, isPinned, mode, initialData, validate]);
|
||||
|
||||
// ===== 취소 핸들러 =====
|
||||
const handleCancel = useCallback(() => {
|
||||
@@ -418,9 +417,8 @@ export function BoardForm({ mode, initialData }: BoardFormProps) {
|
||||
mode={mode}
|
||||
isLoading={isBoardsLoading}
|
||||
onCancel={handleCancel}
|
||||
onSubmit={async (_data: Record<string, unknown>) => {
|
||||
await handleSubmit();
|
||||
return { success: true };
|
||||
onSubmit={async () => {
|
||||
return await handleSubmit();
|
||||
}}
|
||||
renderForm={renderFormContent}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user