* chore(deps-dev): bump typescript from 4.4.4 to 4.7.4 Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.4.4 to 4.7.4. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v4.4.4...v4.7.4) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * tsc * tsc Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom.moor@gmail.com>
55 lines
809 B
TypeScript
55 lines
809 B
TypeScript
import { computed, observable } from "mobx";
|
|
import type { Role } from "@shared/types";
|
|
import ParanoidModel from "./ParanoidModel";
|
|
import Field from "./decorators/Field";
|
|
|
|
class User extends ParanoidModel {
|
|
@Field
|
|
@observable
|
|
id: string;
|
|
|
|
@Field
|
|
@observable
|
|
avatarUrl: string;
|
|
|
|
@Field
|
|
@observable
|
|
name: string;
|
|
|
|
@Field
|
|
@observable
|
|
color: string;
|
|
|
|
@Field
|
|
@observable
|
|
language: string;
|
|
|
|
email: string;
|
|
|
|
isAdmin: boolean;
|
|
|
|
isViewer: boolean;
|
|
|
|
lastActiveAt: string;
|
|
|
|
isSuspended: boolean;
|
|
|
|
@computed
|
|
get isInvited(): boolean {
|
|
return !this.lastActiveAt;
|
|
}
|
|
|
|
@computed
|
|
get role(): Role {
|
|
if (this.isAdmin) {
|
|
return "admin";
|
|
} else if (this.isViewer) {
|
|
return "viewer";
|
|
} else {
|
|
return "member";
|
|
}
|
|
}
|
|
}
|
|
|
|
export default User;
|