Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Removed unused `DeliveryDates` Stimulus controller

Damian Legawiec6df1ded728c0
diff --git a/storefront/app/javascript/spree/storefront/application.js b/storefront/app/javascript/spree/storefront/application.js
index ebc097e237..58403af10a 100644
--- a/storefront/app/javascript/spree/storefront/application.js
+++ b/storefront/app/javascript/spree/storefront/application.js
@@ -24,7 +24,6 @@ import CheckoutPromotionsController from 'spree/storefront/controllers/promotion
import CheckoutSummaryController from 'spree/storefront/controllers/summary_controller'
import ClearInputController from 'spree/storefront/controllers/clear_input_controller'
import CopyInputController from 'spree/storefront/controllers/copy_input_controller'
-import DeliveryDatesController from 'spree/storefront/controllers/delivery_dates_controller'
import DropdownController from 'spree/storefront/controllers/dropdown_controller'
import EnableButtonController from 'spree/core/controllers/enable_button_controller'
import HeaderController from 'spree/storefront/controllers/header_controller'
@@ -58,7 +57,6 @@ application.register('checkout-delivery', CheckoutDeliveryController)
application.register('checkout-promotions', CheckoutPromotionsController)
application.register('clear-input', ClearInputController)
application.register('copy-input', CopyInputController)
-application.register('delivery-dates', DeliveryDatesController)
application.register('dropdown', DropdownController)
application.register('enable-button', EnableButtonController)
application.register('header', HeaderController)
diff --git a/storefront/app/javascript/spree/storefront/controllers/delivery_dates_controller.js b/storefront/app/javascript/spree/storefront/controllers/delivery_dates_controller.js
deleted file mode 100644
index 586ac7f83d..0000000000
--- a/storefront/app/javascript/spree/storefront/controllers/delivery_dates_controller.js
+++ /dev/null
@@ -1,62 +0,0 @@
-import { Controller } from '@hotwired/stimulus'
-
-export default class extends Controller {
- static values = { start: Number, end: Number }
-
- connect() {
- this.element.innerHTML = this.totalDaysWithWeekends(this.startValue, this.endValue);
- }
-
- totalDaysWithWeekends(startAt, endAt) {
- const startDate = new Date();
- const endDate = endAt ? new Date() : null;
-
- this.calculateDate(startDate, startAt);
-
- if (endDate)
- this.calculateDate(endDate, endAt);
-
- const startDateFormat = this.formatDate(startDate)
-
- if (endDate && startDate.getTime() !== endDate.getTime()) {
- const endDateFormat = this.formatDate(endDate)
- return `${startDateFormat} - ${endDateFormat}`;
- } else {
- return startDateFormat
- }
- }
-
- calculateDate(date, daysToAdd) {
- let addedDays = 0;
- while (addedDays < daysToAdd) {
- date.setDate(date.getDate() + 1);
-
- if (date.getDay() !== 0 && date.getDay() !== 6) {
- addedDays++;
- }
- }
- }
-
- formatDate(date) {
- const day = date.getDate()
- const dayOrdinal = this.getDayOrdinal(day)
- const month = date.toLocaleString('default', { month: 'long' })
-
- return `${day}${dayOrdinal} ${month}`;
- }
-
- getDayOrdinal(day) {
- if (day > 3 && day < 21) return 'th';
-
- switch (day % 10) {
- case 1:
- return 'st';
- case 2:
- return 'nd';
- case 3:
- return 'rd';
- default:
- return 'th';
- }
- }
-}