ih-portal
Version:
A project for connecting interaction hub services with catalyst-ui components
60 lines (45 loc) • 1.33 kB
JSX
import React, { Component, PropTypes } from 'react';
import { ClassSchedule } from 'catalyst-ui';
export default class ClassScheduleProv extends Component {
constructor() {
super(...arguments);
this.fetch = this.fetch.bind(this);
this.invalidate = this.invalidate.bind(this);
}
componentDidMount() {
const { classSchedule } = this.props;
if (!classSchedule || (classSchedule.lastAction && classSchedule.lastAction.status === 'error') || !classSchedule.data) {
this.fetch();
}
}
fetch() {
const requestParams = {
url: __STUDENT_ACCOUNT_URL__,
auth: [__USERNAME__, __PASSWORD__],
};
this.props.fetch(requestParams);
}
invalidate() {
const requestParams = {
url: __STUDENT_ACCOUNT_URL__,
auth: [__USERNAME__, __PASSWORD__],
};
this.props.invalidate(requestParams);
}
render() {
const data = this.props.classSchedule;
var props = {};
props.isFetching = data.isFetching;
if (data.faultMessages) {
props.Fault = data.faultMessages;
}
return (
<ClassSchedule {...props} />
);
}
}
ClassScheduleProv.propTypes = {
classSchedule: PropTypes.object,
fetch: PropTypes.func.isRequired,
invalidate: PropTypes.func.isRequired,
};