Commit 4fe1bdf2 authored by Florent Chehab's avatar Florent Chehab
Browse files

Cleaning

parent 0e42118e
......@@ -19,17 +19,7 @@ import Typography from "@material-ui/core/Typography";
import isUrl from "../../../../utils/isUrl";
// eslint-disable-next-line no-unused-vars
const styles = theme => ({
container: {
display: "flex",
flexWrap: "wrap",
},
usefulLinkContainer: {
display: "flex",
flexWrap: "wrap",
}
});
class UsefulLinksField extends Field {
......@@ -239,6 +229,18 @@ UsefulLinksField.propTypes = {
descriptionMaxLength: PropTypes.number.isRequired
};
const styles = {
container: {
display: "flex",
flexWrap: "wrap",
},
usefulLinkContainer: {
display: "flex",
flexWrap: "wrap",
}
};
export default compose(
withStyles(styles, { withTheme: true }),
)(UsefulLinksField);
import React from "react";
// import PropTypes from "prop-types";
import withStyles from "@material-ui/core/styles/withStyles";
import CustomComponentForAPI from "../../CustomComponentForAPI";
import React, { Component } from "react";
import GenericGroupModules from "../shared/GenericGroupModule";
const styles = theme => ({ // eslint-disable-line no-unused-vars
root: {},
});
class CampusesCitiesTab extends CustomComponentForAPI {
customRender() {
/**
* Tab on the university page related to Campuses and cities
*
* @class CampusesCitiesTab
* @extends {Component}
*/
class CampusesCitiesTab extends Component {
render() {
return (
<div>
<GenericGroupModules groupTitle={"Logement"}/>
<GenericGroupModules groupTitle={"Vie étudiante"}/>
<GenericGroupModules groupTitle={"Vie quotidienne (et transport)"}/>
<GenericGroupModules groupTitle={"Autre chose ?"}/>
<GenericGroupModules groupTitle={"Logement"} />
<GenericGroupModules groupTitle={"Vie étudiante"} />
<GenericGroupModules groupTitle={"Vie quotidienne (et transport)"} />
<GenericGroupModules groupTitle={"Autre chose ?"} />
</div>
);
}
}
// CampusesCitiesTab.propTypes = {
// classes: PropTypes.object.isRequired,
// univId: PropTypes.string.isRequired,
// };
export default withStyles(styles)(CampusesCitiesTab);
export default CampusesCitiesTab;
import React from "react";
import React, { Component } from "react";
import PropTypes from "prop-types";
import withStyles from "@material-ui/core/styles/withStyles";
import CustomComponentForAPI from "../../CustomComponentForAPI";
import compose from "recompose/compose";
import Grid from "@material-ui/core/Grid";
import UniversityGeneral from "../modules/UniversityGeneral";
import UniversitySemestersDates from "../modules/UniversitySemestersDates";
import UniversityDri from "../modules/UniversityDri";
......@@ -14,23 +12,16 @@ import CountryDri from "../modules/CountryDri";
import withWidth, { isWidthUp } from "@material-ui/core/withWidth";
import UnivInfoConsumer from "../shared/UnivInfoConsumer";
const styles = theme => ({ // eslint-disable-line no-unused-vars
root1: {
display: "flex",
width: "90%",
marginLeft: "auto",
marginRight: "auto"
},
root2: {
display: "flex",
width: "100%"
},
});
class GeneralInfoTab extends CustomComponentForAPI {
/**
* Main tab of the university page
*
* @class GeneralInfoTab
* @extends {Component}
*/
class GeneralInfoTab extends Component {
customRender() {
render() {
const { classes, theme } = this.props;
// Resizing with the grid was causing weird gaps so we rerender depending on the width
if (isWidthUp("lg", this.props.width)) {
......@@ -119,8 +110,21 @@ class GeneralInfoTab extends CustomComponentForAPI {
GeneralInfoTab.propTypes = {
classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
width: PropTypes.any // TODO better
};
const styles = {
root1: {
display: "flex",
width: "90%",
marginLeft: "auto",
marginRight: "auto"
},
root2: {
display: "flex",
width: "100%"
},
};
export default compose(
withWidth({ noSSR: true }),
......
import React from "react";
// import PropTypes from "prop-types";
import withStyles from "@material-ui/core/styles/withStyles";
import CustomComponentForAPI from "../../CustomComponentForAPI";
import React, { Component } from "react";
import GenericGroupModules from "../shared/GenericGroupModule";
// eslint-disable-next-line no-unused-vars
const styles = theme => ({
root: {},
});
class MoreTab extends CustomComponentForAPI {
/**
* Tab on the university page containing "more" information
*
* @class MoreTab
* @extends {Component}
*/
class MoreTab extends Component {
customRender() {
render() {
return (
<div>
<GenericGroupModules groupTitle={"Administratif"} />
<GenericGroupModules groupTitle={"Assurances"} />
<GenericGroupModules groupTitle={"Transport"} />
<GenericGroupModules groupTitle={"Culture"}/>
<GenericGroupModules groupTitle={"Culture"} />
<GenericGroupModules groupTitle={"Tourisme"} />
<GenericGroupModules groupTitle={"Photos"}/>
<GenericGroupModules groupTitle={"Autres"}/>
<GenericGroupModules groupTitle={"Photos"} />
<GenericGroupModules groupTitle={"Autres"} />
</div>
);
}
}
// MoreTab.propTypes = {
// classes: PropTypes.object.isRequired,
// univId: PropTypes.string.isRequired,
// };
export default withStyles(styles)(MoreTab);
export default MoreTab;
import React from "react";
// import PropTypes from "prop-types";
import withStyles from "@material-ui/core/styles/withStyles";
import CustomComponentForAPI from "../../CustomComponentForAPI";
import React, {Component} from "react";
import PreviousDeparture from "../modules/PreviousDeparture";
import GenericModule from "../shared/GenericModule";
const styles = theme => ({ // eslint-disable-line no-unused-vars
root: {},
});
class PreviousDeparturesTab extends CustomComponentForAPI {
/**
* Tab on the university page containing information related to previous departure
*
* @class PreviousDeparturesTab
* @extends {Component}
*/
class PreviousDeparturesTab extends Component {
customRender() {
render() {
return (
<GenericModule title="Florent Chehab | GI05~FDD | Automne 2018~échange">
<PreviousDeparture />
......@@ -22,9 +22,4 @@ class PreviousDeparturesTab extends CustomComponentForAPI {
}
// PreviousDeparturesTab.propTypes = {
// classes: PropTypes.object.isRequired,
// univId: PropTypes.string.isRequired,
// };
export default withStyles(styles)(PreviousDeparturesTab);
export default PreviousDeparturesTab;
import React from "react";
import React, { Component } from "react";
import PropTypes from "prop-types";
import withStyles from "@material-ui/core/styles/withStyles";
import CustomComponentForAPI from "../../CustomComponentForAPI";
import compose from "recompose/compose";
import Grid from "@material-ui/core/Grid";
import UniversityScholarships from "../modules/UniversityScholarships";
import CountryScholarships from "../modules/CountryScholarships";
import UnivInfoConsumer from "../shared/UnivInfoConsumer";
const styles = theme => ({ // eslint-disable-line no-unused-vars
root: {
display: "flex",
width: "90%",
marginLeft: "auto",
marginRight: "auto"
},
});
class ScholarshipsTab extends CustomComponentForAPI {
/**
* Tab on the university page containing information related to scholarship
*
* @class ScholarshipsTab
* @extends {Component}
*/
class ScholarshipsTab extends Component {
customRender() {
render() {
const { classes } = this.props;
return (
<div className={classes.root}>
......@@ -51,10 +46,17 @@ class ScholarshipsTab extends CustomComponentForAPI {
ScholarshipsTab.propTypes = {
classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
};
const styles = {
root: {
display: "flex",
width: "90%",
marginLeft: "auto",
marginRight: "auto"
},
};
export default compose(
withStyles(styles, { withTheme: true }),
withStyles(styles),
)(ScholarshipsTab);
import React from "react";
// import PropTypes from "prop-types";
import withStyles from "@material-ui/core/styles/withStyles";
import CustomComponentForAPI from "../../CustomComponentForAPI";
import React, { Component } from "react";
import GenericGroupModules from "../shared/GenericGroupModule";
const styles = theme => ({ // eslint-disable-line no-unused-vars
});
class UniversityMoreTab extends CustomComponentForAPI {
customRender() {
/**
* Tab containing specific comments about the unviversity
*
* @class UniversityMoreTab
* @extends {Component}
*/
class UniversityMoreTab extends Component {
render() {
return (
<div>
<GenericGroupModules groupTitle={"Partenariats spécifiques"} />
......@@ -19,12 +19,7 @@ class UniversityMoreTab extends CustomComponentForAPI {
</div>
);
}
}
// UniversityMoreTab.propTypes = {
// classes: PropTypes.object.isRequired,
// univId: PropTypes.string.isRequired,
// };
export default withStyles(styles)(UniversityMoreTab);
export default UniversityMoreTab;
/*
* This file contains the redux reducers related to the filter component
*/
import { SAVE_SELECTED_UNIVERSITIES, SAVE_FILTER_CONFIG } from "../actions/action-types";
/**
* Reducer: Save the selected universities
*
* @export
* @param {array} [state=[]]
* @param {string} action
* @returns
*/
export function saveSelectedUniversities(state = [], action) {
switch (action.type) {
case SAVE_SELECTED_UNIVERSITIES:
return {
selection: action.new_selection,
};
case SAVE_SELECTED_UNIVERSITIES:
return {
selection: action.newSelection,
};
default:
return state;
default:
return state;
}
}
/**
* Reducer: Save the filter config
*
* @export
* @param {object} [state={ countriesFilter: { selectedItems: [], inputValue: "" } }]
* @param {string} action
* @returns
*/
export function saveFilterConfig(state = { countriesFilter: { selectedItems: [], inputValue: "" } }, action) {
switch (action.type) {
case SAVE_FILTER_CONFIG:
return Object.assign({}, state, action.config);
case SAVE_FILTER_CONFIG:
return Object.assign({}, state, action.config);
default:
return state;
default:
return state;
}
}
import { combineReducers } from "redux";
import { saveMainMapPosition } from "./map";
import { saveSelectedUniversities } from "./filter";
import { saveFilterConfig } from "./filter";
import { saveMainMapStatus } from "./map";
import { saveSelectedUniversities, saveFilterConfig } from "./filter";
import { saveAppTheme, saveAppColorPicker } from "./theme";
import { saveUniversityBeingViewed } from "./universityPage";
import { apiReducers } from "../api/buildApiActionsAndReducers";
// Combine the reducers related to the app
const app = combineReducers({
mainMap: saveMainMapPosition,
mainMap: saveMainMapStatus,
selectedUniversities: saveSelectedUniversities,
filter: saveFilterConfig,
appTheme: saveAppTheme,
......@@ -16,8 +16,10 @@ const app = combineReducers({
universityBeingViewed: saveUniversityBeingViewed,
});
// Get the redux reducer for all api related stuff
const api = combineReducers(apiReducers);
// Create the final reduce reducer
const rootReducer = combineReducers({
api,
app
......
import { SAVE_MAIN_MAP_POSITION } from "../actions/action-types";
/*
* This file contains the redux reducers related to the map component
*/
export function saveMainMapPosition(state = { center: [0, 2], zoom: 2, selected_layer: "OpenStreetMap France" }, action) {
import { SAVE_MAIN_MAP_STATUS } from "../actions/action-types";
/**
* Reducer: save map status/state
*
* @export
* @param {object} [state={ center: [0, 2], zoom: 2, selectedLayer: "OpenStreetMap France" }]
* @param {string} action
* @returns
*/
export function saveMainMapStatus(state = { center: [0, 2], zoom: 2, selectedLayer: "OpenStreetMap France" }, action) {
switch (action.type) {
case SAVE_MAIN_MAP_POSITION:
return {
center: action.new_position.center,
zoom: action.new_position.zoom,
selected_layer: action.new_position.selected_layer
};
case SAVE_MAIN_MAP_STATUS:
return {
center: action.newStatus.center,
zoom: action.newStatus.zoom,
selectedLayer: action.newStatus.selectedLayer
};
default:
return state;
default:
return state;
}
}
import { SAVE_SELECTED_UNIVERSITIES, SAVE_FILTER_CONFIG } from "../actions/action-types";
/*
* This file contains the redux reducers related to the search component
* TODO: check what is done in this file, seem not to be super coherent and a mix with filter
*/
export function saveSelectedUniversities(state = [], action) {
switch (action.type) {
case SAVE_SELECTED_UNIVERSITIES:
return {
selection: action.new_selection,
};
// import { SAVE_SELECTED_UNIVERSITIES, SAVE_FILTER_CONFIG } from "../actions/action-types";
default:
return state;
}
}
// /**
// * Reducer: save the selected universities
// *
// * @export
// * @param {array} [state=[]]
// * @param {string} action
// * @returns
// */
// export function saveSelectedUniversities(state = [], action) {
// switch (action.type) {
// case SAVE_SELECTED_UNIVERSITIES:
// return {
// selection: action.newSelection,
// };
export function saveFilterConfig(state = { countriesFilter: { selectedItems: [], inputValue: "" } }, action) {
switch (action.type) {
case SAVE_FILTER_CONFIG:
return Object.assign({}, state, action.config);
// default:
// return state;
// }
// }
default:
return state;
}
}
// export function saveFilterConfig(state = { countriesFilter: { selectedItems: [], inputValue: "" } }, action) {
// switch (action.type) {
// case SAVE_FILTER_CONFIG:
// return Object.assign({}, state, action.config);
// default:
// return state;
// }
// }
/*
* This file contains the redux reducers related to the theme provider and color picker components
*/
import { SAVE_APP_THEME, SAVE_APP_COLOR_PICKER } from "../actions/action-types";
import indigo from "@material-ui/core/colors/indigo";
import pink from "@material-ui/core/colors/pink";
// Default theme applied to the site
const defaultTheme = {
palette: {
primary: {main: pink[500]},
secondary: {main: indigo["A400"]},
primary: { main: pink[500] },
secondary: { main: indigo["A400"] },
type: "dark"
}
};
export function saveAppTheme(state = { theme: defaultTheme, savedAt: Date.now() }, action) {
switch (action.type) {
case SAVE_APP_THEME:
return {
theme: action.theme,
savedAt: Date.now()
};
default:
return state;
}
}
// Default color picker state
const defaultColorPicker = {
primary: defaultTheme.palette.primary.main,
secondary: defaultTheme.palette.secondary.main,
......@@ -35,11 +27,41 @@ const defaultColorPicker = {
updatedAt: Date.now()
};
/**
* Reducer: save app theme
*
* @export
* @param {object} [state={ theme: defaultTheme, savedAt: Date.now() }]
* @param {string} action
* @returns
*/
export function saveAppTheme(state = { theme: defaultTheme, savedAt: Date.now() }, action) {
switch (action.type) {
case SAVE_APP_THEME:
return {
theme: action.theme,
savedAt: Date.now()
};
default:
return state;
}
}
/**
* Reducer: save the color picker state
*
* @export
* @param {object} [state=defaultColorPicker]
* @param {string} action
* @returns
*/
export function saveAppColorPicker(state = defaultColorPicker, action) {
switch (action.type) {
case SAVE_APP_COLOR_PICKER: