Skip to content

Commit

Permalink
Update debug page
Browse files Browse the repository at this point in the history
  • Loading branch information
kwelch-eb committed Nov 2, 2018
1 parent c06cdf2 commit 9991e96
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<script async src="https://ebmedia.eventbrite.com/s3-build/26869-rc2015-01-26-a5d995d/django/js/src/plugins/api.js"></script>
<title>Hackathon Extension</title>
</head>
<body>
Expand Down
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const BASE_URL = process.env.REACT_APP_BASE_URL || 'https://eventbrite.com';
export const BASE_API_URL = process.env.REACT_APP_BASE_API_URL || 'https://www.evbqaapi.com/v3/';
export const CLIENT_SECRET = process.env.REACT_APP_CLIENT_SECRET;
export const CLIENT_ID = process.env.REACT_APP_CLIENT_ID;
38 changes: 32 additions & 6 deletions src/pages/ExtensionPage.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,48 @@
import React from 'react';
import {parse} from 'query-string';
import { parse } from 'query-string';
import jwt from 'jsonwebtoken';
import {CLIENT_SECRET} from '../constants';
import eventbrite from 'eventbrite';
import { BASE_API_URL, CLIENT_SECRET } from '../constants';

export default class ExtensionPage extends React.PureComponent {
constructor(props) {
super(props);
const query = parse(props.location.search);
const query = parse(props.location.search || '');
const token = query.esr ? jwt.decode(query.esr, CLIENT_SECRET) : null;
this.state = {
token: query.esr ? jwt.decode(query.esr, CLIENT_SECRET): null,
}
...token,
};
this.sdk = eventbrite({ baseUrl: BASE_API_URL, token: token.auth_token });
}

componentDidMount() {
this.sdk.request('/users/me/').then(user => this.setState({ user }));
// this isn't working so it has scroll :sad_panda:
// window.EB.FrameAPI.init({});
}

getUserDetails = () => {
const { user } = this.state;
if (user) {
return (
<div>
<h1>{user.name}</h1>
{user.image_id && <img src={user.image_id} alt="User Avatar" />}
</div>
);
}
return null;
};

render() {
return (
<div>
<h1>Token details</h1>
<code>{JSON.stringify(this.state.token)}</code>
<code>{JSON.stringify(this.state)}</code>
{Array.from({ length: 10 }).map((_, i) => (
<br key={i} />
))}
{this.getUserDetails()}
</div>
);
}
Expand Down

0 comments on commit 9991e96

Please sign in to comment.