import { Card } from '@/components/ui/card'
import { Switch } from '@/components/ui/switch'
import { Label } from '@/components/ui/label'
import { SystemSettings } from '@/types/system-params'

interface FeatureToggleCardProps {
  settings: SystemSettings
  onSettingsChange: (updates: Partial<SystemSettings>) => void
}

export function FeatureToggleCard({ settings, onSettingsChange }: FeatureToggleCardProps) {
  return (
    <Card className="p-6">
      <h3 className="mb-4">功能开关</h3>
      <div className="space-y-4">
        <div className="flex items-center justify-between">
          <div>
            <Label>允许用户注册</Label>
            <p className="text-sm text-muted-foreground">开启后允许新用户自主注册账号</p>
          </div>
          <Switch
            checked={settings.enableRegistration}
            onCheckedChange={(checked) => onSettingsChange({ enableRegistration: checked })}
          />
        </div>
        <div className="flex items-center justify-between">
          <div>
            <Label>允许访客访问</Label>
            <p className="text-sm text-muted-foreground">开启后允许未登录用户访问部分公开内容</p>
          </div>
          <Switch
            checked={settings.enableGuestAccess}
            onCheckedChange={(checked) => onSettingsChange({ enableGuestAccess: checked })}
          />
        </div>
      </div>
    </Card>
  )
}