From b27a6de330f918f6891141f70e0930ea267e2bd4 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 9 Feb 2024 15:28:50 +0530 Subject: [PATCH 1/3] Improved: logic to show loader while logout to show during notification unsubscribe(#274) --- src/store/modules/user/actions.ts | 3 --- src/views/Settings.vue | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 87f9017ce..90d775812 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -124,8 +124,6 @@ const actions: ActionTree = { // store the url on which we need to redirect the user after logout api completes in case of SSO enabled let redirectionUrl = '' - emitter.emit('presentLoader', { message: 'Logging out', backdropDismiss: false }) - // Calling the logout api to flag the user as logged out, only when user is authorised // if the user is already unauthorised then not calling the logout api as it returns 401 again that results in a loop, thus there is no need to call logout api if the user is unauthorised if(!payload?.isUserUnauthorised) { @@ -169,7 +167,6 @@ const actions: ActionTree = { window.location.href = redirectionUrl } - emitter.emit('dismissLoader') return redirectionUrl; }, diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 0922de46d..d8b362898 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -341,6 +341,7 @@ export default defineComponent({ return timeZoneModal.present(); }, async logout () { + emitter.emit('presentLoader', { message: 'Logging out', backdropDismiss: false }) // remove firebase notification registration token - // OMS and auth is required hence, removing it before logout (clearing state) try { @@ -356,6 +357,7 @@ export default defineComponent({ window.location.href = `${process.env.VUE_APP_LOGIN_URL}?isLoggedOut=true&redirectUrl=${redirectUrl}` } }) + emitter.emit('dismissLoader') }, goToLaunchpad() { window.location.href = `${process.env.VUE_APP_LOGIN_URL}` From 70b9074addcfcdf3098e45ed930c0db0714c087e Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 9 Feb 2024 16:50:19 +0530 Subject: [PATCH 2/3] Fixed: notfications not coming up after app refresh (#274) --- package-lock.json | 234 +++----------------- package.json | 2 +- public/firebase-messaging-sw.js | 2 +- src/App.vue | 9 + src/components/OrderItemRejHistoryModal.vue | 2 +- src/components/ProductListItem.vue | 6 +- src/utils/firebase.ts | 4 +- src/views/Catalog.vue | 6 +- src/views/ProductDetail.vue | 6 +- 9 files changed, 59 insertions(+), 212 deletions(-) diff --git a/package-lock.json b/package-lock.json index e553a8630..31eb240d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@casl/ability": "^6.0.0", "@hotwax/app-version-info": "^1.0.0", "@hotwax/apps-theme": "^1.1.0", - "@hotwax/dxp-components": "^1.11.0", + "@hotwax/dxp-components": "file:../dxp-components", "@hotwax/oms-api": "^1.11.1", "@ionic/core": "6.7.5", "@ionic/vue": "6.7.5", @@ -53,6 +53,37 @@ "typescript": "~4.7.4" } }, + "../dxp-components": { + "version": "1.12.1", + "license": "Apache-2.0", + "dependencies": { + "@hotwax/oms-api": "^1.8.1", + "@ionic/core": "^7.6.0", + "@ionic/vue": "^7.6.0", + "firebase": "^10.3.1", + "luxon": "^3.3.0", + "pinia": "2.0.36", + "pinia-plugin-persistedstate": "^3.1.0", + "register-service-worker": "^1.7.2", + "vue": "^3.3.4", + "vue-i18n": "^9.2.2" + }, + "devDependencies": { + "@babel/types": "^7.22.11", + "@types/luxon": "^3.3.0", + "@types/node": "^20.5.7", + "@vitejs/plugin-vue": "^4.3.4", + "@vue/eslint-config-prettier": "^8.0.0", + "@vue/eslint-config-typescript": "^11.0.3", + "@vue/tsconfig": "^0.1.3", + "eslint": "^8.48.0", + "eslint-plugin-vue": "^9.17.0", + "rollup-plugin-typescript2": "^0.35.0", + "typescript": "~4.7.4", + "vite": "^4.4.9", + "vue-tsc": "^1.8.8" + } + }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", @@ -2807,23 +2838,8 @@ "integrity": "sha512-3Vec4pGWJVs6vDbL/pO5hYqoF1zn2w8liXuleqDJ7waI2R5JuF2eaJmYcUQETnk/DZIg47bDdyOSxihQltB2Ow==" }, "node_modules/@hotwax/dxp-components": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@hotwax/dxp-components/-/dxp-components-1.11.0.tgz", - "integrity": "sha512-z9UNzi1veT8Aj8Y1WWAGBGOR+I0s6A58qrsFj+L3LkpxTkq6zGN/JS80tTv29obEeeOfONm6XyLHvNOM6TFKyA==", - "dependencies": { - "@hotwax/oms-api": "^1.8.1", - "@ionic/core": "^6.7.5", - "@ionic/vue": "^6.7.5", - "@types/vue-barcode-reader": "^0.0.0", - "firebase": "^10.3.1", - "luxon": "^3.3.0", - "pinia": "2.0.36", - "pinia-plugin-persistedstate": "^3.1.0", - "register-service-worker": "^1.7.2", - "vue": "^3.3.4", - "vue-barcode-reader": "^1.0.3", - "vue-i18n": "^9.2.2" - } + "resolved": "../dxp-components", + "link": true }, "node_modules/@hotwax/oms-api": { "version": "1.11.1", @@ -2859,47 +2875,6 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, - "node_modules/@intlify/core-base": { - "version": "9.8.0", - "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.8.0.tgz", - "integrity": "sha512-UxaSZVZ1DwqC/CltUZrWZNaWNhfmKtfyV4BJSt/Zt4Or/fZs1iFj0B+OekYk1+MRHfIOe3+x00uXGQI4PbO/9g==", - "dependencies": { - "@intlify/message-compiler": "9.8.0", - "@intlify/shared": "9.8.0" - }, - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://github.com/sponsors/kazupon" - } - }, - "node_modules/@intlify/message-compiler": { - "version": "9.8.0", - "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.8.0.tgz", - "integrity": "sha512-McnYWhcoYmDJvssVu6QGR0shqlkJuL1HHdi5lK7fNqvQqRYaQ4lSLjYmZxwc8tRNMdIe9/KUKfyPxU9M6yCtNQ==", - "dependencies": { - "@intlify/shared": "9.8.0", - "source-map-js": "^1.0.2" - }, - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://github.com/sponsors/kazupon" - } - }, - "node_modules/@intlify/shared": { - "version": "9.8.0", - "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.8.0.tgz", - "integrity": "sha512-TmgR0RCLjzrSo+W3wT0ALf9851iFMlVI9EYNGeWvZFUQTAJx0bvfsMlPdgVtV1tDNRiAfhkFsMKu6jtUY1ZLKQ==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://github.com/sponsors/kazupon" - } - }, "node_modules/@ionic/core": { "version": "6.7.5", "resolved": "https://registry.npmjs.org/@ionic/core/-/core-6.7.5.tgz", @@ -3728,33 +3703,6 @@ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", "dev": true }, - "node_modules/@types/vue-barcode-reader": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/@types/vue-barcode-reader/-/vue-barcode-reader-0.0.0.tgz", - "integrity": "sha512-yngQhd35qGjCxMXWIqsAtF7qmxe0qUYRVd9qW5I/CcRPWDdBpqVkHnQSh6ro5BIBl3NQ3ppky7kMKS4pr+XwCQ==", - "dependencies": { - "vue": "^2.0.0" - } - }, - "node_modules/@types/vue-barcode-reader/node_modules/@vue/compiler-sfc": { - "version": "2.7.15", - "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.15.tgz", - "integrity": "sha512-FCvIEevPmgCgqFBH7wD+3B97y7u7oj/Wr69zADBf403Tui377bThTjBvekaZvlRr4IwUAu3M6hYZeULZFJbdYg==", - "dependencies": { - "@babel/parser": "^7.18.4", - "postcss": "^8.4.14", - "source-map": "^0.6.1" - } - }, - "node_modules/@types/vue-barcode-reader/node_modules/vue": { - "version": "2.7.15", - "resolved": "https://registry.npmjs.org/vue/-/vue-2.7.15.tgz", - "integrity": "sha512-a29fsXd2G0KMRqIFTpRgpSbWaNBK3lpCTOLuGLEDnlHWdjB8fwl6zyYZ8xCrqkJdatwZb4mGHiEfJjnw0Q6AwQ==", - "dependencies": { - "@vue/compiler-sfc": "2.7.15", - "csstype": "^3.1.0" - } - }, "node_modules/@types/webpack-env": { "version": "1.18.4", "resolved": "https://registry.npmjs.org/@types/webpack-env/-/webpack-env-1.18.4.tgz", @@ -5168,26 +5116,6 @@ "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==", "dev": true }, - "node_modules/@zxing/library": { - "version": "0.19.3", - "resolved": "https://registry.npmjs.org/@zxing/library/-/library-0.19.3.tgz", - "integrity": "sha512-RUv5svewpDoD0ymXleOP8yVTO5BLkR0zn5coGC/Vs1671u0OBJ4xdtR8WVWf08OcvrieEMHdSfQY3ZKtqII/hg==", - "dependencies": { - "ts-custom-error": "^3.2.1" - }, - "engines": { - "node": ">= 10.4.0" - }, - "optionalDependencies": { - "@zxing/text-encoding": "~0.9.0" - } - }, - "node_modules/@zxing/text-encoding": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/@zxing/text-encoding/-/text-encoding-0.9.0.tgz", - "integrity": "sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA==", - "optional": true - }, "node_modules/abbrev": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-2.0.0.tgz", @@ -12816,64 +12744,6 @@ "node": ">=0.10.0" } }, - "node_modules/pinia": { - "version": "2.0.36", - "resolved": "https://registry.npmjs.org/pinia/-/pinia-2.0.36.tgz", - "integrity": "sha512-4UKApwjlmJH+VuHKgA+zQMddcCb3ezYnyewQ9NVrsDqZ/j9dMv5+rh+1r48whKNdpFkZAWVxhBp5ewYaYX9JcQ==", - "dependencies": { - "@vue/devtools-api": "^6.5.0", - "vue-demi": "*" - }, - "funding": { - "url": "https://github.com/sponsors/posva" - }, - "peerDependencies": { - "@vue/composition-api": "^1.4.0", - "typescript": ">=4.4.4", - "vue": "^2.6.14 || ^3.2.0" - }, - "peerDependenciesMeta": { - "@vue/composition-api": { - "optional": true - }, - "typescript": { - "optional": true - } - } - }, - "node_modules/pinia-plugin-persistedstate": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.0.tgz", - "integrity": "sha512-tZbNGf2vjAQcIm7alK40sE51Qu/m9oWr+rEgNm/2AWr1huFxj72CjvpQcIQzMknDBJEkQznCLAGtJTIcLKrKdw==", - "peerDependencies": { - "pinia": "^2.0.0" - } - }, - "node_modules/pinia/node_modules/vue-demi": { - "version": "0.14.6", - "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.6.tgz", - "integrity": "sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==", - "hasInstallScript": true, - "bin": { - "vue-demi-fix": "bin/vue-demi-fix.js", - "vue-demi-switch": "bin/vue-demi-switch.js" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/antfu" - }, - "peerDependencies": { - "@vue/composition-api": "^1.0.0-rc.1", - "vue": "^3.0.0-0 || ^2.6.0" - }, - "peerDependenciesMeta": { - "@vue/composition-api": { - "optional": true - } - } - }, "node_modules/pkg-dir": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", @@ -14768,6 +14638,7 @@ "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -15596,14 +15467,6 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "dev": true }, - "node_modules/ts-custom-error": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/ts-custom-error/-/ts-custom-error-3.3.1.tgz", - "integrity": "sha512-5OX1tzOjxWEgsr/YEUWSuPrQ00deKLh6D7OTWcvNHm12/7QPyRh8SYpyWvA4IZv8H/+GQWQEh/kwo95Q9OVW1A==", - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/ts-loader": { "version": "9.5.1", "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.5.1.tgz", @@ -16155,14 +16018,6 @@ } } }, - "node_modules/vue-barcode-reader": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/vue-barcode-reader/-/vue-barcode-reader-1.0.3.tgz", - "integrity": "sha512-z4mv7+ai/8vECppBTb00tHnyFMMx6W1rAaQe+v214ihoaWK9iGrn8ZZsmgSxf3lwnrtGaibLdkonTtMrGsO+dA==", - "dependencies": { - "@zxing/library": "^0.19.1" - } - }, "node_modules/vue-component-type-helpers": { "version": "1.8.25", "resolved": "https://registry.npmjs.org/vue-component-type-helpers/-/vue-component-type-helpers-1.8.25.tgz", @@ -16274,25 +16129,6 @@ "integrity": "sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog==", "dev": true }, - "node_modules/vue-i18n": { - "version": "9.8.0", - "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.8.0.tgz", - "integrity": "sha512-Izho+6PYjejsTq2mzjcRdBZ5VLRQoSuuexvR8029h5CpN03FYqiqBrShMyf2I1DKkN6kw/xmujcbvC+4QybpsQ==", - "dependencies": { - "@intlify/core-base": "9.8.0", - "@intlify/shared": "9.8.0", - "@vue/devtools-api": "^6.5.0" - }, - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://github.com/sponsors/kazupon" - }, - "peerDependencies": { - "vue": "^3.0.0" - } - }, "node_modules/vue-loader": { "version": "17.3.1", "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-17.3.1.tgz", diff --git a/package.json b/package.json index 49634ea8d..e50db5773 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@casl/ability": "^6.0.0", "@hotwax/app-version-info": "^1.0.0", "@hotwax/apps-theme": "^1.1.0", - "@hotwax/dxp-components": "^1.11.0", + "@hotwax/dxp-components": "file:../dxp-components", "@hotwax/oms-api": "^1.11.1", "@ionic/core": "6.7.5", "@ionic/vue": "6.7.5", diff --git a/public/firebase-messaging-sw.js b/public/firebase-messaging-sw.js index decaf31a9..a88d10905 100644 --- a/public/firebase-messaging-sw.js +++ b/public/firebase-messaging-sw.js @@ -7,7 +7,7 @@ importScripts('https://www.gstatic.com/firebasejs/8.10.1/firebase-messaging.js') // wrapping the logic inside function and calling it as an IIFE // to provide return statement support (function () { - const firebaseConfig = { apiKey: "", authDomain: "", databaseURL: "", projectId: "", storageBucket: "", messagingSenderId: "", appId: "" } + const firebaseConfig = { apiKey: "AIzaSyAq-jeG6dy8y2O6p_RYKk_MpkfTZ97GF_Q", authDomain: "http://hotwax-digital-commerce.firebaseapp.com/", databaseURL: "https://hotwax-digital-commerce.firebaseio.com/", projectId: "hotwax-digital-commerce", storageBucket: "http://hotwax-digital-commerce.appspot.com/", messagingSenderId: "211268342110", appId: "1:211268342110:web:6fa33f0d16129925c27fcf" } if (Object.values(firebaseConfig).some(value => !value)) { return diff --git a/src/App.vue b/src/App.vue index fbd764067..01927a959 100644 --- a/src/App.vue +++ b/src/App.vue @@ -14,6 +14,8 @@ import { initialise, resetConfig } from '@/adapter' import { useRouter } from 'vue-router'; import { translate, useProductIdentificationStore } from "@hotwax/dxp-components"; import logger from '@/logger' +import { addNotification, storeClientRegistrationToken } from '@/utils/firebase'; +import { initialiseFirebaseApp } from '@hotwax/dxp-components'; export default defineComponent({ name: 'App', @@ -98,6 +100,13 @@ export default defineComponent({ await useProductIdentificationStore().getIdentificationPref(this.currentEComStore?.productStoreId) .catch((error) => logger.error(error)); } + + await initialiseFirebaseApp( + JSON.parse(process.env.VUE_APP_FIREBASE_CONFIG), + process.env.VUE_APP_FIREBASE_VAPID_KEY, + storeClientRegistrationToken, + addNotification, + ) }, unmounted() { emitter.off('presentLoader', this.presentLoader); diff --git a/src/components/OrderItemRejHistoryModal.vue b/src/components/OrderItemRejHistoryModal.vue index ee9e8a96a..fae7ac985 100644 --- a/src/components/OrderItemRejHistoryModal.vue +++ b/src/components/OrderItemRejHistoryModal.vue @@ -13,7 +13,7 @@ - +

{{ getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(item.productId)) }}

diff --git a/src/components/ProductListItem.vue b/src/components/ProductListItem.vue index d99473dcc..e4da4229c 100644 --- a/src/components/ProductListItem.vue +++ b/src/components/ProductListItem.vue @@ -1,7 +1,7 @@