This repository has been archived by the owner on May 29, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from ubclaunchpad/frontend/create_event
frontend: create event
- Loading branch information
Showing
6 changed files
with
173 additions
and
2 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
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,57 @@ | ||
import React, { Component } from 'react'; | ||
import Notification from '../../components/Notification'; | ||
class CreateEvent extends Component { | ||
constructor(props, context) { | ||
super(props, context); | ||
this.state = { | ||
eventname: '', | ||
notification: null, | ||
}; | ||
this.updateTextFields = this.updateTextFields.bind(this); | ||
} | ||
|
||
updateTextFields(e) { | ||
const infoField = e.target.getAttribute('name'); | ||
this.setState({ [infoField]: e.target.value }); | ||
} | ||
|
||
async checkEventName() { | ||
const { eventname } = this.state; | ||
|
||
if (!eventname) { | ||
this.setState({ | ||
notification: { | ||
type: 'error', | ||
message: 'Event name cannot be empty', | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
render() { | ||
const { notification, eventname } = this.state; | ||
return ( | ||
<div> | ||
<div className="card card-smallpad card-box margin-top-100 margin-sides-auto w-800"> | ||
<div> | ||
<a href="/login">Go Back</a> | ||
<div className="card-align-right"><a href="/login">X</a></div> | ||
</div> | ||
<div className="pad-left-100 title card-title">Create Event</div> | ||
<Notification {...notification} /> | ||
<h2 className="pad-left-100 fw-normal card-description pad-bot-m">Add a point of data entry to your application period</h2> | ||
<h2 className="pad-left-100 flex-ai-start pad-top- fw-normal card-text">Event Name</h2> | ||
<div className="pad-left-100 flex-inlinegrid margin-top-xs margin-bottom-xs pad-bot-m"> | ||
<input className="input-box input-large" name="eventname" type="eventname" placeholder="Eg. Launch Pad Interview Notes" onChange={this.updateTextFields} /> | ||
</div> | ||
<div className="pad-ends-25 flex-al-center"> | ||
<button className="button-click button-small animate-button margin-ends-xs margin-right-s" type="submit" eventname={eventname} onClick={this.checkEventName}><a href="/event/type">Next</a></button> | ||
<a href="/login" className="card-underline">Cancel</a> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default CreateEvent; |
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,71 @@ | ||
import React, { Component } from 'react'; | ||
import Notification from '../../components/Notification'; | ||
class CreateEvent extends Component { | ||
constructor(props, context) { | ||
super(props, context); | ||
this.state = { | ||
eventtype: '', | ||
notification: null, | ||
}; | ||
this.updateTextFields = this.updateTextFields.bind(this); | ||
} | ||
|
||
updateTextFields(e) { | ||
const infoField = e.target.getAttribute('name'); | ||
this.setState({ [infoField]: e.target.value }); | ||
this.attemptCreateEvent(); | ||
} | ||
|
||
// TODO once endpoint is set up, currently does nothing | ||
async attemptCreateEvent() { | ||
const { | ||
eventtype, | ||
} = this.state; | ||
const { client, eventname } = this.props; | ||
|
||
if (!eventtype) { | ||
this.setState({ | ||
notification: { | ||
type: 'error', | ||
message: 'Event type cannot be empty', | ||
}, | ||
}); | ||
} else { | ||
try { | ||
await client.createEvent({ eventname, eventtype }); | ||
} catch (e) { | ||
this.setState({ | ||
notification: { | ||
type: 'error', | ||
message: 'Failed to create a new event.', | ||
}, | ||
}); | ||
} | ||
} | ||
} | ||
|
||
render() { | ||
const { notification } = this.state; | ||
return ( | ||
<div> | ||
<div className="card card-smallpad card-box margin-top-100 margin-sides-auto w-600"> | ||
<div> | ||
<a href="/event">Go Back</a> | ||
<div className="card-align-right"><a href="/event">Skip</a></div> | ||
</div> | ||
<div className="pad-left-50 title card-title">Event type</div> | ||
<Notification {...notification} /> | ||
<h2 className="pad-left-50 fw-normal card-description pad-bot-xs">Pick an event type</h2> | ||
<div className="pad-ends-25 flex-al-center"> | ||
<button className="button-click button-small animate-button margin-ends-xs margin-right-s" type="submit" name="email" onClick={this.updateTextFields}><a href="/event/type">Email</a></button> | ||
<button className="button-click button-small animate-button margin-ends-xs margin-right-s" type="submit" name="form" onClick={this.updateTextFields}><a href="/event/type">Form</a></button> | ||
<button className="button-click button-small animate-button margin-ends-xs margin-right-s" type="submit" name="interview" onClick={this.updateTextFields}><a href="/event/type">Interview</a></button> | ||
<button className="button-click button-small animate-button margin-ends-xs margin-right-s" type="submit" name="notes" onClick={this.updateTextFields}><a href="/event/type">Notes</a></button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default CreateEvent; |
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,10 +1,45 @@ | ||
// Default Card (without fixed weight and height) | ||
.card { | ||
background: white; | ||
padding: 25px 50px; | ||
&-smallpad { padding: 10px 15px; } | ||
|
||
border-radius: 50px; | ||
padding: 25px 50px; | ||
&-box { border-radius: 10px; } | ||
|
||
.card { | ||
&-title { color: $gray-2; } | ||
&-text { color: $gray-3; } | ||
&-underline { | ||
&:hover { | ||
text-decoration: underline; | ||
transition: all $transition-time ease-in-out; | ||
} | ||
} | ||
&-description { font-size: 16px; color: $gray-3; } | ||
} | ||
&-align-right { | ||
right: 15px; | ||
top: 5px; | ||
float: right; | ||
} | ||
&-button { | ||
background-color: rgb(243, 62, 62); | ||
border: none; | ||
color: white; | ||
padding: 15px 32px; | ||
text-align: center; | ||
text-decoration: none; | ||
display: inline-block; | ||
border-radius: 12px; | ||
|
||
.button { | ||
&-small { font-size: 14px; } | ||
&-large { font-size: 16px; } | ||
} | ||
} | ||
&-row { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
} |
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