Skip to content

Commit

Permalink
Merge pull request #39 from RileyManda/feature/ui-navigation
Browse files Browse the repository at this point in the history
Feature/UI navigation
  • Loading branch information
RileyManda authored Oct 19, 2023
2 parents 0a284ba + 8d36dcb commit 4519a88
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/controllers/shopping_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ShoppingController < ApplicationController
def index; end
end
2 changes: 2 additions & 0 deletions app/helpers/shopping_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ShoppingHelper
end
5 changes: 5 additions & 0 deletions app/views/food/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<%= "Welcome, #{current_user.email}" %>
<%= link_to 'Recipes', recipe_index_path, class: 'btn small btn-primary' %>
<%= link_to 'Public Recipes', public_recipes_path, class: 'btn small btn-primary' %>
<%= link_to 'Food', food_index_path, class: 'btn small btn-primary' %>
<%= link_to "Shopping", shopping_index_path, class: 'btn btn-primary' %>

<h1 class="text-center mt-3">Foods</h1>
<main class="container mt-3">
<div class="card">
Expand Down
2 changes: 1 addition & 1 deletion app/views/recipe/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="container">
<h1><%= @recipe.name %></h1>
<div class="d-flex justify-content-between">
<p>Preparation Time: <%= @recipe.preparation_time %> minutes</p>
<p>Preparation Time: <%= @recipe.preparation_time %> hours</p>
<div class="form-check form-switch">
<%= form_for @recipe, url: recipe_path(@recipe), method: :patch do |f| %>
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
Expand Down
44 changes: 44 additions & 0 deletions app/views/shopping/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<div class="container">
<h1>Shopping List</h1>
<div class="d-flex justify-content-between">
<p>Amount of food to buy:</p>

<div>
Recipe: Recipe2Link
</div>

</div>
<p>Total value of of food needed:</p>
<div>
Inventory: Inventory1
</div>
<div class="mt-4">
<table class="table table-bordered">
<thead>
<tr>
<th>Food</th>
<th>Quantity</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<% if @recipe_foods.present? %>
<% @recipe_foods.each do |recipe_food| %>
<tr>
<td><%= recipe_food.food.name %></td>
<td><%= recipe_food.quantity %>g</td>
<td>$<%= recipe_food.quantity * recipe_food.food.price %></td>
<td>
</td>
</tr>
<% end %>
<% else %>
<tr>
<td colspan="4">No shopping list available.</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<%= link_to '< Back To All Recipes', recipe_index_path, class: 'btn small btn-primary' %>
</div>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Rails.application.routes.draw do
get 'shopping/index'
root 'food#index'
devise_for :users

Expand All @@ -12,6 +13,7 @@
resources :recipe_foods, only: [:new, :create, :destroy]
post '', to: 'recipe#create', on: :new, as: 'create_recipe'
get 'new_recipe', to: 'recipe#new', on: :new, as: 'new_recipe'
get 'shopping', to: 'shopping#index', as: 'shopping_index'
end

delete 'recipe/:id', to: 'recipe#destroy', as: 'remove_recipe'
Expand Down
15 changes: 15 additions & 0 deletions spec/helpers/shopping_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'rails_helper'

# Specs in this file have access to a helper object that includes
# the ShoppingHelper. For example:
#
# describe ShoppingHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe ShoppingHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
10 changes: 10 additions & 0 deletions spec/requests/shopping_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'rails_helper'

RSpec.describe 'Shoppings', type: :request do
describe 'GET /index' do
it 'returns http success' do
get '/shopping/index'
expect(response).to have_http_status(:success)
end
end
end
5 changes: 5 additions & 0 deletions spec/views/shopping/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

RSpec.describe 'shopping/index.html.erb', type: :view do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit 4519a88

Please sign in to comment.