import { Session } from "common" ; import { SessionActions , SessionActionTypes } from "./actions" ; /**
 * Session data
 *
 * The `renewed` flag describes whether the session successfully renewd after
 * a successful login attempt. This is necessary, so we know when the session
 * was actually persisted to local storage.
 */ export interface SessionData extends Session < string > { renewed ? : boolean ; } /**
 * Session state
 */ export type SessionState = SessionData | null ; param state param action export function session ( state = null , action ) { switch ( action . type ) { case SessionActionTypes . INIT : const { id , access } = action . session ; return { id , access , renewed : true } ; case SessionActionTypes . TERMINATE : return null ; default : return state ; } }