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