Commit eb3bdfee authored by Paul Kaplan's avatar Paul Kaplan

Fix linting

parent acedd550
import React from 'react';
import PropTypes from 'prop-types';
export default function Debug({label, data}) {
return <div style={{padding: '2rem', 'border': '1px solid red', margin: '2rem'}}>
<small>{label}</small>
<code>
<pre style={{fontSize: '0.75rem'}}>
{JSON.stringify(data, null, ' ')}
</pre>
</code>
</div>
}
\ No newline at end of file
const Debug = ({label, data}) => (<div style={{padding: '2rem', border: '1px solid red', margin: '2rem'}}>
<small>{label}</small>
<code>
<pre style={{fontSize: '0.75rem'}}>
{JSON.stringify(data, null, ' ')}
</pre>
</code>
</div>);
Debug.propTypes = {
label: PropTypes.string,
data: PropTypes.any // eslint-disable-line react/forbid-prop-types
};
export default Debug;
import React, {useEffect} from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import {useParams} from 'react-router';
......@@ -16,20 +18,34 @@ const StudioActivity = ({items, loading, error, onInitialLoad}) => {
<div>
<h2>Activity</h2>
{loading && <div>Loading...</div>}
{error && <Debug label="Error" data={error} />}
{error && <Debug
label="Error"
data={error}
/>}
<div>
{items.map((item, index) =>
<Debug label="Activity Item" data={item} key={index} />
(<Debug
label="Activity Item"
data={item}
key={index}
/>)
)}
</div>
</div>
);
};
StudioActivity.propTypes = {
items: PropTypes.array, // eslint-disable-line react/forbid-prop-types
loading: PropTypes.bool,
error: PropTypes.object, // eslint-disable-line react/forbid-prop-types
onInitialLoad: PropTypes.func
};
export default connect(
(state) => activity.selector(state),
(dispatch) => ({
onInitialLoad: (studioId) => dispatch(
state => activity.selector(state),
dispatch => ({
onInitialLoad: studioId => dispatch(
activity.actions.loadMore(activityFetcher.bind(null, studioId, 0)))
})
)(StudioActivity);
......@@ -12,4 +12,4 @@ const StudioComments = () => {
);
};
export default StudioComments;
\ No newline at end of file
export default StudioComments;
import React, {useEffect} from 'react';
import React, {useEffect, useCallback} from 'react';
import PropTypes from 'prop-types';
import {useParams} from 'react-router-dom';
import {connect} from 'react-redux';
import {curators, managers} from './lib/redux-modules'
import {curatorFetcher, managerFetcher} from './lib/fetchers'
import {curators, managers} from './lib/redux-modules';
import {curatorFetcher, managerFetcher} from './lib/fetchers';
import Debug from './debug.jsx';
const StudioCurators = () => {
......@@ -23,20 +24,38 @@ const MemberList = ({studioId, items, error, loading, moreToLoad, onLoadMore}) =
useEffect(() => {
if (studioId && items.length === 0) onLoadMore(studioId, 0);
}, [studioId]);
const handleLoadMore = useCallback(() => onLoadMore(studioId, items.length), [studioId, items.length]);
return <React.Fragment>
{error && <Debug label="Error" data={error} />}
return (<React.Fragment>
{error && <Debug
label="Error"
data={error}
/>}
{items.map((item, index) =>
<Debug label="Member" data={item} key={index} />
(<Debug
label="Member"
data={item}
key={index}
/>)
)}
{loading ? <small>Loading...</small> : (
moreToLoad ?
<button onClick={() => onLoadMore(studioId, items.length)}>
<button onClick={handleLoadMore}>
Load more
</button> :
<small>No more to load</small>
)}
</React.Fragment>
</React.Fragment>);
};
MemberList.propTypes = {
studioId: PropTypes.string,
items: PropTypes.array, // eslint-disable-line react/forbid-prop-types
loading: PropTypes.bool,
error: PropTypes.object, // eslint-disable-line react/forbid-prop-types
moreToLoad: PropTypes.bool,
onLoadMore: PropTypes.func
};
const ManagerList = connect(
......
......@@ -13,15 +13,21 @@ const StudioInfo = () => {
if (!studioId) return;
infoFetcher(studioId)
.then(data => setState({loading: false, error: null, data}))
.catch(error => setState({loading: false, error, data: null}))
.catch(error => setState({loading: false, error, data: null}));
}, [studioId]);
return (
<div>
<h2>Studio Info</h2>
{state.loading && <div>Loading..</div>}
{state.error && <Debug label="Error" data={state.error} />}
<Debug label="Studio Info" data={state.data} />
{state.error && <Debug
label="Error"
data={state.error}
/>}
<Debug
label="Studio Info"
data={state.data}
/>
</div>
);
};
......
import React, {useEffect} from 'react';
import React, {useEffect, useCallback} from 'react';
import PropTypes from 'prop-types';
import {useParams} from 'react-router-dom';
import {connect} from 'react-redux'
import {connect} from 'react-redux';
import {projectFetcher} from './lib/fetchers';
import {projects} from './lib/redux-modules'
import {projects} from './lib/redux-modules';
import Debug from './debug.jsx';
const {actions, selector} = projects;
......@@ -17,17 +18,26 @@ const StudioProjects = ({
if (studioId && items.length === 0) onLoadMore(studioId, 0);
}, [studioId]);
const handleLoadMore = useCallback(() => onLoadMore(studioId, items.length), [studioId, items.length]);
return (
<div>
<h2>Projects</h2>
{error && <Debug label="Error" data={error} />}
{error && <Debug
label="Error"
data={error}
/>}
<div>
{items.map((item, index) =>
<Debug label="Project" data={item} key={index} />
(<Debug
label="Project"
data={item}
key={index}
/>)
)}
{loading ? <small>Loading...</small> : (
moreToLoad ?
<button onClick={() => onLoadMore(studioId, items.length)}>
<button onClick={handleLoadMore}>
Load more
</button> :
<small>No more to load</small>
......@@ -37,15 +47,19 @@ const StudioProjects = ({
);
};
const mapStateToProps = (state) => {
return selector(state);
StudioProjects.propTypes = {
items: PropTypes.array, // eslint-disable-line react/forbid-prop-types
loading: PropTypes.bool,
error: PropTypes.object, // eslint-disable-line react/forbid-prop-types
moreToLoad: PropTypes.bool,
onLoadMore: PropTypes.func
};
const mapDispatchToProps = (dispatch) => {
return {
onLoadMore: (studioId, offset) => dispatch(
actions.loadMore(projectFetcher.bind(null, studioId, offset))
)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(StudioProjects);
\ No newline at end of file
const mapStateToProps = state => selector(state);
const mapDispatchToProps = dispatch => ({
onLoadMore: (studioId, offset) => dispatch(
actions.loadMore(projectFetcher.bind(null, studioId, offset))
)
});
export default connect(mapStateToProps, mapDispatchToProps)(StudioProjects);
import React, {useEffect} from 'react';
import React from 'react';
import {
BrowserRouter as Router,
Switch,
......@@ -22,7 +22,7 @@ import {
curators,
managers,
activity
} from './lib/redux-modules'
} from './lib/redux-modules';
const StudioShell = () => {
const match = useRouteMatch();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment