Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
64340c4
PC-83: Add Customer Form layout
PivtoranisV Apr 1, 2025
3ea8848
PC-83: add PcInput for improved input handling
PivtoranisV Apr 1, 2025
185bee9
PC-83: Fixed layout for mobile screens
PivtoranisV Apr 2, 2025
bf9ef3f
PC-83: Add typeahead for company select
PivtoranisV Apr 2, 2025
f0cce3f
PC-84: Add CustomersController and CustomerSerializer with associated…
OGoncharenko Apr 3, 2025
7cf7351
PC-84: Fix linter
OGoncharenko Apr 3, 2025
180a86f
PC-83: Update styles for dropdown menu
PivtoranisV Apr 3, 2025
e0cbd32
PC-83: Add arrow down and up icon to the dropdown menu
PivtoranisV Apr 3, 2025
ea92670
Merge remote-tracking branch 'origin/PC-90' into PC-82
vb-cmd Apr 3, 2025
9c20925
PC-85 Add company logo component with preview and file upload
vb-cmd Apr 3, 2025
23716af
PC-85 Fix lint and update brakeman
vb-cmd Apr 4, 2025
bba8202
PC-85 Refactor test for customer list response
vb-cmd Apr 4, 2025
f345b95
PC-85 Add test for customer logo
vb-cmd Apr 4, 2025
e6c884e
PC-86: Implement next button logic
PivtoranisV Apr 4, 2025
86abeeb
Merge remote-tracking branch 'origin/PC-82' into PC-82
vb-cmd Apr 4, 2025
a9143f5
Merge branch 'PC-77' into PC-82
vb-cmd Apr 4, 2025
7727c50
PC-84: Add customer fetching and validation to CustomerForm component
OGoncharenko Apr 6, 2025
08657e9
PC-84: Try to fix build
OGoncharenko Apr 6, 2025
1671343
PC-84: Try to fix build
OGoncharenko Apr 6, 2025
e429320
PC-86: Add specs for upsert action
PivtoranisV Apr 7, 2025
a2f259e
PC-83: Refactor styles and structure in CustomerInfo
PivtoranisV Apr 7, 2025
d5ce101
PC-85 Move CompanyLogoUploader component to its own file, add logo pa…
vb-cmd Apr 7, 2025
8731555
Merge remote-tracking branch 'origin/PC-82' into PC-82
vb-cmd Apr 7, 2025
1e590c9
PC-85 Fix handleLogoUpload and handleNext in CustomerForm.jsx
vb-cmd Apr 7, 2025
5e2421b
PC-83: Fixed icon position in dropdownSelect
PivtoranisV Apr 8, 2025
78152bf
PC-85: Move function to its own file and fix image preview
vb-cmd Apr 8, 2025
a9dc141
PC-84: Sort customers by updated_at
PivtoranisV Apr 8, 2025
e064fb4
PC-85: Fix logo attachment and display it
vb-cmd Apr 9, 2025
455a04c
Merge remote-tracking branch 'origin/PC-82' into PC-82
vb-cmd Apr 9, 2025
5ac21be
PC-85: Replace logo with logo_url
vb-cmd Apr 9, 2025
b114637
Merge branch 'master' of https://github.com/wahanegi/clever-calculato…
PivtoranisV Apr 10, 2025
bf75567
Merge branch 'PC-82' of https://github.com/wahanegi/clever-calculator…
PivtoranisV Apr 10, 2025
c6aedd5
Merge branch 'master' into PC-82
vb-cmd Apr 16, 2025
1be9a87
PC-109: Change default cursor
vb-cmd Apr 21, 2025
cb4db71
PC-108: Chevron icon overlap with the long entered data in the Compan…
IvanRuskevych Apr 21, 2025
edd3cbd
PC-110: Fix logo validation not showing after submission
vb-cmd Apr 21, 2025
1945175
PC-112: Fix bug where the logo doesn't adjust correctly
vb-cmd Apr 22, 2025
7a6fe09
PC-111: Fix bug where chevron icon is not clickable and does not disp…
vb-cmd Apr 22, 2025
1f67d05
PC-82: Fix test
vb-cmd Apr 23, 2025
2bcba02
PC-82: Fix lint
vb-cmd Apr 23, 2025
b9f51c2
PC-112: Fix and rename PcLogoUploader.jsx; resolve bug causing incorr…
vb-cmd Apr 23, 2025
a306678
PC-113: Fix Next button in CustomerForm.jsx
vb-cmd Apr 23, 2025
a05fccd
PC-82: Fix file upload in fetchService.js when file has no name
vb-cmd Apr 25, 2025
bd717c6
PC-82: Fix dropdown menu not working when user clicks icon
vb-cmd Apr 25, 2025
07fe925
PC-82: Fix display logo
vb-cmd Apr 28, 2025
2ee4e78
PC-131: Fix bug where clicking the Company input doesn't show the dro…
vb-cmd Apr 29, 2025
d554c32
PC-130: Fix bug where Next button becomes enabled after selecting a v…
vb-cmd Apr 29, 2025
e20b899
PC-115: Add clear X button to the Company input field
vb-cmd Apr 29, 2025
8474e02
PC-114: Add vertical scroll to the dropdown menu and remove the item …
vb-cmd Apr 29, 2025
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
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ gem "activeadmin", "~> 3.3.0" # A framewor
# gem "bcrypt", "~> 3.1" # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
gem "bootsnap", '~> 1.18.4', require: false # Reduces boot times through caching; required in config/boot.rb
gem "cssbundling-rails", '~> 1.4.3' # Bundle and process CSS [https://github.com/rails/cssbundling-rails]
# gem "image_processing", "~> 1.2" # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
gem "devise", "~> 4.9.4" # Authentication
gem "image_processing", "~> 1.2" # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
gem "jbuilder", '~> 2.13.0' # Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jsbundling-rails", '~> 1.3.1' # Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
gem "jsonapi-serializer", "~> 2.2.0" # Fast, simple and easy to use JSON:API serialization library (also known as fast_jsonapi).
gem "kamal", '~> 2.5.3', require: false # Deploy this application anywhere as a Docker container [https://kamal-deploy.org]
gem "pg", "~> 1.5.9" # Use postgresql as the database for Active Record
gem "puma", "~> 6.6.0" # Use the Puma web server [https://github.com/puma/puma]
gem "rails", "~> 8.0.2" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "ruby-vips", "~> 2.2" # Ruby extension for the libvips image processing library.
gem 'sass-rails', '~> 6.0.0' # Ruby on Rails stylesheet engine for Sass
gem "solid_cable", '~> 3.0.7' # Use the database-backed adapters for Action Cable
gem "solid_cache", '~> 1.0.7' # Use the database-backed adapters for Rails.cache
Expand Down
12 changes: 12 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ GEM
activesupport (>= 5.2)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
image_processing (1.14.0)
mini_magick (>= 4.9.5, < 6)
ruby-vips (>= 2.0.17, < 3)
inherited_resources (1.14.0)
actionpack (>= 6.0)
has_scope (>= 0.6)
Expand Down Expand Up @@ -229,6 +232,9 @@ GEM
net-pop
net-smtp
marcel (1.0.4)
mini_magick (5.2.0)
benchmark
logger
mini_mime (1.1.5)
minitest (5.25.5)
msgpack (1.8.0)
Expand Down Expand Up @@ -370,6 +376,9 @@ GEM
rubocop (~> 1.72, >= 1.72.1)
rubocop-rspec (~> 3.5)
ruby-progressbar (1.13.0)
ruby-vips (2.2.3)
ffi (~> 1.12)
logger
ruby2_keywords (0.0.5)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
Expand Down Expand Up @@ -449,6 +458,7 @@ GEM
zeitwerk (2.7.2)

