blob: 42f2407696a776131039f7010ac4f9555bb1f9df [file] [log] [blame]
Michael Landoefa037d2017-02-19 12:57:33 +02001import React from 'react';
2import {connect} from 'react-redux';
3import ConfirmationModalView from 'nfvo-components/confirmations/ConfirmationModalView.jsx';
4import LicenseAgreementActionHelper from './LicenseAgreementActionHelper.js';
5import i18n from 'nfvo-utils/i18n/i18n.js';
6
7function renderMsg(licenseAgreementToDelete) {
8 let name = licenseAgreementToDelete ? licenseAgreementToDelete.name : '';
9 let msg = i18n('Are you sure you want to delete "{name}"?', {name});
10 return(
11 <div>
12 <p>{msg}</p>
13 </div>
14 );
15};
16
17const mapStateToProps = ({licenseModel: {licenseAgreement}}, {licenseModelId}) => {
18 let {licenseAgreementToDelete} = licenseAgreement;
19 const show = licenseAgreementToDelete !== false;
20 return {
21 show,
22 title: 'Warning!',
23 type: 'warning',
24 msg: renderMsg(licenseAgreementToDelete),
25 confirmationDetails: {licenseAgreementToDelete, licenseModelId}
26 };
27};
28
29const mapActionsToProps = (dispatch) => {
30 return {
31 onConfirmed: ({licenseAgreementToDelete, licenseModelId}) => {
32
33 LicenseAgreementActionHelper.deleteLicenseAgreement(dispatch, {licenseModelId, licenseAgreementId: licenseAgreementToDelete.id});
34 LicenseAgreementActionHelper.hideDeleteConfirm(dispatch);
35 },
36 onDeclined: () => {
37 LicenseAgreementActionHelper.hideDeleteConfirm(dispatch);
38 }
39 };
40};
41
42export default connect(mapStateToProps, mapActionsToProps)(ConfirmationModalView);
43