import React from 'react';
import WidgetForm from 'components/widget/WidgetForm';
import Title from 'components/ui/Title';
import Page from 'components/layout/page';

export default class WidgetEdit extends React.Component {

  static async getInitialProps({ query }) {
    const datasetID = query.id;
    const widgetID = query.widget_id;
    return { datasetID, widgetID };
  }

  render() {
    const { datasetID, widgetID } = this.props;
    return (
      <Page
        title="Edit widget"
        description="Edit widget description..."
      >
        <div className="row">
          <div className="column small-12">
            <Title className="-huge -p-primary">
              Edit Widget
            </Title>
            <WidgetForm
              application={['rw']}
              authorization={`${process.env.TEMP_TOKEN}`}
              dataset={datasetID}
              widget={widgetID}
              onSubmit={() => window.location = `/admin/datasets/${datasetID}/widgets`}
            />
          </div>
        </div>
      </Page>
    );
  }
}

@@ -62,16 +62,21 @@
 /widget/
+form/
 WidgetFo
@@ -937,64 +937,62 @@
  =%3E 
-window.location = %60/admin/datasets/$%7BdatasetID%7D/widgets%60
+Router.pushRoute('dataset_widgets', %7B id: datasetID %7D)
 %7D%0A  

fix submit route