- added company name for Documents page;
- disabled buttons for document uploads when no company added/selected;
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useState } from 'react';
|
|||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { classNames } from 'primereact/utils';
|
import { classNames } from 'primereact/utils';
|
||||||
import { wrap } from 'object-path-immutable';
|
import { wrap } from 'object-path-immutable';
|
||||||
import { isEmpty, isNil } from 'ramda';
|
import { head, isEmpty, isNil } from 'ramda';
|
||||||
|
|
||||||
// api
|
// api
|
||||||
import DocumentCategoryService from '../../service/document-category-service';
|
import DocumentCategoryService from '../../service/document-category-service';
|
||||||
@@ -18,11 +18,13 @@ import { Calendar } from 'primereact/calendar';
|
|||||||
import { FileUpload } from 'primereact/fileupload';
|
import { FileUpload } from 'primereact/fileupload';
|
||||||
import formatDateString from '../../helpers/formatDateString';
|
import formatDateString from '../../helpers/formatDateString';
|
||||||
import CompanyDocumentsService from '../../service/company-documents-service';
|
import CompanyDocumentsService from '../../service/company-documents-service';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
|
|
||||||
const DocumentsBeneficiary = () => {
|
const DocumentsBeneficiary = () => {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||||
|
const companies = useStore().main.companies();
|
||||||
const [isVisibleAddNewDialog, setIsVisibleAddNewDialog] = useState(false);
|
const [isVisibleAddNewDialog, setIsVisibleAddNewDialog] = useState(false);
|
||||||
const documentCategories= useStore().main.documentCategories();
|
const documentCategories= useStore().main.documentCategories();
|
||||||
const [newFileData, setNewFileData] = useState({});
|
const [newFileData, setNewFileData] = useState({});
|
||||||
@@ -31,6 +33,7 @@ const DocumentsBeneficiary = () => {
|
|||||||
const today = new Date();
|
const today = new Date();
|
||||||
const tomorrow = new Date(today);
|
const tomorrow = new Date(today);
|
||||||
tomorrow.setDate(today.getDate() + 1);
|
tomorrow.setDate(today.getDate() + 1);
|
||||||
|
const company = head(companies.filter(o => o.id === chosenCompanyId));
|
||||||
|
|
||||||
const onCreateNew = useCallback((type) => {
|
const onCreateNew = useCallback((type) => {
|
||||||
const newData = wrap({})
|
const newData = wrap({})
|
||||||
@@ -138,14 +141,28 @@ const DocumentsBeneficiary = () => {
|
|||||||
<div className="appPage">
|
<div className="appPage">
|
||||||
<div className="appPage__pageHeader">
|
<div className="appPage__pageHeader">
|
||||||
<h1>{__('Gestione documenti', 'gepafin')}</h1>
|
<h1>{__('Gestione documenti', 'gepafin')}</h1>
|
||||||
|
{company ? <span className="companyName">{company.companyName}</span> : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
|
{isEmpty(chosenCompanyId) || chosenCompanyId === 0
|
||||||
|
? <>
|
||||||
|
<div className="appPageSection__message warning">
|
||||||
|
<i className="pi pi-exclamation-triangle"></i>
|
||||||
|
<span className="summary">{__('Attenzione', 'gepafin')}</span>
|
||||||
|
<span>
|
||||||
|
{__('Per caricare i file devi Registare un Azienda clicca', 'gepafin')}
|
||||||
|
<Link to={`/agguingi-azienda`} style={{marginLeft: '0.5ch'}}>{__('qua', 'gepafin')}</Link>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="appPage__spacer"></div>
|
||||||
|
</> : null}
|
||||||
|
|
||||||
<div className="appPageSection statsBigBadges">
|
<div className="appPageSection statsBigBadges">
|
||||||
<h2>
|
<h2>
|
||||||
{__('Documenti del rappresentante legale', 'gepafin')}
|
{__('Documenti del rappresentante legale', 'gepafin')}
|
||||||
<Button
|
<Button
|
||||||
|
disabled={isEmpty(chosenCompanyId) || chosenCompanyId === 0}
|
||||||
onClick={() => onCreateNew('PERSONAL_DOCUMENT')}
|
onClick={() => onCreateNew('PERSONAL_DOCUMENT')}
|
||||||
size="small"
|
size="small"
|
||||||
label={__('Aggiungi nuovo')} icon="pi pi-plus" iconPos="right"/>
|
label={__('Aggiungi nuovo')} icon="pi pi-plus" iconPos="right"/>
|
||||||
@@ -159,6 +176,7 @@ const DocumentsBeneficiary = () => {
|
|||||||
<h2>
|
<h2>
|
||||||
{__('Documenti dell\'azienda', 'gepafin')}
|
{__('Documenti dell\'azienda', 'gepafin')}
|
||||||
<Button
|
<Button
|
||||||
|
disabled={isEmpty(chosenCompanyId) || chosenCompanyId === 0}
|
||||||
onClick={() => onCreateNew('COMPANY_DOCUMENT')}
|
onClick={() => onCreateNew('COMPANY_DOCUMENT')}
|
||||||
size="small"
|
size="small"
|
||||||
label={__('Aggiungi nuovo')} icon="pi pi-plus" iconPos="right"/>
|
label={__('Aggiungi nuovo')} icon="pi pi-plus" iconPos="right"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user