Skip to content

Commit

Permalink
Removed provider control parameters from ordering.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 committed Jul 23, 2019
1 parent 390e1a3 commit 35daa35
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/helpers/order/order-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function sendSubmitOrder({ service_parameters: { providerControlPar
...orderItem,
...parameters,
service_parameters,
provider_control_parameters: providerControlParameters
provider_control_parameters: providerControlParameters || {}
};
await orderApi.addToOrder(order.id, orderItem);
return orderApi.submitOrder(order.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import { schemaParsers } from '@data-driven-forms/react-form-renderer';

import FormRenderer from '../common/form-renderer';
import { fetchServicePlans, sendSubmitOrder } from '../../redux/actions/order-actions';
import { fetchProviderControlParameters } from '../../helpers/portfolio/portfolio-helper';

/**
* TO DO
* We need some explicit way of telling what kind of schema is being received
*/
const createFormSchema = (servicePlanSchema, providerControlParameters) => {
const createFormSchema = (servicePlanSchema, providerControlParameters = { type: 'object', properties: {}}) => {
const providerFields = schemaParsers.mozillaParser(providerControlParameters).schema.fields
.map(({ name, ...rest }) => ({ name: `providerControlParameters.${name}`, ...rest }));
let initialSchema = servicePlanSchema.schema;
Expand All @@ -29,8 +28,7 @@ const createFormSchema = (servicePlanSchema, providerControlParameters) => {

class OrderServiceFormStepConfiguration extends React.Component {
state = {
selectedPlanIdx: 0,
controlParametersLoaded: false
selectedPlanIdx: 0
};

optionRow = (plan, _option, selectedId, onChange) =>
Expand All @@ -46,7 +44,6 @@ class OrderServiceFormStepConfiguration extends React.Component {
componentDidMount() {
const { id } = this.props;
this.props.fetchPlans(id);
fetchProviderControlParameters(id).then(providerControlParameters => this.setState({ providerControlParameters, controlParametersLoaded: true }));
}

handlePlanChange = (arg, event) => {
Expand All @@ -69,9 +66,8 @@ class OrderServiceFormStepConfiguration extends React.Component {
};

render() {
const { controlParametersLoaded, providerControlParameters } = this.state;
if (!this.props.isLoading && controlParametersLoaded) {
const formSchema = createFormSchema(this.props.servicePlans[this.state.selectedPlanIdx].create_json_schema, providerControlParameters);
if (!this.props.isLoading && this.props.servicePlans.length > 0) {
const formSchema = createFormSchema(this.props.servicePlans[this.state.selectedPlanIdx].create_json_schema);
return (
<Stack gutter="md">
<StackItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ describe('<OrderServiceFormStepConfiguration />', () => {
ENABLE_OAUTH: 'true',
MEMORY_LIMIT: '512Mi'
},
provider_control_parameters: {},
portfolio_item_id: '1' });
return res.status(200);
}));
Expand Down

0 comments on commit 35daa35

Please sign in to comment.