import RootStore from './RootStore' ; import { observable , runInAction } from 'mobx' ; import { LoginRequest , User } from '@appkit-common/model/auth' ; import { login } from '@client/model/serverApi' ; export default class UserStore { rootStore : RootStore ; @ observable loggedIn : boolean = false ; @ observable user : User ; @ observable loginModalOpen : boolean = false ; logout = async ( ) => { console . log ( `do logout` ) ; runInAction ( ( ) => { this . loggedIn = false ; } ) ; } ; login = async ( req ) => { const res = await login ( req ) ; console . log ( `got res ${ JSON . stringify ( res ) }` ) ; runInAction ( ( ) => { this . user = res . user ; this . loggedIn = true ; } ) ; } ; constructor ( rootStore ) { this . rootStore = rootStore ; } }