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

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

export function SessionManagementCard({ settings, onSettingsChange }: SessionManagementCardProps) {
  return (
    <Card className="p-6">
      <h3 className="mb-4">会话管理</h3>
      <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
        <div>
          <Label>会话超时时间（分钟）</Label>
          <Input
            type="number"
            value={settings.sessionTimeout}
            onChange={(e) => onSettingsChange({ sessionTimeout: parseInt(e.target.value) || 30 })}
            min={5}
            max={1440}
          />
          <p className="text-sm text-muted-foreground mt-1">
            用户无操作超过此时间后将自动退出登录
          </p>
        </div>
        <div>
          <Label>最大登录尝试次数</Label>
          <Input
            type="number"
            value={settings.maxLoginAttempts}
            onChange={(e) => onSettingsChange({ maxLoginAttempts: parseInt(e.target.value) || 5 })}
            min={3}
            max={10}
          />
          <p className="text-sm text-muted-foreground mt-1">
            连续登录失败达到此次数后账号将被临时锁定
          </p>
        </div>
      </div>
    </Card>
  )
}