-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: �Connect error handling with Toast �system for multiple error s…
…cenarios (#122) * feat: Implement Toast component with headless pattern - Add base Toast UI component with variant styles - Create cva variants for different toast types (default, error, success, warning) - Add close button with hover effect - Keep component headless by separating styling from logic * feat: Add ToastContainer with slide animation - Create ToastContainer to manage toast stack - Implement smooth slide animations for toast enter/exit - Add state management for animation timing - Handle multiple toasts with proper stacking * feat: Add toast store using Zustand for global state access - Use global state management for showing toasts from anywhere in app - Implement toast CRUD operations - Add auto-dismiss with configurable duration * feat: Integrate toast system into app root - Add ToastContainer to App component * feat: Enhance Toast components accessibility - Add ARIA roles and live regions for screen reader support - Implement keyboard navigation and focus management - Add ESC key to dismiss toasts - Add focus styles consistent with design system - Connect aria-labelledby/describedby with unique IDs - Improve close button accessibility with contextual labels * feat: Implement max toast limit and FIFO behavior - Add MAX_TOASTS constant to limit the number of toasts to 5 * feat: Refactor room creation logic in useCreateRoom hook and Add toast for error - Changed the implementation of the useCreateRoom hook to manage loading state and error handling more effectively. - Removed the useMutation from React Query and implemented a custom async function for room creation. - Added toast notifications for success and error handling (commented out for future implementation). * feat: Implement Toast system for WebSocket and API error handling - Define detailed messages for each error code - Client errors (4xxx) - Server errors (5xxx) - Game logic errors (6xxx) - Connection errors (7xxx) - Distinguish error titles by namespace - Separate areas for game/drawing/chat - Display appropriate error messages for each function - Differentiate Toast UI based on error situations - Adjust display time according to severity - Apply error variant styles * feat: Add Toast message for ink depletion - Check ink levels at the start of drawing - Provide visual feedback when ink is low - Display error toast message - Implement friendly UX with emoji - Automatically dismiss after 2 seconds * design: Enhance adative Toast design
- Loading branch information
Showing
8 changed files
with
149 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { SocketErrorCode } from '@troublepainter/core'; | ||
import { SocketNamespace } from '@/stores/socket/socket.config'; | ||
|
||
export const ERROR_MESSAGES: Record<SocketErrorCode, string> = { | ||
// 클라이언트 에러 (4xxx) | ||
[SocketErrorCode.BAD_REQUEST]: '잘못된 요청입니다. 다시 시도해 주세요.', | ||
[SocketErrorCode.UNAUTHORIZED]: '인증이 필요합니다.', | ||
[SocketErrorCode.FORBIDDEN]: '접근 권한이 없습니다.', | ||
[SocketErrorCode.NOT_FOUND]: '요청한 리소스를 찾을 수 없습니다.', | ||
[SocketErrorCode.VALIDATION_ERROR]: '입력 데이터가 유효하지 않습니다.', | ||
[SocketErrorCode.RATE_LIMIT]: '너무 많은 요청을 보냈습니다. 잠시 후 다시 시도해주세요.', | ||
|
||
// 서버 에러 (5xxx) | ||
[SocketErrorCode.INTERNAL_ERROR]: '서버 내부 오류가 발생했습니다.', | ||
[SocketErrorCode.NOT_IMPLEMENTED]: '아직 구현되지 않은 기능입니다.', | ||
[SocketErrorCode.SERVICE_UNAVAILABLE]: '서비스를 일시적으로 사용할 수 없습니다.', | ||
|
||
// 게임 로직 에러 (6xxx) | ||
[SocketErrorCode.GAME_NOT_STARTED]: '게임이 아직 시작되지 않았습니다.', | ||
[SocketErrorCode.GAME_ALREADY_STARTED]: '이미 게임이 진행 중입니다.', | ||
[SocketErrorCode.INVALID_TURN]: '유효하지 않은 턴입니다.', | ||
[SocketErrorCode.ROOM_FULL]: '방이 가득 찼습니다.', | ||
[SocketErrorCode.ROOM_NOT_FOUND]: '해당 방을 찾을 수 없습니다.', | ||
[SocketErrorCode.PLAYER_NOT_FOUND]: '플레이어를 찾을 수 없습니다.', | ||
[SocketErrorCode.INSUFFICIENT_PLAYERS]: '게임 시작을 위한 플레이어 수가 부족합니다.', | ||
|
||
// 연결 관련 에러 (7xxx) | ||
[SocketErrorCode.CONNECTION_ERROR]: '연결 오류가 발생했습니다.', | ||
[SocketErrorCode.CONNECTION_TIMEOUT]: '연결 시간이 초과되었습니다.', | ||
[SocketErrorCode.CONNECTION_CLOSED]: '연결이 종료되었습니다.', | ||
} as const; | ||
|
||
export const getErrorTitle = (namespace: SocketNamespace): string => { | ||
switch (namespace) { | ||
case SocketNamespace.GAME: | ||
return '게임 오류'; | ||
case SocketNamespace.DRAWING: | ||
return '드로잉 오류'; | ||
case SocketNamespace.CHAT: | ||
return '채팅 오류'; | ||
default: | ||
return '연결 오류'; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters