import React from 'react';
import { __ } from '@wordpress/i18n';
import { useNavigate } from 'react-router-dom';
import { head } from 'ramda';

// store
import { useStoreValue } from '../../store';

// components
import { Button } from 'primereact/button';
import ErrorBoundary from '../../components/ErrorBoundary';
import MyLatestSubmissionsTableAsync from '../DashboardBeneficiario/components/MyLatestSubmissionsTableAsync';

const Imieibandi = () => {
    const navigate = useNavigate();
    const chosenCompanyId = useStoreValue('chosenCompanyId');
    const companies = useStoreValue('companies');
    const company = head(companies.filter(o => o.id === chosenCompanyId));

    const gotToBandiDisponibili = () => {
        navigate('/bandi')
    }

    return(
        <div className="appPage">
            <div className="appPage__pageHeader">
                <h1>{__('Domande in Lavorazione', 'gepafin')}</h1>
                {company ? <span className="companyName">{company.companyName}</span> : null}
            </div>

            <div className="appPage__spacer"></div>

            <div className="appPageSection">
                <ErrorBoundary><MyLatestSubmissionsTableAsync/></ErrorBoundary>
            </div>

            <div className="appPage__spacer"></div>

            <div className="appPageSection__hr">
                <span>{__('Azioni rapide', 'gepafin')}</span>
            </div>

            <div className="appPage__spacer"></div>

            <div className="appPageSection">
                <div className="appPageSection__actions">
                    <Button
                        onClick={gotToBandiDisponibili}
                        label={__('Bandi disponibili', 'gepafin')} icon="pi pi-bookmark" iconPos="right"/>
                    {/*<Button
                        disabled={true}
                        outlined
                        onClick={() => {
                        }}
                        label={__('Contatta assistenza', 'gepafin')} icon="pi pi-envelope" iconPos="right"/>*/}
                </div>
            </div>
        </div>
    )
}

export default Imieibandi;