32 lines
591 B
TypeScript

import { makeAutoObservable } from 'mobx';
import { RootStore } from './root';
export type User = {
displayName: string;
username: string;
department: string;
position: string;
mail: string;
domain: string;
};
export class UserStore {
root: RootStore;
user?: User = undefined;
constructor(rootStore: RootStore) {
makeAutoObservable(this);
this.root = rootStore;
}
hydrate = (user: User) => {
this.user = user;
};
getDomainName() {
if (this.user) {
const { username, domain } = this.user;
return `${domain}\\${username}`;
}
}
}