- implementing immutable.js
This commit is contained in:
39
app/domain/Profile.js
Normal file
39
app/domain/Profile.js
Normal 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),
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user