Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing chat #5

Open
wants to merge 198 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
198 commits
Select commit Hold shift + click to select a range
f064a18
setting up database
aprilrueb Nov 15, 2017
17364b3
Merge pull request #1 from aprilrueb/database
cmccarthy15 Nov 16, 2017
17c8428
frontend firebase
thorsenaa Nov 16, 2017
5093eb4
component Messages added
thorsenaa Nov 16, 2017
39903ab
Merge pull request #2 from aprilrueb/withAshi
cmccarthy15 Nov 16, 2017
93db4cf
rendering some basic chat stuff
cmccarthy15 Nov 16, 2017
af38859
Merge pull request #3 from aprilrueb/starting-again
cmccarthy15 Nov 16, 2017
9b7e379
styling chat - bottom right
thorsenaa Nov 16, 2017
bcc7a7b
added react router and reorganized the components a little
cmccarthy15 Nov 17, 2017
6c7fd23
Merge pull request #13 from aprilrueb/make-routes
cmccarthy15 Nov 17, 2017
61e41ca
Merge branch 'master' into continue-chat
thorsenaa Nov 17, 2017
95a6590
firebase auth is working. will put a user on the state of the app com…
cmccarthy15 Nov 17, 2017
75c2782
chat timestamp now in real time
thorsenaa Nov 17, 2017
5a7fdd8
Merge pull request #16 from aprilrueb/continue-chat
cmccarthy15 Nov 17, 2017
3be0645
fixing merge conflicts in appjsx
cmccarthy15 Nov 17, 2017
335f938
Merge pull request #14 from aprilrueb/firebase-auth
thorsenaa Nov 17, 2017
4606e53
started bot file which will really just be functions
cmccarthy15 Nov 17, 2017
e45cbc9
now renders the displayName of logged in user
cmccarthy15 Nov 17, 2017
ee0fa1d
pinned component rendering
ellapitassi Nov 17, 2017
8109ef2
messages to bot also show in chat
cmccarthy15 Nov 17, 2017
2303383
removed some comments and stuff
cmccarthy15 Nov 17, 2017
db35b44
merged branches
ellapitassi Nov 18, 2017
f7ae929
Merge pull request #17 from aprilrueb/itinerary/pinned
cmccarthy15 Nov 18, 2017
caab4be
fixed merge conflicts with master
cmccarthy15 Nov 18, 2017
d681c6b
didn't save something
cmccarthy15 Nov 18, 2017
4bc61a6
Bot can send messages to chat based on user input
cmccarthy15 Nov 18, 2017
2452ea8
made notes on google places api and working on getting it up
cmccarthy15 Nov 18, 2017
207d3d7
bot responds in chat
cmccarthy15 Nov 20, 2017
02c9e40
Merge pull request #18 from aprilrueb/chatbot
cmccarthy15 Nov 20, 2017
709be34
associating ze things
aprilrueb Nov 20, 2017
8c27af7
bot and chat working again
aprilrueb Nov 20, 2017
f87d005
checks if user is part of trip
aprilrueb Nov 20, 2017
6626726
Merge pull request #19 from aprilrueb/associating
cmccarthy15 Nov 20, 2017
33cc358
basic ternary in event component
cmccarthy15 Nov 20, 2017
9feb7d5
using googleapi to get lat and long of a city
ellapitassi Nov 20, 2017
c2a32de
command func in bot returns lat and long
thorsenaa Nov 20, 2017
9890380
trying to get events to associate with their dates and dates to be or…
cmccarthy15 Nov 20, 2017
0d3ac02
backtracking to use arrays and loop
cmccarthy15 Nov 20, 2017
76b260b
renders underneath dates
cmccarthy15 Nov 20, 2017
6833607
can get activities for city
thorsenaa Nov 20, 2017
7e133aa
chat styling
aprilrueb Nov 20, 2017
6c9a72a
places render 20 options
thorsenaa Nov 20, 2017
a99b54a
trying to work on liking feature for pinned events
cmccarthy15 Nov 21, 2017
7bcdbb3
users can like pinned events... needs more testing though
cmccarthy15 Nov 21, 2017
562c51b
scrolling working
aprilrueb Nov 21, 2017
0755f58
Merge pull request #22 from aprilrueb/scrolling
cmccarthy15 Nov 21, 2017
aaf5d37
fixing merge conflicts
cmccarthy15 Nov 21, 2017
6d8f718
submitting for code review
ellapitassi Nov 21, 2017
f1b09dd
Merge pull request #23 from aprilrueb/itinerary
aprilrueb Nov 21, 2017
406161e
Merge branch 'master' into places
ellapitassi Nov 21, 2017
f568543
Merge pull request #24 from aprilrueb/places
ellapitassi Nov 21, 2017
9199a2f
post code review
aprilrueb Nov 21, 2017
5024896
moment working
aprilrueb Nov 21, 2017
a78c988
Merge pull request #31 from aprilrueb/moment
cmccarthy15 Nov 21, 2017
8fb28cd
firestore functions index.js working
thorsenaa Nov 21, 2017
3b3d39b
starting add event form, rendering month and day drop down
cmccarthy15 Nov 21, 2017
83e0961
can submit a new date
cmccarthy15 Nov 21, 2017
709870c
adds new event to firestore yippee
cmccarthy15 Nov 21, 2017
4d52af9
adding an event closes the addevent form
cmccarthy15 Nov 21, 2017
a0b7152
Merge pull request #32 from aprilrueb/add-itin-event
aprilrueb Nov 22, 2017
e785341
ashified axios changed admin-key
thorsenaa Nov 22, 2017
c62bc8b
all botfuncs
thorsenaa Nov 22, 2017
25e65df
sends an email using a cloud function'
cmccarthy15 Nov 22, 2017
65d6007
trying to debug itinerary and unsure why geopoint needs to be on trip…
ellapitassi Nov 22, 2017
37cabda
fixed merge conflicts with master
cmccarthy15 Nov 22, 2017
b504196
changed console logs in tip
cmccarthy15 Nov 22, 2017
ac4c05d
fixing conflicts with and merging with invitations branch
cmccarthy15 Nov 22, 2017
ed16b31
itinerary renders with complete date range using componentwillreceive…
cmccarthy15 Nov 22, 2017
a56609d
removed event from line 25 of functions indexjs and setting location …
cmccarthy15 Nov 23, 2017
d905256
changed the field from city to location in case they're going to some…
cmccarthy15 Nov 23, 2017
d69bac5
hit a block due to port issues but updated the text a little and pass…
cmccarthy15 Nov 24, 2017
d96bc0a
updates the dates in firestore but doesn't rerender component
cmccarthy15 Nov 24, 2017
99a7504
will need to pass trip info into itinerary. helper wrapper function w…
cmccarthy15 Nov 24, 2017
ff42cf1
adding an event automatically rerenders the itinerary with the extra …
cmccarthy15 Nov 26, 2017
4708a4d
Merge pull request #52 from aprilrueb/itin-update-dates
aprilrueb Nov 26, 2017
1e4db66
some flexboxy and bootstrappy styling to pinned and trip
cmccarthy15 Nov 26, 2017
ccddbcb
can add a comment with some bugs
cmccarthy15 Nov 26, 2017
0368bd2
fixing merge conflicts with master
cmccarthy15 Nov 26, 2017
dfb18fd
added in some bot stuff
cmccarthy15 Nov 26, 2017
4ae6607
Merge pull request #53 from aprilrueb/botfunctions
ellapitassi Nov 26, 2017
f41536d
Merge pull request #54 from aprilrueb/invitations
ellapitassi Nov 26, 2017
070f4fb
trying to fix merge conflicts
cmccarthy15 Nov 26, 2017
6a2bd40
added some styling
cmccarthy15 Nov 26, 2017
00da9d3
working on homepage
aprilrueb Nov 26, 2017
aecff53
adding sidebar
ellapitassi Nov 26, 2017
3b0249d
getting hard coded sidebar to appear
ellapitassi Nov 26, 2017
9c40696
most styling okay but the add event form looks terrible
cmccarthy15 Nov 27, 2017
6b2cdc3
styling. issues with heights of pinned and itinerary
cmccarthy15 Nov 27, 2017
25f1966
homepage with one image
aprilrueb Nov 27, 2017
5472e75
hp working
aprilrueb Nov 27, 2017
fe7ba20
homepage working
aprilrueb Nov 27, 2017
1195bcc
have a functioning sidebar
ellapitassi Nov 27, 2017
320e490
still working on bugs
cmccarthy15 Nov 27, 2017
ba8add1
chat-styling
thorsenaa Nov 27, 2017
37db3fe
Merge pull request #56 from aprilrueb/sidebar
cmccarthy15 Nov 27, 2017
17da548
fixing merge conflicts
cmccarthy15 Nov 27, 2017
e3ee34c
Merge branch 'master' into chat-styling
thorsenaa Nov 27, 2017
9a5629e
Merge pull request #57 from aprilrueb/chat-styling
thorsenaa Nov 27, 2017
e6254fe
new homepage
aprilrueb Nov 27, 2017
805dc1d
Merge pull request #58 from aprilrueb/background-images
cmccarthy15 Nov 27, 2017
963a176
fixing merge conflicts
cmccarthy15 Nov 27, 2017
0e74f24
sidebar logout now pushes to history to send back to home screen
cmccarthy15 Nov 27, 2017
a573d64
Merge pull request #55 from aprilrueb/pinned-styling
aprilrueb Nov 27, 2017
00d472a
added a new styling tag
cmccarthy15 Nov 27, 2017
d0d73c2
multiple trips will all use bot but sends multiple replies
cmccarthy15 Nov 27, 2017
89aca85
can get top five of a search type and print to msg
cmccarthy15 Nov 27, 2017
09eaa3a
sidebar button in right place, and uses menu icon
ellapitassi Nov 27, 2017
28f394f
can pin from chat
thorsenaa Nov 27, 2017
64b642a
small bug fix
ellapitassi Nov 27, 2017
a2314d1
some progress on dashboard
aprilrueb Nov 27, 2017
467433a
Merge pull request #59 from aprilrueb/newTrip
cmccarthy15 Nov 27, 2017
e0cb5a4
Merge pull request #60 from aprilrueb/user-dashboard
cmccarthy15 Nov 27, 2017
9a4c143
resolved firebase debug issue
thorsenaa Nov 27, 2017
24b27b6
Merge pull request #61 from aprilrueb/bot-search-places
thorsenaa Nov 27, 2017
89c064f
fixed trips on dashboard
aprilrueb Nov 27, 2017
e6ca025
user dashboard renders correct names of trips
cmccarthy15 Nov 27, 2017
5fe2820
dashboard
aprilrueb Nov 27, 2017
25ec5d2
Merge branch 'master' of https://github.com/aprilrueb/capstone
aprilrueb Nov 27, 2017
96fb752
fixed chat first pin button
thorsenaa Nov 27, 2017
ebadd3c
Merge branch 'master' into bot-search-places
thorsenaa Nov 27, 2017
adc083b
Merge pull request #62 from aprilrueb/bot-search-places
thorsenaa Nov 27, 2017
35f50e2
more changes to dash
aprilrueb Nov 27, 2017
7248eb2
Merge branch 'master' of https://github.com/aprilrueb/capstone
aprilrueb Nov 27, 2017
f2e205c
Merge branch 'master' into user-dashboard
aprilrueb Nov 27, 2017
3c4a9c9
Merge pull request #63 from aprilrueb/user-dashboard
cmccarthy15 Nov 27, 2017
79251b3
ashi's changes
aprilrueb Nov 27, 2017
ea05f2f
getting up to date
ellapitassi Nov 28, 2017
d2d619a
added in stuff from the cr file on caryn's computer
cmccarthy15 Nov 28, 2017
2f3063a
took blur off shadow box of pins
cmccarthy15 Nov 28, 2017
a969364
my acct from sidebar doesnt render homepage first
cmccarthy15 Nov 28, 2017
e8c676f
events are now onSnapshot and onState. removed all comment stuff
cmccarthy15 Nov 28, 2017
119f7e0
if the user has liked the pin, it renders the heart button in red
cmccarthy15 Nov 28, 2017
9327cb8
removed unnecessary console logs
cmccarthy15 Nov 28, 2017
d0d6542
updating trip startdate and enddate works again
cmccarthy15 Nov 28, 2017
a3528ed
sidebar now watches using onshapshot but trip switching doesnt work
cmccarthy15 Nov 28, 2017
814cde9
switching between trips works again
cmccarthy15 Nov 28, 2017
442a7f5
removed console logs
cmccarthy15 Nov 28, 2017
f3bfacf
Merge pull request #64 from aprilrueb/cr2-caryn
cmccarthy15 Nov 28, 2017
5230db9
new hp working
aprilrueb Nov 28, 2017
68e201c
rewriting message
thorsenaa Nov 28, 2017
776f92b
Merge branch 'master' of https://github.com/aprilrueb/capstone
ellapitassi Nov 28, 2017
3b89cf6
nearly all bot cloud function working some bugs
cmccarthy15 Nov 28, 2017
bfc6326
adding trips
ellapitassi Nov 28, 2017
64589ba
bot grammar nearly done
cmccarthy15 Nov 28, 2017
7750c35
can send email that is pretty well formatted
cmccarthy15 Nov 28, 2017
88d2e13
almost to being able to have a user join a trip
cmccarthy15 Nov 28, 2017
47d1173
lots of lil changes
aprilrueb Nov 28, 2017
e4330ae
access to inviteId param and notes
cmccarthy15 Nov 28, 2017
f31f4d4
message still adds empty chat string, also adding random pins
thorsenaa Nov 28, 2017
67c35cc
joining the trip will do firestore updates and redirect you
cmccarthy15 Nov 28, 2017
0a2bf8d
can add an event and it redirects, start date gets set to today and e…
ellapitassi Nov 28, 2017
920c5b3
empty chat no longer submits
thorsenaa Nov 28, 2017
152c217
Merge pull request #65 from aprilrueb/fixing-chat
thorsenaa Nov 28, 2017
4569cb1
can add events outside of date range, and start and end date get updated
ellapitassi Nov 29, 2017
4893b02
got back to pre-snapshot
cmccarthy15 Nov 29, 2017
edf8d21
Merge pull request #66 from aprilrueb/restoring-previous
aprilrueb Nov 29, 2017
6394874
Merge branch 'master' into invite-ashi
cmccarthy15 Nov 29, 2017
8440346
small changes
aprilrueb Nov 29, 2017
c515b41
trying to keep snapshot stuff
ellapitassi Nov 29, 2017
7f99794
Merge branch 'master' of https://github.com/aprilrueb/capstone
ellapitassi Nov 29, 2017
5d9c92e
merging branches
ellapitassi Nov 29, 2017
41b7ee8
homepage done
aprilrueb Nov 29, 2017
352092f
Merge pull request #67 from aprilrueb/background-images
ellapitassi Nov 29, 2017
7aa0653
Merge branch 'master' of https://github.com/aprilrueb/capstone
ellapitassi Nov 29, 2017
eb0d23c
merging again
ellapitassi Nov 29, 2017
01e8d23
deleted console.log
ellapitassi Nov 29, 2017
6b76662
Merge pull request #68 from aprilrueb/newTrip
aprilrueb Nov 29, 2017
895919b
Merge branch 'master' into invite-ashi
cmccarthy15 Nov 29, 2017
c8207c2
chat updates when switching trips
cmccarthy15 Nov 29, 2017
b5eb920
pinned also updates on trip switch
cmccarthy15 Nov 29, 2017
6ddcd64
itin, pinned and chat all update on trip switch
cmccarthy15 Nov 29, 2017
9e0740d
i am so dumb.joyce is so helpful
cmccarthy15 Nov 29, 2017
0592e48
itin working with thisprops = nextProps
cmccarthy15 Nov 29, 2017
9964940
chat itin and pin all work with thisprops = nextprops now
cmccarthy15 Nov 29, 2017
5629672
updated trip to use snapshot subscribes and now adding event updates …
cmccarthy15 Nov 29, 2017
aaad4c4
does not work for dates outside of range
cmccarthy15 Nov 29, 2017
24aef9b
Merge pull request #69 from aprilrueb/switch-trips
ellapitassi Nov 29, 2017
6407bc3
scrolling works and chatbutton stays
cmccarthy15 Nov 29, 2017
f4ca1d2
Merge branch 'master' into scroll-style
cmccarthy15 Nov 29, 2017
9f2e64f
scrolling done
cmccarthy15 Nov 29, 2017
f2a50fd
Merge pull request #70 from aprilrueb/scroll-style
aprilrueb Nov 29, 2017
8c3c3d4
added peach color
cmccarthy15 Nov 29, 2017
a989c5a
chat bubbles
aprilrueb Nov 29, 2017
951c055
new peach color
cmccarthy15 Nov 29, 2017
5c418aa
chat looking gooood
aprilrueb Nov 29, 2017
a8dbf23
sidebar disappears after adding trip and trip text box clears out
ellapitassi Nov 29, 2017
a00cdf5
done with chat styling
aprilrueb Nov 29, 2017
2852610
fixed conflicts
aprilrueb Nov 29, 2017
26fb5e2
finished with chat
aprilrueb Nov 29, 2017
80eda64
Merge pull request #71 from aprilrueb/peach
ellapitassi Nov 29, 2017
846bb7a
fixed conflicts
aprilrueb Nov 29, 2017
999e037
Merge pull request #72 from aprilrueb/chat-styling
ellapitassi Nov 29, 2017
164a7cf
Merge pull request #73 from aprilrueb/newTrip
aprilrueb Nov 29, 2017
e5bfca4
change chat color
aprilrueb Nov 29, 2017
3333188
Merge pull request #74 from aprilrueb/chat-styling
ellapitassi Nov 29, 2017
be2fb31
search results updated
thorsenaa Nov 29, 2017
60834c1
Merge pull request #75 from aprilrueb/fixing-chat
ellapitassi Nov 29, 2017
b5e6866
bot interaction and delete pinned events
thorsenaa Nov 29, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"ecmaFeatures": {
"jsx": true,
"modules": true
},
"env": {
"browser": true,
"node": true
},
"parser": "babel-eslint",
"rules": {
"quotes": [
2,
"single"
],
"strict": [
2,
"never"
],
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/react-in-jsx-scope": 2
},
"plugins": [
"react"
]
}
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "capstone-98fe9"
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ functions/node_modules
public/bundle.js
public/bundle.js.map
functions/lib.js

