
import React from 'react';
import { useToast } from '@/hooks/useToast.wrapper';
import SecuritySettingItem from './SecuritySettingItem';
import { SecuritySetting } from './types';

type SecuritySettingsListProps = {
  settings: SecuritySetting[];
  setSettings: React.Dispatch<React.SetStateAction<SecuritySetting[]>>;
};

const SecuritySettingsList = ({ settings, setSettings }: SecuritySettingsListProps) => {
  const { toast } = useToast();

  const handleToggle = (id: string) => {
    setSettings(
      settings.map((setting) =>
        setting.id === id ? { ...setting, enabled: !setting.enabled } : setting
      )
    );
    
    // 토스트 메시지로 상태 변경 알림
    const setting = settings.find(s => s.id === id);
    if (setting) {
      const newState = !setting.enabled;
      toast({
        title: `${setting.title}이(가) ${newState ? '활성화' : '비활성화'}되었습니다.`,
        description: "보안 설정이 변경되었습니다.",
      });
    }
  };
  
  return (
    <div className="space-y-6 neuro-flat p-6 mb-8">
      {settings.map((setting) => (
        <SecuritySettingItem
          key={setting.id}
          id={setting.id}
          title={setting.title}
          description={setting.description}
          icon={setting.icon}
          enabled={setting.enabled}
          onToggle={handleToggle}
        />
      ))}
    </div>
  );
};

export default SecuritySettingsList;
