Skip to content

Conversation

@young-jin-son
Copy link
Collaborator

@young-jin-son young-jin-son commented Jul 17, 2025

Issue Number

close #304

As-Is

  • 로그아웃 버튼 클릭 시 확인 없이 바로 로그아웃됨

To-Be

  • 로그아웃 버튼 클릭 시 확인 모달 추가

Check List

  • 테스트가 전부 통과되었나요?
  • 모든 commit이 push 되었나요?
  • merge할 branch를 확인했나요?
  • Assignee를 지정했나요?
  • Label을 지정했나요?

Test Screenshot

(Optional) Additional Description

Summary by CodeRabbit

  • New Features

    • Added a confirmation modal when clicking the logout button, allowing users to confirm or cancel the logout action.
  • Enhancements

    • Improved logout flow by preventing accidental logouts and providing a clearer user experience.

@young-jin-son young-jin-son self-assigned this Jul 17, 2025
@young-jin-son young-jin-son added refactor 코드 리팩토링 (기능은 그대로인데, 코드 개선, 폴더 변경, 변수명/함수명 수정) FE 프론트엔드 작업 labels Jul 17, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 17, 2025

Walkthrough

The LogoutButton component was updated to introduce a confirmation modal that appears after the logout button is clicked. The drawer is closed first, then the modal prompts the user to confirm or cancel the logout action. Confirming logs the user out and closes the modal; cancelling simply closes the modal.

Changes

File(s) Change Summary
frontend/src/components/Button/LogoutButton/... Enhanced LogoutButton to show confirmation modal before logout; manages modal state and flow.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LogoutButton
    participant Drawer
    participant HomeModal
    participant LogoutMutation

    User->>LogoutButton: Clicks Logout
    LogoutButton->>Drawer: closeDrawer()
    LogoutButton->>HomeModal: Open confirmation modal
    User->>HomeModal: Confirm logout
    HomeModal->>LogoutButton: onConfirm
    LogoutButton->>LogoutMutation: Execute logout
    LogoutButton->>HomeModal: Close modal
    User->>HomeModal: Cancel
    HomeModal->>LogoutButton: onClose
    LogoutButton->>HomeModal: Close modal
Loading

Assessment against linked issues

Objective Addressed Explanation
Close sidebar (drawer) when logout button is clicked (#304)
Show logout confirmation modal (#304)
Proceed with logout on "로그아웃" click in modal (#304)
Close modal without logout on "취소하기" click (#304)

Poem

A bunny with code in its paws,
Added a modal for logout’s cause.
No more abrupt goodbyes—
Now a prompt will arise,
“Are you sure?” it will pause!
Click “로그아웃” to go, or “취소” to stay,
The logout’s now gentle, in every way. 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b03ddc3 and c6db157.

📒 Files selected for processing (1)
  • frontend/src/components/Button/LogoutButton/index.tsx (1 hunks)
🔇 Additional comments (5)
frontend/src/components/Button/LogoutButton/index.tsx (5)

10-12: LGTM! Proper hooks usage and state management.

The state management and hooks usage follow React best practices with clear separation of concerns.


14-17: LGTM! Clear handler with proper separation of concerns.

The logout click handler properly separates the drawer closing and modal opening actions.


24-26: LGTM! Clean modal close handler.

Simple and effective modal close handler.


28-42: LGTM! Clean render logic with proper conditional rendering.

The component render logic is well-structured with appropriate conditional rendering for the modal. The modal props are clearly defined and consistently used.

Note: The content prop uses an array format which appears to be specific to the HomeModal component's expected interface.


1-42: HomeModal is already a generic, reusable component

The HomeModal implementation lives under frontend/src/pages/PlanPage/components/HomeModal and is used in multiple contexts (PlanPage, MainPage, DeleteAccountButton, LogoutButton) with only generic props (title, content, close, onConfirm, optional confirmText). No further decoupling or refactoring is required.

Comment on lines +19 to +22
const handleConfirmLogout = () => {
logoutMutation();
setIsModalOpen(false);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider improving error handling and operation order.

The current implementation calls logoutMutation() before closing the modal, which could lead to UI inconsistencies if the logout fails. Consider handling the logout result or reordering operations.

 const handleConfirmLogout = () => {
-  logoutMutation();
-  setIsModalOpen(false);
+  setIsModalOpen(false);
+  logoutMutation();
 };

Or better yet, handle the logout result:

 const handleConfirmLogout = async () => {
+  try {
+    await logoutMutation();
     setIsModalOpen(false);
+  } catch (error) {
+    // Handle logout error - maybe show error message
+    console.error('Logout failed:', error);
+  }
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleConfirmLogout = () => {
logoutMutation();
setIsModalOpen(false);
};
// Before:
// const handleConfirmLogout = () => {
// logoutMutation();
// setIsModalOpen(false);
// };
// Improved: handle the logout result and only close the modal on success
const handleConfirmLogout = async () => {
try {
await logoutMutation();
setIsModalOpen(false);
} catch (error) {
// Handle logout error - maybe show an error message to the user
console.error('Logout failed:', error);
}
};
🤖 Prompt for AI Agents
In frontend/src/components/Button/LogoutButton/index.tsx around lines 19 to 22,
the logoutMutation is called before closing the modal, which may cause UI
inconsistencies if logout fails. Refactor handleConfirmLogout to await the
logoutMutation call and only close the modal if the logout succeeds.
Additionally, add error handling to manage any logout failures gracefully
without closing the modal prematurely.

import * as S from './LogoutButton.styled';

import { useDrawer } from '@/components/Drawer/hooks/useDrawer';
import HomeModal from '@/pages/PlanPage/components/HomeModal';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider relocating the modal to a shared components directory.

Importing HomeModal from a page-specific directory (@/pages/PlanPage/components/HomeModal) into a generic button component creates tight coupling and violates component isolation principles. This makes the LogoutButton dependent on PlanPage components, which could lead to maintainability issues.

Consider one of these solutions:

  1. Move HomeModal to a shared components directory (e.g., @/components/Modal/HomeModal)
  2. Create a generic confirmation modal component specifically for logout actions
  3. Use a global modal context or state management solution
-import HomeModal from '@/pages/PlanPage/components/HomeModal';
+import ConfirmationModal from '@/components/Modal/ConfirmationModal';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import HomeModal from '@/pages/PlanPage/components/HomeModal';
// frontend/src/components/Button/LogoutButton/index.tsx
import React, { useState } from 'react';
import { useLogoutMutation } from '@/hooks/useLogoutMutation';
import { useDrawer } from '@/hooks/useDrawer';
-import HomeModal from '@/pages/PlanPage/components/HomeModal';
+import ConfirmationModal from '@/components/Modal/ConfirmationModal';
// …rest of the component…
🤖 Prompt for AI Agents
In frontend/src/components/Button/LogoutButton/index.tsx at line 7, the import
of HomeModal from a page-specific directory creates tight coupling and breaks
component isolation. To fix this, move HomeModal to a shared components
directory such as @/components/Modal/HomeModal, or alternatively create a
generic confirmation modal for logout actions, or implement a global modal
context/state management to handle modals more cleanly and decouple LogoutButton
from PlanPage components.

@young-jin-son young-jin-son merged commit 35879d4 into develop Jul 17, 2025
3 checks passed
@young-jin-son young-jin-son deleted the refactor/#304 branch July 17, 2025 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FE 프론트엔드 작업 refactor 코드 리팩토링 (기능은 그대로인데, 코드 개선, 폴더 변경, 변수명/함수명 수정)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] 로그아웃 확인 모달 추가

2 participants