Browse Source

Update to stage-3.

feature/bike-tracking
Drew Larson 7 years ago
parent
commit
7c2df81c6a
  1. 3
      bikeshop_project/.babelrc
  2. 8
      bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx
  3. 18
      bikeshop_project/assets/js/bikes/components/BikeModal/index.jsx
  4. 15
      bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx
  5. 18
      bikeshop_project/assets/js/components/SignedInList.jsx
  6. 4
      bikeshop_project/package.json
  7. 50
      bikeshop_project/webpack.config.js
  8. 8
      bikeshop_project/webpack.dev.config.js

3
bikeshop_project/.babelrc

@ -1,3 +1,4 @@
{
presets: ['es2015', 'stage-0', 'react']
"presets": ["latest", "stage-3", "react"],
"plugins": ["transform-runtime"]
}

8
bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx

@ -75,7 +75,7 @@ class BikeForm extends React.Component {
});
}
handleSave = () => {
handleSave() {
const id = this.state.bike.id;
const data = JSON.stringify(this.state.bike);
const csrfToken = Cookies.get('csrftoken');
@ -99,7 +99,7 @@ class BikeForm extends React.Component {
});
}
render = () => {
render() {
const timezone = moment.tz.guess();
const {
claimed_at,
@ -255,4 +255,8 @@ class BikeForm extends React.Component {
}
}
BikeForm.propTypes = {
editing: PropTypes.bool,
handleClose: PropTypes.func,
}
export default BikeForm;

18
bikeshop_project/assets/js/bikes/components/BikeModal/index.jsx

@ -6,13 +6,7 @@ import BikeForm from '../BikeForm';
/**
* A modal dialog can only be closed by selecting one of the actions.
*/
export default class BikeModal extends React.Component {
static propTypes = {
open: PropTypes.bool,
bike: PropTypes.object,
editing: PropTypes.bool,
}
class BikeModal extends React.Component {
constructor(props) {
super(props);
@ -23,7 +17,7 @@ export default class BikeModal extends React.Component {
};
}
componentWillReceiveProps = (newProps) => {
componentWillReceiveProps(newProps) {
this.setState({
...this.state,
open: newProps.open || false,
@ -32,7 +26,7 @@ export default class BikeModal extends React.Component {
});
}
handleClose = () => {
handleClose() {
this.setState({ open: false });
};
@ -63,3 +57,9 @@ export default class BikeModal extends React.Component {
</div>);
}
}
export default BikeModal.propTypes = {
open: PropTypes.bool,
bike: PropTypes.object,
editing: PropTypes.bool,
};

15
bikeshop_project/assets/js/bikes/components/BikeTable/index.jsx

@ -42,19 +42,6 @@ export default class BikeTable extends React.Component {
}
getBikes = () => {
fetch('/api/v1/bikes/', {
credentials: 'same-origin',
})
.then(checkStatus)
.then(parseJSON)
.then((data) => {
this.setState({ bikes: data });
})
.catch((error) => {
console.log('request failed', error);
});
}
handleEditBike(bike) {
this.setState({
...this.state,
@ -66,7 +53,7 @@ export default class BikeTable extends React.Component {
});
}
handleAddBike = () => {
handleAddBike() {
this.setState({
...this.state,
bikeModal: {

18
bikeshop_project/assets/js/components/SignedInList.jsx

@ -32,15 +32,7 @@ const styles = {
},
};
export default class SignedInList extends React.Component {
static propTypes = {
members: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.number,
purpose: PropTypes.string,
at: PropTypes.instanceOf(moment),
})),
}
class SignedInList extends React.Component {
constructor(props) {
super(props);
this.state = { tick: 0 };
@ -117,3 +109,11 @@ export default class SignedInList extends React.Component {
);
}
}
export default SignedInList.propTypes = {
members: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.number,
purpose: PropTypes.string,
at: PropTypes.instanceOf(moment),
})),
};

4
bikeshop_project/package.json

@ -29,9 +29,9 @@
"babel-core": "^6.9.1",
"babel-loader": "^6.2.4",
"babel-polyfill": "^6.22.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-latest": "^6.22.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-preset-stage-3": "^6.22.0",
"css-loader": "^0.23.1",
"eslint": "^3.9.1",
"eslint-plugin-import": "^2.1.0",

50
bikeshop_project/webpack.config.js

@ -1,50 +0,0 @@
const path = require('path');
const webpack = require('webpack');
const BundleTracker = require('webpack-bundle-tracker');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');
module.exports = {
context: __dirname,
devtool: 'inline-source-map',
entry: {
signin: './assets/js/index',
members: './assets/js/members/index',
},
output: {
path: path.resolve('./assets/bundles/'),
filename: '[name]-[hash].js',
},
plugins: [
new BundleTracker({ filename: './webpack-stats.json' }),
new ExtractTextPlugin('react-toolbox.css', { allChunks: true }),
new webpack.NoErrorsPlugin(),
],
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'stage-0', 'react'],
},
},
{
test: /(\.scss|\.css)$/,
loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass?sourceMap!toolbox'),
},
],
},
resolve: {
modulesDirectories: [
'node_modules',
'bower_components',
path.resolve(__dirname, './node_modules'),
],
extensions: ['', '.js', '.jsx', '.scss'],
},
postcss: [autoprefixer],
};

8
bikeshop_project/webpack.dev.config.js

@ -30,13 +30,15 @@ config.plugins = config.plugins.concat([
new ExtractTextPlugin('react-toolbox.css', { allChunks: true }),
]);
// Add a loader for JSX files with react-hot enabled
// Add a loader for JSX files
config.module.loaders.push(
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['react-hot', 'babel-loader'],
loader: 'babel-loader',
query: {
presets: ['latest', 'react', 'stage-3'],
},
},
{
test: /(\.scss|\.css)$/,

Loading…
Cancel
Save