import { api } from "@/lib/api-client";

export interface GdprExportPayload {
  profile: Record<string, unknown>;
  partner: Record<string, unknown>;
  entity_memberships: unknown[];
  exam_attempts: unknown[];
  exam_answers: unknown[];
  ai_feedback: unknown[];
  ai_calls: unknown[];
  tickets: unknown[];
  coaching_sessions: unknown[];
  exported_at: string;
  export_format_version: string;
}

export interface GdprEraseResponse {
  ok: boolean;
  message: string;
  summary: {
    anonymised_partner_fields: string[];
    deactivated_user: boolean;
    deleted_feedback_count: number;
    deleted_coaching_count: number;
    retained_attempts_count: number;
  };
}

export const gdprService = {
  async exportMyData(): Promise<GdprExportPayload> {
    return api.get<GdprExportPayload>("/gdpr/export");
  },
  async eraseMyAccount(): Promise<GdprEraseResponse> {
    return api.post<GdprEraseResponse>("/gdpr/delete", { confirm: true });
  },
};
