136 refactor 채팅 UI 문의하기 라우트 경로 기본 질문 내용 수정#137
Conversation
📝 WalkthroughWalkthroughChatRoom 컴포넌트에 textarea 자동 크기 조정 기능을 추가했으며, 관리자 채팅 생성 로직을 새로운 Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (4)
src/pages/User/hooks/useAdminChatMutation.ts (1)
5-14: 깔끔한 추상화입니다.중복된 mutation + navigation 로직을 잘 통합했습니다. 다만
onError핸들링이 없어서 API 실패 시 사용자에게 피드백이 없을 수 있습니다.🛠️ 에러 처리 추가 제안
+import { toast } from '@/utils/toast'; // 또는 프로젝트의 toast 유틸리티 export const useAdminChatMutation = () => { const navigate = useNavigate(); return useMutation({ mutationFn: postAdminChatRoom, onSuccess: ({ chatRoomId }) => { navigate(`/chats/${chatRoomId}`); }, + onError: () => { + // 사용자에게 에러 피드백 + }, }); };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/pages/User/hooks/useAdminChatMutation.ts` around lines 5 - 14, The hook useAdminChatMutation currently only handles success navigation (mutationFn: postAdminChatRoom -> onSuccess uses navigate) but lacks an onError handler to surface API failures; add an onError callback to the useMutation options that accepts the error (and optionally variables/context) and calls a user-visible error reporting function (e.g., showToast, enqueueSnackbar, or processLogger) to display a friendly message and log details, and ensure navigate is not called on failures; locate useAdminChatMutation, postAdminChatRoom, and the existing onSuccess block to add this onError behavior.src/pages/User/Profile/index.tsx (2)
19-19: 로딩 상태 처리 고려
isPending을 활용해 버튼 중복 클릭 방지 및 로딩 상태 표시를 추가하면 UX가 개선됩니다.- const { mutate: goToAdminChat } = useAdminChatMutation(); + const { mutate: goToAdminChat, isPending } = useAdminChatMutation();버튼에
disabled={isPending}추가 권장.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/pages/User/Profile/index.tsx` at line 19, The Admin chat mutation hook (useAdminChatMutation) exposes an isPending state that isn't used; update the UI to prevent duplicate clicks by reading isPending alongside mutate (const { mutate: goToAdminChat, isPending } = useAdminChatMutation()) and: 1) add disabled={isPending} to the button that triggers goToAdminChat, 2) guard the click handler so it returns early if isPending to avoid double-invokes, and 3) optionally show a loading indicator (spinner/text) based on isPending to reflect the loading state.
44-49: 익명 함수 제거 가능
onClick={() => goToAdminChat()}은onClick={goToAdminChat}으로 간소화할 수 있습니다.♻️ 간소화 제안
<button - onClick={() => goToAdminChat()} + onClick={goToAdminChat} className="bg-primary text-indigo-5 mt-auto w-full rounded-lg py-2.5 text-center text-lg leading-7 font-bold" >🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/pages/User/Profile/index.tsx` around lines 44 - 49, The onClick handler currently uses an unnecessary anonymous arrow; replace onClick={() => goToAdminChat()} with a direct reference onClick={goToAdminChat} to simplify the JSX and avoid creating a new function on every render—update the button element that uses the onClick prop and ensure the goToAdminChat function is already properly defined/accessible in the component scope.src/pages/User/MyPage/index.tsx (1)
48-59: Profile과 동일하게 간소화 및 로딩 상태 처리 권장
onClick={() => goToAdminChat()}→onClick={goToAdminChat}isPending으로 버튼 비활성화 처리♻️ 개선 제안
- const { mutate: goToAdminChat } = useAdminChatMutation(); + const { mutate: goToAdminChat, isPending } = useAdminChatMutation();<button - onClick={() => goToAdminChat()} - className="bg-indigo-0 active:bg-indigo-5 w-full rounded-sm text-left transition-colors" + onClick={goToAdminChat} + disabled={isPending} + className="bg-indigo-0 active:bg-indigo-5 w-full rounded-sm text-left transition-colors disabled:opacity-50" >🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/pages/User/MyPage/index.tsx` around lines 48 - 59, Simplify the button click handler and add pending-state disable: change onClick={() => goToAdminChat()} to onClick={goToAdminChat} on the button element (the element rendering ChatIcon/RightArrowIcon) and wire the component's isPending boolean to the button's disabled prop (e.g., disabled={isPending}) so the button is disabled during loading; optionally add aria-busy={isPending} or a visual loading indicator while isPending is true to prevent duplicate navigation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/pages/User/hooks/useAdminChatMutation.ts`:
- Around line 5-14: The hook useAdminChatMutation currently only handles success
navigation (mutationFn: postAdminChatRoom -> onSuccess uses navigate) but lacks
an onError handler to surface API failures; add an onError callback to the
useMutation options that accepts the error (and optionally variables/context)
and calls a user-visible error reporting function (e.g., showToast,
enqueueSnackbar, or processLogger) to display a friendly message and log
details, and ensure navigate is not called on failures; locate
useAdminChatMutation, postAdminChatRoom, and the existing onSuccess block to add
this onError behavior.
In `@src/pages/User/MyPage/index.tsx`:
- Around line 48-59: Simplify the button click handler and add pending-state
disable: change onClick={() => goToAdminChat()} to onClick={goToAdminChat} on
the button element (the element rendering ChatIcon/RightArrowIcon) and wire the
component's isPending boolean to the button's disabled prop (e.g.,
disabled={isPending}) so the button is disabled during loading; optionally add
aria-busy={isPending} or a visual loading indicator while isPending is true to
prevent duplicate navigation.
In `@src/pages/User/Profile/index.tsx`:
- Line 19: The Admin chat mutation hook (useAdminChatMutation) exposes an
isPending state that isn't used; update the UI to prevent duplicate clicks by
reading isPending alongside mutate (const { mutate: goToAdminChat, isPending } =
useAdminChatMutation()) and: 1) add disabled={isPending} to the button that
triggers goToAdminChat, 2) guard the click handler so it returns early if
isPending to avoid double-invokes, and 3) optionally show a loading indicator
(spinner/text) based on isPending to reflect the loading state.
- Around line 44-49: The onClick handler currently uses an unnecessary anonymous
arrow; replace onClick={() => goToAdminChat()} with a direct reference
onClick={goToAdminChat} to simplify the JSX and avoid creating a new function on
every render—update the button element that uses the onClick prop and ensure the
goToAdminChat function is already properly defined/accessible in the component
scope.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/pages/Chat/ChatRoom.tsxsrc/pages/Manager/ManagedRecruitmentForm/index.tsxsrc/pages/User/MyPage/index.tsxsrc/pages/User/Profile/index.tsxsrc/pages/User/hooks/useAdminChatMutation.ts
Summary by CodeRabbit
릴리스 노트
New Features
Refactor