Fix security settings UI
Fix text alignment issues and add data reset functionality to the security and privacy settings page.
This commit is contained in:
@@ -1,11 +1,21 @@
|
|||||||
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { ArrowLeft, Shield, Lock, Key, Fingerprint, Eye, EyeOff, UserX } from 'lucide-react';
|
import { ArrowLeft, Shield, Lock, Key, Fingerprint, Eye, EyeOff, UserX, Trash2 } from 'lucide-react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Switch } from '@/components/ui/switch';
|
import { Switch } from '@/components/ui/switch';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
import { useToast } from '@/hooks/use-toast';
|
import { useToast } from '@/hooks/use-toast';
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogClose
|
||||||
|
} from '@/components/ui/dialog';
|
||||||
|
import { resetAllStorageData } from '@/utils/storageUtils';
|
||||||
|
|
||||||
type SecuritySetting = {
|
type SecuritySetting = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -18,6 +28,7 @@ type SecuritySetting = {
|
|||||||
const SecurityPrivacySettings = () => {
|
const SecurityPrivacySettings = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
const [isResetDialogOpen, setIsResetDialogOpen] = useState(false);
|
||||||
|
|
||||||
const [settings, setSettings] = useState<SecuritySetting[]>([
|
const [settings, setSettings] = useState<SecuritySetting[]>([
|
||||||
{
|
{
|
||||||
@@ -84,9 +95,7 @@ const SecurityPrivacySettings = () => {
|
|||||||
const newState = !setting.enabled;
|
const newState = !setting.enabled;
|
||||||
toast({
|
toast({
|
||||||
title: `${setting.title}이(가) ${newState ? '활성화' : '비활성화'}되었습니다.`,
|
title: `${setting.title}이(가) ${newState ? '활성화' : '비활성화'}되었습니다.`,
|
||||||
description: newState
|
description: "보안 설정이 변경되었습니다.",
|
||||||
? "보안 설정이 변경되었습니다."
|
|
||||||
: "보안 설정이 변경되었습니다.",
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -100,6 +109,27 @@ const SecurityPrivacySettings = () => {
|
|||||||
navigate('/settings');
|
navigate('/settings');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleResetAllData = () => {
|
||||||
|
// 데이터 초기화 수행
|
||||||
|
try {
|
||||||
|
resetAllStorageData();
|
||||||
|
toast({
|
||||||
|
title: "모든 데이터가 초기화되었습니다.",
|
||||||
|
description: "모든 예산, 지출 내역, 설정이 초기화되었습니다.",
|
||||||
|
});
|
||||||
|
setIsResetDialogOpen(false);
|
||||||
|
// 초기화 후 설정 페이지로 이동
|
||||||
|
setTimeout(() => navigate('/settings'), 1000);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('데이터 초기화 실패:', error);
|
||||||
|
toast({
|
||||||
|
title: "데이터 초기화 실패",
|
||||||
|
description: "데이터를 초기화하는 중 문제가 발생했습니다.",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-neuro-background pb-24">
|
<div className="min-h-screen bg-neuro-background pb-24">
|
||||||
<div className="max-w-md mx-auto px-6">
|
<div className="max-w-md mx-auto px-6">
|
||||||
@@ -126,12 +156,12 @@ const SecurityPrivacySettings = () => {
|
|||||||
<div className="neuro-pressed p-3 rounded-full text-neuro-income">
|
<div className="neuro-pressed p-3 rounded-full text-neuro-income">
|
||||||
{setting.icon}
|
{setting.icon}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className="flex-1 mr-4">
|
||||||
<h3 className="font-medium">{setting.title}</h3>
|
<h3 className="font-medium">{setting.title}</h3>
|
||||||
<p className="text-xs text-gray-500">{setting.description}</p>
|
<p className="text-xs text-gray-500">{setting.description}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center">
|
||||||
<Switch
|
<Switch
|
||||||
id={`${setting.id}-switch`}
|
id={`${setting.id}-switch`}
|
||||||
checked={setting.enabled}
|
checked={setting.enabled}
|
||||||
@@ -149,6 +179,49 @@ const SecurityPrivacySettings = () => {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Data Reset Section */}
|
||||||
|
<div className="neuro-flat p-6 mb-8">
|
||||||
|
<div className="flex items-center space-x-4">
|
||||||
|
<div className="neuro-pressed p-3 rounded-full text-red-500">
|
||||||
|
<Trash2 size={20} />
|
||||||
|
</div>
|
||||||
|
<div className="flex-1">
|
||||||
|
<h3 className="font-medium">데이터 초기화</h3>
|
||||||
|
<p className="text-xs text-gray-500">모든 예산, 지출 내역, 설정이 초기화됩니다.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
variant="destructive"
|
||||||
|
className="w-full mt-4"
|
||||||
|
onClick={() => setIsResetDialogOpen(true)}
|
||||||
|
>
|
||||||
|
모든 데이터 초기화
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Reset Dialog */}
|
||||||
|
<Dialog open={isResetDialogOpen} onOpenChange={setIsResetDialogOpen}>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>정말 모든 데이터를 초기화하시겠습니까?</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
이 작업은 되돌릴 수 없으며, 모든 예산, 지출 내역, 설정이 영구적으로 삭제됩니다.
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<DialogFooter className="flex flex-col sm:flex-row gap-2 sm:gap-0">
|
||||||
|
<DialogClose asChild>
|
||||||
|
<Button variant="outline" className="sm:mr-2">취소</Button>
|
||||||
|
</DialogClose>
|
||||||
|
<Button
|
||||||
|
variant="destructive"
|
||||||
|
onClick={handleResetAllData}
|
||||||
|
>
|
||||||
|
확인, 모든 데이터 초기화
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
{/* Save Button */}
|
{/* Save Button */}
|
||||||
<div className="px-6">
|
<div className="px-6">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user