Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced dropdown with buttons #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 37 additions & 22 deletions packages/example-forum/lib/components/users/UsersAccountMenu.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
import { Components, registerComponent } from 'meteor/vulcan:core';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'meteor/vulcan:i18n';
import { STATES } from 'meteor/vulcan:accounts';
import { registerComponent } from 'meteor/vulcan:core'
import React, { Component } from 'react'
import { withApollo } from 'react-apollo';
import { Accounts } from 'meteor/accounts-base'

const UsersAccountMenu = ({ state }) => (
<Components.Dropdown
variant="default"
id="accounts-dropdown"
className="users-account-menu"
trigger={
<div className="dropdown-toggle-inner">
<Components.Icon name="user" />
<FormattedMessage id="users.sign_up_log_in" />
</div>
}
pullRight
menuContents={<Components.AccountsLoginForm formState={state ? STATES[state] : STATES.SIGN_UP} />}
/>
);
class UsersAccountMenu extends Component {
login = () => {
Meteor.loginWithGithub(null, error => {
if (error) {
// eslint-disable-next-line no-console
console.log(error)
if (error instanceof Accounts.LoginCancelledError) {
// do nothing
} else {
const errorId = `accounts.error_${error.reason
.toLowerCase()
.replace(/ /g, '_')}`

alert(errorId)
}
return
}

this.props.client.resetStore()
})

}

UsersAccountMenu.displayName = 'UsersAccountMenu';
render() {
return (
<>
<button onClick={this.login}>Sign in</button>
<button onClick={this.login}>Sign up</button>
</>
)
}

registerComponent({ name: 'UsersAccountMenu', component: UsersAccountMenu });
}

registerComponent({ name: 'UsersAccountMenu', component: withApollo(UsersAccountMenu) })