Skip to content
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

Holina/top nav/footer #67

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
6eb713b
Readr tree diagram
Millington-Holi7 Jul 23, 2024
d84c25a
set up ruby version and database
bhood239 Jul 24, 2024
2ac81ff
update database.yml
bhood239 Jul 24, 2024
c91fecb
ERD
laraibsshaikh10 Jul 24, 2024
0153f09
set up filesystem
bhood239 Jul 25, 2024
cd07028
create tables and migrate
bhood239 Jul 25, 2024
88bae70
create basic full crud operations and routes
bhood239 Jul 25, 2024
4884de0
Make a basic book component without props
vyshudoulagar Jul 25, 2024
92e5f16
Make a basic miniprofile component without props
vyshudoulagar Jul 25, 2024
3335cc3
Make a basic booklist component
vyshudoulagar Jul 25, 2024
18651ff
Add basic props for book and booklist, Add custom rating component
vyshudoulagar Jul 25, 2024
8198349
Add props to mini profile
vyshudoulagar Jul 25, 2024
c272228
implement functions to get data from books api
bhood239 Jul 26, 2024
9e7cccf
create useBookData custom hooks
bhood239 Jul 26, 2024
118534e
Merge pull request #2 from bhood239/ben/database/setup
vyshudoulagar Jul 26, 2024
513511e
Merge pull request #1 from bhood239/ben/feature/books_api
vyshudoulagar Jul 26, 2024
938b74e
Add necessary comments
vyshudoulagar Jul 26, 2024
73ee22c
Add comments, and update the code in book
vyshudoulagar Jul 26, 2024
449d5c3
Merge pull request #3 from bhood239/vyshnavi/components/miniprofile
vyshudoulagar Jul 26, 2024
4819d1c
Merge branch 'master' into vyshnavi/components/booklist
vyshudoulagar Jul 26, 2024
8e83c13
Merge pull request #4 from bhood239/vyshnavi/components/booklist
bhood239 Jul 26, 2024
1cd0127
Add post and postList components
laraibsshaikh10 Jul 26, 2024
31cd011
Pulled changes from master
laraibsshaikh10 Jul 26, 2024
feb9f91
begin creating API requests
bhood239 Jul 26, 2024
3b33f11
create book status api requests
bhood239 Jul 26, 2024
7fad6a6
Make searchResult component
vyshudoulagar Jul 26, 2024
38afd04
Add comments
vyshudoulagar Jul 26, 2024
3b75398
Add props to booklist
vyshudoulagar Jul 26, 2024
8a272ae
Create postForm
laraibsshaikh10 Jul 27, 2024
fcc064b
Add followers and following methods in friends controller
vyshudoulagar Jul 27, 2024
6ec3a1c
Edit followers and following method
vyshudoulagar Jul 27, 2024
1daa233
create loginform component, add comments in useApplicationData about …
vyshudoulagar Jul 27, 2024
6a2b4a7
Add rating and time_spent in hours
laraibsshaikh10 Jul 27, 2024
0ca011d
Add loginpage backend controller
vyshudoulagar Jul 27, 2024
01fcbdd
make login and register page demo style and change backend according …
vyshudoulagar Jul 27, 2024
1ba47b0
update form and backend to work on browser, add cors
vyshudoulagar Jul 27, 2024
f698f1c
Add functions, hooks in BookList
vyshudoulagar Jul 27, 2024
9f962dc
organize apiRequests into folders
bhood239 Jul 28, 2024
feecf5a
create custom hooks for postData and userdata
bhood239 Jul 28, 2024
0c87e77
create useBookStatus custom hook
bhood239 Jul 28, 2024
b8cb0f1
create seeds
bhood239 Jul 28, 2024
68676d9
Merge pull request #5 from bhood239/vyshnavi/components/searchResults
bhood239 Jul 28, 2024
009d624
Make book api return correct data
vyshudoulagar Jul 28, 2024
bd63cbf
Add Top nav pages
Millington-Holi7 Jul 28, 2024
0372470
merge changes
Millington-Holi7 Jul 28, 2024
6a10f06
created Top Nav and footer and called them in App.
Millington-Holi7 Jul 29, 2024
a7bd100
Fix spelling mistake
laraibsshaikh10 Jul 30, 2024
85b954d
Merge pull request #9 from bhood239/laraib/components/postForm
laraibsshaikh10 Jul 30, 2024
edb8616
Merge pull request #6 from bhood239/ben/feature/useApiData
vyshudoulagar Jul 30, 2024
c5ca186
Revert "Laraib/components/post form"
bhood239 Jul 30, 2024
e143e7c
Merge pull request #10 from bhood239/revert-9-laraib/components/postForm
bhood239 Jul 30, 2024
b2ef7e7
Change ruby version in gemfile
laraibsshaikh10 Jul 30, 2024
fe2f423
Merge branch 'master' into laraib/components/postForm
vyshudoulagar Jul 30, 2024
53fca8d
Merge pull request #11 from bhood239/laraib/components/postForm
vyshudoulagar Jul 30, 2024
ed21d42
use custom hooks to update status
vyshudoulagar Jul 30, 2024
5487a8a
Merge pull request #8 from bhood239/vyshnavi/components/registerpage
bhood239 Jul 30, 2024
d7018cd
fixing merge conflicts
bhood239 Jul 30, 2024
818e1b0
Merge pull request #7 from bhood239/vyshnavi/components/booklistapi
bhood239 Jul 30, 2024
722763a
correct the links of imported files, update booklist to use custom ho…
vyshudoulagar Jul 30, 2024
18d049b
Merge branch 'master' into Holina/TopNav/footer
bhood239 Jul 30, 2024
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
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.2
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ gem "pg", "~> 1.1"
# Use the Puma web server [https://github.com/puma/puma]
gem "puma", ">= 5.0"

