From 3f6a7857c52f7a150228f0fb25e938d32db71799 Mon Sep 17 00:00:00 2001 From: github username Date: Thu, 24 Oct 2019 14:13:26 -0700 Subject: [PATCH 1/2] Made route for new cache form --- frontend/src/App.js | 23 +++- frontend/src/Navbar.js | 12 ++ frontend/src/components/CacheNewForm.js | 157 +++++++++++++++++++++++ frontend/src/components/login/index.js | 6 +- frontend/src/containers/CacheProfCont.js | 5 +- 5 files changed, 197 insertions(+), 6 deletions(-) create mode 100644 frontend/src/components/CacheNewForm.js diff --git a/frontend/src/App.js b/frontend/src/App.js index 8ab1fb9..09c6fff 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -3,14 +3,19 @@ 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' // import { Login, Signup } from "./components/login/index"; // import { render } from 'react-dom'; @@ -62,6 +67,12 @@ export default class App extends Component {
{/* } handleCacheClick={this.handleCacheClick}/> */} + + + + + + + { + return ( + + ); + }} + /> + {/* */} diff --git a/frontend/src/Navbar.js b/frontend/src/Navbar.js index b4b65f1..ee0a5be 100644 --- a/frontend/src/Navbar.js +++ b/frontend/src/Navbar.js @@ -49,6 +49,18 @@ class Navbar extends React.Component { background: 'royalblue' }} >Caches + + New Cache + + + + + + + + + + + + + + + + ) + } +} + diff --git a/frontend/src/components/login/index.js b/frontend/src/components/login/index.js index 45e030c..e7c2b82 100644 --- a/frontend/src/components/login/index.js +++ b/frontend/src/components/login/index.js @@ -1,4 +1,4 @@ -import "./style.scss"; +// import "./style.scss"; -export { Login } from "./login"; -export { Signup } from "./register"; \ No newline at end of file +// export { Login } from "./login"; +// export { Signup } from "./register"; \ No newline at end of file diff --git a/frontend/src/containers/CacheProfCont.js b/frontend/src/containers/CacheProfCont.js index b1632ac..92587ca 100644 --- a/frontend/src/containers/CacheProfCont.js +++ b/frontend/src/containers/CacheProfCont.js @@ -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 { From 9886feef99591a1540a2ed994d6a100e5d6db9c1 Mon Sep 17 00:00:00 2001 From: github username Date: Thu, 24 Oct 2019 14:14:05 -0700 Subject: [PATCH 2/2] Made route for new cache form --- geo-app-backend/app/models/cache.rb | 27 +++++++++++++++++-- geo-app-backend/app/models/history.rb | 8 ++++++ .../app/serializers/cache_serializer.rb | 2 +- .../app/serializers/history_serializer.rb | 2 +- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/geo-app-backend/app/models/cache.rb b/geo-app-backend/app/models/cache.rb index a006fac..668279e 100644 --- a/geo-app-backend/app/models/cache.rb +++ b/geo-app-backend/app/models/cache.rb @@ -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 diff --git a/geo-app-backend/app/models/history.rb b/geo-app-backend/app/models/history.rb index 9c8db89..6b3b29e 100644 --- a/geo-app-backend/app/models/history.rb +++ b/geo-app-backend/app/models/history.rb @@ -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 diff --git a/geo-app-backend/app/serializers/cache_serializer.rb b/geo-app-backend/app/serializers/cache_serializer.rb index e6055c2..8b7c2a5 100644 --- a/geo-app-backend/app/serializers/cache_serializer.rb +++ b/geo-app-backend/app/serializers/cache_serializer.rb @@ -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 diff --git a/geo-app-backend/app/serializers/history_serializer.rb b/geo-app-backend/app/serializers/history_serializer.rb index 1c68fce..8417e86 100644 --- a/geo-app-backend/app/serializers/history_serializer.rb +++ b/geo-app-backend/app/serializers/history_serializer.rb @@ -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