import { List } from '@iqser/common-ui/lib/utils';
import { IDossier } from '../dossiers';
import { TrashItem } from './trash.item';

export class TrashDossier extends TrashItem implements Partial<IDossier> {
    readonly type = 'dossier';
    readonly icon = 'red:folder';

    readonly isSoftDeleted = true;
    readonly fileDossierName = '-';

    readonly dossierId: string;
    readonly dossierTemplateId: string;
    readonly dossierName: string;
    readonly memberIds: List;
    readonly date: string;
    readonly dueDate?: string;
    readonly ownerId: string;
    readonly softDeletedTime: string;
    readonly id: string;

    constructor(
        dossier: IDossier,
        protected readonly _retentionHours: number,
        readonly hasRestoreRights: boolean,
        readonly hasHardDeleteRights: boolean,
        readonly ownerName: string,
    ) {
        super(_retentionHours, dossier.softDeletedTime, hasRestoreRights, hasHardDeleteRights);
        this.dossierId = dossier.dossierId;
        this.dossierTemplateId = dossier.dossierTemplateId;
        this.date = dossier.date;
        this.dossierName = dossier.dossierName;
        this.dueDate = dossier.dueDate;
        this.memberIds = dossier.memberIds;
        this.ownerId = dossier.ownerId;

        // Because of migrations, for some this is not set
        this.softDeletedTime = dossier.softDeletedTime || '-';

        this.id = this.dossierId;
    }

    get searchKey(): string {
        return this.dossierName;
    }

    get name(): string {
        return this.dossierName;
    }
}