gem 'rack-cors'

# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
# gem "importmap-rails"

Expand All @@ -34,7 +36,7 @@ gem "puma", ">= 5.0"
# gem "kredis"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"
gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ GEM
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
base64 (0.2.0)
bcrypt (3.1.20)
bigdecimal (3.1.4)
bootsnap (1.17.0)
msgpack (~> 1.2)
Expand Down Expand Up @@ -132,6 +133,8 @@ GEM
net-smtp (0.4.0)
net-protocol
nio4r (2.5.9)
nokogiri (1.15.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
pg (1.5.4)
Expand All @@ -142,6 +145,8 @@ GEM
nio4r (~> 2.0)
racc (1.7.3)
rack (3.0.8)
rack-cors (2.0.2)
rack (>= 2.0.0)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
Expand Down Expand Up @@ -214,14 +219,17 @@ GEM
zeitwerk (2.6.12)

PLATFORMS
arm64-darwin-23
x86_64-linux

DEPENDENCIES
bcrypt (~> 3.1.7)
bootsnap (~> 1.17.0)
capybara
debug
pg (~> 1.1)
puma (>= 5.0)
rack-cors
rails (~> 7.1.1)
selenium-webdriver
spring
Expand Down
43 changes: 43 additions & 0 deletions app/controllers/api/book_statuses_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module Api
class BookStatusesController < ApplicationController
def index
@book_statuses = BookStatus.all
render json: @book_statuses
end

def show
@book_status = BookStatus.find(params[:id])
render json: @book_status
end

def create
@book_status = BookStatus.new(book_status_params)
if @book_status.save
render json: @book_status, status: :created
else
render json: @book_status.errors, status: :unprocessable_entity
end
end

def update
@book_status = BookStatus.find(params[:id])
if @book_status.update(book_status_params)
render json: @book_status
else
render json: @book_status.errors, status: :unprocessable_entity
end
end

def destroy
@book_status = BookStatus.find(params[:id])
@book_status.destroy
head :no_content
end

private

def book_status_params
params.require(:book_status).permit(:status, :fave_books, :book_id, :user_id)
end
end
end
55 changes: 55 additions & 0 deletions app/controllers/api/friends_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module Api
class FriendsController < ApplicationController
def index
@friends = Friend.all
render json: @friends
end

def show
@friend = Friend.find(params[:id])
render json: @friend
end

def followers
@followers = User.joins("JOIN friends ON friends.follower_id = users.id")
.where("friends.following_id = ?", params[:id])
render json: @followers
end

def following
@following = User.joins("JOIN friends ON friends.following_id = users.id")
.where("friends.following_id = ?", params[:id])
render json: @following
end

def create
@friend = Friend.new(friend_params)
if @friend.save
render json: @friend, status: :created
else
render json: @friend.errors, status: :unprocessable_entity
end
end

def update
@friend = Friend.find(params[:id])
if @friend.update(friend_params)
render json: @friend
else
render json: @friend.errors, status: :unprocessable_entity
end
end

def destroy
@friend = Friend.find(params[:id])
@friend.destroy
head :no_content
end

private

def friend_params
params.require(:friend).permit(:follower_id, :following_id)
end
end
end
45 changes: 45 additions & 0 deletions app/controllers/api/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module Api
class PostsController < ApplicationController
def index
@posts = Post.includes(:user).all
render json: @posts.to_json(include: :user)
end

def show
@post = Post.includes(:user).find(params[:id])
render json: @post.to_json(include: :user)
end

def create
@post = Post.new(post_params)
if @post.save
render json: @post, status: :created
else
render json: @post.errors, status: :unprocessable_entity
end
end

def update
@post = Post.find(params[:id])
if @post.update(post_params)
render json: @post
else
render json: @post.errors, status: :unprocessable_entity
end
end

def destroy
@post = Post.find(params[:id])
@post.destroy
head :no_content
end

private

def post_params
params.require(:post).permit(:rating, :review, :time_spent, :book_id, :user_id)
end
end
end

# find out how to return the related records
17 changes: 17 additions & 0 deletions app/controllers/api/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Api::SessionsController < ApplicationController
def create
user = User.authenticate_with_credentials(params[:email], params[:password])
user = current_user
if user
session[:user_id] = user.id
render json: { notice: 'Logged in successfully' }, status: :ok
else
render json: { alert: 'Invalid email or password' }, status: :unauthorized
end
end

def destroy
session[:user_id] = nil
render json: { notice: 'Logged out successfully' }, status: :ok
end
end
48 changes: 48 additions & 0 deletions app/controllers/api/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module Api
class UsersController < ApplicationController
def index
@users = User.includes(:posts).all
render json: @users.to_json(include: :posts)
end

def show
@user = User.includes(:posts).find(params[:id])
render json: @user.to_json(include: :posts)
end

def new
@user = User.new
end

def create
@user = User.new(user_params)
if @user.save
session[:user_id] = @user.id
render json: @user, status: :created
else
render json: @user.errors, status: :unprocessable_entity
end
end

def update
@user = User.find(params[:id])
if @user.update(user_params)
render json: @user
else
render json: @user.errors, status: :unprocessable_entity
end
end

def destroy
@user = User.find(params[:id])
@user.destroy
head :no_content
end

private

def user_params
params.require(:user).permit(:name, :email, :password, :password_confirmation) #removed awards, followers and following
end
end
end
6 changes: 6 additions & 0 deletions app/models/book_status.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class BookStatus < ApplicationRecord
belongs_to :user

validates :status, presence: true
validates :book_id, presence: true
end
7 changes: 7 additions & 0 deletions app/models/friend.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Friend < ApplicationRecord
belongs_to :follower, class_name: 'User'
belongs_to :following, class_name: 'User'

validates :follower_id, presence: true
validates :following_id, presence: true
end
6 changes: 6 additions & 0 deletions app/models/post.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Post < ApplicationRecord
belongs_to :user

validates :rating, presence: true, inclusion: { in: 1..5 }
validates :book_id, presence: true
end
21 changes: 21 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class User < ApplicationRecord
has_secure_password
has_many :posts
has_many :book_statuses
has_many :followed_friends, class_name: 'Friend', foreign_key: 'follower_id'
has_many :following_friends, class_name: 'Friend', foreign_key: 'following_id'

validates :name, presence: true
validates :email, presence: true, uniqueness: { case_sensitive: false }
validates :password, presence: true, length: { minimum: 6 }, allow_nil: true

def self.authenticate_with_credentials(email, password)
normalized_email = email.strip.downcase
user = User.find_by(email: normalized_email)
if user
user
else
nil
end
end
end
1 change: 0 additions & 1 deletion client/.env.example

This file was deleted.

Loading