#API Keys
admin-key.json
76 changes: 75 additions & 1 deletion App.jsx
Original file line number Diff line number Diff line change
@@ -1 +1,75 @@
export default () => '🔥 Ready.'
import Trip from './client/Trip'

import {Switch, Route} from 'react-router'
import {BrowserRouter as Router} from 'react-router-dom'
import React, { Component } from 'react'
import { HomePage } from './client'
import firebase, { auth, provider, db } from '~/fire'
import Sidebar from './client/Sidebar';
import Dashboard from './client/Dashboard';
import JoinTrip from './client/JoinTrip'

export default class App extends Component{
constructor(props){
super(props)
this.state = { user: null }
this.login = this.login.bind(this)
this.logout = this.logout.bind(this)
}

componentDidMount() {
auth.onAuthStateChanged(user => {
if (user) {
this.setState({ user })
}
})
}

login() {
auth.signInWithPopup(provider)
.then((result) => {
const user = result.user
this.setState({ user }) // things we want off this... email, displayName, photoURL, uid
db.collection('users').doc(user.uid).set({
displayName: user.displayName,
email: user.email,
photoURL: user.photoURL
}, { merge: true });
})
}

logout() {
auth.signOut()
.then(() => {
this.setState({user: null})
})
}

render(){

const isLoggedIn = this.state.user;
return (
<Router>
{isLoggedIn ?
(<div>
<Sidebar logout={ this.logout } userId={this.state.user.uid} />
<Switch>
<Route exact path="/" render={(props) => <Dashboard user={this.state.user} {...props} />} /> {/* their acct dashboard */}
<Route path="/:tripId" render={(props) => <Trip user={this.state.user} {...props} />} /> {/* an individual trip */}
<Route exact path="/join/:inviteId" render={
({match: {params: {inviteId} }}) => <JoinTrip inviteId={inviteId} />
} />
</Switch>
</div>
)
: (<Switch>
<Route exact path="/" render={() => <HomePage login={this.login} />} /> {/* HomePage incl. login */}
<Route exact path="/join/:inviteId" render={
({ match: { params: { inviteId } } }) => <JoinTrip inviteId={inviteId} login={this.login} />
} />
</Switch>)
}
</Router>
);
}
}
32 changes: 32 additions & 0 deletions bot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var admin = require("firebase-admin");

