forked from hotwax/dxp-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/hotwax/dxp-components into …
…dxp-components/hotwax#138
- Loading branch information
Showing
13 changed files
with
2,795 additions
and
650 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ module.exports = { | |
"@vue/eslint-config-typescript/recommended", | ||
"@vue/eslint-config-prettier" | ||
] | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<template> | ||
<!-- TODO: implement support for i18n --> | ||
<ion-card> | ||
<ion-card-header> | ||
<ion-card-title> | ||
{{ 'Product Identifier' }} | ||
</ion-card-title> | ||
</ion-card-header> | ||
|
||
<ion-card-content> | ||
{{ 'Choosing a product identifier allows you to view products with your preferred identifiers.' }} | ||
</ion-card-content> | ||
|
||
<ion-item> | ||
<ion-label>{{ "Primary Product Identifier" }}</ion-label> | ||
<ion-select interface="popover" :placeholder="'primary identifier'" :value="productIdentificationPref.primaryId" @ionChange="setProductIdentificationPref($event.detail.value, 'primaryId')"> | ||
<ion-select-option v-for="identification in productIdentificationOptions" :key="identification" :value="identification" >{{ identification }}</ion-select-option> | ||
</ion-select> | ||
</ion-item> | ||
<ion-item> | ||
<ion-label>{{ "Secondary Product Identifier" }}</ion-label> | ||
<ion-select interface="popover" :placeholder="'secondary identifier'" :value="productIdentificationPref.secondaryId" @ionChange="setProductIdentificationPref($event.detail.value, 'secondaryId')"> | ||
<ion-select-option v-for="identification in productIdentificationOptions" :key="identification" :value="identification" >{{ identification }}</ion-select-option> | ||
<ion-select-option value="">{{ "None" }}</ion-select-option> | ||
</ion-select> | ||
</ion-item> | ||
</ion-card> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { IonCard, IonCardContent, IonCardHeader, IonCardTitle, IonItem, IonLabel, IonSelect, IonSelectOption } from '@ionic/vue'; | ||
import { appContext } from 'src'; | ||
import { useProductIdentificationStore } from 'src/store/productIdentification'; | ||
import { computed, onMounted } from 'vue'; | ||
const productIdentificationStore = useProductIdentificationStore(); | ||
const appState = appContext.config.globalProperties.$store | ||
const eComStore = computed(() => appState.getters['user/getCurrentEComStore']) | ||
const productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref); | ||
const productIdentificationOptions = productIdentificationStore.getProductIdentificationOptions; | ||
onMounted(() => { | ||
productIdentificationStore.getIdentificationPref(eComStore.value.productStoreId); | ||
}) | ||
function setProductIdentificationPref(value: string | any, id: string) { | ||
productIdentificationStore.setProductIdentificationPref(id, value, eComStore.value.productStoreId) | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { initializeApp } from "firebase/app"; | ||
import { getMessaging, getToken, onMessage } from "firebase/messaging"; | ||
|
||
const initialiseFirebaseApp = async ( | ||
appFirebaseConfig: any, | ||
appFirebaseVapidKey: string, | ||
storeClientRegistrationToken: Function, | ||
addNotification: Function | ||
) => { | ||
const firebaseConfig = appFirebaseConfig | ||
|
||
const app = initializeApp(firebaseConfig); | ||
const messaging = getMessaging(app); | ||
const permission = await Notification.requestPermission(); | ||
|
||
if (permission === "granted") { | ||
const token = await getToken(messaging, { | ||
vapidKey: appFirebaseVapidKey | ||
}); | ||
await storeClientRegistrationToken(token) | ||
|
||
// handle foreground message | ||
onMessage(messaging, (payload: any) => { | ||
addNotification({ notification: payload, isForeground: true }); | ||
}); | ||
|
||
// handle background message (service worker) | ||
const broadcast = new BroadcastChannel('FB_BG_MESSAGES'); | ||
broadcast.onmessage = (event) => { | ||
addNotification({ notification: event.data, isForeground: false }); | ||
}; | ||
} else { | ||
alert("You denied notifications."); | ||
} | ||
}; | ||
|
||
export { | ||
initialiseFirebaseApp, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,30 @@ | ||
const goToOms = (token: string, oms: string) => { | ||
const link = (oms.startsWith('http') ? oms.replace(/api\/?/, "") : `https://${oms}.hotwax.io/`) + `?token=${token}` | ||
const link = (oms.startsWith('http') ? oms.replace(/api\/?/, "") : `https://${oms}.hotwax.io/`) + `commerce/control/main?token=${token}` | ||
|
||
window.open(link, '_blank', 'noopener, noreferrer') | ||
} | ||
|
||
const getProductIdentificationValue = (productIdentifier: string, product: any) => { | ||
// handled this case as on page load initially the data is not available, so not to execute furthur code | ||
// untill product is not available | ||
if(!Object.keys(product).length) { | ||
return; | ||
} | ||
|
||
let value = product[productIdentifier] | ||
|
||
// considered that the goodIdentification will always have values in the format "productIdentifier/value" and there will be no entry like "productIdentifier/" | ||
const identification = product['goodIdentifications'].find((identification: string) => identification.startsWith(productIdentifier + "/")) | ||
|
||
if(identification) { | ||
const goodIdentification = identification.split('/') | ||
value = goodIdentification[1] | ||
} | ||
|
||
return value; | ||
} | ||
|
||
export { | ||
getProductIdentificationValue, | ||
goToOms | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ | |
"path": "./tsconfig.vite-config.json" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
"composite": true, | ||
"types": ["node", "vitest"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters