-
Notifications
You must be signed in to change notification settings - Fork 0
T1-2846 #37
base: master
Are you sure you want to change the base?
T1-2846 #37
Conversation
@@ -152,6 +152,16 @@ export default class Basket { | |||
// load default start date instance | |||
if (!startDateInstance) startDateInstance = this.getCurrentDateInstance() | |||
|
|||
// check that selected date and timespan is within available dates | |||
const tmpBasketEntry = new BasketEntry({}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why empty object?
@@ -215,6 +225,13 @@ export default class Basket { | |||
* @returns {Promise<boolean>} | |||
*/ | |||
async updateBasketEntries(basketEntriesArray) { | |||
// check validity dates | |||
const checkResult = this.checkAvailableDates(basketEntriesArray) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, this seems very weird
const checkResult = this.checkAvailableDates([basketEntryInstance]) | ||
if (!checkResult) { | ||
EventBus.$emit('spinnerHide') | ||
return false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lots of duplicate code aswell, you have the same logic 3 times here now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to improve? If the check fails, the function has to exit and return a boolean..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-scheurer it cant be that the logic has to check for this behaviour 3 times in a row. If it indeed does, you should split up the function it is in into 3 separate functions, as it makes it obvious that the current function is handling 3 different usecases at the same time.
@@ -655,7 +655,8 @@ export default class Product { | |||
filterProductDefinitionsByProductDefinitionAndAttributeKey( | |||
attributeKey, | |||
productDefinition, | |||
excludeAttributeKeys = [] | |||
excludeAttributeKeys = [], | |||
includeMauiOnly = false | |||
) { | |||
let filteredProductDefinitions = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
filteredProductDefinitions = filteredProductDefinitions.filter( | ||
(prodDef) => !prodDef.isMauiOnly() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not modify existing objects. this obscures what the array contains. this should be named mauiOnlyProductDefinitions
for (let i = 0; i < bookingDateList.length; i++) { | ||
const bookingDate = bookingDateList[i] | ||
const foundAvailableDate = availableDateList.find((availableDate) => { | ||
return availableDate.getTime() === bookingDate.getTime() | ||
}) | ||
if (!foundAvailableDate) { | ||
EventBus.$emit('notify', i18n.t('basket.dateNotAvailable')) | ||
return false | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use for of. you are not using an index anywhere.
No description provided.