Commit 8658d749 authored by Florent Chehab's avatar Florent Chehab

Better POO in modules

parent ff58b6fd
...@@ -7,7 +7,7 @@ import __pick from 'lodash/pick'; ...@@ -7,7 +7,7 @@ import __pick from 'lodash/pick';
import Markdown from '../../shared/Markdown'; import Markdown from '../../shared/Markdown';
import MyComponent from '../../MyComponent'; import Module from '../shared/Module';
import GenericModule from '../shared/GenericModule'; import GenericModule from '../shared/GenericModule';
import GenericGroupModule from '../shared/GenericGroupModule'; import GenericGroupModule from '../shared/GenericGroupModule';
...@@ -47,19 +47,7 @@ function parseRawModelData(rawModelData) { ...@@ -47,19 +47,7 @@ function parseRawModelData(rawModelData) {
} }
class CountryDri extends MyComponent { class CountryDri extends Module {
ignoreInvalidation = true;
componentWillUnmount() {
this.props.invalidateData(true);
}
myComponentDidUpdate() {
if (this.props.countryDri.invalidated && !this.props.countryDri.isLoading) {
this.props.fetchData.countryDri(this.props.countryId);
}
}
myRender() { myRender() {
const countryDriItems = this.getFetchedData('countryDri'); const countryDriItems = this.getFetchedData('countryDri');
const { countries, classes } = this.props; const { countries, classes } = this.props;
......
...@@ -7,7 +7,7 @@ import __pick from 'lodash/pick'; ...@@ -7,7 +7,7 @@ import __pick from 'lodash/pick';
import Markdown from '../../shared/Markdown'; import Markdown from '../../shared/Markdown';
import MyComponent from '../../MyComponent'; import Module from '../shared/Module';
import GenericModule from '../shared/GenericModule'; import GenericModule from '../shared/GenericModule';
import GenericGroupModule from '../shared/GenericGroupModule'; import GenericGroupModule from '../shared/GenericGroupModule';
...@@ -50,19 +50,7 @@ function parseRawModelData(rawModelData) { ...@@ -50,19 +50,7 @@ function parseRawModelData(rawModelData) {
} }
class UniversityDri extends MyComponent { class UniversityDri extends Module {
ignoreInvalidation = true;
componentWillUnmount() {
this.props.invalidateData(true);
}
myComponentDidUpdate() {
if (this.props.universityDri.invalidated && !this.props.universityDri.isLoading) {
this.props.fetchData.universityDri(this.props.univId);
}
}
myRender() { myRender() {
const univDriItems = this.getFetchedData('universityDri'); const univDriItems = this.getFetchedData('universityDri');
const { universities, classes } = this.props; const { universities, classes } = this.props;
......
...@@ -8,7 +8,7 @@ import __pick from 'lodash/pick'; ...@@ -8,7 +8,7 @@ import __pick from 'lodash/pick';
import Markdown from '../../shared/Markdown'; import Markdown from '../../shared/Markdown';
import Typography from '@material-ui/core/Typography'; import Typography from '@material-ui/core/Typography';
import MyComponent from '../../MyComponent'; import Module from '../shared/Module';
import TextLink from '../../other/TextLink'; import TextLink from '../../other/TextLink';
import Grid from '@material-ui/core/Grid'; import Grid from '@material-ui/core/Grid';
import Divider from '@material-ui/core/Divider'; import Divider from '@material-ui/core/Divider';
...@@ -84,11 +84,7 @@ function parseRawModelData(rawModelData) { ...@@ -84,11 +84,7 @@ function parseRawModelData(rawModelData) {
} }
class UniversityGeneral extends MyComponent { class UniversityGeneral extends Module {
componentWillUnmount() {
this.props.invalidateData();
}
myRender() { myRender() {
const univInfos = this.getFetchedData('universitiesEl'); const univInfos = this.getFetchedData('universitiesEl');
const { classes } = this.props; const { classes } = this.props;
......
...@@ -5,7 +5,7 @@ import compose from 'recompose/compose'; ...@@ -5,7 +5,7 @@ import compose from 'recompose/compose';
import { connect } from "react-redux"; import { connect } from "react-redux";
import __pick from 'lodash/pick'; import __pick from 'lodash/pick';
import MyComponent from '../../MyComponent'; import Module from '../shared/Module';
import GenericModule from '../shared/GenericModule'; import GenericModule from '../shared/GenericModule';
import GenericGroupModule from '../shared/GenericGroupModule'; import GenericGroupModule from '../shared/GenericGroupModule';
...@@ -65,19 +65,7 @@ function parseRawModelData(rawModelData) { ...@@ -65,19 +65,7 @@ function parseRawModelData(rawModelData) {
} }
class UniversityScholarships extends MyComponent { class UniversityScholarships extends Module {
ignoreInvalidation = true;
componentWillUnmount() {
this.props.invalidateData(true);
}
myComponentDidUpdate() {
if (this.props.universityScholarships.invalidated && !this.props.universityScholarships.isLoading) {
this.props.fetchData.universityScholarships(this.props.univId);
}
}
myRender() { myRender() {
const univScholarshipsItems = this.getFetchedData('universityScholarships'); const univScholarshipsItems = this.getFetchedData('universityScholarships');
const { universities, currencies, classes } = this.props; const { universities, currencies, classes } = this.props;
......
...@@ -17,7 +17,7 @@ import LocalFloristIcon from '@material-ui/icons/LocalFlorist'; ...@@ -17,7 +17,7 @@ import LocalFloristIcon from '@material-ui/icons/LocalFlorist';
import GenericModule from '../shared/GenericModule'; import GenericModule from '../shared/GenericModule';
import MyComponent from '../../MyComponent'; import Module from '../shared/Module';
import dateStrToStr from '../../../utils/dateStrToStr'; import dateStrToStr from '../../../utils/dateStrToStr';
...@@ -126,12 +126,8 @@ function parseRawModelData(rawModelData) { ...@@ -126,12 +126,8 @@ function parseRawModelData(rawModelData) {
} }
class UniversitySemestersDates extends MyComponent { class UniversitySemestersDates extends Module {
componentWillUnmount() {
this.props.invalidateData();
}
myRender() { myRender() {
const semestersDates = this.getFetchedData('universitiesSemestersDatesEl'); const semestersDates = this.getFetchedData('universitiesSemestersDatesEl');
const { classes } = this.props; const { classes } = this.props;
......
import React from 'react';
import MyComponent from '../../MyComponent';
class Module extends MyComponent {
// prevent hard reset of module when refetching
ignoreInvalidation = true;
componentWillUnmount() {
this.props.invalidateData(true);
}
myComponentDidUpdate() {
this.fetchAbleProps.map((propKey) => {
if (this.props[propKey].invalidated && !this.props[propKey].isLoading) {
this.props.fetchData[propKey](this.props.univId);
}
})
}
}
export default Module;
\ No newline at end of file
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