- implementing immutable.js

This commit is contained in:
2019-07-17 03:21:23 -04:00
parent 8ecf036cc4
commit 434a1ded24
39 changed files with 1123 additions and 187 deletions

27
app/domain/TicketClass.js Normal file
View File

@@ -0,0 +1,27 @@
import { List, Record } from 'immutable';
export default class TicketClass extends Record({
available: 0,
capacity: 0,
endSale: null,
id: null,
itemId: null,
name: null,
price: 0,
startSale: null,
}) {
get isAlmostGone() {
return this.available < (this.capacity * 0.20);
}
get isSoldOut() {
return this.available === 0;
}
}
TicketClass.fromJS = (data = {}) => {
return new TicketClass({
id: data._id,
...data,
});
};