import * as React from "react" ; import { branch , compose , lifecycle , pure , renderComponent , setDisplayName } from "recompose" ; import { LeaveRequest } from "common" ; import { Loading } from "components" ; import { WithFormSubmit , withFormSubmit , withRememberMe , WithRememberMeDispatch , WithSession , withSession } from "enhancers" ; import { LeaveSuccess } from "./LeaveSuccess" ; /**
 * Lifecycle properties
 */ type LifecycleProps = WithSession & WithRememberMeDispatch & WithFormSubmit < LeaveRequest > ; /**
 * Branch properties
 */ type BranchProps = WithFormSubmit < LeaveRequest > ; return export const Render = ( ) => < Loading />; return export function enhance ( ) { return compose ( withSession ( ) , withRememberMe ( ) , withFormSubmit < LeaveRequest > ( { message : "You signed out of your account" , authorize : true } ) , lifecycle < LifecycleProps , { } > ( { componentWillMount ( ) { const { setRememberMeFailed } = this . props ; setRememberMeFailed ( ) ; } , async componentDidMount ( ) { const { submit , terminateSession } = this . props ; await submit ( ) ; terminateSession ( ) ; } } ) , branch < BranchProps > ( ( { form } ) => form . success || Boolean ( form . err ) , renderComponent ( LeaveSuccess ) ) , pure , setDisplayName ( "Leave" ) ) ; } /**
 * Sign out component
 */ export const Leave = enhance ( ) ( Render ) ;