feat: alert/confirm을 공통 모달 다이얼로그로 통합
모든 window.alert/confirm 을 업무 삭제 모달과 동일한 구조/디자인의 공통 모달로 대체하고, 한 곳에서 관리하도록 다이얼로그 시스템을 도입한다. - dialog.store: 알림/확인 큐 + Promise 기반 상태 관리 - useDialog(): alert/confirm 컴포저블 API - AppDialog: App 루트 1회 마운트, 전역 .modal-*/.mbtn 클래스로 렌더 (variant: info/success/warning/danger → 아이콘·버튼 색) - relay.css: modal-ico.info/.warning, mbtn.primary 변형 추가 - 교체: API 에러 알림(useApi), 검증/성공 알림(Signup/ProjectCreate/ ProjectSettings/TaskCreate), 삭제·제거 확인(ProjectSettings/ ProjectMembers/AgentChatPanel) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import axios, {
|
||||
type AxiosResponse,
|
||||
type InternalAxiosRequestConfig,
|
||||
} from 'axios'
|
||||
import { useDialogStore } from '@/stores/dialog.store'
|
||||
|
||||
// axios 요청 설정 확장 — 호출 단위 옵션
|
||||
declare module 'axios' {
|
||||
@@ -35,9 +36,10 @@ const ErrorCodeLexicon: Record<string, string> = {
|
||||
BIZ_001: '요청하신 작업을 완료하지 못했습니다. 다시 시도해 주세요.',
|
||||
}
|
||||
|
||||
// 사용자 노출용 알림 — Toast 라이브러리 도입 시 이 함수만 교체하면 됨
|
||||
// 사용자 노출용 에러 알림 — 전역 공통 다이얼로그(danger)로 표시.
|
||||
// (인터셉터 실행 시점엔 pinia 가 활성화돼 있어 store 접근 가능)
|
||||
const showErrorUI = (message: string) => {
|
||||
window.alert(message)
|
||||
void useDialogStore().alert(message, { variant: 'danger' })
|
||||
}
|
||||
|
||||
// 에러 코드 → 메시지 변환 (미정의 코드는 SYS_001 로 폴백, 항상 문자열 보장)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { useDialogStore, type DialogOptions } from '@/stores/dialog.store'
|
||||
|
||||
// 전역 알림/확인 다이얼로그 — window.alert/confirm 대체.
|
||||
// 사용 예:
|
||||
// const dialog = useDialog()
|
||||
// await dialog.alert('저장했습니다.', { variant: 'success' })
|
||||
// if (await dialog.confirm('삭제할까요?', { confirmText: '삭제' })) { ... }
|
||||
export function useDialog() {
|
||||
const store = useDialogStore()
|
||||
return {
|
||||
alert: (text: string, opts?: DialogOptions): Promise<void> =>
|
||||
store.alert(text, opts).then(() => undefined),
|
||||
confirm: (text: string, opts?: DialogOptions): Promise<boolean> => store.confirm(text, opts),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user