From 951d1e18f43fa2a11ca6890fd5f5487bfe9885ed Mon Sep 17 00:00:00 2001 From: shreya-sridhar Date: Wed, 2 Dec 2020 20:11:29 +0000 Subject: [PATCH 01/26] added models --- app/models/customer.rb | 2 ++ app/models/food.rb | 2 ++ app/models/order.rb | 2 ++ bin/run.rb | 2 -- 4 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 app/models/customer.rb create mode 100644 app/models/food.rb create mode 100644 app/models/order.rb diff --git a/app/models/customer.rb b/app/models/customer.rb new file mode 100644 index 00000000..fc0f5d42 --- /dev/null +++ b/app/models/customer.rb @@ -0,0 +1,2 @@ +class Customer < ActiveRecord::Base +end \ No newline at end of file diff --git a/app/models/food.rb b/app/models/food.rb new file mode 100644 index 00000000..78ba5e9b --- /dev/null +++ b/app/models/food.rb @@ -0,0 +1,2 @@ +class Food < ActiveRecord::Base +end \ No newline at end of file diff --git a/app/models/order.rb b/app/models/order.rb new file mode 100644 index 00000000..6d008986 --- /dev/null +++ b/app/models/order.rb @@ -0,0 +1,2 @@ +class Order < ActiveRecord::Base +end diff --git a/bin/run.rb b/bin/run.rb index cf08c338..c782482c 100644 --- a/bin/run.rb +++ b/bin/run.rb @@ -1,5 +1,3 @@ require_relative '../config/environment' - - puts "HELLO WORLD" From 49139cc56efd382cb3d00a3d187f1c363f24468f Mon Sep 17 00:00:00 2001 From: shreya-sridhar Date: Wed, 2 Dec 2020 20:55:33 +0000 Subject: [PATCH 02/26] added model relationships --- app/models/customer.rb | 2 ++ app/models/food.rb | 2 ++ app/models/order.rb | 2 ++ 3 files changed, 6 insertions(+) diff --git a/app/models/customer.rb b/app/models/customer.rb index fc0f5d42..a7f8c277 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,2 +1,4 @@ class Customer < ActiveRecord::Base + has_many :orders + has_many :foods, through: :orders end \ No newline at end of file diff --git a/app/models/food.rb b/app/models/food.rb index 78ba5e9b..ea9c839d 100644 --- a/app/models/food.rb +++ b/app/models/food.rb @@ -1,2 +1,4 @@ class Food < ActiveRecord::Base + belongs_to: customer + belongs_to: order end \ No newline at end of file diff --git a/app/models/order.rb b/app/models/order.rb index 6d008986..3ec6756c 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,2 +1,4 @@ class Order < ActiveRecord::Base + has_many :foods + has_many :customers, through: :foods end From 3e418ff78afe69022eb482602119bb06c5713599 Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Wed, 2 Dec 2020 13:17:26 -0800 Subject: [PATCH 03/26] first commit --- Gemfile | 21 +++++++++- Gemfile.lock | 112 ++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 104 insertions(+), 29 deletions(-) diff --git a/Gemfile b/Gemfile index c004f4ca..5cbcd3fb 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,26 @@ # frozen_string_literal: true +# source "https://rubygems.org" + +# gem "sinatra-activerecord" +# gem "sqlite3" +# gem "pry" +# gem "require_all" + source "https://rubygems.org" +gem "activerecord", '~> 5.2' gem "sinatra-activerecord" -gem "sqlite3" +gem "sqlite3", '~> 1.3.6' gem "pry" gem "require_all" +gem "faker" +gem "rake" +gem "tty-prompt" +gem "pastel" +gem "tty-progressbar" +gem "tty-spinner" +gem 'tty-font' +gem 'date' +gem 'rest-client' +gem 'json' + diff --git a/Gemfile.lock b/Gemfile.lock index 9589226d..acfd83fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,56 +1,112 @@ GEM remote: https://rubygems.org/ specs: - activemodel (6.0.3.1) - activesupport (= 6.0.3.1) - activerecord (6.0.3.1) - activemodel (= 6.0.3.1) - activesupport (= 6.0.3.1) - activesupport (6.0.3.1) + activemodel (5.2.4.4) + activesupport (= 5.2.4.4) + activerecord (5.2.4.4) + activemodel (= 5.2.4.4) + activesupport (= 5.2.4.4) + arel (>= 9.0) + activesupport (5.2.4.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) - coderay (1.1.1) - concurrent-ruby (1.1.6) - i18n (1.8.2) + arel (9.0.0) + coderay (1.1.3) + concurrent-ruby (1.1.7) + date (3.0.1) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) + faker (2.15.1) + i18n (>= 1.6, < 2) + http-accept (1.7.0) + http-cookie (1.0.3) + domain_name (~> 0.5) + i18n (1.8.5) concurrent-ruby (~> 1.0) - method_source (0.8.2) - minitest (5.14.1) - mustermann (1.0.3) - pry (0.10.4) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) + json (2.3.1) + method_source (1.0.0) + mime-types (3.3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2020.1104) + minitest (5.14.2) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + netrc (0.11.0) + pastel (0.8.0) + tty-color (~> 0.5) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) rack (2.2.3) - rack-protection (2.0.7) + rack-protection (2.1.0) rack - require_all (1.3.3) - sinatra (2.0.7) + rake (13.0.1) + require_all (3.0.0) + rest-client (2.1.0) + http-accept (>= 1.7.0, < 2.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + ruby2_keywords (0.0.2) + sinatra (2.1.0) mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.7) + rack (~> 2.2) + rack-protection (= 2.1.0) tilt (~> 2.0) - sinatra-activerecord (2.0.12) - activerecord (>= 3.2) + sinatra-activerecord (2.0.21) + activerecord (>= 4.1) sinatra (>= 1.0) - slop (3.6.0) sqlite3 (1.3.13) + strings-ansi (0.1.0) thread_safe (0.3.6) tilt (2.0.10) - tzinfo (1.2.7) + tty-color (0.6.0) + tty-cursor (0.7.1) + tty-font (0.5.0) + tty-progressbar (0.17.0) + strings-ansi (~> 0.1.0) + tty-cursor (~> 0.7) + tty-screen (~> 0.7) + unicode-display_width (~> 1.6) + tty-prompt (0.22.0) + pastel (~> 0.8) + tty-reader (~> 0.8) + tty-reader (0.8.0) + tty-cursor (~> 0.7) + tty-screen (~> 0.8) + wisper (~> 2.0) + tty-screen (0.8.1) + tty-spinner (0.9.3) + tty-cursor (~> 0.7) + tzinfo (1.2.8) thread_safe (~> 0.1) - zeitwerk (2.3.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.7) + unicode-display_width (1.7.0) + wisper (2.0.1) PLATFORMS ruby DEPENDENCIES + activerecord (~> 5.2) + date + faker + json + pastel pry + rake require_all + rest-client sinatra-activerecord - sqlite3 + sqlite3 (~> 1.3.6) + tty-font + tty-progressbar + tty-prompt + tty-spinner BUNDLED WITH 1.14.6 From 978368464f508970194d5870b3569c0f4357b54d Mon Sep 17 00:00:00 2001 From: shreya-sridhar Date: Wed, 2 Dec 2020 21:19:25 +0000 Subject: [PATCH 04/26] modified relationships --- app/models/food.rb | 4 ++-- app/models/order.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/food.rb b/app/models/food.rb index ea9c839d..a8e7cd5e 100644 --- a/app/models/food.rb +++ b/app/models/food.rb @@ -1,4 +1,4 @@ class Food < ActiveRecord::Base - belongs_to: customer - belongs_to: order + has_many :orders + has_many :customers, through: :orders end \ No newline at end of file diff --git a/app/models/order.rb b/app/models/order.rb index 3ec6756c..28333564 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,4 +1,4 @@ class Order < ActiveRecord::Base - has_many :foods - has_many :customers, through: :foods + belongs_to: customer + belongs_to: food end From e081047e83d4d2e77d7b22ed0f966e013684d4c1 Mon Sep 17 00:00:00 2001 From: shreya-sridhar Date: Wed, 2 Dec 2020 22:31:11 +0000 Subject: [PATCH 05/26] done --- Gemfile | 2 +- db/migrate/20201202221901_create_orders.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20201202221901_create_orders.rb diff --git a/Gemfile b/Gemfile index 5cbcd3fb..7f208228 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -# frozen_string_literal: true +#frozen_string_literal: true # source "https://rubygems.org" # gem "sinatra-activerecord" diff --git a/db/migrate/20201202221901_create_orders.rb b/db/migrate/20201202221901_create_orders.rb new file mode 100644 index 00000000..85713f31 --- /dev/null +++ b/db/migrate/20201202221901_create_orders.rb @@ -0,0 +1,10 @@ +class CreateOrders < ActiveRecord::Migration[5.2] + def change + create_table :orders do |t| + t.integer :user_id + t.integer :food_id + t.integer :quantity + t.integer :price + t.timestamp + end +end From d369d832ecf5b9ae525c7b3a6f3cf3bdb5d1c672 Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Wed, 2 Dec 2020 14:45:10 -0800 Subject: [PATCH 06/26] created two tables --- app/models/order.rb | 4 ++-- bin/cli.rb | 0 db/migrate/20201202221901_create_orders.rb | 6 +++++- db/migrate/20201202224028_create_foods.rb | 11 +++++++++++ db/migrate/20201202224240_create_customers.rb | 10 ++++++++++ 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 bin/cli.rb create mode 100644 db/migrate/20201202224028_create_foods.rb create mode 100644 db/migrate/20201202224240_create_customers.rb diff --git a/app/models/order.rb b/app/models/order.rb index 28333564..d5c52a14 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,4 +1,4 @@ class Order < ActiveRecord::Base - belongs_to: customer - belongs_to: food + belongs_to :customer + belongs_to :food end diff --git a/bin/cli.rb b/bin/cli.rb new file mode 100644 index 00000000..e69de29b diff --git a/db/migrate/20201202221901_create_orders.rb b/db/migrate/20201202221901_create_orders.rb index 85713f31..3cbbab51 100644 --- a/db/migrate/20201202221901_create_orders.rb +++ b/db/migrate/20201202221901_create_orders.rb @@ -4,7 +4,11 @@ def change t.integer :user_id t.integer :food_id t.integer :quantity - t.integer :price + t.integer :total + t.timestamp + + end + end end diff --git a/db/migrate/20201202224028_create_foods.rb b/db/migrate/20201202224028_create_foods.rb new file mode 100644 index 00000000..d723bcb8 --- /dev/null +++ b/db/migrate/20201202224028_create_foods.rb @@ -0,0 +1,11 @@ +class CreateFoods < ActiveRecord::Migration[5.2] + def change + create_table :foods do |t| + t.string :name + t.integer :price + + t.timestamp + end + + end +end diff --git a/db/migrate/20201202224240_create_customers.rb b/db/migrate/20201202224240_create_customers.rb new file mode 100644 index 00000000..d237d1fa --- /dev/null +++ b/db/migrate/20201202224240_create_customers.rb @@ -0,0 +1,10 @@ +class CreateCustomers < ActiveRecord::Migration[5.2] + def change + create_table :customers do |t| + t.string :name + + t.timestamp + end + + end +end From 2a0eae32f52f84dc66a87a4ca39d341fdd01b7c4 Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Wed, 2 Dec 2020 15:00:27 -0800 Subject: [PATCH 07/26] seeds --- db/migrate/seeds.rb | 18 ++++++++++++++++++ db/schema.rb | 31 +++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 db/migrate/seeds.rb create mode 100644 db/schema.rb diff --git a/db/migrate/seeds.rb b/db/migrate/seeds.rb new file mode 100644 index 00000000..143ce680 --- /dev/null +++ b/db/migrate/seeds.rb @@ -0,0 +1,18 @@ +require_relative "../app/models/customer.rb" +require_relative "../app/models/food.rb" +require_relative "../app/models/order.rb" +require_relative "../config/environment.rb" + + + +Customer.destroy_all +Food.destroy_all +Order.destroy_all + + +puts "Customer" + +10.times do + Customer.create( + name + ) \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 00000000..ae58a993 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,31 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_12_02_224240) do + + create_table "customers", force: :cascade do |t| + t.string "name" + end + + create_table "foods", force: :cascade do |t| + t.string "name" + t.integer "price" + end + + create_table "orders", force: :cascade do |t| + t.integer "user_id" + t.integer "food_id" + t.integer "quantity" + t.integer "total" + end + +end From e052d17ed9cf13527d2a3ff8cbdee523d84389ed Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Wed, 2 Dec 2020 17:26:13 -0800 Subject: [PATCH 08/26] Made some seeds --- config/environment.rb | 1 + db/migrate/20201202221901_create_orders.rb | 4 +- db/migrate/20201202224028_create_foods.rb | 2 +- db/migrate/20201202224240_create_customers.rb | 2 +- db/migrate/seeds.rb | 18 ------ db/schema.rb | 8 ++- db/seeds.rb | 56 +++++++++++++++++++ 7 files changed, 68 insertions(+), 23 deletions(-) delete mode 100644 db/migrate/seeds.rb create mode 100644 db/seeds.rb diff --git a/config/environment.rb b/config/environment.rb index 4dbe13e5..723e66d8 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -3,3 +3,4 @@ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') require_all 'lib' +require_all 'app' \ No newline at end of file diff --git a/db/migrate/20201202221901_create_orders.rb b/db/migrate/20201202221901_create_orders.rb index 3cbbab51..e83c8808 100644 --- a/db/migrate/20201202221901_create_orders.rb +++ b/db/migrate/20201202221901_create_orders.rb @@ -1,12 +1,12 @@ class CreateOrders < ActiveRecord::Migration[5.2] def change create_table :orders do |t| - t.integer :user_id + t.integer :customer_id t.integer :food_id t.integer :quantity t.integer :total - t.timestamp + t.timestamps end diff --git a/db/migrate/20201202224028_create_foods.rb b/db/migrate/20201202224028_create_foods.rb index d723bcb8..dbc31092 100644 --- a/db/migrate/20201202224028_create_foods.rb +++ b/db/migrate/20201202224028_create_foods.rb @@ -4,7 +4,7 @@ def change t.string :name t.integer :price - t.timestamp + t.timestamps end end diff --git a/db/migrate/20201202224240_create_customers.rb b/db/migrate/20201202224240_create_customers.rb index d237d1fa..e128734c 100644 --- a/db/migrate/20201202224240_create_customers.rb +++ b/db/migrate/20201202224240_create_customers.rb @@ -3,7 +3,7 @@ def change create_table :customers do |t| t.string :name - t.timestamp + t.timestamps end end diff --git a/db/migrate/seeds.rb b/db/migrate/seeds.rb deleted file mode 100644 index 143ce680..00000000 --- a/db/migrate/seeds.rb +++ /dev/null @@ -1,18 +0,0 @@ -require_relative "../app/models/customer.rb" -require_relative "../app/models/food.rb" -require_relative "../app/models/order.rb" -require_relative "../config/environment.rb" - - - -Customer.destroy_all -Food.destroy_all -Order.destroy_all - - -puts "Customer" - -10.times do - Customer.create( - name - ) \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index ae58a993..c9a08773 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -14,18 +14,24 @@ create_table "customers", force: :cascade do |t| t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "foods", force: :cascade do |t| t.string "name" t.integer "price" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "orders", force: :cascade do |t| - t.integer "user_id" + t.integer "customer_id" t.integer "food_id" t.integer "quantity" t.integer "total" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 00000000..057f46bd --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,56 @@ +require_relative "../config/environment.rb" +require_relative "../app/models/customer.rb" +require_relative "../app/models/food.rb" +require_relative "../app/models/order.rb" + + + +Order.destroy_all +Customer.destroy_all +Food.destroy_all + + +puts "Customer" + +20.times do + Customer.create( + name: Faker::Name.name + ) +end + +puts "Food" + +100.times do + Food.create( + name: Faker::Food.ingredient, + price: rand(20..180) + ) + +end + +# 60.times do +# Order.create( +# customer_id: Customer.all.map{|cus| cus.id}.sample, +# food_id: Food.all.map{|fo| fo.id}.sample, +# quantity: rand(1..20), +# total: Food.all.map{|foo| foo.price if foo.id == self.food_id} * self.quantity +# ) +# end + +#Custome(name: "Dan") +#Food.new(name: "Apple", price: 1 ) +Order.create(customer_id: 180, food_id: 831, quantity:10) +#total: Food.all.map{|foo| foo.price if foo.id == self.food_id} * self.quantity + + + + + + + + +# c1 = Customer.create(name:'Dan') + +# f1 = Food.create(name:'pie',price: 2) + + From 000de44be9aca1d7ebc91c233ebc5eed8d4eaa81 Mon Sep 17 00:00:00 2001 From: shreya-sridhar Date: Thu, 3 Dec 2020 01:28:30 +0000 Subject: [PATCH 09/26] done --- db/migrate/20201202221901_create_orders.rb | 1 - db/migrate/20201202224240_create_customers.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/db/migrate/20201202221901_create_orders.rb b/db/migrate/20201202221901_create_orders.rb index 3cbbab51..9612e455 100644 --- a/db/migrate/20201202221901_create_orders.rb +++ b/db/migrate/20201202221901_create_orders.rb @@ -5,7 +5,6 @@ def change t.integer :food_id t.integer :quantity t.integer :total - t.timestamp end diff --git a/db/migrate/20201202224240_create_customers.rb b/db/migrate/20201202224240_create_customers.rb index d237d1fa..a3ba401b 100644 --- a/db/migrate/20201202224240_create_customers.rb +++ b/db/migrate/20201202224240_create_customers.rb @@ -2,7 +2,6 @@ class CreateCustomers < ActiveRecord::Migration[5.2] def change create_table :customers do |t| t.string :name - t.timestamp end From 1a5ba09e9581b414c68598f22cdf89c4486c7b03 Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Thu, 3 Dec 2020 09:49:07 -0800 Subject: [PATCH 10/26] start layout --- bin/cli.rb | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/run.rb | 6 +++++- db/seeds.rb | 16 +++++++-------- 3 files changed, 69 insertions(+), 9 deletions(-) diff --git a/bin/cli.rb b/bin/cli.rb index e69de29b..22de193c 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -0,0 +1,56 @@ +class CLI + + attr_reader :prompt, :font + attr_accessor :customer + + + + def main_menu + @prompt = TTY::Prompt.new + @font = TTY::Font.new + @pastel = Pastel.new + opener + puts @pastel.cyan(@font.write(" Shopping Cart !!")) + opener + prompt = TTY::Prompt.new + choices = ['🔹Login' ,'🔹Signup', '🔹Exit'] # '🔹Update Name Info', '🔹Delete Account' + choice = prompt.select("\n 🔹Welcome to Shopping Cart, please make a selection🔹\n", choices) # do not use multi_select it leaves an octogon symble + + if choice == '🔹Login' + login + elsif choice == '🔹Signup' + signup + elsif choice == '🔹Exit' + puts "**********" + puts "Good Bye!" + puts "**********" + end + + + end + + + def login + + end + + def signup + + end + + + + + + + def opener + puts "\n 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 \n " + end + + + + + + + +end diff --git a/bin/run.rb b/bin/run.rb index c782482c..ac1331d7 100644 --- a/bin/run.rb +++ b/bin/run.rb @@ -1,3 +1,7 @@ require_relative '../config/environment' +require_relative '../bin/cli.rb' -puts "HELLO WORLD" +#puts "HELLO WORLD" + +cli = CLI.new +cli.main_menu diff --git a/db/seeds.rb b/db/seeds.rb index 057f46bd..f1dee054 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -28,14 +28,14 @@ end -# 60.times do -# Order.create( -# customer_id: Customer.all.map{|cus| cus.id}.sample, -# food_id: Food.all.map{|fo| fo.id}.sample, -# quantity: rand(1..20), -# total: Food.all.map{|foo| foo.price if foo.id == self.food_id} * self.quantity -# ) -# end +60.times do + Order.create( + customer_id: Customer.all.sample.id, + food_id: Food.all.sample.id, + quantity: rand(1..20), + #total: Food.all.map{|foo| foo.price if foo.id == self.food_id} * self.quantity + ) +end #Custome(name: "Dan") #Food.new(name: "Apple", price: 1 ) From f3cd4da2c4cb45d53d102b1dccbcc4ac22cedef3 Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Thu, 3 Dec 2020 10:20:40 -0800 Subject: [PATCH 11/26] start cli --- bin/cli.rb | 26 ++++++++++++++++++++++---- db/seeds.rb | 5 +++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/bin/cli.rb b/bin/cli.rb index 22de193c..4e3d3a3b 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -21,9 +21,7 @@ def main_menu elsif choice == '🔹Signup' signup elsif choice == '🔹Exit' - puts "**********" - puts "Good Bye!" - puts "**********" + exit end @@ -31,11 +29,31 @@ def main_menu def login + + shopping + end + + def profile + end + + def shopping + choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] end + + + def signup - + login + + shopping + end + + def exit + puts "**********" + puts "Good Bye!" + puts "**********" end diff --git a/db/seeds.rb b/db/seeds.rb index f1dee054..79627e38 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -28,6 +28,11 @@ end + +#Faker::Food.vegetables +#Faker::Food.spice +#Faker::Food.fruits + 60.times do Order.create( customer_id: Customer.all.sample.id, From 879a55f83d751b022d427dad4c487e07b12a8714 Mon Sep 17 00:00:00 2001 From: shreya-sridhar Date: Thu, 3 Dec 2020 18:26:32 +0000 Subject: [PATCH 12/26] done --- db/migrate/20201202224240_create_customers.rb | 1 + db/schema.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/db/migrate/20201202224240_create_customers.rb b/db/migrate/20201202224240_create_customers.rb index a3ba401b..bf9ead87 100644 --- a/db/migrate/20201202224240_create_customers.rb +++ b/db/migrate/20201202224240_create_customers.rb @@ -2,6 +2,7 @@ class CreateCustomers < ActiveRecord::Migration[5.2] def change create_table :customers do |t| t.string :name + t.string :password t.timestamp end diff --git a/db/schema.rb b/db/schema.rb index 840534c4..a2b31c93 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -14,6 +14,7 @@ create_table "customers", force: :cascade do |t| t.string "name" + t.string "password" end create_table "foods", force: :cascade do |t| From 61807ebb04043d96625780f4071f173eb0343550 Mon Sep 17 00:00:00 2001 From: shreya-sridhar Date: Thu, 3 Dec 2020 18:57:07 +0000 Subject: [PATCH 13/26] decided some methods --- bin/cli.rb | 38 ++++++++++++++++++----- db/migrate/20201202224028_create_foods.rb | 2 +- db/schema.rb | 1 + 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/bin/cli.rb b/bin/cli.rb index 4e3d3a3b..94eef33f 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -27,27 +27,51 @@ def main_menu end + + def signup - def login - + #create user_name & password -> update the table shopping end - def profile + def login + #gets user_name & password -> check if password matches user_name in table else 1. Error Msg 2. Exit 3. Re-login 4. Reset Password -> Signup + shopping end - def shopping choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] end + def profile + #reset user_name & password + go_back + end + def go_back + -> if else + end + def go_to_shopping + # # choose from aisles choices = [fruits, vegetables, spices, meats, delete items] + # # select foods from aisle and display prices and emojis + # # added to cart -> optional to add quantity + # # at the end of aisles, go back to aisle choices + # go_back + # cart = [] + end - def signup - login + def view_cart(cart) + cart = [] + total = calculates total + checkout + go_back + end - shopping + def checkout + show receipt + exit + go_back end def exit diff --git a/db/migrate/20201202224028_create_foods.rb b/db/migrate/20201202224028_create_foods.rb index dbc31092..71f94ca3 100644 --- a/db/migrate/20201202224028_create_foods.rb +++ b/db/migrate/20201202224028_create_foods.rb @@ -2,8 +2,8 @@ class CreateFoods < ActiveRecord::Migration[5.2] def change create_table :foods do |t| t.string :name + t.string :category t.integer :price - t.timestamps end diff --git a/db/schema.rb b/db/schema.rb index a2b31c93..ceff928c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -19,6 +19,7 @@ create_table "foods", force: :cascade do |t| t.string "name" + t.string "category" t.integer "price" t.datetime "created_at", null: false t.datetime "updated_at", null: false From ef325e2ff8a28531bd6c8cd1aae9893726589dda Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Thu, 3 Dec 2020 12:06:41 -0800 Subject: [PATCH 14/26] more seeds --- bin/cli.rb | 4 +- db/migrate/20201202224240_create_customers.rb | 1 + db/seeds.rb | 45 +++++++++++++++++-- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/bin/cli.rb b/bin/cli.rb index 94eef33f..247aad58 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -40,7 +40,7 @@ def login end def shopping - choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] + #choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] end def profile @@ -49,7 +49,7 @@ def profile end def go_back - -> if else + #-> if else end def go_to_shopping diff --git a/db/migrate/20201202224240_create_customers.rb b/db/migrate/20201202224240_create_customers.rb index bf9ead87..c6b0f4b4 100644 --- a/db/migrate/20201202224240_create_customers.rb +++ b/db/migrate/20201202224240_create_customers.rb @@ -3,6 +3,7 @@ def change create_table :customers do |t| t.string :name t.string :password + t.timestamp end diff --git a/db/seeds.rb b/db/seeds.rb index 3f3f6c01..1c1e426d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -11,21 +11,58 @@ 20.times do Customer.create( - name: Faker::Name.name + name: Faker::Name.name, + password: Faker::Barcode.ean ) end + +c1 = Customer.new(name:'Dan', password:'123') +c2 = Customer.new(name:'Tee', password:'321') +c3 = Customer.new(name:'Bob', password:'111') + +f1 = Food.new(name: 'Methi', category: 'Spice', price: 10) +f2 = Food.new(name: 'Rosemary', category: 'Spice', price: 10) +f3 = Food.new(name: 'Parsnip', category: 'Vegetables', price: 10) + + +or1 = (customer_id: c1, food_id: f1, quantity: 2, total:) + + + + + + + puts "Food" -100.times do +30.times do + Food.create( + name: Faker::Food.fruits, + price: rand(20..180), + category: "Fruits" + ) +end + +30.times do Food.create( - name: Faker::Food.ingredient, - price: rand(20..180) + name: Faker::Food.vegetables, + price: rand(20..180), + category: "Vegetables" ) +end +30.times do + Food.create( + name: Faker::Food.spice, + price: rand(20..180), + category: "Spice" + ) end + + #Faker::Food.vegetables #Faker::Food.spice #Faker::Food.fruits From 217b3c2ec41489a37e0a1fc143a3870764e9579e Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Thu, 3 Dec 2020 13:28:51 -0800 Subject: [PATCH 15/26] seeds --- db/seeds.rb | 75 ++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 1c1e426d..2bd2139d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -26,39 +26,38 @@ f3 = Food.new(name: 'Parsnip', category: 'Vegetables', price: 10) -or1 = (customer_id: c1, food_id: f1, quantity: 2, total:) - - - +or1 = Order.new(customer_id: c1, food_id: f1, quantity: 2, total: 20) +or2 = Order.new(customer_id: c2, food_id: f2, quantity: 2, total: 20) +or3 = Order.new(customer_id: c3, food_id: f3, quantity: 2, total: 20) puts "Food" -30.times do - Food.create( - name: Faker::Food.fruits, - price: rand(20..180), - category: "Fruits" - ) -end +# 30.times do +# Food.create( +# name: Faker::Food.fruits, +# price: rand(20..180), +# category: "Fruits" +# ) +# end -30.times do - Food.create( - name: Faker::Food.vegetables, - price: rand(20..180), - category: "Vegetables" - ) -end +# 30.times do +# Food.create( +# name: Faker::Food.vegetables, +# price: rand(20..180), +# category: "Vegetables" +# ) +# end -30.times do - Food.create( - name: Faker::Food.spice, - price: rand(20..180), - category: "Spice" - ) -end +# 30.times do +# Food.create( +# name: Faker::Food.spice, +# price: rand(20..180), +# category: "Spice" +# ) +# end @@ -67,19 +66,19 @@ #Faker::Food.spice #Faker::Food.fruits -60.times do - Order.create( - customer_id: Customer.all.sample.id, - food_id: Food.all.sample.id, - quantity: rand(1..20), - #total: Food.all.map{|foo| foo.price if foo.id == self.food_id} * self.quantity - ) -end - -#Custome(name: "Dan") -#Food.new(name: "Apple", price: 1 ) -Order.create(customer_id: 180, food_id: 831, quantity:10) -#total: Food.all.map{|foo| foo.price if foo.id == self.food_id} * self.quantity +# 60.times do +# Order.create( +# customer_id: Customer.all.sample.id, +# food_id: Food.all.sample.id, +# quantity: rand(1..20), +# #total: Food.all.map{|foo| foo.price if foo.id == self.food_id} * self.quantity +# ) +# end + +# #Custome(name: "Dan") +# #Food.new(name: "Apple", price: 1 ) +# Order.create(customer_id: 180, food_id: 831, quantity:10) +# #total: Food.all.map{|foo| foo.price if foo.id == self.food_id} * self.quantity From c8cc4c8f3153bf654c63e4d20d23190cafdaca9b Mon Sep 17 00:00:00 2001 From: shreya-sridhar Date: Thu, 3 Dec 2020 22:13:02 +0000 Subject: [PATCH 16/26] added login methods --- bin/cli.rb | 71 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/bin/cli.rb b/bin/cli.rb index 94eef33f..b80b443e 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -1,10 +1,10 @@ +require 'io/console' + class CLI attr_reader :prompt, :font attr_accessor :customer - - def main_menu @prompt = TTY::Prompt.new @font = TTY::Font.new @@ -23,33 +23,56 @@ def main_menu elsif choice == '🔹Exit' exit end - - end - - def signup - - #create user_name & password -> update the table - shopping + def self.signup + puts "Enter user name" + user_name = gets.chomp + puts "Enter password" + user_password = STDIN.noecho(&:gets).chomp + if !Customer.exists?(name: user_name) + Customer.create(name: user_name , password: user_password) + else + puts "Oops! This user name is already taken!" + self.signup + # accept user_name & password -> update the table with new user if user name is unique else retry + # go to shopping method - TBD end def login - #gets user_name & password -> check if password matches user_name in table else 1. Error Msg 2. Exit 3. Re-login 4. Reset Password -> Signup - shopping + attempts = 0 + while attempts <= 3 do + login_choices = ["Forgot User Name or Password?", "Exit"] + puts "Enter user name" + user_name = gets.chomp + puts "Enter password" + user_password = STDIN.noecho(&:gets).chomp + if Customer.exists?(name: user_name, password: user_password) + shopping + else + puts "Invalid User Name or Password" + attempts += 1 + login + end + end + + # After 3 attempts - prints max login attempts over. + # Forgot password + # gets user_name & password -> check if password matches user_name in table else 1. Error Msg 2. Exit 3. Re-login 4. Reset Password -> Signup + # shopping end - def shopping - choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] + # def shopping + # choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] end def profile - #reset user_name & password - go_back + # #reset user_name & password + # go_back end def go_back - -> if else + # -> if else end def go_to_shopping @@ -62,16 +85,16 @@ def go_to_shopping end def view_cart(cart) - cart = [] - total = calculates total - checkout - go_back + # cart = [] + # total = calculates total + # checkout + # go_back end def checkout - show receipt - exit - go_back + # show receipt + # exit + # go_back end def exit @@ -89,7 +112,7 @@ def opener puts "\n 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 \n " end - +end From ccd3b70218bb4261bbfba29401a89c464f005d55 Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Thu, 3 Dec 2020 14:18:38 -0800 Subject: [PATCH 17/26] cli --- bin/cli.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/cli.rb b/bin/cli.rb index 247aad58..abdacd08 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -40,7 +40,8 @@ def login end def shopping - #choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] + prompt = TTY::Prompt.new + choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] end def profile From c034cc6b19a746ccddc7bd7fdda669e0b341e0f1 Mon Sep 17 00:00:00 2001 From: shreya-sridhar Date: Thu, 3 Dec 2020 22:57:00 +0000 Subject: [PATCH 18/26] working login and signup --- bin/cli.rb | 24 ++++++++++-------------- db/seeds.rb | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/bin/cli.rb b/bin/cli.rb index 4ae91c17..de05d85e 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -9,9 +9,7 @@ def main_menu @prompt = TTY::Prompt.new @font = TTY::Font.new @pastel = Pastel.new - opener puts @pastel.cyan(@font.write(" Shopping Cart !!")) - opener prompt = TTY::Prompt.new choices = ['🔹Login' ,'🔹Signup', '🔹Exit'] # '🔹Update Name Info', '🔹Delete Account' choice = prompt.select("\n 🔹Welcome to Shopping Cart, please make a selection🔹\n", choices) # do not use multi_select it leaves an octogon symble @@ -25,16 +23,18 @@ def main_menu end end - def self.signup + def signup puts "Enter user name" user_name = gets.chomp puts "Enter password" user_password = STDIN.noecho(&:gets).chomp if !Customer.exists?(name: user_name) Customer.create(name: user_name , password: user_password) + puts "yay" else puts "Oops! This user name is already taken!" self.signup + end # accept user_name & password -> update the table with new user if user name is unique else retry # go to shopping method - TBD end @@ -49,20 +49,23 @@ def login user_password = STDIN.noecho(&:gets).chomp if Customer.exists?(name: user_name, password: user_password) shopping + return else puts "Invalid User Name or Password" attempts += 1 login end end + end # After 3 attempts - prints max login attempts over. # Forgot password # gets user_name & password -> check if password matches user_name in table else 1. Error Msg 2. Exit 3. Re-login 4. Reset Password -> Signup # shopping - end + def shopping + puts "yay" #choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] end @@ -104,18 +107,11 @@ def exit end - - - - def opener puts "\n 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 \n " end - end - - - - -end +shopping_cart = CLI.new() +# shopping_cart.main_menu +shopping_cart.login \ No newline at end of file diff --git a/db/seeds.rb b/db/seeds.rb index 2bd2139d..ad9a322d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -17,18 +17,18 @@ end -c1 = Customer.new(name:'Dan', password:'123') -c2 = Customer.new(name:'Tee', password:'321') -c3 = Customer.new(name:'Bob', password:'111') +Customer.create(name:'Dan', password:'123') +Customer.create(name:'Tee', password:'321') +Customer.create(name:'Bob', password:'111') -f1 = Food.new(name: 'Methi', category: 'Spice', price: 10) -f2 = Food.new(name: 'Rosemary', category: 'Spice', price: 10) -f3 = Food.new(name: 'Parsnip', category: 'Vegetables', price: 10) +Food.create(name: 'Methi', category: 'Spice', price: 10) +Food.create(name: 'Rosemary', category: 'Spice', price: 10) +Food.create(name: 'Parsnip', category: 'Vegetables', price: 10) -or1 = Order.new(customer_id: c1, food_id: f1, quantity: 2, total: 20) -or2 = Order.new(customer_id: c2, food_id: f2, quantity: 2, total: 20) -or3 = Order.new(customer_id: c3, food_id: f3, quantity: 2, total: 20) +Order.create(customer_id: Customer.all.sample.id, food_id: Food.all.sample.id, quantity: 2, total: 20) +Order.create(customer_id: Customer.all.sample.id, food_id: Food.all.sample.id, quantity: 2, total: 20) +Order.create(customer_id: Customer.all.sample.id, food_id: Food.all.sample.id, quantity: 2, total: 20) @@ -76,7 +76,7 @@ # end # #Custome(name: "Dan") -# #Food.new(name: "Apple", price: 1 ) +# #Food.create(name: "Apple", price: 1 ) # Order.create(customer_id: 180, food_id: 831, quantity:10) # #total: Food.all.map{|foo| foo.price if foo.id == self.food_id} * self.quantity From 1328b9da833e10beed8c773352939764248454ef Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Thu, 3 Dec 2020 14:57:20 -0800 Subject: [PATCH 19/26] did a little work on shopping method --- bin/cli.rb | 24 ++++++++++++++++++++---- db/seeds.rb | 19 ++++++++++--------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/bin/cli.rb b/bin/cli.rb index 4a0da36f..21f07461 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -35,10 +35,13 @@ def self.signup else puts "Oops! This user name is already taken!" self.signup + end + # accept user_name & password -> update the table with new user if user name is unique else retry # go to shopping method - TBD end + def login attempts = 0 while attempts <= 3 do @@ -65,8 +68,23 @@ def login def shopping prompt = TTY::Prompt.new choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] + choice = prompt.select(choices) + + if choice == '🔹View Profile' + view_profile + elsif choice == '🔹View Cart' + view_cart + elsif choice == '🔹Get To Shopping' + go_to_shopping + elsif choice == '🔹Checkout' + checkout + elsif choice == '🔹Exit' + exit + end end + + def profile # #reset user_name & password # go_back @@ -106,17 +124,15 @@ def exit - - - def opener puts "\n 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 \n " end + end -end + diff --git a/db/seeds.rb b/db/seeds.rb index 2bd2139d..2ec1fa96 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -17,24 +17,25 @@ end -c1 = Customer.new(name:'Dan', password:'123') -c2 = Customer.new(name:'Tee', password:'321') -c3 = Customer.new(name:'Bob', password:'111') +Customer.create(name:'Dan', password:'123') +Customer.create(name:'Tee', password:'321') +Customer.create(name:'Bob', password:'111') -f1 = Food.new(name: 'Methi', category: 'Spice', price: 10) -f2 = Food.new(name: 'Rosemary', category: 'Spice', price: 10) -f3 = Food.new(name: 'Parsnip', category: 'Vegetables', price: 10) +Food.create(name: 'Methi', category: 'Spice', price: 10) +Food.create(name: 'Rosemary', category: 'Spice', price: 10) +Food.create(name: 'Parsnip', category: 'Vegetables', price: 10) -or1 = Order.new(customer_id: c1, food_id: f1, quantity: 2, total: 20) -or2 = Order.new(customer_id: c2, food_id: f2, quantity: 2, total: 20) -or3 = Order.new(customer_id: c3, food_id: f3, quantity: 2, total: 20) +Order.create(customer_id: Customer.all.sample.id, food_id: Food.all.sample.id, quantity: 2, total: 20) +Order.create(customer_id: Customer.all.sample.id, food_id: Food.all.sample.id, quantity: 2, total: 20) +Order.create(customer_id: Customer.all.sample.id, food_id: Food.all.sample.id, quantity: 2, total: 20) puts "Food" + # 30.times do # Food.create( # name: Faker::Food.fruits, From be9dd110c8985176d7b1b2393d1231f5df30d8fa Mon Sep 17 00:00:00 2001 From: shreya-sridhar Date: Thu, 3 Dec 2020 23:07:14 +0000 Subject: [PATCH 20/26] added signup login methods --- bin/cli.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/cli.rb b/bin/cli.rb index de05d85e..2e6dd825 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -9,7 +9,9 @@ def main_menu @prompt = TTY::Prompt.new @font = TTY::Font.new @pastel = Pastel.new + opener puts @pastel.cyan(@font.write(" Shopping Cart !!")) + opener prompt = TTY::Prompt.new choices = ['🔹Login' ,'🔹Signup', '🔹Exit'] # '🔹Update Name Info', '🔹Delete Account' choice = prompt.select("\n 🔹Welcome to Shopping Cart, please make a selection🔹\n", choices) # do not use multi_select it leaves an octogon symble @@ -39,8 +41,7 @@ def signup # go to shopping method - TBD end - def login - attempts = 0 + def login(attempts = 0) while attempts <= 3 do login_choices = ["Forgot User Name or Password?", "Exit"] puts "Enter user name" @@ -53,7 +54,7 @@ def login else puts "Invalid User Name or Password" attempts += 1 - login + login(attempts) end end end @@ -114,4 +115,4 @@ def opener shopping_cart = CLI.new() # shopping_cart.main_menu -shopping_cart.login \ No newline at end of file +shopping_cart.login(attempts = 0) \ No newline at end of file From 9e7ad4bd1f6e3d311a54b08a877a4fb14383b2db Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Thu, 3 Dec 2020 15:08:14 -0800 Subject: [PATCH 21/26] Dan --- bin/cli.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/cli.rb b/bin/cli.rb index 21f07461..f23fd648 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -25,7 +25,7 @@ def main_menu end end - def self.signup + def signup puts "Enter user name" user_name = gets.chomp puts "Enter password" From 57fedbb23024b86457d237ff4d25409b5c174ec2 Mon Sep 17 00:00:00 2001 From: shreya-sridhar Date: Fri, 4 Dec 2020 00:55:04 +0000 Subject: [PATCH 22/26] added user profile methods --- bin/cli.rb | 79 +++++++++++++++++++++++++++++++++++++------ config/environment.rb | 2 ++ 2 files changed, 70 insertions(+), 11 deletions(-) diff --git a/bin/cli.rb b/bin/cli.rb index 2e6dd825..5bc5de26 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -1,4 +1,5 @@ require 'io/console' +# require 'pry' class CLI @@ -6,6 +7,7 @@ class CLI attr_accessor :customer def main_menu + system 'clear' @prompt = TTY::Prompt.new @font = TTY::Font.new @pastel = Pastel.new @@ -17,7 +19,8 @@ def main_menu choice = prompt.select("\n 🔹Welcome to Shopping Cart, please make a selection🔹\n", choices) # do not use multi_select it leaves an octogon symble if choice == '🔹Login' - login + attempts = 0 + login(attempts) elsif choice == '🔹Signup' signup elsif choice == '🔹Exit' @@ -26,23 +29,38 @@ def main_menu end def signup + system 'clear' puts "Enter user name" user_name = gets.chomp puts "Enter password" user_password = STDIN.noecho(&:gets).chomp if !Customer.exists?(name: user_name) Customer.create(name: user_name , password: user_password) - puts "yay" + if tried_user_names.include? user_name + puts "You already tried this user name!" + end else puts "Oops! This user name is already taken!" - self.signup + @prompt = TTY::Prompt.new + prompt = TTY::Prompt.new + choices = ['🔹Sign-Up With Different User Name' , '🔹Login','🔹Exit'] + choice = prompt.select("\n ? \n",choices) + if choice == '🔹Login' + attempts = 0 + login(attempts) + elsif choice == '🔹Sign-Up With Different User Name' + signup + else choice == '🔹Exit' + exit + end end # accept user_name & password -> update the table with new user if user name is unique else retry # go to shopping method - TBD end - def login(attempts = 0) - while attempts <= 3 do + def login(attempts) + system 'clear' + if attempts < 3 login_choices = ["Forgot User Name or Password?", "Exit"] puts "Enter user name" user_name = gets.chomp @@ -54,12 +72,25 @@ def login(attempts = 0) else puts "Invalid User Name or Password" attempts += 1 - login(attempts) + @prompt = TTY::Prompt.new + prompt = TTY::Prompt.new + choices = ['🔹Re-Login' ,'🔹Forgot User Name/Password', '🔹Exit'] + choice = prompt.select("\n ? \n",choices) + if choice == '🔹Re-Login' + login(attempts) + elsif choice == '🔹Forgot User Name/Password' + puts "Sign-Up" + signup + elsif choice == '🔹Exit' + exit + end end + else + puts "Maximum number of login attempts exceeded. Try again later!" end end - # After 3 attempts - prints max login attempts over. + # After 3 attempts - prints max login attempts over -> Advanced -> Do a timestamp-based entry # Forgot password # gets user_name & password -> check if password matches user_name in table else 1. Error Msg 2. Exit 3. Re-login 4. Reset Password -> Signup # shopping @@ -71,8 +102,34 @@ def shopping end def profile + system 'clear' + @prompt = TTY::Prompt.new + prompt = TTY::Prompt.new + choices = ['🔹Reset User Name' ,'🔹Reset Password', '🔹Delete Account', '🔹Exit'] + choice = prompt.select("\n ? \n",choices) + if choice == '🔹Reset User Name' + puts "Enter new user name" + user_name = gets.chomp + Customer.update_attribute(name, user_name) + elsif choice == '🔹Reset Password' + puts "Enter new password" + user_password = STDIN.noecho(&:gets).chomp + Customer.update_attribute(password, user_password) + elsif choice == '🔹Delete Account' + puts "Enter your user name" + user_name = gets.chomp + puts "Enter your password" + user_password = STDIN.noecho(&:gets).chomp + Customer.exists?(name: user_name, password: user_password): + User.destroy_all(name: user_name) + puts "Account Deleted. We hope to see you again soon!" + exit + else choice == '🔹Exit' + exit + end # #reset user_name & password - # go_back + # go_back + # delete account end def go_back @@ -113,6 +170,6 @@ def opener end end -shopping_cart = CLI.new() -# shopping_cart.main_menu -shopping_cart.login(attempts = 0) \ No newline at end of file +# shopping_cart = CLI.new() +# # shopping_cart.main_menu +# shopping_cart.login(attempts = 0) diff --git a/config/environment.rb b/config/environment.rb index 723e66d8..be2210c0 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -2,5 +2,7 @@ Bundler.require ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') +ActiveRecord::Base.logger = nil + require_all 'lib' require_all 'app' \ No newline at end of file From fac1595a211bbc2ab7522e43fbef20c82d2d6aa8 Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Thu, 3 Dec 2020 16:56:33 -0800 Subject: [PATCH 23/26] Dan --- bin/cli.rb | 49 +++++++++++++++++++++++++++++++------------ config/environment.rb | 4 ++++ 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/bin/cli.rb b/bin/cli.rb index 4d75a2e5..58bd8fe5 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -1,4 +1,5 @@ require 'io/console' +require 'tty-prompt' class CLI @@ -42,10 +43,10 @@ def signup end - def login + def login(attempts=0) attempts = 0 while attempts <= 3 do - login_choices = ["Forgot User Name or Password?", "Exit"] + #login_choices = ["Forgot User Name or Password?", "Exit"] puts "Enter user name" user_name = gets.chomp puts "Enter password" @@ -68,14 +69,29 @@ def login def shopping - puts "yay" - #choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] + puts 'yay' + @prompt = TTY::Prompt.new + prompt = TTY::Prompt.new + choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] + system 'clear' + choice = prompt.select("\n 🔹Welcome Back!!🔹 \n", choices) + if choice == '🔹View Profile' + profile + elsif choice == '🔹View Cart' + view_cart + elsif choice == '🔹Get To Shopping' + go_to_shopping + elsif choice == '🔹Checkout' + checkout + elsif choice == '🔹Exit' + exit + end end - def profile # #reset user_name & password + # delete account # go_back end @@ -90,9 +106,16 @@ def go_to_shopping # # at the end of aisles, go back to aisle choices # go_back # cart = [] + shopping end def view_cart(cart) + customer.food.each{|food| + puts "Fruits #{}" + puts "Vegetables #{}" + puts "Spices #{}" + + } # cart = [] # total = calculates total # checkout @@ -101,6 +124,7 @@ def view_cart(cart) def checkout # show receipt + #update cart/remove stuff if need be # exit # go_back end @@ -118,18 +142,17 @@ def opener end -end + # def opener + # puts "\n 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 \n " + # end - def opener - puts "\n 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 \n " - end -end + # shopping_cart = CLI.new() + # # shopping_cart.main_menu + # shopping_cart.signup #(attempts = 0) -shopping_cart = CLI.new() -# shopping_cart.main_menu -shopping_cart.login(attempts = 0) +end diff --git a/config/environment.rb b/config/environment.rb index 723e66d8..a15e1b85 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -2,5 +2,9 @@ Bundler.require ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') + +ActiveRecord::Base.logger = nil + + require_all 'lib' require_all 'app' \ No newline at end of file From b997127548954ccc7e1f056d48e9534459604893 Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Fri, 4 Dec 2020 13:59:37 -0800 Subject: [PATCH 24/26] shopping method --- bin/cli.rb | 151 +++++++++++++++++++++++++++------------------------- db/seeds.rb | 13 ++--- 2 files changed, 85 insertions(+), 79 deletions(-) diff --git a/bin/cli.rb b/bin/cli.rb index 9b1be444..b3b7f208 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -5,11 +5,10 @@ class CLI attr_reader :prompt, :font - attr_accessor :customer + attr_accessor :customer, :cart def main_menu system 'clear' - @prompt = TTY::Prompt.new @font = TTY::Font.new @pastel = Pastel.new opener @@ -37,12 +36,9 @@ def signup user_password = STDIN.noecho(&:gets).chomp if !Customer.exists?(name: user_name) Customer.create(name: user_name , password: user_password) - if tried_user_names.include? user_name - puts "You already tried this user name!" - end else puts "Oops! This user name is already taken!" - @prompt = TTY::Prompt.new + prompt = TTY::Prompt.new choices = ['🔹Sign-Up With Different User Name' , '🔹Login','🔹Exit'] choice = prompt.select("\n ? \n",choices) @@ -51,7 +47,7 @@ def signup login(attempts) elsif choice == '🔹Sign-Up With Different User Name' signup - else choice == '🔹Exit' + elsif choice == '🔹Exit' exit end end @@ -62,12 +58,8 @@ def signup def login(attempts=0) attempts = 0 - while attempts <= 3 do - #login_choices = ["Forgot User Name or Password?", "Exit"] - def login(attempts) system 'clear' if attempts < 3 - login_choices = ["Forgot User Name or Password?", "Exit"] puts "Enter user name" user_name = gets.chomp puts "Enter password" @@ -78,7 +70,7 @@ def login(attempts) else puts "Invalid User Name or Password" attempts += 1 - @prompt = TTY::Prompt.new + prompt = TTY::Prompt.new choices = ['🔹Re-Login' ,'🔹Forgot User Name/Password', '🔹Exit'] choice = prompt.select("\n ? \n",choices) @@ -103,24 +95,13 @@ def login(attempts) def shopping -<<<<<<< HEAD -<<<<<<< HEAD - prompt = TTY::Prompt.new - choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] - choice = prompt.select(choices) - - if choice == '🔹View Profile' - view_profile -======= puts 'yay' - @prompt = TTY::Prompt.new prompt = TTY::Prompt.new choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] system 'clear' choice = prompt.select("\n 🔹Welcome Back!!🔹 \n", choices) if choice == '🔹View Profile' profile ->>>>>>> Dan elsif choice == '🔹View Cart' view_cart elsif choice == '🔹Get To Shopping' @@ -130,19 +111,16 @@ def shopping elsif choice == '🔹Exit' exit end -<<<<<<< HEAD -======= - puts "yay" - #choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] ->>>>>>> Dan -======= ->>>>>>> Dan end + #puts "yay" + #choices = [ '🔹View Profile ', '🔹View Cart', '🔹Get To Shopping','🔹Checkout', '🔹Exit'] + + + def profile system 'clear' - @prompt = TTY::Prompt.new prompt = TTY::Prompt.new choices = ['🔹Reset User Name' ,'🔹Reset Password', '🔹Delete Account', '🔹Exit'] choice = prompt.select("\n ? \n",choices) @@ -159,53 +137,102 @@ def profile user_name = gets.chomp puts "Enter your password" user_password = STDIN.noecho(&:gets).chomp - Customer.exists?(name: user_name, password: user_password): + Customer.exists?(name: user_name, password: user_password) User.destroy_all(name: user_name) puts "Account Deleted. We hope to see you again soon!" exit - else choice == '🔹Exit' + elsif choice == '🔹Exit' exit end # #reset user_name & password -<<<<<<< HEAD + # delete account # go_back -======= + # go_back # delete account ->>>>>>> 57fedbb23024b86457d237ff4d25409b5c174ec2 + end def go_back #-> if else end - def go_to_shopping + def go_to_shopping(cart = []) + system 'clear' + prompt = TTY::Prompt.new + choices = ['🔹Fruits', '🔹Vegetables', '🔹Spices','🔹View Cart', '🔹Exit'] + choice = prompt.select("\n Select an Aisle! \n", choices) + if choice == '🔹Fruits' + prompt = TTY::Prompt.new + fruit_choices = Food.where(category: "Fruits").map{|fruit| fruit.name} + prompt.multi_select("Use Space Bar |____| to select fruits", fruit_choices) + cart << fruit_choices + #puts "fruit added" + go_to_shopping(cart.flatten) + #puts "fruit added" + elsif choice == '🔹Vegetables' + prompt = TTY::Prompt.new + vegetable_choices = Food.where(category: "Vegetables").map{|veg| veg.name} + prompt.multi_select("Use Space Bar |____| to select Vegetables", vegetable_choices) + cart << vegetable_choices + #puts "Veg added" + go_to_shopping(cart.flatten) + #puts "Veg added" + elsif choice == '🔹Spices' + prompt = TTY::Prompt.new + spice_choices = Food.where(category: "Spices").map{|spice| spice.name} + prompt.multi_select("Use Space Bar |____| to select Spices", spice_choices) + puts "Spice has been added to your cart" + cart << spice_choices + #puts "Spice has been added to your cart" + go_to_shopping(cart.flatten) + #puts "Spice has been added to your cart" + elsif choice == '🔹View Cart' + #puts "Cart is #{cart}" + view_cart(cart.flatten) + elsif choice == '🔹Exit' and cart.length == 0 + exit + end # # choose from aisles choices = [fruits, vegetables, spices, meats, delete items] # # select foods from aisle and display prices and emojis # # added to cart -> optional to add quantity # # at the end of aisles, go back to aisle choices # go_back # cart = [] - shopping + #shopping end - def view_cart(cart) - customer.food.each{|food| - puts "Fruits #{}" - puts "Vegetables #{}" - puts "Spices #{}" - } + + def view_cart(cart=[]) + if cart.length == 0 + puts "Your cart is empty" + go_to_shopping + else + puts "Cart is #{cart}" + end + + end + + # } # cart = [] # total = calculates total # checkout # go_back - end - def checkout + + def checkout(cart) + puts "Receipt" + # customer.food.each{|food| + # puts "Fruits #{}" + # puts "Vegetables #{}" + # puts "Spices #{}" + # have a price and food list and a grand total + # show receipt #update cart/remove stuff if need be + ## be able to select items out of the cart # exit # go_back end @@ -224,36 +251,14 @@ def opener - - # def opener - # puts "\n 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 \n " - # end - - - - -<<<<<<< HEAD -<<<<<<< HEAD -======= - def opener - puts "\n 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 🔹 \n " - end end -<<<<<<< HEAD -shopping_cart = CLI.new() -# shopping_cart.main_menu -shopping_cart.login(attempts = 0) ->>>>>>> Dan -======= +# shopping_cart = CLI.new() +# # shopping_cart.main_menu +# shopping_cart.login(attempts = 0) + # shopping_cart = CLI.new() # # shopping_cart.main_menu # shopping_cart.signup #(attempts = 0) -end ->>>>>>> Dan -======= -# shopping_cart = CLI.new() -# # shopping_cart.main_menu -# shopping_cart.login(attempts = 0) ->>>>>>> 57fedbb23024b86457d237ff4d25409b5c174ec2 + diff --git a/db/seeds.rb b/db/seeds.rb index c9d23048..c3a0e6e1 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -21,14 +21,15 @@ Customer.create(name:'Tee', password:'321') Customer.create(name:'Bob', password:'111') -Food.create(name: 'Methi', category: 'Spice', price: 10) -Food.create(name: 'Rosemary', category: 'Spice', price: 10) -Food.create(name: 'Parsnip', category: 'Vegetables', price: 10) +Food.create(name: 'Methi', category: 'Spices', price: 3) +Food.create(name: 'Rosemary', category: 'Spices', price: 1) +Food.create(name: 'Parsnip', category: 'Vegetables', price: 4) +Food.create(name: 'Apple', category: "Fruits", price: 2) -Order.create(customer_id: Customer.all.sample.id, food_id: Food.all.sample.id, quantity: 2, total: 20) -Order.create(customer_id: Customer.all.sample.id, food_id: Food.all.sample.id, quantity: 2, total: 20) -Order.create(customer_id: Customer.all.sample.id, food_id: Food.all.sample.id, quantity: 2, total: 20) +Order.create(customer_id: Customer.all.sample.id, food_id: Food.all.sample.id, quantity: 2) +Order.create(customer_id: Customer.all.sample.id, food_id: Food.all.sample.id, quantity: 2) +Order.create(customer_id: Customer.all.sample.id, food_id: Food.all.sample.id, quantity: 2) From f8075df4d46892c70955d4543931840a495b1fa6 Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Fri, 4 Dec 2020 14:24:45 -0800 Subject: [PATCH 25/26] checkout start --- bin/cli.rb | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/bin/cli.rb b/bin/cli.rb index b3b7f208..3ec1efd3 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -161,12 +161,12 @@ def go_back def go_to_shopping(cart = []) system 'clear' prompt = TTY::Prompt.new - choices = ['🔹Fruits', '🔹Vegetables', '🔹Spices','🔹View Cart', '🔹Exit'] + choices = ['🔹Fruits', '🔹Vegetables', '🔹Spices','🔹View Cart', '🔹Checkout', '🔹Exit'] choice = prompt.select("\n Select an Aisle! \n", choices) if choice == '🔹Fruits' prompt = TTY::Prompt.new fruit_choices = Food.where(category: "Fruits").map{|fruit| fruit.name} - prompt.multi_select("Use Space Bar |____| to select fruits", fruit_choices) + prompt.multi_select("Use Space Bar |____| to select/unselect Fruits, and hit Enter when done.", fruit_choices) cart << fruit_choices #puts "fruit added" go_to_shopping(cart.flatten) @@ -174,7 +174,7 @@ def go_to_shopping(cart = []) elsif choice == '🔹Vegetables' prompt = TTY::Prompt.new vegetable_choices = Food.where(category: "Vegetables").map{|veg| veg.name} - prompt.multi_select("Use Space Bar |____| to select Vegetables", vegetable_choices) + prompt.multi_select("Use Space Bar |____| to select/unselect Vegetables, and hit Enter when done.", vegetable_choices) cart << vegetable_choices #puts "Veg added" go_to_shopping(cart.flatten) @@ -182,7 +182,7 @@ def go_to_shopping(cart = []) elsif choice == '🔹Spices' prompt = TTY::Prompt.new spice_choices = Food.where(category: "Spices").map{|spice| spice.name} - prompt.multi_select("Use Space Bar |____| to select Spices", spice_choices) + prompt.multi_select("Use Space Bar |____| to select/unselect Spices, and hit Enter when done.", spice_choices) puts "Spice has been added to your cart" cart << spice_choices #puts "Spice has been added to your cart" @@ -191,6 +191,8 @@ def go_to_shopping(cart = []) elsif choice == '🔹View Cart' #puts "Cart is #{cart}" view_cart(cart.flatten) + elsif choice == '🔹Checkout' + checkout(cart) elsif choice == '🔹Exit' and cart.length == 0 exit end @@ -210,7 +212,8 @@ def view_cart(cart=[]) puts "Your cart is empty" go_to_shopping else - puts "Cart is #{cart}" + puts "Your cart has #{cart} inside." + go_to_shopping end end @@ -223,7 +226,17 @@ def view_cart(cart=[]) def checkout(cart) - puts "Receipt" + prompt = TTY::Prompt.new + choices = ['🔹Remove & Add', '🔹View Receipt', '🔹Exit'] + choice = prompt.select('\n \n', choices) + if choice == '🔹Remove & Add' + remove_and_add + elsif choice == '🔹View Receipt' + view_receipt + elsif choice == '🔹Exit' + exit + end + # customer.food.each{|food| # puts "Fruits #{}" # puts "Vegetables #{}" @@ -237,6 +250,16 @@ def checkout(cart) # go_back end + def remove_and_add + + end + + + def view_receipt + + end + + def exit puts "**********" puts "Good Bye!" From 0704c2766ede4fc0e683036eb8b9a1b15c335573 Mon Sep 17 00:00:00 2001 From: DanTheMan114 Date: Mon, 7 Dec 2020 09:30:18 -0800 Subject: [PATCH 26/26] Dan --- bin/cli.rb | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/bin/cli.rb b/bin/cli.rb index 3ec1efd3..33d9e470 100644 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -1,6 +1,6 @@ require 'io/console' require 'tty-prompt' -# require 'pry' +require 'pry' class CLI @@ -225,12 +225,12 @@ def view_cart(cart=[]) # go_back - def checkout(cart) + def checkout(cart=[]) prompt = TTY::Prompt.new choices = ['🔹Remove & Add', '🔹View Receipt', '🔹Exit'] choice = prompt.select('\n \n', choices) if choice == '🔹Remove & Add' - remove_and_add + remove_and_add(cart) elsif choice == '🔹View Receipt' view_receipt elsif choice == '🔹Exit' @@ -250,10 +250,44 @@ def checkout(cart) # go_back end - def remove_and_add + def remove_and_add(cart) + prompt = TTY::Prompt.new + choices = ['🔹Remove', '🔹Add', '🔹Exit'] + choice = prompt.select('\n \n', choices) + if choice == '🔹Remove' + remove(cart) + elsif choice == '🔹Add' + go_to_shopping(cart) + elsif choice == '🔹Exit' + exit + end + + end + + def remove(cart=[]) + trash = [] + puts 'YOU ARE NOW REMOVING ITEMS FROM A CART' + prompt = TTY::Prompt.new + choices = (cart) + choice = prompt.multi_select('\n \n', choices) + if choice == cart.index(0..10) + trash << cart.index(0..10) + trash.destroy_all + checkout + else + puts 'yay' + checkout + end + end + def take_out() + + end + + + def view_receipt