PLATFORMS
arm64-darwin-23
arm64-darwin-24
x86_64-darwin-24
x86_64-linux
Expand All @@ -465,6 +475,7 @@ DEPENDENCIES
dotenv
factory_bot_rails
faker
image_processing (~> 1.2)
jbuilder (~> 2.13.0)
jsbundling-rails (~> 1.3.1)
jsonapi-serializer (~> 2.2.0)
Expand All @@ -478,6 +489,7 @@ DEPENDENCIES
rubocop
rubocop-rails
rubocop-rspec_rails
ruby-vips (~> 2.2)
sass-rails (~> 6.0.0)
shoulda-matchers
solid_cable (~> 3.0.7)
Expand Down
3 changes: 3 additions & 0 deletions app/assets/images/icons/arrow-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/images/icons/arrow-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/images/icons/cross.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/assets/images/icons/placeholder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion app/assets/stylesheets/application.bootstrap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ $utilities: map-merge(
@import 'application/buttons';
@import 'application/customer_info';
@import 'application/layout';
@import 'application/login_page';
@import 'application/login_page';
@import 'application/customer_form.scss';
@import 'application/input.scss';
@import 'application/header';
4 changes: 2 additions & 2 deletions app/assets/stylesheets/application/buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
}

&:disabled {
border-color: $gray-disable !important;
color: $text-gray-disable !important;
border-color: $secondary!important;
color: $secondary!important;
background: $white !important;
}
}
Expand Down
27 changes: 27 additions & 0 deletions app/assets/stylesheets/application/customer_form.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.customer-form {
max-width: 1120px;
padding: 31px;
}

.image-placeholder {
max-width: 136px;
width: 136px;

label:hover {
cursor: pointer;
}
}

.client-input {
max-width: 615px;
}

.title-input {
max-width: 241px;
}

@media (max-width: 575px) {
.title-input {
max-width: 100%;
}
}
98 changes: 98 additions & 0 deletions app/assets/stylesheets/application/input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
.border-label {
position: absolute;
top: -0.4rem;
left: 0.8rem;
background: linear-gradient(to bottom, $light 50%, $white 50%);
}

