diff --git a/.env.example b/.env.example index 6b5883e3..0af1894a 100644 --- a/.env.example +++ b/.env.example @@ -3,3 +3,4 @@ VUE_APP_I18N_FALLBACK_LOCALE=en VUE_APP_CACHE_MAX_AGE=3600 VUE_APP_VIEW_SIZE=10 VUE_APP_SECURITY_KEY=VUE_APP_SECURITY_KEY +VUE_APP_DATE_FORMAT=MM/dd/yyyy diff --git a/changelogs/unreleased/-24gtujf.yml b/changelogs/unreleased/-24gtujf.yml new file mode 100644 index 00000000..6bd3ceb1 --- /dev/null +++ b/changelogs/unreleased/-24gtujf.yml @@ -0,0 +1,6 @@ +--- +title: Updated the code to make date format configurable through env file +ticket_id: "#24gtujf" +merge_request: 28 +author: Disha Talreja +type: performance diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 8e55d90e..95110e5d 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -4,6 +4,7 @@ import RootState from '@/store/RootState' import OrderState from './OrderState' import * as types from './mutation-types' import router from '@/router' +import { DateTime } from 'luxon'; const actions: ActionTree = { @@ -23,6 +24,7 @@ const actions: ActionTree = { const product = products.find((product: any) => { return item.shopifyProductSKU == product.internalName; }) + item.arrivalDate = DateTime.fromFormat(item.arrivalDate, "D").toFormat(process.env.VUE_APP_DATE_FORMAT ? process.env.VUE_APP_DATE_FORMAT : 'MM/dd/yyyy' ); item.parentProductId = product.groupId; item.internalName = product.internalName; item.parentProductName = product.parentProductName; diff --git a/src/views/OrderDetail.vue b/src/views/OrderDetail.vue index 850d3cf9..35efb8e4 100644 --- a/src/views/OrderDetail.vue +++ b/src/views/OrderDetail.vue @@ -337,7 +337,7 @@ export default defineComponent({ this.ordersList.items.map((item: any) => { if (item.isSelected) { item.quantityOrdered -= this.numberOfPieces; - item.arrivalDate = DateTime.fromFormat(item.arrivalDate, "D").plus({ days: this.numberOfDays }).toFormat('MM/dd/yyyy'); + item.arrivalDate = DateTime.fromFormat(item.arrivalDate, process.env.VUE_APP_DATE_FORMAT ? process.env.VUE_APP_DATE_FORMAT : 'MM/dd/yyyy').plus({ days: this.numberOfDays }).toFormat(process.env.VUE_APP_DATE_FORMAT ? process.env.VUE_APP_DATE_FORMAT : 'MM/dd/yyyy'); item.isNewProduct = this.catalog; if(this.facilityId) { item.facilityId = this.facilityId;