diff --git a/public/index.html b/public/index.html index 264f3eb..ed67afb 100644 --- a/public/index.html +++ b/public/index.html @@ -6,6 +6,7 @@ + Hackathon Extension diff --git a/src/constants.js b/src/constants.js index 05bda4d..a004f38 100644 --- a/src/constants.js +++ b/src/constants.js @@ -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; \ No newline at end of file diff --git a/src/pages/ExtensionPage.js b/src/pages/ExtensionPage.js index 62a6b5e..f65312d 100644 --- a/src/pages/ExtensionPage.js +++ b/src/pages/ExtensionPage.js @@ -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 ( +
+

{user.name}

+ {user.image_id && User Avatar} +
+ ); + } + return null; + }; + render() { return (

Token details

- {JSON.stringify(this.state.token)} + {JSON.stringify(this.state)} + {Array.from({ length: 10 }).map((_, i) => ( +
+ ))} + {this.getUserDetails()}
); }