import { SerializationClass } from '@humand-packages/common';
import { PublicUserPaginatedSC } from '../../../users/presentation/serializationClasses/publicUserPaginatedSC';
import { EditCategorizedHourStatusResult } from '../../business/models/timeTracking/editCategorizedHourStatusResult';
import { TimeTrackingCategorizedHourStatus } from '../../infrastructure/constants/timeTracking/categorizedHourStatus';
import { EditCategorizedHourStatusDTO } from '../dataTransferObjects/editCategorizedHourStatusDTO';
import { TimeTrackingCategorizedHourApprovalStepSC } from './TimeTrackingCategorizedHourApprovalStepSC';

export interface EditCategorizedHourStatusSCInput {
    comment: string | null;
    result: EditCategorizedHourStatusResult;
    status: TimeTrackingCategorizedHourStatus;
}

export class EditCategorizedHourStatusSC extends SerializationClass<EditCategorizedHourStatusSCInput, EditCategorizedHourStatusDTO> {
    serialize({ comment, result, status }: EditCategorizedHourStatusSCInput): EditCategorizedHourStatusDTO {
        const publicUserSC = new PublicUserPaginatedSC();
        return {
            approvalSteps: new TimeTrackingCategorizedHourApprovalStepSC().serializeList(result.approvalSteps),
            status,
            statusOverride: {
                admin: result.admin ? publicUserSC.serialize(result.admin) : null,
                comment,
            },
        };
    }
}
