- added pec email reject;
This commit is contained in:
@@ -15,6 +15,7 @@ import { Column } from 'primereact/column';
|
|||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import { Toast } from 'primereact/toast';
|
import { Toast } from 'primereact/toast';
|
||||||
import { Dialog } from 'primereact/dialog';
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
import { Editor } from 'primereact/editor';
|
||||||
|
|
||||||
import translationStrings from '../../../../translationStringsForComponents';
|
import translationStrings from '../../../../translationStringsForComponents';
|
||||||
import { autorizationNames } from '../../../../configData';
|
import { autorizationNames } from '../../../../configData';
|
||||||
@@ -26,6 +27,9 @@ const LatestPecEmailsTable = () => {
|
|||||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||||
const [isVisibleDetails, setIsVisibleDetails] = useState(false);
|
const [isVisibleDetails, setIsVisibleDetails] = useState(false);
|
||||||
const [previewItem, setPreviewItem] = useState({});
|
const [previewItem, setPreviewItem] = useState({});
|
||||||
|
const [isVisibleRejectDialog, setIsVisibleRejectDialog] = useState(false);
|
||||||
|
const [rejectMotivation, setRejectMotivation] = useState('');
|
||||||
|
const [pendingRejectIds, setPendingRejectIds] = useState([]);
|
||||||
const toast = useRef(null);
|
const toast = useRef(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -103,6 +107,57 @@ const LatestPecEmailsTable = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openRejectDialog = (ids) => {
|
||||||
|
if (isEmpty(ids)) return;
|
||||||
|
setPendingRejectIds(ids);
|
||||||
|
setIsVisibleRejectDialog(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const hideRejectDialog = () => {
|
||||||
|
setIsVisibleRejectDialog(false);
|
||||||
|
setRejectMotivation('');
|
||||||
|
setPendingRejectIds([]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const doReject = () => {
|
||||||
|
if (isEmpty(pendingRejectIds)) return;
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
setIsVisibleRejectDialog(false);
|
||||||
|
for (let id of pendingRejectIds) {
|
||||||
|
PecEmailService.rejectUserAction(id, getUserRejectActionCallback, errGetUserRejectActionCallbacks,
|
||||||
|
rejectMotivation ? [['motivation', rejectMotivation]] : []
|
||||||
|
);
|
||||||
|
}
|
||||||
|
setRejectMotivation('');
|
||||||
|
setPendingRejectIds([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const getUserRejectActionCallback = (resp) => {
|
||||||
|
if (resp.status === 'SUCCESS') {
|
||||||
|
if (toast.current && resp.message) {
|
||||||
|
toast.current.show({
|
||||||
|
severity: 'success',
|
||||||
|
summary: '',
|
||||||
|
detail: resp.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
PecEmailService.getPecEmails(getCallback, errGetCallbacks);
|
||||||
|
} else {
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const errGetUserRejectActionCallbacks = (resp) => {
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
if (toast.current && resp.message) {
|
||||||
|
toast.current.show({
|
||||||
|
severity: resp.status === 'SUCCESS' ? 'info' : 'error',
|
||||||
|
summary: '',
|
||||||
|
detail: resp.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const doShowDetails = (row) => {
|
const doShowDetails = (row) => {
|
||||||
setPreviewItem(row);
|
setPreviewItem(row);
|
||||||
setIsVisibleDetails(true);
|
setIsVisibleDetails(true);
|
||||||
@@ -117,6 +172,16 @@ const LatestPecEmailsTable = () => {
|
|||||||
setPreviewItem({});
|
setPreviewItem({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const headerRejectDialog = () => <span>{__('Confermare il rifiuto', 'gepafin')}</span>;
|
||||||
|
|
||||||
|
const footerRejectDialog = useCallback(() => (
|
||||||
|
<div>
|
||||||
|
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideRejectDialog} outlined/>
|
||||||
|
<Button type="button" disabled={localAsyncRequest}
|
||||||
|
label={__('Invia', 'gepafin')} onClick={doReject} severity="danger"/>
|
||||||
|
</div>
|
||||||
|
), [pendingRejectIds, rejectMotivation, localAsyncRequest]);
|
||||||
|
|
||||||
const footerDialog = useCallback(() => {
|
const footerDialog = useCallback(() => {
|
||||||
return <div>
|
return <div>
|
||||||
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideDialog} outlined/>
|
<Button type="button" label={__('Annulla', 'gepafin')} onClick={hideDialog} outlined/>
|
||||||
@@ -160,11 +225,37 @@ const LatestPecEmailsTable = () => {
|
|||||||
icon="pi pi-check"
|
icon="pi pi-check"
|
||||||
size="small"
|
size="small"
|
||||||
iconPos="right"/>
|
iconPos="right"/>
|
||||||
|
<Button severity="danger"
|
||||||
|
onClick={() => openRejectDialog([rowData.userActionId])}
|
||||||
|
label={__('Rifiuta', 'gepafin')}
|
||||||
|
icon="pi pi-times"
|
||||||
|
size="small"
|
||||||
|
iconPos="right"/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
const header = renderHeader();
|
const header = renderHeader();
|
||||||
|
|
||||||
|
const renderHeaderEditor = () => {
|
||||||
|
return (
|
||||||
|
<span className="ql-formats">
|
||||||
|
<button className="ql-bold" aria-label="Bold"></button>
|
||||||
|
<button className="ql-italic" aria-label="Italic"></button>
|
||||||
|
<button className="ql-underline" aria-label="Underline"></button>
|
||||||
|
<button className="ql-link" aria-label="Link"></button>
|
||||||
|
<button className="ql-list" value="ordered"></button>
|
||||||
|
<button className="ql-header" value="2"></button>
|
||||||
|
<button className="ql-header" value="3"></button>
|
||||||
|
<button className="ql-blockquote"></button>
|
||||||
|
<button className="ql-list" value="bullet"></button>
|
||||||
|
<button className="ql-indent" value="-1"></button>
|
||||||
|
<button className="ql-indent" value="+1"></button>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const headerEditor = renderHeaderEditor();
|
||||||
|
|
||||||
return <div className="appPageSection__table">
|
return <div className="appPageSection__table">
|
||||||
<DataTable value={items}
|
<DataTable value={items}
|
||||||
paginator showGridlines
|
paginator showGridlines
|
||||||
@@ -220,6 +311,28 @@ const LatestPecEmailsTable = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
|
<Dialog
|
||||||
|
visible={isVisibleRejectDialog}
|
||||||
|
modal
|
||||||
|
header={headerRejectDialog}
|
||||||
|
footer={footerRejectDialog}
|
||||||
|
style={{ maxWidth: '600px', width: '100%' }}
|
||||||
|
onHide={hideRejectDialog}>
|
||||||
|
<div className="appForm__field">
|
||||||
|
<label>{__('Motivazione', 'gepafin')}</label>
|
||||||
|
<div translate="no">
|
||||||
|
<Editor
|
||||||
|
value={rejectMotivation}
|
||||||
|
readOnly={localAsyncRequest}
|
||||||
|
headerTemplate={headerEditor}
|
||||||
|
placeholder={__('Digita qui la motivazione (opzionale)', 'gepafin')}
|
||||||
|
onTextChange={(e) => setRejectMotivation(e.htmlValue)}
|
||||||
|
style={{ height: 80 * 3, width: '100%' }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,4 +11,8 @@ export default class PecEmailService {
|
|||||||
static doUserAction = (callback, errCallback, queryParams) => {
|
static doUserAction = (callback, errCallback, queryParams) => {
|
||||||
NetworkService.post(`${API_BASE_URL}/pecMail/userAction`, {}, callback, errCallback, queryParams);
|
NetworkService.post(`${API_BASE_URL}/pecMail/userAction`, {}, callback, errCallback, queryParams);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static rejectUserAction = (userAction, callback, errCallback, queryParams) => {
|
||||||
|
NetworkService.post(`${API_BASE_URL}/pecMail/userAction/${userAction}/reject`, {}, callback, errCallback, queryParams);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user