declare namespace Api {
  namespace WorkReport {
    namespace Common {
      interface PageParams {
        pageNo: number;
        pageSize: number;
      }

      type ReportType = 'weekly' | 'monthly' | 'project';
      type WorkReportStatusCode = 'draft' | 'pending_approval' | 'approved' | 'rejected';

      interface WorkReportStatusDict {
        statusCode: WorkReportStatusCode | string;
        statusName: string;
        sort: number;
        initialFlag: boolean;
        terminalFlag: boolean;
        allowEdit: boolean;
      }

      interface WorkReportApprovalRecord {
        id: string;
        statusLogId: string;
        approvalRound: number;
        conclusion: string;
        opinion?: string | null;
        auditorUserId: string;
        auditorName: string;
        createTime: string;
      }

      interface PersonalReportReviewItem {
        id?: string;
        itemNumber?: number | null;
        itemTitle: string;
        workHours?: number | null;
        contentText?: string | null;
        contentJson?: unknown;
        reflectionText?: string | null;
      }

      interface PersonalReportPlanItem {
        id?: string;
        itemNumber?: number | null;
        itemTitle: string;
        targetText?: string | null;
        targetJson?: unknown;
        supportNeed?: string | null;
      }

      type WorkReportBaseSearchParams = CommonType.RecordNullable<
        Pick<PageParams, 'pageNo' | 'pageSize'> & {
          keyword: string;
          statusCode: WorkReportStatusCode | string;
          periodStartDate: string[];
          submitTime: string[];
          supervisorName: string;
        }
      >;

      type ContentExportParams<TSearch> = Partial<TSearch> & {
        exportAll?: boolean;
        ids?: string[];
      };

      interface StatusActionParams {
        reason?: string | null;
      }

      interface PageResult<T> {
        total: number;
        list: T[];
      }

      interface TeamReportUnsubmittedReport {
        userId: string;
        userNickname: string;
        periodKey: string;
        periodLabel: string;
        projectId?: string | null;
        projectName?: string | null;
      }

      interface TeamReportSummary {
        periodStartDate?: string | null;
        periodEndDate?: string | null;
        expectedReportCount: number;
        submittedReportCount: number;
        unsubmittedReportCount: number;
        pendingApprovalReportCount: number;
        unsubmittedReports: TeamReportUnsubmittedReport[];
      }

      interface TeamReportSummaryParams {
        reportType: ReportType;
        periodKey?: string | null;
        periodStartDate?: string | null;
        periodEndDate?: string | null;
      }

      interface TeamReportRemindParams {
        reportType: ReportType;
        periodKey: string;
        userIds?: string[] | null;
        projectId?: string | null;
      }

      interface TeamReportRemindResult {
        remindedCount: number;
      }
    }

    namespace Weekly {
      interface WeeklyReportTravelSegment {
        id?: string;
        sort?: number | null;
        startDate?: string | null;
        endDate?: string | null;
        travelDays?: number | null;
        location?: string | null;
      }

      interface WeeklyReport {
        id: string;
        reporterId: string;
        reporterName: string;
        reporterDeptName?: string | null;
        reporterPostName?: string | null;
        supervisorUserId: string;
        supervisorName: string;
        periodKey: string;
        periodLabel: string;
        periodStartDate: string;
        periodEndDate: string;
        statusCode: Common.WorkReportStatusCode | string;
        statusName: string;
        allowEdit: boolean;
        terminal: boolean;
        isBusinessTrip: boolean;
        totalTravelDays?: number | string | null;
        totalWorkHours?: number | string | null;
        approvalComment?: string | null;
        lastStatusReason?: string | null;
        submitTime?: string | null;
        approvalTime?: string | null;
        createTime?: string | null;
        updateTime?: string | null;
        reviewItems: Common.PersonalReportReviewItem[];
        planItems: Common.PersonalReportPlanItem[];
        travelSegments: WeeklyReportTravelSegment[];
      }

      type WeeklyReportSearchParams = Common.WorkReportBaseSearchParams & {
        reporterIds?: string[] | null;
        isBusinessTrip?: boolean | string | null;
      };

      interface WeeklyReportSaveParams {
        periodKey: string;
        periodLabel: string;
        periodStartDate: string;
        periodEndDate: string;
        isBusinessTrip: boolean;
        reviewItems: Common.PersonalReportReviewItem[];
        planItems: Common.PersonalReportPlanItem[];
        travelSegments: WeeklyReportTravelSegment[];
      }

      type WeeklyReportDefaultDraftParams = Pick<
        WeeklyReportSaveParams,
        'periodKey' | 'periodLabel' | 'periodStartDate' | 'periodEndDate'
      >;

      type WeeklyReportRefreshDraftParams = WeeklyReportSaveParams;
    }

