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

Add typechecking #937

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
34 changes: 30 additions & 4 deletions amelie/personal_tab/static/js/personal_tab_pos.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,13 @@ function setupCalculator(calculator) {
if(!isNaN(inputValue) && inputValue > 0){
// Add to cart
// We replace the potential ',' by a '.' for the parseFloat function.
addToCart(productId, productName, parseInt(inputfield.attr('value'), 10), parseFloat(productPrice.replace(",", ".")), productImage);
let price;
if (typeof productPrice === 'string' || productPrice instanceof String) {
price = parseFloat(productPrice.replace(",", "."))
} else {
price = parseFloat(productPrice)
}
addToCart(productId, productName, parseInt(inputfield.attr('value'), 10), price, productImage);
// Clear the input field
inputfield.attr('value', '');
// Return to main tab
Expand Down Expand Up @@ -471,7 +477,14 @@ function setupShopPage(){
resetCart();
var article_elem = $(event.currentTarget.parentElement);
var article_id = article_elem.data('id');
var article_price = parseFloat(article_elem.data('price').replace(",", ".")); // Replace the ',' by a '.' for the Dutch website.
// We replace the potential ',' by a '.' for the parseFloat function.
let price;
if (typeof productPrice === 'string' || productPrice instanceof String) {
price = parseFloat(productPrice.replace(",", "."))
} else {
price = parseFloat(productPrice)
}
var article_price = price; // Replace the ',' by a '.' for the Dutch website.
var article_name = article_elem.data('name');
var article_image = article_elem.data('image');
addToCartInstant(article_id, article_name, 1, article_price, article_image);
Expand All @@ -481,7 +494,14 @@ function setupShopPage(){
resetCart();
var article_elem = $(event.currentTarget.parentElement);
var article_id = article_elem.data('id');
var article_price = parseFloat(article_elem.data('price').replace(",", ".")); // Replace the ',' by a '.' for the Dutch website.
// We replace the potential ',' by a '.' for the parseFloat function.
let price;
if (typeof productPrice === 'string' || productPrice instanceof String) {
price = parseFloat(productPrice.replace(",", "."))
} else {
price = parseFloat(productPrice)
}
var article_price = price; // Replace the ',' by a '.' for the Dutch website.
var article_name = article_elem.data('name');
var article_image = article_elem.data('image');
addToCartInstant(article_id, article_name, 1, article_price, article_image);
Expand All @@ -490,7 +510,13 @@ function setupShopPage(){
$('.article-addtocart').click(function(event){
var article_elem = $(event.currentTarget.parentElement);
var article_id = article_elem.data('id');
var article_price = parseFloat(article_elem.data('price').replace(",", ".")); // Replace the ',' by a '.' for the Dutch website.
let price;
if (typeof productPrice === 'string' || productPrice instanceof String) {
price = parseFloat(productPrice.replace(",", "."))
} else {
price = parseFloat(productPrice)
}
var article_price = price; // Replace the ',' by a '.' for the Dutch website.
var article_name = article_elem.data('name');
var article_image = article_elem.data('image');
addToCart(article_id, article_name, 1, article_price, article_image);
Expand Down