Skip to content

Commit

Permalink
Merge pull request #234 from vtex-apps/fix-bussines-days
Browse files Browse the repository at this point in the history
Fix bussines days
  • Loading branch information
cdcs0128 authored Jan 9, 2024
2 parents 1645cf8 + 280ac33 commit d513d28
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 837 deletions.
2 changes: 1 addition & 1 deletion checkout-ui-custom/checkout6-custom.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion checkout-ui-custom/checkout6-custom.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion checkout-ui-custom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"eslint": "^8.40.0",
"extract-loader": "^2.0.1",
"file-loader": "^2.0.0",
"node-sass": "^4.9.3",
"sass": "^1.69.5",
"postcss-cli": "^6.0.0",
"postcss-loader": "^3.0.0",
"sass-loader": "^7.1.0",
Expand Down
26 changes: 17 additions & 9 deletions checkout-ui-custom/src/_js/_v.custom.checkout.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,22 +551,30 @@ class checkoutCustom {
return holidaysCount;
}

addBusinessDays(n, lang = window.i18n.options.lng) {
addBusinessDays(n, days, lang = window.i18n.options.lng) {
const _this = this

let typeDays = days.replace(/[0-9]/g, '');

try {

let d = new Date()

d = new Date(d.getTime())
const day = d.getDay()

d.setDate(
d.getDate() +
n +
(day === 6 ? 2 : +!day) +
Math.floor((n - 1 + (day % 6 || 1)) / 5) * 2
)
if(typeDays === "d") {
d.setDate(
d.getDate() + n
)
} else {
d.setDate(
d.getDate() +
n +
(day === 6 ? 2 : +!day) +
Math.floor((n - 1 + (day % 6 || 1)) / 5) * 2
)
}

let bdHolidays = 0
if(_this._holidays ) {
Expand Down Expand Up @@ -691,7 +699,7 @@ class checkoutCustom {
$(this)
.find(mainSTIelems.join(', '))
.html(
`${_delivtext} <strong>${_this.addBusinessDays(days)}</strong>`
`${_delivtext} <strong>${_this.addBusinessDays(days, selectedSlaDays)}</strong>`
)
.addClass('v-changeShippingTimeInfo-elem-active')
}
Expand Down Expand Up @@ -736,7 +744,7 @@ class checkoutCustom {
} // check if is pickup. OBS: none of others solutions worked, needs constantly update

deliveryDates.push(
`${_delivtext} <strong>${_this.addBusinessDays(days)}</strong>`
`${_delivtext} <strong>${_this.addBusinessDays(days, selectedSlaDays)}</strong>`
)
}
}
Expand Down
882 changes: 60 additions & 822 deletions checkout-ui-custom/yarn.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "checkout-ui-custom",
"vendor": "vtex",
"version": "0.15.1",
"version": "0.15.2",
"title": "Checkout Custom",
"description": "Make possible to customize the checkout layout using a easy to use interface from the admin",
"builders": {
Expand Down
2 changes: 1 addition & 1 deletion node/templates/checkout6-custom.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion node/templates/checkout6-custom.js

Large diffs are not rendered by default.

0 comments on commit d513d28

Please sign in to comment.