    namespace Monthly {
      interface MonthlyReport {
        id: string;
        reporterId: string;
        reporterName: string;
        reporterDeptName?: string | null;
        reporterPostName?: string | null;
        supervisorUserId: string;
        supervisorName: string;
        periodKey: string;
        periodLabel: string;
        periodStartDate: string;
        periodEndDate: string;
        statusCode: Common.WorkReportStatusCode | string;
        statusName: string;
        signOffStatus?: string | null;
        signOffStatusName?: string | null;
        allowEdit: boolean;
        terminal: boolean;
        totalWorkHours?: number | string | null;
        approvalComment?: string | null;
        lastStatusReason?: string | null;
        submitTime?: string | null;
        approvalTime?: string | null;
        createTime?: string | null;
        updateTime?: string | null;
        reviewItems: Common.PersonalReportReviewItem[];
        planItems: Common.PersonalReportPlanItem[];
      }

      type MonthlyReportSearchParams = Common.WorkReportBaseSearchParams & {
        reporterIds?: string[] | null;
        signOffStatus?: string | null;
      };

      interface MonthlyReportSaveParams {
        periodKey: string;
        periodLabel: string;
        periodStartDate: string;
        periodEndDate: string;
        reviewItems: Common.PersonalReportReviewItem[];
        planItems: Common.PersonalReportPlanItem[];
      }

      type MonthlyReportDefaultDraftParams = Pick<
        MonthlyReportSaveParams,
        'periodKey' | 'periodLabel' | 'periodStartDate' | 'periodEndDate'
      >;

      type MonthlyReportRefreshDraftParams = MonthlyReportSaveParams;

      interface MonthlyReportApproveParams extends Common.StatusActionParams {
        meetingDate?: string | null;
        strengthDesc?: string | null;
        strengthExample?: string | null;
        weaknessDesc?: string | null;
        weaknessExample?: string | null;
        improvementSuggestion?: string | null;
        performanceResult?: string | null;
        employeeSignName?: string | null;
        employeeSignedDate?: string | null;
        supervisorSignName?: string | null;
        supervisorSignedDate?: string | null;
      }

      interface MonthlyReportApprovalRecord extends Common.WorkReportApprovalRecord {
        meetingDate?: string | null;
        strengthDesc?: string | null;
        strengthExample?: string | null;
        weaknessDesc?: string | null;
        weaknessExample?: string | null;
        improvementSuggestion?: string | null;
        performanceResult?: string | null;
        employeeSignName?: string | null;
        employeeSignatureFileId?: string | null;
        employeeSignedDate?: string | null;
        supervisorSignName?: string | null;
        supervisorSignatureFileId?: string | null;
        supervisorSignedDate?: string | null;
      }

      interface MonthlyReportSignOffConfirmParams {
        meetingDate: string;
        employeeSignedDate?: string | null;
      }

      interface MonthlyReportSignOffDetail {
        report: MonthlyReport;
        latestApprovalRecord: MonthlyReportApprovalRecord | null;
      }
    }

    namespace Project {
      interface WorkReportMemberSnapshot {
        userId: string;
        userName: string;
      }

      interface ProjectReportItem {
        id?: string;
        itemTitle: string;
        workHours?: number | null;
        priorityCode?: string | null;
        progressRate?: number | null;
      }

      interface ProjectReportOwnerProjectOption {
        id: string;
        projectCode: string;
        projectName: string;
      }

      interface ProjectReport {
        id: string;
        projectId: string;
        projectName: string;
        projectOwnerId: string;
        projectOwnerName: string;
        technicalOwnerName?: string | null;
        projectMemberSnapshot: WorkReportMemberSnapshot[];
        supervisorUserId: string;
        supervisorName: string;
        periodKey: string;
        periodLabel: string;
        periodStartDate: string;
        periodEndDate: string;
        flag?: number | null;
        statusCode: Common.WorkReportStatusCode | string;
        statusName: string;
        allowEdit: boolean;
        terminal: boolean;
        projectStatusDesc?: string | null;
        projectProgressPlan?: string | null;
        projectKeyPoints?: string | null;
        projectProblems?: string | null;
        totalWorkHours?: number | string | null;
        approvalComment?: string | null;
        lastStatusReason?: string | null;
        submitTime?: string | null;
        approvalTime?: string | null;
        createTime?: string | null;
        updateTime?: string | null;
        currentItems: ProjectReportItem[];
        nextItems: ProjectReportItem[];
      }

      type ProjectReportSearchParams = Common.WorkReportBaseSearchParams & {
        projectOwnerIds?: string[] | null;
        projectId?: string | null;
        flag?: number | null;
      };

      interface ProjectReportSaveParams {
        projectId: string;
        periodKey: string;
        periodLabel: string;
        periodStartDate: string;
        periodEndDate: string;
        flag?: number | null;
        projectStatusDesc?: string | null;
        projectProgressPlan?: string | null;
        projectKeyPoints?: string | null;
        projectProblems?: string | null;
        currentItems: ProjectReportItem[];
        nextItems: ProjectReportItem[];
      }

      type ProjectReportDefaultDraftParams = Pick<
        ProjectReportSaveParams,
        'periodKey' | 'periodLabel' | 'periodStartDate' | 'periodEndDate' | 'flag'
      >;

      type ProjectReportRefreshDraftParams = Omit<ProjectReportSaveParams, 'projectId'>;
    }
  }
}
