export interface SafetyQuizComplianceRow {
  readonly userId: string;
  readonly name: string;
  readonly avatar: string | null;
  readonly tenantName: string | null;
  readonly tenantLogo: string | null;
  readonly role: string;
  readonly status: 'complete' | 'pending';
  readonly score: string;
  readonly date: string;
}

export interface SafetyQuizSubmission {
  readonly quizId: string;
  readonly quizTitle: string;
  readonly weekOf: string;
  readonly score: number;
  readonly totalQuestions: number;
  readonly answers: readonly number[];
}

export interface SafetyQuizCompletionSummary {
  readonly completedCount: number;
  readonly totalStaff: number;
  readonly pendingCount: number;
  readonly completionRate: number;
}

export type SafetyQuizStage = 'intro' | 'question' | 'complete';

export interface SafetyQuizPage {
  readonly quiz: import('@/shared/types/app').SafetyQuiz | null;
  readonly weekOf: string;
  readonly stage: SafetyQuizStage;
  readonly currentQuestionIndex: number;
  readonly selectedAnswer: number | null;
  readonly showExplanation: boolean;
  readonly score: number;
  readonly answers: readonly number[];
  readonly complianceRows: readonly SafetyQuizComplianceRow[];
  readonly completionSummary: SafetyQuizCompletionSummary;
  readonly canViewCompliance: boolean;
  readonly canManageQuizContent: boolean;
  readonly canPersistResult: boolean;
  readonly isQuizLoading: boolean;
  readonly isComplianceLoading: boolean;
  readonly isSavingResult: boolean;
  readonly quizError: unknown;
  readonly complianceError: unknown;
  readonly saveResultError: unknown;
  readonly startQuiz: () => void;
  readonly selectAnswer: (answerIndex: number) => void;
  readonly goToNextQuestion: () => Promise<void>;
  readonly resetQuiz: () => void;
}

export interface SafetyQuizContentEditor {
  readonly draft: import('@/shared/types/app').SafetyQuiz | null;
  readonly isLoading: boolean;
  readonly isSaving: boolean;
  readonly isDeleting: boolean;
  readonly errorMessage: string | null;
  readonly validationError: string | null;
  readonly savedMessage: string | null;
  readonly canSave: boolean;
  readonly updateQuiz: (patch: Partial<import('@/shared/types/app').SafetyQuiz>) => void;
  readonly updateWeeklyFocus: (patch: Partial<import('@/shared/types/app').SafetyQuiz['weeklyFocus']>) => void;
  readonly updateReminder: (index: number, value: string) => void;
  readonly addReminder: () => void;
  readonly removeReminder: (index: number) => void;
  readonly updateQuestion: (
    index: number,
    patch: Partial<import('@/shared/types/app').QuizQuestion>,
  ) => void;
  readonly updateQuestionOption: (questionIndex: number, optionIndex: number, value: string) => void;
  readonly addQuestion: () => void;
  readonly removeQuestion: (index: number) => void;
  readonly addQuestionOption: (questionIndex: number) => void;
  readonly removeQuestionOption: (questionIndex: number, optionIndex: number) => void;
  readonly addDefaultQuiz: () => void;
  readonly reset: () => void;
  readonly save: () => Promise<void>;
  readonly deleteQuiz: () => Promise<void>;
}
