ih-portal
Version:
A project for connecting interaction hub services with catalyst-ui components
58 lines (46 loc) • 1.39 kB
JSX
import React, { Component, PropTypes } from 'react';
import { CourseHistory } from 'catalyst-ui';
export default class CourseHistoryProv extends Component {
constructor() {
super(...arguments);
this.fetch = this.fetch.bind(this);
this.invalidate = this.invalidate.bind(this);
}
componentDidMount() {
const { courseHistory } = this.props;
if (!courseHistory || (courseHistory.lastAction && courseHistory.lastAction.status === 'error') || !courseHistory.data) {
this.fetch();
}
}
fetch() {
const requestParams = {
url: __SCHEDULE_URL__,
auth: [__USERNAME__, __PASSWORD__],
};
const term = '';
const mode = '2';
const acadCareer = '';
this.props.fetch(requestParams, term, mode, acadCareer);
}
invalidate() {
const requestParams = {
url: __SCHEDULE_URL__,
auth: [__USERNAME__, __PASSWORD__],
};
const term = '';
const mode = '2';
const acadCareer = '';
this.props.invalidate(requestParams, term, mode , acadCareer);
}
render() {
const { data } = this.props;
return (
<CourseHistory coursesData={data.data} isFetching={data.isFetching}/>
);
}
}
CourseHistoryProv.propTypes = {
data: PropTypes.object,
fetch: PropTypes.func.isRequired,
invalidate: PropTypes.func.isRequired,
};