2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
16 import {connect} from 'react-redux';
18 import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js';
19 import SoftwareProductCreationActionHelper from './SoftwareProductCreationActionHelper.js';
20 import SoftwareProductCreationView from './SoftwareProductCreationView.jsx';
21 import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
22 import SoftwareProductActionHelper from '../SoftwareProductActionHelper.js';
24 export const mapStateToProps = ({finalizedLicenseModelList, softwareProductList, softwareProduct: {softwareProductCreation, softwareProductCategories} }) => {
25 let {genericFieldInfo} = softwareProductCreation;
26 let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo);
29 for (let i = 0; i < softwareProductList.length; i++) {
30 VSPNames[softwareProductList[i].name] = softwareProductList[i].id;
34 data: softwareProductCreation.data,
35 selectedVendorId: softwareProductCreation.selectedVendorId,
36 disableVendor: softwareProductCreation.disableVendor,
37 softwareProductCategories,
38 finalizedLicenseModelList,
40 formReady: softwareProductCreation.formReady,
46 export const mapActionsToProps = (dispatch) => {
48 onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}),
49 onCancel: () => SoftwareProductCreationActionHelper.resetData(dispatch),
50 onSubmit: (softwareProduct) => {
51 SoftwareProductCreationActionHelper.resetData(dispatch);
52 SoftwareProductCreationActionHelper.createSoftwareProduct(dispatch, {softwareProduct}).then(response => {
53 SoftwareProductActionHelper.fetchSoftwareProductList(dispatch).then(() => {
54 let {vendorId: licenseModelId, licensingVersion} = softwareProduct;
55 OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId: response.vspId, licenseModelId, licensingVersion});
59 onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName)
63 export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductCreationView);