import type { PersonalityQuizKind } from '@/shared/constants/personality';

export type PersonalityAnswerValue = string | number;

export interface PersonalityQuizResultDto {
  readonly id: string;
  readonly quiz_kind: PersonalityQuizKind;
  readonly quiz_id: string;
  readonly quiz_title: string;
  readonly week_of: string | null;
  readonly personality_type: string | null;
  readonly quiz_answers: Record<string, PersonalityAnswerValue>;
  readonly score: number | null;
  readonly total_questions: number;
  readonly result_label: string | null;
  readonly result_payload: unknown | null;
  readonly user_name: string | null;
  readonly user_role: string | null;
  readonly completed_at: string;
  readonly organizationId: string | null;
  readonly campusId: string | null;
  readonly userId: string | null;
  readonly createdById: string | null;
  readonly updatedById: string | null;
  readonly createdAt: string;
  readonly updatedAt: string;
}

export interface PersonalityQuizResultMutationDto {
  readonly quiz_kind: PersonalityQuizKind;
  readonly quiz_id: string;
  readonly quiz_title: string;
  readonly personality_type?: string | null;
  readonly quiz_answers: Record<string, PersonalityAnswerValue>;
  readonly score?: number | null;
  readonly total_questions: number;
  readonly result_label?: string | null;
  readonly result_payload?: unknown;
}

export interface PersonalityQuizResultHistoryDto {
  readonly rows: readonly PersonalityQuizResultDto[];
  readonly count: number;
}

export interface PersonalityDistributionDto {
  readonly type: string;
  readonly count: number;
}

export interface PersonalityCompletionSummaryDto {
  readonly totalStaff: number;
  readonly completedCount: number;
  readonly pendingCount: number;
  readonly selfAssessmentCompletedCount: number;
  readonly personalityCompletedCount: number;
  readonly completionRate: number;
}

export interface PersonalityCompletionRowDto {
  readonly userId: string;
  readonly name: string;
  readonly email: string | null;
  readonly avatar: string | null;
  readonly tenantName: string | null;
  readonly tenantLogo: string | null;
  readonly role: string | null;
  readonly status: 'complete' | 'pending';
  readonly completedKinds: readonly PersonalityQuizKind[];
  readonly selfAssessment: PersonalityQuizResultDto | null;
  readonly personality: PersonalityQuizResultDto | null;
}

export interface PersonalityCompletionDto {
  readonly summary: PersonalityCompletionSummaryDto;
  readonly rows: readonly PersonalityCompletionRowDto[];
}
