Bin
2025-12-17 05a69820e0c402b0b33c063d3b922f0a0571cbbb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { types } from "mobx-state-tree";
import { camelizeKeys } from "../utils/helpers";
import { StringOrNumberID } from "./types";
 
export const User = types
  .model("User", {
    id: StringOrNumberID,
    firstName: types.string,
    lastName: types.string,
    username: types.string,
    email: types.string,
    lastActivity: types.string,
    avatar: types.maybeNull(types.string),
    initials: types.string,
  })
  .views((self) => ({
    get fullName() {
      return [self.firstName, self.lastName]
        .filter((n) => !!n)
        .join(" ")
        .trim();
    },
 
    get displayName() {
      return self.fullName || (self.username ? self.username : self.email);
    },
  }))
  .preProcessSnapshot((sn) => {
    return camelizeKeys(sn);
  });