aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/User.ts
diff options
context:
space:
mode:
authorLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-08-17 05:07:38 +0530
committerLibravatar GitHub <noreply@github.com>2021-08-17 05:07:38 +0530
commit0fbee32c27a6efdfe88534303922d189ddbba817 (patch)
tree2b9dddba64ff1519e293c64b3b42b4d9172ec4d3 /src/models/User.ts
parentRevert "chore: update outdated node_modules (#1807)" (diff)
downloadferdium-app-0fbee32c27a6efdfe88534303922d189ddbba817.tar.gz
ferdium-app-0fbee32c27a6efdfe88534303922d189ddbba817.tar.zst
ferdium-app-0fbee32c27a6efdfe88534303922d189ddbba817.zip
Typescript conversion (#1805)
Diffstat (limited to 'src/models/User.ts')
-rw-r--r--src/models/User.ts82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/models/User.ts b/src/models/User.ts
new file mode 100644
index 000000000..8c6c2b1c9
--- /dev/null
+++ b/src/models/User.ts
@@ -0,0 +1,82 @@
1import { observable } from 'mobx';
2
3interface IUser {
4 id: string | null;
5 email: string | null;
6 firstname: string | null;
7 lastname: string | null;
8 organization: string | null;
9 accountType: string | null;
10 beta: boolean;
11 donor: object;
12 isDonor: boolean;
13 isMiner: boolean;
14 locale: boolean;
15 isSubscriptionOwner: boolean;
16 hasSubscription: boolean;
17 hadSubscription: boolean;
18 team: object;
19}
20
21// TODO: Need to cleanup these fields since we have removed the tiers of the paid plans from Ferdi
22export default class User {
23 id: string | null = null;
24
25 @observable email: string | null = null;
26
27 @observable firstname: string | null = null;
28
29 @observable lastname: string | null = null;
30
31 @observable organization: string | null = null;
32
33 @observable accountType: string | null = null;
34
35 @observable emailIsConfirmed = true;
36
37 // TODO: Need to delete references to 'subscription' and 'donor'
38 // better assume it's confirmed to avoid noise
39 @observable subscription = {};
40
41 @observable isSubscriptionOwner = false;
42
43 @observable hasSubscription = true;
44
45 @observable hadSubscription = false;
46
47 @observable beta = false;
48
49 @observable donor = {};
50
51 @observable isDonor = false;
52
53 @observable isMiner = false;
54
55 @observable locale = false;
56
57 @observable team = {};
58
59 constructor(data: IUser) {
60 if (!data.id) {
61 throw Error('User requires Id');
62 }
63
64 this.id = data.id;
65 this.email = data.email || this.email;
66 this.firstname = data.firstname || this.firstname;
67 this.lastname = data.lastname || this.lastname;
68 this.organization = data.organization || this.organization;
69 this.accountType = data.accountType || this.accountType;
70 this.beta = data.beta || this.beta;
71 this.donor = data.donor || this.donor;
72 this.isDonor = data.isDonor || this.isDonor;
73 this.isMiner = data.isMiner || this.isMiner;
74 this.locale = data.locale || this.locale;
75
76 this.isSubscriptionOwner = data.isSubscriptionOwner || this.isSubscriptionOwner;
77 this.hasSubscription = data.hasSubscription || this.hasSubscription;
78 this.hadSubscription = data.hadSubscription || this.hadSubscription;
79
80 this.team = data.team || this.team;
81 }
82}