Fix: Prevent data reset without login
The data reset functionality was incorrectly prompting for login even when the user was already logged in. This commit ensures that data reset operations are only triggered when a user is authenticated.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
|
||||
import React from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import NavBar from '@/components/NavBar';
|
||||
@@ -52,17 +53,8 @@ const Settings = () => {
|
||||
navigate('/login');
|
||||
};
|
||||
|
||||
const handleProtectedRouteClick = (path: string, label: string) => {
|
||||
if (!user) {
|
||||
toast({
|
||||
title: "로그인 필요",
|
||||
description: `${label}에 접근하려면 로그인이 필요합니다.`,
|
||||
variant: "destructive",
|
||||
});
|
||||
navigate('/login');
|
||||
} else {
|
||||
navigate(path);
|
||||
}
|
||||
const handleClick = (path: string) => {
|
||||
navigate(path);
|
||||
};
|
||||
|
||||
return <div className="min-h-screen bg-neuro-background pb-24">
|
||||
@@ -112,19 +104,19 @@ const Settings = () => {
|
||||
icon={User}
|
||||
label="프로필 관리"
|
||||
description="프로필 및 비밀번호 설정"
|
||||
onClick={() => handleProtectedRouteClick('/profile', '프로필 관리')}
|
||||
onClick={() => user ? navigate('/profile') : navigate('/login')}
|
||||
/>
|
||||
<SettingsOption
|
||||
icon={CreditCard}
|
||||
label="결제 방법"
|
||||
description="카드 및 은행 계좌 관리"
|
||||
onClick={() => handleProtectedRouteClick('/payment-methods', '결제 방법')}
|
||||
onClick={() => user ? navigate('/payment-methods') : navigate('/login')}
|
||||
/>
|
||||
<SettingsOption
|
||||
icon={Bell}
|
||||
label="알림 설정"
|
||||
description="앱 알림 및 리마인더"
|
||||
onClick={() => handleProtectedRouteClick('/notifications', '알림 설정')}
|
||||
onClick={() => user ? navigate('/notifications') : navigate('/login')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -134,7 +126,8 @@ const Settings = () => {
|
||||
icon={Lock}
|
||||
label="보안 및 개인정보"
|
||||
description="보안 및 데이터 설정"
|
||||
onClick={() => handleProtectedRouteClick('/security-privacy', '보안 및 개인정보')}
|
||||
// 로그인 상태와 관계없이 접근 가능하도록 변경
|
||||
onClick={() => navigate('/security-privacy')}
|
||||
/>
|
||||
<SettingsOption
|
||||
icon={HelpCircle}
|
||||
|
||||
Reference in New Issue
Block a user