const React = require('react'); const createClass = require('create-react-class'); const Nav = require('naturalcrit/nav/nav.jsx'); const Account = createClass({ displayName : 'AccountNavItem', getInitialState : function() { return { url : '' }; }, componentDidMount : function(){ if(typeof window !== 'undefined'){ this.setState({ url : window.location.href }); } }, handleLogout : function(){ if(confirm('Are you sure you want to log out?')) { document.cookie = `nc_session=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;samesite=lax;${window.domain ? `domain=${window.domain}` : ''}`; window.location = '/'; }; }, render : function(){ if(global.account){ return {global.account.username} brews logout ; } return login ; } }); module.exports = Account;