'use client'

import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { Label } from '@/components/ui/label'
import { Switch } from '@/components/ui/switch'

type SubmissionConfigProps = {
  config: Record<string, unknown>
  onChange: (config: Record<string, unknown>) => void
}

export function SubmissionConfig({ config, onChange }: SubmissionConfigProps) {
  const update = (key: string, value: unknown) => {
    onChange({ ...config, [key]: value })
  }

  return (
    <div className="space-y-6">
      <Card>
        <CardHeader>
          <CardTitle className="text-base">Notifications & Locking</CardTitle>
          <CardDescription>Behavior when the submission round activates</CardDescription>
        </CardHeader>
        <CardContent className="space-y-4">
          <div className="flex items-center justify-between">
            <div>
              <Label htmlFor="notifyEligibleTeams">Notify Eligible Teams</Label>
              <p className="text-xs text-muted-foreground">
                Send email notification to teams when submission window opens
              </p>
            </div>
            <Switch
              id="notifyEligibleTeams"
              checked={(config.notifyEligibleTeams as boolean) ?? true}
              onCheckedChange={(v) => update('notifyEligibleTeams', v)}
            />
          </div>

          <div className="flex items-center justify-between">
            <div>
              <Label htmlFor="lockPreviousWindows">Lock Previous Windows</Label>
              <p className="text-xs text-muted-foreground">
                Prevent uploads to earlier submission windows when this round activates
              </p>
            </div>
            <Switch
              id="lockPreviousWindows"
              checked={(config.lockPreviousWindows as boolean) ?? true}
              onCheckedChange={(v) => update('lockPreviousWindows', v)}
            />
          </div>
        </CardContent>
      </Card>
    </div>
  )
}