.form-control::placeholder {
color: $gray;
}

textarea {
resize: none;
}

.form-control:focus,
.form-control:active,
.form-select:focus,
.form-select:active {
box-shadow: none !important;
background-color: $white !important;
}

.form-control:-webkit-autofill,
.form-select:-webkit-autofill {
background-color: white !important;
transition: background-color 5000s ease-in-out 0s;
}

.form-control:-webkit-autofill:focus,
.form-select:-webkit-autofill:focus {
background-color: white !important;
}

.rbt-input-main {
border: none !important;
border-radius: 4px;
}

.rbt-menu .dropdown-item:hover,
.rbt-menu .dropdown-item:focus {
background-color: $light;
color: $primary;
}

.rbt-menu .dropdown-item {
padding: 6px 12px;
color: $gray-700;
}

.rbt-menu.dropdown-menu.show {
margin-top: 5px;
outline: 1px solid $primary;
border-inline: 5px solid $white;
width: calc(100% + 2px) !important;
margin-left: -2px;
max-height: 185px !important;
}

.rbt-highlight-text {
background-color: $light;
color: $primary;
padding: 0;
}

.rbt-input-hint {
color: transparent;
}

/**
*** TYPEAHEAD CUSTOM STYLES for "Customer info" Page ***
**/
.pc-typeahead-customer-info {
.pc-icon-reserve-place {
padding-right: 60px;
}

.pc-typeahead-controls {
width: 60px;
}

.pc-typeahead-button {
width: 24px;
}
}

/**
*** LOGO UPLOADER ***
**/
.pc-logo-uploader {
width: 136px;
height: 117px;

&-display {
width: 130px;
height: 110px;
}
}
2 changes: 0 additions & 2 deletions app/assets/stylesheets/application/layout.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import 'layout/header';

.layout {
background-image: url('./assets/bg-calculator.png');
background-position: left calc(#{min(50vh, 504px)});
Expand Down
30 changes: 0 additions & 30 deletions app/assets/stylesheets/application/login_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,6 @@
height: 24px;
}

.border-label {
position: absolute;
top: -0.4rem;
left: 0.8rem;
background: linear-gradient(to bottom, $light 50%, $white 50%);
}

.form-control {
height: 42px;
}

.form-control::placeholder {
color: $gray;
}

.form-control:focus,
.form-control:active {
box-shadow: none !important;
background-color: $white !important;
}

.form-control:-webkit-autofill {
background-color: white !important;
transition: background-color 5000s ease-in-out 0s;
}

.form-control:-webkit-autofill:focus {
background-color: white !important;
}

.or-divider {
display: flex;
align-items: center;
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/application/typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ h2,
$custom-colors: (
'gray': $gray,
'gray-light': $gray-light,
'gray-700': $gray-700,
'blue-light': $blue-light,
'blue-sky': $blue-sky,
'red-light': $red-light,
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/application/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $danger: #f12711;
// Other Colors
$gray: #9e9e9e;
$gray-light: #d9d9d9;
$gray-700: #616161;
$blue-light: #e2e6f9;
$blue-sky: #3f84bd;
$red-light: #f5b8b8;
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/api/v1/base_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Api
module V1
class BaseController < ApplicationController
before_action :authenticate_user!
end
end
end
30 changes: 30 additions & 0 deletions app/controllers/api/v1/customers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Api
module V1
class CustomersController < BaseController
def index
customers = Customer.order(updated_at: :desc)
render json: CustomerSerializer.new(customers).serializable_hash, status: :ok
end

def upsert
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upsert might be a typo (I'm not sure what that word means)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rogergraves upsert is combination of update and insert words that is used in SQL. So, here in Customers controller upsert action will create or update the customer (I’m not sure what is better name for this method could be). Here is the link

https://www.cockroachlabs.com/blog/sql-upsert/

company_name = customer_params[:company_name].downcase
customer = Customer.where('LOWER(company_name) = ?', company_name).first_or_initialize
customer.assign_attributes(customer_params)

if customer.save
render json: CustomerSerializer.new(customer).serializable_hash, status: :ok
else
render json: ErrorSerializer.new(customer.errors).serializable_hash, status: :unprocessable_entity
end
end

private

def customer_params
params.expect(customer: [:company_name, :first_name, :last_name,
:email, :position, :address,
:notes, :logo])
end
end
end
end
3 changes: 1 addition & 2 deletions app/controllers/api/v1/quotes_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Api
module V1
class QuotesController < ApplicationController
before_action :authenticate_user!
class QuotesController < BaseController
before_action :set_quote, only: [:update]

def create
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
class ApplicationController < ActionController::Base
allow_browser versions: :modern

before_action :authenticate_user!, unless: :active_admin_controller?
before_action :set_active_storage_url_options

private

def active_admin_controller?
is_a?(ActiveAdmin::BaseController)
end

def set_active_storage_url_options
ActiveStorage::Current.url_options = { protocol: request.protocol, host: request.host, port: request.port }
end
end
Loading