Skip to content

Commit

Permalink
switched back to netlify
Browse files Browse the repository at this point in the history
  • Loading branch information
kwelch-eb committed Nov 1, 2018
1 parent 96cd03c commit 4a87736
Show file tree
Hide file tree
Showing 9 changed files with 956 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CLIENT_SECRET=
CLIENT_ID=
REACT_APP_TARGET=web
REACT_APP_TARGET=web
REACT_APP_BASE_URL=https://eventbrite.com
3 changes: 3 additions & 0 deletions .netlify/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"siteId": "0619e094-044d-4807-842b-389eb23dbd07"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "yarn build",
"deploy": "now ./build/ --public --static"
"deploy": "netlify deploy --prod --dir=build/"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -30,6 +30,6 @@
"not op_mini all"
],
"devDependencies": {
"now": "^11.4.6"
"netlify-cli": "^2.1.3"
}
}
1 change: 1 addition & 0 deletions public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* /index.html 200
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { HashRouter as Router, Route } from 'react-router-dom';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import { RegisterPage, HomePage } from './pages';
import(/* webpackPreload: true */'eventbrite_design_system/css/eds.css');

Expand Down
3 changes: 3 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const BASE_URL = process.env.REACT_APP_BASE_URL || 'https://eventbrite.com';
export const CLIENT_SECRET = process.env.REACT_APP_CLIENT_SECRET;
export const CLIENT_ID = process.env.REACT_APP_CLIENT_ID;
7 changes: 3 additions & 4 deletions src/pages/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import queryString from 'query-string';
import {sortBy} from 'lodash';
import DataTable from 'eventbrite_design_system/dataTable/DataTable';
import Button from 'eventbrite_design_system/button/Button';

const CLIENT_ID = process.env.CLIENT_ID;
import {CLIENT_ID, BASE_URL} from '../constants';

export default class SomeOtherPage extends Component {
constructor(props) {
Expand All @@ -23,7 +22,7 @@ export default class SomeOtherPage extends Component {
}

handleClick = () => {
window.location.href = 'https://www.eventbrite.com/oauth/authorize?response_type=token&client_id='+CLIENT_ID;
window.location.href = `${BASE_URL}/oauth/authorize?response_type=token&client_id=${CLIENT_ID}`;
}

componentDidMount() {
Expand All @@ -48,7 +47,7 @@ export default class SomeOtherPage extends Component {
}

fetchEventAttendees(event_id, key) {
return fetch(`https://www.eventbriteapi.com/v3/events/${event_id}/attendees/?token=${this.state.access_token}`)
return fetch(`${BASE_URL}/api/v3/events/${event_id}/attendees/?token=${this.state.access_token}`)
.then((response) => (response.json()))
.then((s) => {
let {
Expand Down
44 changes: 22 additions & 22 deletions src/pages/RegisterPage.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import React, { Component } from 'react';
import request from 'request';
import querystring from 'querystring';

const OAUTH_URL = 'https://www.eventbrite.com/oauth/token';
const CLIENT_SECRET = process.env.CLIENT_SECRET;
const CLIENT_ID = process.env.CLIENT_ID;

import { CLIENT_ID, CLIENT_SECRET, BASE_URL } from '../constants';

export default class Register extends Component {
componentDidMount() {
console.log(this.props);
var url_parts = querystring.parse(this.props.location.search);
var _code = url_parts['?code'];
var url = OAUTH_URL;
var url = `${BASE_URL}/oauth/token`;

var form = {
code: _code,
client_secret: CLIENT_SECRET,
client_id: CLIENT_ID,
grant_type: 'authorization_code'
code: _code,
client_secret: CLIENT_SECRET,
client_id: CLIENT_ID,
grant_type: 'authorization_code',
};

var formData = querystring.stringify(form);
Expand All @@ -28,27 +24,31 @@ export default class Register extends Component {
console.log(_code);
console.log(form);

request({
request(
{
headers: {
'Content-Length': contentLength,
'Content-Type': 'application/x-www-form-urlencoded'
'Content-Length': contentLength,
'Content-Type': 'application/x-www-form-urlencoded',
},
uri: url,
body: formData,
method: 'POST'
}, function (err, resp, body) {
console.log(err, resp, body);
});
method: 'POST',
},
function(err, resp, body) {
console.log(err, resp, body);
}
);
}

render() {
const parsedHash = querystring.parse(window.location.hash);
return (
<div>
<h2>Register</h2>
<code>
{JSON.stringify(this.props)}
</code>
<h2>Register</h2>
<code>{JSON.stringify(this.props)}</code>
<h2>More stuff</h2>
<code>{JSON.stringify(parsedHash)}</code>
</div>
);
}
}
}
Loading

0 comments on commit 4a87736

Please sign in to comment.