import * as React from "react";
import { RecordsList as CoreRecordsList } from "src/Views/User/Modules/Entities/RecordsList";
import { ListRecordsCriteria, FieldQuery, Sorting } from "src/Models";

export class RecordsList extends React.Component<any, any> {
    constructor(props: any) {
        super(props);

        this.state = {
            criteria: null
        }

        this.getSentCorrespondences();
    }

    private getSentCorrespondences() {

        let correspondencesListCriteria = new ListRecordsCriteria();
        correspondencesListCriteria.asLookup = false;
        correspondencesListCriteria.entityId = 14;
        correspondencesListCriteria.query = new Array<FieldQuery>();
        correspondencesListCriteria.sorting = new Sorting();
        correspondencesListCriteria.sorting.fieldId = 190;
        correspondencesListCriteria.sorting.direction = 1;

        this.setState({ 'criteria': correspondencesListCriteria });
    }

    public render(): JSX.Element {
        return (<CoreRecordsList criteria={this.state.criteria}
            {...this.props}></CoreRecordsList>)
    }
}