trc-client-core
Version:
The core of the TRC Client
56 lines (53 loc) • 2.15 kB
JSX
var _ = require('lodash');
var RegistrationMixin = {
waitlistCutoff(soData) {
return soData.get('soMaximumEnrolment') - soData.get('otherEnrolledParticipants');
},
remainingPlaces(registrations, soData) {
var registrationsSize = 0;
if(registrations) {
registrationsSize = registrations.size;
}
return soData.get('soMaximumEnrolment') - (soData.get('otherEnrolledParticipants') + registrationsSize);
},
currentStatus(registration, key, soData) {
if(registration.get('status')) {
return registration.get('status');
}
else if(key >= this.waitlistCutoff(soData)) {
return 'WAITLISTING';
}
},
renderSOItemsModalList() {
return _.map(this.props.soData, (data, key)=> {
// Enrolling from waitlist. Ridiculousness
// The views above are modifying the data structure
if(data === '') {
return <div key={key} className="row-bottom">{key}</div>;
}
var soItem = data[0];
var colorClass = '';
if(data.length) {
if(soItem.soRemainingSpots === 'FULL') {
colorClass = 't-red';
} else if (soItem.soSpots < data.length) {
colorClass = 't-yellow';
}
return (
<div key={key} className="row-bottom">
<h3 className={`hug ${colorClass}`}>{soItem.facility}<span className="right">{soItem.soRemainingSpots}</span></h3>
<div className="hug t-muted">{soItem.date}</div>
<ul className="lst-points">
{data.map((person, subkey) => {
if(!person.alreadyEnrolled) {
return <li key={subkey}>{person.name}</li>;
}
})}
</ul>
</div>
);
}
});
}
};
module.exports = RegistrationMixin;