-
Notifications
You must be signed in to change notification settings - Fork 0
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
implemented some expert's recommendation #21
Open
kukurudz-nadia
wants to merge
15
commits into
dev
Choose a base branch
from
changes-after-demo
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2f92c60
implemented some expert's recommendation
31b32ba
changed has_and_belongs_to_many on has_many through relationships (#22)
kukurudz-nadia 5088b75
deleted helpers (#23)
kukurudz-nadia da48e32
added dependent (#24)
kukurudz-nadia 43a2218
changed tailwind import files (#27)
kukurudz-nadia c6e3324
added layaout for products (#28)
kukurudz-nadia ee90513
added favicon (#29)
kukurudz-nadia 4136279
changed path
28e3f14
changed naming (#30)
kukurudz-nadia c388d14
resolved-some-problems (#31)
kukurudz-nadia 13a8b1b
Resolved problems (#32)
kukurudz-nadia ae5ebff
added cart for registered and unregistered user
kukurudz-nadia 9df99e0
-
kukurudz-nadia 07cd385
-
b6aadce
added a part of order (#38)
kukurudz-nadia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,2 +1,2 @@ | ||
web: bin/rails server -p 3000 | ||
css: bin/rails tailwindcss:watch | ||
web: rails server -p 3000 | ||
css: rails tailwindcss:watch |
Binary file removed
BIN
-71.9 KB
app/assets/images/breathtaking-online-shopping-statistics-you-never-knew.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Binary file removed
BIN
-11 MB
...y_online-shopping-or-ecommmerce-delivery-service-concept-paper_10701474_824.jpg
Binary file not shown.
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 |
---|---|---|
@@ -1,13 +1,4 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
/* | ||
|
||
@layer components { | ||
.btn-primary { | ||
@apply py-2 px-4 bg-blue-200; | ||
} | ||
} | ||
|
||
*/ | ||
@import "tailwindcss/base"; | ||
@import "tailwindcss/components"; | ||
@import "./components/buttons.css"; | ||
@import "tailwindcss/utilities"; |
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,13 @@ | ||
@layer components { | ||
.btn-gradient { | ||
@apply text-gray-900 bg-gradient-to-r from-teal-200 to-lime-200 hover:bg-gradient-to-l hover:from-teal-200 hover:to-lime-200 focus:ring-4 focus:outline-none focus:ring-lime-200 dark:focus:ring-teal-700 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2; | ||
} | ||
|
||
.btn-green { | ||
@apply text-white bg-gradient-to-r from-green-400 via-green-500 to-green-600 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-green-300 dark:focus:ring-green-800 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2; | ||
} | ||
|
||
.btn-blue { | ||
@apply bg-cyan-500 text-white active:bg-cyan-600 font-bold uppercase text-xs px-4 py-2 rounded shadow hover:shadow-md outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150; | ||
} | ||
} |
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,14 +1,2 @@ | ||
class ApplicationController < ActionController::Base | ||
before_action :initialize_session | ||
before_action :load_cart | ||
|
||
private | ||
|
||
def initialize_session | ||
session[:cart] ||= [] | ||
end | ||
|
||
def load_cart | ||
@cart = Product.find(session[:cart]) | ||
end | ||
end |
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,6 +1,22 @@ | ||
class CartsController < ApplicationController | ||
before_action :authenticate_user! | ||
|
||
def show | ||
@cart = resource | ||
end | ||
|
||
def create | ||
end | ||
|
||
def destroy | ||
end | ||
|
||
|
||
private | ||
|
||
def resource | ||
if user_signed_in? | ||
Product.where(id: current_user.cart.cart_products.pluck(:product_id)) | ||
elsif session[:product_id] | ||
Product.where(id: session[:product_id]) | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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,9 +1,19 @@ | ||
class CategoriesController < ApplicationController | ||
def index | ||
@categories = Category.all | ||
end | ||
|
||
def show | ||
@category = Category.find(params[:id]) | ||
end | ||
def index | ||
@categories = collection | ||
end | ||
|
||
def show | ||
@category = resource | ||
end | ||
|
||
private | ||
|
||
def collection | ||
Category.ordered | ||
end | ||
|
||
def resource | ||
collection.find(params[:id]) | ||
end | ||
end |
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,5 +1,2 @@ | ||
class HomeController < ApplicationController | ||
def index | ||
render | ||
end | ||
end |
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,51 +1,56 @@ | ||
class OrdersController < ApplicationController | ||
before_action :set_quote, only: [:show, :edit, :update, :destroy] | ||
|
||
def index | ||
@orders = Order.all | ||
end | ||
|
||
def show | ||
@order = Order.find(params[:id]) | ||
end | ||
|
||
def new | ||
@order = Order.new | ||
@order = Order.create(user_id: current_user.id, status: "created", ordered_at: DateTime.current) | ||
current_user.cart.products.each do |item| | ||
@order.products << item | ||
current_user.cart[:id] = nil | ||
end | ||
# address = Address.new(address_params) | ||
# address.save | ||
# @order_detail = OrderDetail.new(order_detail_params) | ||
# @order_detail.save | ||
@order.save | ||
end | ||
|
||
def create | ||
@order = Order.new(order_params) | ||
|
||
if @order.save | ||
redirect_to orders_path, notice: "Order was successfully created." | ||
else | ||
render :new | ||
|
||
current_user.cart.cart_products.each do |item| | ||
@order.cart_products << item | ||
item.cart_id = nil | ||
end | ||
end | ||
|
||
def edit | ||
@order.save | ||
Cart.destroy(session[:cart_id]) | ||
session[:cart_id] = nil | ||
redirect_to root_path | ||
end | ||
|
||
def update | ||
if @order.update(order_params) | ||
redirect_to orders_path, notice: "Order was successfully updated." | ||
else | ||
render :edit | ||
respond_to do |format| | ||
if @order.update(order_params) | ||
format.html { redirect_to @order, notice: 'Website was successfully updated.' } | ||
format.json { render :show, status: :ok, location: @order } | ||
else | ||
format.html { render :edit } | ||
format.json { render json: @order.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
def destroy | ||
@order.destroy | ||
redirect_to orders_path, notice: "Order was successfully destroyed." | ||
end | ||
|
||
private | ||
def order_params | ||
params.require(:order).permit() | ||
end | ||
|
||
def set_quote | ||
@order = Order.find(params[:id]) | ||
end | ||
# def order_detail_params | ||
# params.require(:order_detail).permit(:first_name, :last_name, :email, address_id: address.id, order_id: @order.id) | ||
# end | ||
|
||
def order_params | ||
params.require(:order).permit(:status, :ordered_at) | ||
end | ||
# def address_params | ||
# params.require(:address).permit(:street, :city, :coutry, :comment, user_id: current_user.id) | ||
# end | ||
end |
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,62 +1,37 @@ | ||
class ProductsController < ApplicationController | ||
before_action :set_product, only: [:show, :edit, :update, :destroy] | ||
|
||
def index | ||
@products = Product.all | ||
end | ||
|
||
def show | ||
end | ||
|
||
def new | ||
@product = Product.new | ||
end | ||
|
||
def create | ||
@product = Product.new(quote_params) | ||
|
||
if @product.save | ||
redirect_to products_path, notice: "Product was successfully created." | ||
if params[:id] | ||
@products = collection.where(category_id: params[:id]) | ||
else | ||
render :new | ||
@products = collection | ||
end | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
if @product.update(product_params) | ||
redirect_to products_path, notice: "Product was successfully updated." | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
@product.destroy | ||
redirect_to products_path, notice: "Product was successfully destroyed." | ||
def show | ||
@product = resource | ||
end | ||
|
||
def add_to_cart | ||
id = params[:id].to_i | ||
session[:cart] << id unless session[:cart].include?(id) | ||
if session[:product_ids].nil? | ||
session[:product_ids] = [] | ||
end | ||
|
||
session[:product_ids] << params[:id] | ||
redirect_to products_path | ||
end | ||
|
||
def remove_from_cart | ||
id = params[:id].to_i | ||
session[:cart].delete(id) | ||
redirect_to products_path | ||
end | ||
|
||
private | ||
|
||
def set_product | ||
@product = Product.find(params[:id]) | ||
def collection | ||
Product.ordered | ||
end | ||
|
||
def product_params | ||
params.require(:product).permit(:name, :price, :description, :position, :category_id) | ||
def resource | ||
collection.find(params[:id]) | ||
end | ||
end |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ресурс?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
і для чого у тебе екшин едіта та апдейта замовлення?) на тій же розетці ти маєш таку можливість?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed