-
Notifications
You must be signed in to change notification settings - Fork 0
[REFACTOR] 로그아웃 확인 모달 추가 #305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,45 @@ | ||||||||||||||||||||||||||||||||||||||||||
| import { useState } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| import useLogoutMutation from './hooks/useLogoutMutation'; | ||||||||||||||||||||||||||||||||||||||||||
| import * as S from './LogoutButton.styled'; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| import { useDrawer } from '@/components/Drawer/hooks/useDrawer'; | ||||||||||||||||||||||||||||||||||||||||||
| import HomeModal from '@/pages/PlanPage/components/HomeModal'; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const LogoutButton = () => { | ||||||||||||||||||||||||||||||||||||||||||
| const [isModalOpen, setIsModalOpen] = useState(false); | ||||||||||||||||||||||||||||||||||||||||||
| const { logoutMutation } = useLogoutMutation(); | ||||||||||||||||||||||||||||||||||||||||||
| const { closeDrawer } = useDrawer(); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const handleLogoutClick = () => { | ||||||||||||||||||||||||||||||||||||||||||
| closeDrawer(); | ||||||||||||||||||||||||||||||||||||||||||
| setIsModalOpen(true); | ||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const handleConfirmLogout = () => { | ||||||||||||||||||||||||||||||||||||||||||
| logoutMutation(); | ||||||||||||||||||||||||||||||||||||||||||
| setIsModalOpen(false); | ||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const handleCloseModal = () => { | ||||||||||||||||||||||||||||||||||||||||||
| setIsModalOpen(false); | ||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||
| <> | ||||||||||||||||||||||||||||||||||||||||||
| <S.LogoutButton onClick={handleLogoutClick}>로그아웃</S.LogoutButton> | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| return <S.LogoutButton onClick={() => logoutMutation()}>로그아웃</S.LogoutButton>; | ||||||||||||||||||||||||||||||||||||||||||
| {isModalOpen && ( | ||||||||||||||||||||||||||||||||||||||||||
| <HomeModal | ||||||||||||||||||||||||||||||||||||||||||
| title="로그아웃" | ||||||||||||||||||||||||||||||||||||||||||
| content={['정말로 로그아웃 하시겠습니까?']} | ||||||||||||||||||||||||||||||||||||||||||
| close={handleCloseModal} | ||||||||||||||||||||||||||||||||||||||||||
| onConfirm={handleConfirmLogout} | ||||||||||||||||||||||||||||||||||||||||||
| confirmText="로그아웃" | ||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||
| </> | ||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| export default LogoutButton; | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
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
HomeModalfrom a page-specific directory (@/pages/PlanPage/components/HomeModal) into a generic button component creates tight coupling and violates component isolation principles. This makes theLogoutButtondependent onPlanPagecomponents, which could lead to maintainability issues.Consider one of these solutions:
HomeModalto a shared components directory (e.g.,@/components/Modal/HomeModal)📝 Committable suggestion
🤖 Prompt for AI Agents