summaryrefslogtreecommitdiff
path: root/app/client/dataset/dataset.new.js
blob: bc169c7fcd6d240722adccce6250e42fc4a64c06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { h, Component } from 'preact'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'

import * as datasetActions from './dataset.actions'

import Loading from '../common/loading.component'
import TextInput from '../common/textInput.component'

function NewDatasetForm (props) {
  const { loading, status, error, history, actions, module } = props
  if (loading) return <Loading />
  console.log(props)
  return (
    <div class='opaque'>
      <div class='heading'>
        <h2>Create a new dataset</h2>
      </div>
      <div class='params'>
        <TextInput
          autofocus
          title={'Name your dataset'}
          onSave={(name) => {
            actions.createFolder(module, name)
            .then(folder => {
              window.location.href = '/' + module.name + '/datasets/' + folder.id + '/'
            })
          }}
        />
      </div>
    </div>
  )
}

const mapStateToProps = state => state

const mapDispatchToProps = (dispatch, ownProps) => ({
  actions: bindActionCreators(datasetActions, dispatch),
})

export default connect(mapStateToProps, mapDispatchToProps)(NewDatasetForm)