Commit 57495259 authored by Paul Kaplan's avatar Paul Kaplan

Fix lint and remove unused code

parent a97263cb
...@@ -32,26 +32,26 @@ const studioReducer = (state, action) => { ...@@ -32,26 +32,26 @@ const studioReducer = (state, action) => {
} }
switch (action.type) { switch (action.type) {
case 'SET_INFO': case 'SET_INFO':
return { return {
...state, ...state,
...action.info ...action.info
}; };
case 'SET_ROLES': case 'SET_ROLES':
return { return {
...state, ...state,
...action.roles ...action.roles
}; };
case 'SET_FETCH_STATUS': case 'SET_FETCH_STATUS':
if (action.error) { if (action.error) {
log.error(action.error); log.error(action.error);
} }
return { return {
...state, ...state,
[action.fetchType]: action.fetchStatus [action.fetchType]: action.fetchStatus
}; };
default: default:
return state; return state;
} }
}; };
...@@ -62,19 +62,19 @@ const setFetchStatus = (fetchType, fetchStatus, error) => ({ ...@@ -62,19 +62,19 @@ const setFetchStatus = (fetchType, fetchStatus, error) => ({
error error
}); });
const setInfo = (info) => ({ const setInfo = info => ({
type: 'SET_INFO', type: 'SET_INFO',
info: info info: info
}); });
const setRoles = (roles) => ({ const setRoles = roles => ({
type: 'SET_ROLES', type: 'SET_ROLES',
roles: roles roles: roles
}); });
const getInfo = (studioId) => (dispatch => { const getInfo = studioId => (dispatch => {
dispatch(setFetchStatus('infoStatus', Status.FETCHING)); dispatch(setFetchStatus('infoStatus', Status.FETCHING));
api({uri: `/studios/${studioId}`,}, (err, body, res) => { api({uri: `/studios/${studioId}`}, (err, body, res) => {
if (err || typeof body === 'undefined' || res.statusCode !== 200) { if (err || typeof body === 'undefined' || res.statusCode !== 200) {
dispatch(setFetchStatus('infoStatus', Status.ERROR, err)); dispatch(setFetchStatus('infoStatus', Status.ERROR, err));
return; return;
...@@ -117,4 +117,4 @@ module.exports = { ...@@ -117,4 +117,4 @@ module.exports = {
Status, Status,
getInfo, getInfo,
getRoles getRoles
} };
const ITEM_LIMIT = 4; const ITEM_LIMIT = 4;
const infoFetcher = studioId => fetch(`${process.env.API_HOST}/studios/${studioId}`)
.then(response => response.json());
const projectFetcher = (studioId, offset) => const projectFetcher = (studioId, offset) =>
fetch(`${process.env.API_HOST}/studios/${studioId}/projects?limit=${ITEM_LIMIT}&offset=${offset}`) fetch(`${process.env.API_HOST}/studios/${studioId}/projects?limit=${ITEM_LIMIT}&offset=${offset}`)
.then(response => response.json()) .then(response => response.json())
...@@ -25,7 +22,6 @@ const activityFetcher = studioId => ...@@ -25,7 +22,6 @@ const activityFetcher = studioId =>
export { export {
activityFetcher, activityFetcher,
infoFetcher,
projectFetcher, projectFetcher,
curatorFetcher, curatorFetcher,
managerFetcher managerFetcher
......
...@@ -3,7 +3,6 @@ import PropTypes from 'prop-types'; ...@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import {useParams} from 'react-router-dom'; import {useParams} from 'react-router-dom';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import Debug from './debug.jsx'; import Debug from './debug.jsx';
import {Status as SessionStatus} from '../../redux/session';
import {getInfo, getRoles} from '../../redux/studio'; import {getInfo, getRoles} from '../../redux/studio';
const StudioInfo = ({username, studio, token, onLoadInfo, onLoadRoles}) => { const StudioInfo = ({username, studio, token, onLoadInfo, onLoadRoles}) => {
...@@ -33,11 +32,13 @@ StudioInfo.propTypes = { ...@@ -33,11 +32,13 @@ StudioInfo.propTypes = {
token: PropTypes.string, token: PropTypes.string,
studio: PropTypes.shape({ studio: PropTypes.shape({
// Fill this in as the data is used, just for demo now // Fill this in as the data is used, just for demo now
}) }),
onLoadInfo: PropTypes.func,
onLoadRoles: PropTypes.func
}; };
export default connect( export default connect(
(state) => { state => {
const user = state.session.session.user; const user = state.session.session.user;
return { return {
studio: state.studio, studio: state.studio,
...@@ -45,8 +46,8 @@ export default connect( ...@@ -45,8 +46,8 @@ export default connect(
token: user && user.token token: user && user.token
}; };
}, },
(dispatch) => ({ dispatch => ({
onLoadInfo: (studioId) => dispatch(getInfo(studioId)), onLoadInfo: studioId => dispatch(getInfo(studioId)),
onLoadRoles: (studioId, username, token) => dispatch( onLoadRoles: (studioId, username, token) => dispatch(
getRoles(studioId, username, token)) getRoles(studioId, username, token))
}) })
......
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