-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(experiences): stub out main mechanisms for experience creation
- Loading branch information
1 parent
eb54748
commit 0e347c0
Showing
14 changed files
with
399 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/components/ExperienceCreateForm/ExperienceCreateForm.container.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @file ExperienceCreateForm.container.js | ||
* Exports a redux-connected ExperienceCreateForm component. | ||
*/ | ||
|
||
import { connect } from 'react-redux'; | ||
|
||
import ExperienceCreateForm from './ExperienceCreateForm'; | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
dispatch | ||
}); | ||
|
||
const mapState = ({ user, experiences }) => ({ | ||
user, | ||
experiences | ||
}); | ||
|
||
export default connect(mapState, mapDispatchToProps)(ExperienceCreateForm); |
97 changes: 97 additions & 0 deletions
97
src/components/ExperienceCreateForm/ExperienceCreateForm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* @file ExperienceCreateForm.js | ||
* Exports a component that allows users to create an EditVR experience. | ||
*/ | ||
|
||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { TextField, Button, withStyles } from '@material-ui/core'; | ||
|
||
import { Message } from '../'; | ||
import ExperienceCreateFormStyles from './ExperienceCreateForm.style'; | ||
import { EXPERIENCES_CREATE } from '../../constants'; | ||
|
||
class ExperienceCreateForm extends Component { | ||
static propTypes = { | ||
submitHandler: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]), | ||
classes: PropTypes.shape({ | ||
textField: PropTypes.string.isRequired, | ||
button: PropTypes.string.isRequired | ||
}).isRequired, | ||
dispatch: PropTypes.func.isRequired, | ||
user: PropTypes.shape({ | ||
authentication: PropTypes.shape({ | ||
accessToken: PropTypes.string.isRequired, | ||
csrfToken: PropTypes.string.isRequired | ||
}).isRequired | ||
}).isRequired, | ||
experiences: PropTypes.shape({ | ||
error: PropTypes.string | ||
}) | ||
}; | ||
|
||
static defaultProps = { | ||
submitHandler: false, | ||
experiences: { | ||
error: null | ||
} | ||
}; | ||
|
||
/** | ||
* Handles a login form submit action. | ||
* | ||
* @param {object} event - Submit event object. | ||
*/ | ||
handleSubmit = event => { | ||
event.preventDefault(); | ||
const { dispatch, user } = this.props; | ||
dispatch({ | ||
type: EXPERIENCES_CREATE, | ||
user, | ||
title: event.target[0].value, | ||
field_experience_path: event.target[1].value | ||
}); | ||
}; | ||
|
||
/** | ||
* {@inheretdoc} | ||
*/ | ||
render() { | ||
const { | ||
classes, | ||
submitHandler, | ||
experiences: { error } | ||
} = this.props; | ||
return ( | ||
<form onSubmit={submitHandler || this.handleSubmit}> | ||
{error && <Message>{error}</Message>} | ||
<TextField | ||
id="title" | ||
label="Title" | ||
type="text" | ||
required | ||
helperText="Enter a user-friendly title for your experience." | ||
className={classes.textField} | ||
/> | ||
<TextField | ||
id="field_experience_path" | ||
label="URL Path" | ||
type="text" | ||
required | ||
helperText="Enter a name for your experience. For example, if you enter 'my-new-experience', your experience will be published to /experience/my-new-experience." | ||
className={classes.textField} | ||
/> | ||
<Button | ||
variant="raised" | ||
color="primary" | ||
type="submit" | ||
className={classes.button} | ||
> | ||
Create | ||
</Button> | ||
</form> | ||
); | ||
} | ||
} | ||
|
||
export default withStyles(ExperienceCreateFormStyles)(ExperienceCreateForm); |
15 changes: 15 additions & 0 deletions
15
src/components/ExperienceCreateForm/ExperienceCreateForm.style.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* @file ExperienceCreateForm.style.js | ||
* Exports ExperienceCreateForm component styles. | ||
*/ | ||
|
||
export default theme => ({ | ||
textField: { | ||
width: '100%', | ||
marginTop: `${theme.spacing.unit * 2}px` | ||
}, | ||
button: { | ||
marginTop: `${theme.spacing.unit * 3}px`, | ||
marginRight: theme.spacing.unit | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.