import uuid
from typing import Dict
from datetime import datetime
from app.domain.models import ExportJobStatus

_jobs: Dict[str, dict] = {}

def create_export_job(case_id: str, target_system: str, include_attachments: bool) -> str:
    job_id = str(uuid.uuid4())
    _jobs[job_id] = {
        "jobId": job_id,
        "caseId": case_id,
        "targetSystem": target_system,
        "includeAttachments": include_attachments,
        "status": ExportJobStatus.QUEUED,
        "createdAt": datetime.utcnow(),
        "updatedAt": datetime.utcnow(),
    }
    return job_id

def set_job_status(job_id: str, status: ExportJobStatus) -> None:
    job = _jobs.get(job_id)
    if not job:
        return
    job["status"] = status
    job["updatedAt"] = datetime.utcnow()

def get_job(job_id: str) -> dict | None:
    return _jobs.get(job_id)
