-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added deploy and updated homepage to be TopFans app
- Loading branch information
Showing
7 changed files
with
175 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"files": ["./build/"], | ||
"public": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,148 @@ | ||
import React from 'react'; | ||
import React, { Component } from 'react'; | ||
import queryString from 'query-string'; | ||
import _ from 'lodash'; | ||
import 'eventbrite_design_system/css/eds.css'; | ||
import DataTable from 'eventbrite_design_system/dataTable/DataTable'; | ||
import Button from 'eventbrite_design_system/button/Button'; | ||
|
||
export default () => ( | ||
<h1>Hello HomePage!</h1> | ||
); | ||
const CLIENT_ID = process.env.CLIENT_ID; | ||
|
||
export default class SomeOtherPage extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
access_token: '', | ||
token_type: '', | ||
user: { | ||
name: '', | ||
}, | ||
attendees: [], | ||
organizers: [], | ||
events: [], | ||
all: false, | ||
}; | ||
} | ||
|
||
handleClick = () => { | ||
window.location.href = 'https://www.eventbrite.com/oauth/authorize?response_type=token&client_id='+CLIENT_ID; | ||
} | ||
|
||
componentDidMount() { | ||
const parsedHash = queryString.parse(window.location.hash); | ||
this.setState({ | ||
...parsedHash | ||
}); | ||
|
||
if (parsedHash.access_token) { | ||
setTimeout(() => { | ||
Promise.all(this.state.events.map((event, key) => { | ||
return this.fetchEventAttendees(event.id, key); | ||
})) | ||
.then(() => { | ||
this.props.eb.FrameAPI.init(); | ||
this.setState({ | ||
all: true | ||
}); | ||
}); | ||
}, 0); | ||
} | ||
} | ||
|
||
fetchEventAttendees(event_id, key) { | ||
return fetch(`https://www.eventbriteapi.com/v3/events/${event_id}/attendees/?token=${this.state.access_token}`) | ||
.then((response) => (response.json())) | ||
.then((s) => { | ||
let { | ||
events | ||
} = this.state; | ||
events[key].attendees = s.attendees; | ||
|
||
this.setState({ | ||
events, | ||
}); | ||
}); | ||
} | ||
|
||
getAllAttendees() { | ||
let { events } = this.state; | ||
let attendees = {}; | ||
|
||
events.forEach((event) => { | ||
if (event.attendees) { | ||
event.attendees.forEach((att) => { | ||
if (!attendees[att.profile.email]) { | ||
attendees[att.profile.email] = 1; | ||
} else { | ||
attendees[att.profile.email]++; | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
return _.sortBy(Object.keys(attendees).map((key) => { | ||
return { | ||
name: key, | ||
visits: attendees[key] | ||
}; | ||
}), (obj) => obj.visits * -1); | ||
} | ||
|
||
renderDataTable(attendees) { | ||
if (Object.keys(attendees).length === 0) { | ||
return; | ||
} | ||
|
||
return ( | ||
<DataTable | ||
items={attendees} | ||
columns={[ | ||
{ | ||
fieldName: 'name', | ||
fieldLabel: 'E-mail', | ||
isEditable: false, | ||
isSortable: true, | ||
}, | ||
{ | ||
fieldName: 'visits', | ||
fieldLabel: 'Visits', | ||
isEditable: false, | ||
isSortable: true, | ||
} | ||
]} | ||
/> | ||
); | ||
} | ||
|
||
render() { | ||
let { | ||
access_token | ||
} = this.state; | ||
|
||
let button = (!access_token) ? ( | ||
<div> | ||
<Button style="fill" onClick={this.handleClick}> | ||
Authenticate | ||
</Button> | ||
</div> | ||
): null; | ||
|
||
let attendees = this.getAllAttendees(); | ||
let table = this.renderDataTable(attendees) | ||
|
||
return ( | ||
<div className="eds-g-grid"> | ||
<div className="eds-g-cell eds-g-cell-12-12"> | ||
<div className="eds-align--center"> | ||
<section className="eds-l-pad-all-4"> | ||
<h2 className="eds-text-hl eds-text--center eds-l-pad-all-2"> | ||
Top Fans | ||
</h2> | ||
{button} | ||
</section> | ||
</div> | ||
{table} | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export { default as HomePage } from './HomePage'; | ||
export { default as RegisterPage } from './RegisterPage'; | ||
// export {default as SomeOtherPage} from './SomeOtherPage' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5754,6 +5754,10 @@ [email protected]: | |
dependencies: | ||
lodash "^4.11.2" | ||
|
||
now@^11.4.6: | ||
version "11.4.6" | ||
resolved "https://registry.npmjs.org/now/-/now-11.4.6.tgz#611729c3de4c1108be72f9f9a4b3851dece29380" | ||
|
||
npm-bundled@^1.0.1: | ||
version "1.0.5" | ||
resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.5.tgz#3c1732b7ba936b3a10325aef616467c0ccbcc979" | ||
|
@@ -6932,6 +6936,13 @@ [email protected], qs@~6.5.2: | |
version "6.5.2" | ||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" | ||
|
||
query-string@^6.2.0: | ||
version "6.2.0" | ||
resolved "https://registry.npmjs.org/query-string/-/query-string-6.2.0.tgz#468edeb542b7e0538f9f9b1aeb26f034f19c86e1" | ||
dependencies: | ||
decode-uri-component "^0.2.0" | ||
strict-uri-encode "^2.0.0" | ||
|
||
querystring-es3@^0.2.0: | ||
version "0.2.1" | ||
resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" | ||
|
@@ -8143,6 +8154,10 @@ stream-shift@^1.0.0: | |
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952" | ||
|
||
strict-uri-encode@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" | ||
|
||
string-length@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/string-length/-/string-length-2.0.0.tgz#d40dbb686a3ace960c1cffca562bf2c45f8363ed" | ||
|