- 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

39
app/domain/Profile.js Normal file
View File

@@ -0,0 +1,39 @@
import { List, Record } from 'immutable';
export default class Profile extends Record({
addresses: new List(),
avatar: null,
email: null,
firstName: null,
generatedNomDeBid: false,
hasLinkedApple: false,
hasLinkedFacebook: false,
hasLinkedGoogle: false,
hasLocalAccount: false,
id: null,
isAllowedToBid: false,
isOrganizationEmployee: false,
isVerified: false,
lastName: null,
nomDeBid: null,
organizationIdentifier: null,
paymentToken: null,
phones: new List(),
}) {
get canBid() {
return this.isAllowedToBid && this.paymentToken !== null;
}
get fullName() {
return `${this.firstName} ${this.lastName}`;
}
}
Profile.fromJS = (data = {}) => {
return new Profile({
id: data._id,
...data,
addresses: new List(data.addresses),
phones: new List(data.phones),
});
};