Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 41 additions & 1 deletion frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@ import "./App.css";
import "./index.css";
import CacheBrowser from "./containers/CacheBrowser";
import CacheProfCont from "./containers/CacheProfCont";

import index from "./components/login/index"
import Login from "./components/login/Login"
import Signup from "./components/login/Signup"
import style from "./components/login/style.scss"
// import Login from "./Login";
// import Login from './components/login/Login'

import MapContainer from "./containers/MapContainer";
import Navbar from "./Navbar";
import React, { Component } from "react";
import Signup from './components/login/Signup';
// import Signup from './components/login/Signup';
import UserContainer from "./containers/UserContainer";
import UserForm from './components/UserForm';
import CacheNewForm from './components/CacheNewForm'


class App extends React.Component {
Expand Down Expand Up @@ -70,12 +79,27 @@ export default class App extends Component {
};

render() {

return (
<Router>
<div className="App">
<Navbar />
{/* <Route exact path="/caches" component={() => <CacheBrowser caches={this.state.caches} />} handleCacheClick={this.handleCacheClick}/> */}

<Route exact path="/login" component={Login} />
<Route exact path="/signup" component={Signup} />
<Route exact path="/profile" component={UserContainer} />
<Route exact path="/map" component={MapContainer} />

<Route

return (
<Router>
<div className="App">
<Navbar />
<Switch>
<Route

exact
path="/caches"
render={() => {
Expand All @@ -97,6 +121,21 @@ export default class App extends Component {
/>
)}
/>


<Route
exact
path="/newcache"
render={() => {
return (
<CacheNewForm />
);
}}
/>

{/* <Route exact path="/login" component={Login} /> */}
<Route exact path="/profile" component={UserContainer} />

<Route exact path="/login" component={Login} />
<Route exact path="/signup" component={Signup} />
<Route exact path="/newProfile" component={UserForm} />
Expand All @@ -105,6 +144,7 @@ export default class App extends Component {
// currentUser={this.state.currentUser}
/>
} />

<Route exact path="/map" component={MapContainer} />
</Switch>
</div>
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ class Navbar extends React.Component {
background: 'royalblue'
}}
>Caches</NavLink>
<NavLink
to="/newcache"
exact
style={link}
activeStyle={{
background: 'royalblue'
}}
>
New Cache
</NavLink>


<NavLink
to="/map"
exact
Expand Down
157 changes: 157 additions & 0 deletions frontend/src/components/CacheNewForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import React, { Component } from "react";

export default class CacheNewForm extends Component {
constructor(props) {
super(props);
this.state = {
cachePost: {
name: "",
size: "",
description: "",
mystery: "",
hint: "",
warnings: "",
coordinates: {
lat: "",
lng: "",
},
photo: "",
},
historyPost: {
created: true,
favorite: false,
to_do: false,
done: true,
difficulty: "",
rating: 5,
comment: "Created the cache!",
// Change user_id when we have auth!
user_id: 1
}
};

this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}

handleChange(event) {
let e = event.target
this.setState({
cachePost: {
name: e.name,
size: e.size,
description: e.description,
mystery: e.mystery,
hint: e.hint,
warnings: e.warnings,
coordinates: {
lat: e.lat,
lng: e.lng,
},
photo: e.photo,
},
historyPost: {
created: true,
favorite: false,
to_do: false,
done: true,
difficulty: e.difficulty,
rating: 5,
comment: "Created the cache!",
// Change user_id when we have auth!
user_id: 1
}
});
}

handleSubmit(event) {
alert('This form was submitted!');
event.preventDefault();
}

render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Name
<input type="text" value={this.state.cachePost.name} onChange={this.handleChange}
/>
</label>
<label>
Size CHANGEME!!!
<input
type="radio"
value={this.state.cachePost.size}
onChange={this.handleChange}
/>
</label>
<label>
Difficulty
<input
type="radio"
value={this.state.historyPost.difficulty}
onChange={this.handleChange}
/>
</label>
<label>
Description
<input
type="text"
value={this.state.cachePost.description}
onChange={this.handleChange}
/>
</label>
<label>
Mystery
<input
type="text"
value={this.state.cachePost.mystery}
onChange={this.handleChange}
/>
</label>
<label>
Hint
<input
type="text"
value={this.state.cachePost.hint}
onChange={this.handleChange}
/>
</label>
<label>
Warnings
<input
type="text"
value={this.state.cachePost.warnings}
onChange={this.handleChange}
/>
</label>
<label>
Latitude
<input
type="text"
value={this.state.cachePost.coordinates.lat}
onChange={this.handleChange}
/>
</label>
<label>
Longitude
<input
type="text"
value={this.state.cachePost.coordinates.lng}
onChange={this.handleChange}
/>
</label>
<label>
Photo URL
<input
type="text"
value={this.state.cachePost.photo}
onChange={this.handleChange}
/>
</label>
<input type="submit" value="Submit" />
</form>
)
}
}

6 changes: 3 additions & 3 deletions frontend/src/components/login/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./style.scss";
// import "./style.scss";

export { Login } from "./login";
export { Signup } from "./register";
// export { Login } from "./login";
// export { Signup } from "./register";
5 changes: 3 additions & 2 deletions frontend/src/containers/CacheProfCont.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import CacheInfoContainer from './CacheInfoContainer'
import CacheReviewsContainer from './CacheReviewsContainer'
import CacheInfoContainer from './CacheInfoContainer';
import CacheReviewsContainer from './CacheReviewsContainer';
import CacheNewForm from '../components/CacheNewForm';


export default class CacheProfCont extends Component {
Expand Down
27 changes: 25 additions & 2 deletions geo-app-backend/app/models/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,32 @@ def average_difficulty
end

def creator
histories.map do |history|
creator = ""
histories.each do |history|
if history.created == true
history.user.username
creator = history.user.username
break
end
end
creator
end

def reviewer
# reviewer = ""
# histories.map do |history|
# if history.id
# reviewer = history.user.username
# end
# reviewer

# histories.user_id == histories.user.id
# return histories.user.username

reviwer = ""
histories.map do |cache_history|
sought_user = User.find(cache_history.user_id)
if cache_history.user_id == sought_user.id
reviewer = [cache_history.id, sought_user.username]
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions geo-app-backend/app/models/history.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
class History < ApplicationRecord
belongs_to :user
belongs_to :cache

def reviewer
return 0
# History.all.each do |history|
# reviewer = history.id
# end
end

end
2 changes: 1 addition & 1 deletion geo-app-backend/app/serializers/cache_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class CacheSerializer < ActiveModel::Serializer
attributes :id, :name, :size, :average_difficulty, :average_rating, :creator, :description, :mystery, :hint, :warnings, :coordinates, :photo, :histories
attributes :id, :name, :size, :average_difficulty, :average_rating, :creator, :description, :mystery, :hint, :warnings, :coordinates, :photo, :reviewer, :histories, :users
end
2 changes: 1 addition & 1 deletion geo-app-backend/app/serializers/history_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class HistorySerializer < ActiveModel::Serializer
attributes :id, :created, :favorite, :to_do, :done, :difficulty, :rating, :comment
attributes :id, :created, :favorite, :to_do, :done, :difficulty, :rating, :comment, :reviewer,
has_one :user
has_one :cache
end