var serviceAccount = require("./admin-key.json");

admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://capstone-98fe9.firebaseio.com"
});

const db = admin.firestore()

const TRIP_ID = '5TT8NzzvNVZAvd8SbEyQ'

let tripIds = [];

const runBot = require('./functions/lib').runBotFromMessageEvent(true)

const trip = db.collection('trips').doc(TRIP_ID)

trip.set({ suppressBot: true }, { merge: true })
process.on('beforeExit', () => trip.set({ suppressBot: false }, { merge: true }))

trip.collection('chat')
.onSnapshot(async snap => {
for (let change of snap.docChanges) {
if (change.type === 'added') {
runBot({ data: change.doc }).catch(console.error)
}
}
})


98 changes: 98 additions & 0 deletions client/AddEvent.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import React, { Component } from 'react';

/* HELPERS FOR THE OPTIONS BELOW */
let days = [];
( () => {
for (var i = 1; i < 32; i++){
days.push(i);
}
})();
let months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
let hours = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'];
let minutes = ['00', '15', '30', '45'];
/* END HELPER */

/* START COMPONENT */
export default class AddEvent extends Component{
constructor(){
super();
this.state = {
name: '',
month: 'January',
day: '1',
year: '2017',
hour: '12',
minute: '00',
ampm: 'PM',
};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}

handleSubmit(evt){
evt.preventDefault();
const {month, day, year, hour, minute, ampm, name} = this.state;
const time = new Date(month + ' ' + day + ' ' + year + ' ' + hour + ':' + minute + ' ' + ampm);
//const trip = this.props.room.parent

/* ADD EVENT TO EVENTS COLLECTION */
// this.props.room.add({name, time, itineraryStatus: true});

// /* RESET START OR END DATE IF THE EVENT TIME IS OUTSIDE THE RANGE */
// console.log("START DATE: ", this.props.startDate, "END DATE: ", this.props.endDate)
// if (!this.props.startDate || time < this.props.startDate){ trip.set({startDate: time}, {merge: true}) }
// if (!this.props.endDate || time > this.props.endDate){ trip.set({endDate: time}, {merge: true}) }

this.props.closeForm(null, name, time);
/* does not include default empty values for other fields of event */
}


handleChange(evt){
evt.preventDefault();
this.setState({[evt.target.name]: evt.target.value});
}

render() {
return (
<div className="add-form">
<form onSubmit={this.handleSubmit}>
<div className="input-field col s6">
<input placeholder="Event Name" type="text" name="name" onChange={this.handleChange} />
</div>
<label className="flex-row">
Date:
<select className="browser-default" value={this.state.month} onChange={this.handleChange} name="month">
{months.map((month, idx) => (
<option key={idx} value={month}>{month}</option>)) }
</select>
<select className="browser-default" value={this.state.day} onChange={this.handleChange} name="day">
{days.map((day, idx) => (
<option key={idx} value={day}>{day}</option>
))}
</select>
<input type="text" name="year" value={this.state.year} onChange={this.handleChange} />
</label>
<label className="flex-row">
Time:
<select className="browser-default" value={this.state.hour} onChange={this.handleChange} name="hour">
{hours.map((hour, idx) => (
<option key={idx} value={hour}>{hour}</option>
))}
</select>
<select className="browser-default" value={this.state.minute} onChange={this.handleChange} name="minute">
{minutes.map((minute, idx) => (
<option key={idx} value={minute}>{minute}</option>
))}
</select>
<select className="browser-default" value={this.state.ampm} onChange={this.handleChange} name="ampm">
<option value="AM">AM</option>
<option value="PM">PM</option>
</select>
</label>
<input className="btn waves-effect waves-light" type="submit" value="Submit" />
</form>
</div>
);
}
}
63 changes: 63 additions & 0 deletions client/AddTrip.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React, { Component } from 'react';
import firebase, { db } from '../fire'
import { withRouter } from 'react-router'
import { SideNavItem, SideNav, Button, Icon } from 'react-materialize'


export class AddTrip extends Component {

constructor(props) {
super(props);
this.state = {
name: '',
}
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}

handleSubmit(evt) {
evt.preventDefault();
const ref = db.collection('trips')
.add({
name: this.state.name,
users: {
[this.props.userid]: true
},
// startDate: new Date(), //(new Date("January 1, 2017 01:15:00")),
// endDate: new Date(new Date().setFullYear(new Date().getFullYear() + 1)),
location: '',
coords: {}
})
.then(({id}) => this.props.history.push(`/${id}`))
this.setState({ name: '' });
}

handleChange(evt) {
evt.preventDefault();
this.setState({
name: evt.target.value,
});
}

render() {
var id = this.state.id
return (
<div className="add trip form">
<form onSubmit={this.handleSubmit}>
<input className="placeholder" placeholder="Trip Name" value={this.state.name} type="text" name="name" onChange={this.handleChange} />
<SideNavItem>
<input
className="btn waves-effect waves-light"
type="submit"
value="Create Trip"
/>

</SideNavItem>
</form>

</div>
)
}
}

export default withRouter(AddTrip)
Loading