/**
 * DSR Mock Data
 *
 * Mock DSR requests and statistics for development/testing fallback.
 */

import { DSRRequest, DSRStatistics } from './types'

// =============================================================================
// MOCK DATA FUNCTIONS
// =============================================================================

export function createMockDSRList(): DSRRequest[] {
  const now = new Date()

  return [
    {
      id: 'dsr-001',
      referenceNumber: 'DSR-2025-000001',
      type: 'access',
      status: 'intake',
      priority: 'high',
      requester: {
        name: 'Max Mustermann',
        email: 'max.mustermann@example.de'
      },
      source: 'web_form',
      sourceDetails: 'Kontaktformular auf breakpilot.de',
      receivedAt: new Date(now.getTime() - 2 * 24 * 60 * 60 * 1000).toISOString(),
      deadline: {
        originalDeadline: new Date(now.getTime() + 28 * 24 * 60 * 60 * 1000).toISOString(),
        currentDeadline: new Date(now.getTime() + 28 * 24 * 60 * 60 * 1000).toISOString(),
        extended: false
      },
      identityVerification: { verified: false },
      assignment: { assignedTo: null },
      createdAt: new Date(now.getTime() - 2 * 24 * 60 * 60 * 1000).toISOString(),
      createdBy: 'system',
      updatedAt: new Date(now.getTime() - 2 * 24 * 60 * 60 * 1000).toISOString(),
      tenantId: 'default-tenant'
    },
    {
      id: 'dsr-002',
      referenceNumber: 'DSR-2025-000002',
      type: 'erasure',
      status: 'identity_verification',
      priority: 'high',
      requester: {
        name: 'Anna Schmidt',
        email: 'anna.schmidt@example.de',
        phone: '+49 170 1234567'
      },
      source: 'email',
      requestText: 'Ich moechte, dass alle meine Daten geloescht werden.',
      receivedAt: new Date(now.getTime() - 5 * 24 * 60 * 60 * 1000).toISOString(),
      deadline: {
        originalDeadline: new Date(now.getTime() + 9 * 24 * 60 * 60 * 1000).toISOString(),
        currentDeadline: new Date(now.getTime() + 9 * 24 * 60 * 60 * 1000).toISOString(),
        extended: false
      },
      identityVerification: { verified: false },
      assignment: {
        assignedTo: 'DSB Mueller',
        assignedAt: new Date(now.getTime() - 4 * 24 * 60 * 60 * 1000).toISOString()
      },
      createdAt: new Date(now.getTime() - 5 * 24 * 60 * 60 * 1000).toISOString(),
      createdBy: 'system',
      updatedAt: new Date(now.getTime() - 4 * 24 * 60 * 60 * 1000).toISOString(),
      tenantId: 'default-tenant'
    },
    {
      id: 'dsr-003',
      referenceNumber: 'DSR-2025-000003',
      type: 'rectification',
      status: 'processing',
      priority: 'normal',
      requester: {
        name: 'Peter Meier',
        email: 'peter.meier@example.de'
      },
      source: 'email',
      requestText: 'Meine Adresse ist falsch gespeichert.',
      receivedAt: new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000).toISOString(),
      deadline: {
        originalDeadline: new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000).toISOString(),
        currentDeadline: new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000).toISOString(),
        extended: false
      },
      identityVerification: {
        verified: true,
        method: 'existing_account',
        verifiedAt: new Date(now.getTime() - 6 * 24 * 60 * 60 * 1000).toISOString(),
        verifiedBy: 'DSB Mueller'
      },
      assignment: {
        assignedTo: 'DSB Mueller',
        assignedAt: new Date(now.getTime() - 6 * 24 * 60 * 60 * 1000).toISOString()
      },
      rectificationDetails: {
        fieldsToCorrect: [
          {
            field: 'Adresse',
            currentValue: 'Musterstr. 1, 12345 Berlin',
            requestedValue: 'Musterstr. 10, 12345 Berlin',
            corrected: false
          }
        ]
      },
      createdAt: new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000).toISOString(),
      createdBy: 'system',
      updatedAt: new Date(now.getTime() - 1 * 24 * 60 * 60 * 1000).toISOString(),
      tenantId: 'default-tenant'
    },
    {
      id: 'dsr-004',
      referenceNumber: 'DSR-2025-000004',
      type: 'portability',
      status: 'processing',
      priority: 'normal',
      requester: {
        name: 'Lisa Weber',
        email: 'lisa.weber@example.de'
      },
      source: 'web_form',
      receivedAt: new Date(now.getTime() - 10 * 24 * 60 * 60 * 1000).toISOString(),
      deadline: {
        originalDeadline: new Date(now.getTime() + 20 * 24 * 60 * 60 * 1000).toISOString(),
        currentDeadline: new Date(now.getTime() + 20 * 24 * 60 * 60 * 1000).toISOString(),
        extended: false
      },
      identityVerification: {
        verified: true,
        method: 'id_document',
        verifiedAt: new Date(now.getTime() - 8 * 24 * 60 * 60 * 1000).toISOString(),
        verifiedBy: 'DSB Mueller'
      },
      assignment: {
        assignedTo: 'IT Team',
        assignedAt: new Date(now.getTime() - 8 * 24 * 60 * 60 * 1000).toISOString()
      },
      notes: 'JSON-Export wird vorbereitet',
      createdAt: new Date(now.getTime() - 10 * 24 * 60 * 60 * 1000).toISOString(),
      createdBy: 'system',
      updatedAt: new Date(now.getTime() - 2 * 24 * 60 * 60 * 1000).toISOString(),
      tenantId: 'default-tenant'
    },
    {
      id: 'dsr-005',
      referenceNumber: 'DSR-2025-000005',
      type: 'objection',
      status: 'rejected',
      priority: 'low',
      requester: {
        name: 'Thomas Klein',
        email: 'thomas.klein@example.de'
      },
      source: 'letter',
      requestText: 'Ich widerspreche der Verarbeitung meiner Daten fuer Marketingzwecke.',
      receivedAt: new Date(now.getTime() - 35 * 24 * 60 * 60 * 1000).toISOString(),
      deadline: {
        originalDeadline: new Date(now.getTime() - 5 * 24 * 60 * 60 * 1000).toISOString(),
        currentDeadline: new Date(now.getTime() - 5 * 24 * 60 * 60 * 1000).toISOString(),
        extended: false
      },
      completedAt: new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000).toISOString(),
      identityVerification: {
        verified: true,
        method: 'postal',
        verifiedAt: new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000).toISOString(),
        verifiedBy: 'DSB Mueller'
      },
      assignment: {
        assignedTo: 'Rechtsabteilung',
        assignedAt: new Date(now.getTime() - 28 * 24 * 60 * 60 * 1000).toISOString()
      },
      objectionDetails: {
        processingPurpose: 'Marketing',
        legalBasis: 'Berechtigtes Interesse (Art. 6(1)(f))',
        objectionGrounds: 'Keine konkreten Gruende genannt',
        decision: 'rejected',
        decisionReason: 'Zwingende schutzwuerdige Gruende fuer die Verarbeitung ueberwiegen',
        decisionBy: 'Rechtsabteilung',
        decisionAt: new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000).toISOString()
      },
      notes: 'Widerspruch unberechtigt - zwingende schutzwuerdige Gruende',
      createdAt: new Date(now.getTime() - 35 * 24 * 60 * 60 * 1000).toISOString(),
      createdBy: 'system',
      updatedAt: new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000).toISOString(),
      tenantId: 'default-tenant'
    },
    {
      id: 'dsr-006',
      referenceNumber: 'DSR-2025-000006',
      type: 'access',
      status: 'completed',
      priority: 'normal',
      requester: {
        name: 'Sarah Braun',
        email: 'sarah.braun@example.de'
      },
      source: 'email',
      receivedAt: new Date(now.getTime() - 45 * 24 * 60 * 60 * 1000).toISOString(),
      deadline: {
        originalDeadline: new Date(now.getTime() - 15 * 24 * 60 * 60 * 1000).toISOString(),
        currentDeadline: new Date(now.getTime() - 15 * 24 * 60 * 60 * 1000).toISOString(),
        extended: false
      },
      completedAt: new Date(now.getTime() - 20 * 24 * 60 * 60 * 1000).toISOString(),
      identityVerification: {
        verified: true,
        method: 'id_document',
        verifiedAt: new Date(now.getTime() - 42 * 24 * 60 * 60 * 1000).toISOString(),
        verifiedBy: 'DSB Mueller'
      },
      assignment: {
        assignedTo: 'DSB Mueller',
        assignedAt: new Date(now.getTime() - 42 * 24 * 60 * 60 * 1000).toISOString()
      },
      dataExport: {
        format: 'pdf',
        generatedAt: new Date(now.getTime() - 20 * 24 * 60 * 60 * 1000).toISOString(),
        generatedBy: 'DSB Mueller',
        fileName: 'datenauskunft_sarah_braun.pdf',
        fileSize: 245000,
        includesThirdPartyData: false
      },
      createdAt: new Date(now.getTime() - 45 * 24 * 60 * 60 * 1000).toISOString(),
      createdBy: 'system',
      updatedAt: new Date(now.getTime() - 20 * 24 * 60 * 60 * 1000).toISOString(),
      tenantId: 'default-tenant'
    }
  ]
}

export function createMockStatistics(): DSRStatistics {
  return {
    total: 6,
    byStatus: {
      intake: 1,
      identity_verification: 1,
      processing: 2,
      completed: 1,
      rejected: 1,
      cancelled: 0
    },
    byType: {
      access: 2,
      rectification: 1,
      erasure: 1,
      restriction: 0,
      portability: 1,
      objection: 1
    },
    overdue: 0,
    dueThisWeek: 2,
    averageProcessingDays: 18,
    completedThisMonth: 1
  }
}
