-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented: product identifier component in settings page from dxp-components (dxp-178) #237
Changes from 7 commits
09c143a
8a09afd
275f920
b6305d1
ee96843
e1b0fd4
4efbc9c
5d5aa7a
89bfd35
3378585
9a237c1
81cae65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { api, client, getConfig, initialise, logout, resetConfig, updateInstanceUrl, updateToken } from '@hotwax/oms-api' | ||
import { api, client, getConfig, getProductIdentificationPref, initialise, logout, resetConfig, setProductIdentificationPref, updateInstanceUrl, updateToken } from '@hotwax/oms-api' | ||
|
||
export { | ||
api, | ||
client, | ||
getConfig, | ||
getProductIdentificationPref, | ||
initialise, | ||
logout, | ||
resetConfig, | ||
setProductIdentificationPref, | ||
updateInstanceUrl, | ||
updateToken | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,7 +7,7 @@ import { hasError, showToast } from '@/utils' | |||||
import { translate } from '@/i18n' | ||||||
import { Settings } from 'luxon' | ||||||
import { updateInstanceUrl, updateToken, resetConfig, logout } from '@/adapter' | ||||||
import { useAuthStore } from '@hotwax/dxp-components'; | ||||||
import { useAuthStore, useProductIdentificationStore } from '@hotwax/dxp-components'; | ||||||
import { getServerPermissionsFromRules, prepareAppPermissions, resetPermissions, setPermissions } from '@/authorization' | ||||||
import emitter from '@/event-bus' | ||||||
|
||||||
|
@@ -21,58 +21,64 @@ const actions: ActionTree<UserState, RootState> = { | |||||
const { token, oms } = payload; | ||||||
dispatch("setUserInstanceUrl", oms); | ||||||
try { | ||||||
if (token) { | ||||||
// Getting the permissions list from server | ||||||
const permissionId = process.env.VUE_APP_PERMISSION_ID; | ||||||
|
||||||
// Prepare permissions list | ||||||
const serverPermissionsFromRules = getServerPermissionsFromRules(); | ||||||
if (permissionId) serverPermissionsFromRules.push(permissionId); | ||||||
|
||||||
const serverPermissions = await UserService.getUserPermissions({ | ||||||
permissionIds: serverPermissionsFromRules | ||||||
}, token); | ||||||
const appPermissions = prepareAppPermissions(serverPermissions); | ||||||
|
||||||
// Checking if the user has permission to access the app | ||||||
// If there is no configuration, the permission check is not enabled | ||||||
if (permissionId) { | ||||||
// As the token is not yet set in the state passing token headers explicitly | ||||||
// TODO Abstract this out, how token is handled should be part of the method not the callee | ||||||
const hasPermission = appPermissions.some((appPermissionId: any) => appPermissionId === permissionId ); | ||||||
// If there are any errors or permission check fails do not allow user to login | ||||||
if (hasPermission) { | ||||||
const permissionError = 'You do not have permission to access the app.'; | ||||||
showToast(translate(permissionError)); | ||||||
console.error("error", permissionError); | ||||||
return Promise.reject(new Error(permissionError)); | ||||||
} | ||||||
if (token) { | ||||||
// Getting the permissions list from server | ||||||
const permissionId = process.env.VUE_APP_PERMISSION_ID; | ||||||
|
||||||
// Prepare permissions list | ||||||
const serverPermissionsFromRules = getServerPermissionsFromRules(); | ||||||
if (permissionId) serverPermissionsFromRules.push(permissionId); | ||||||
|
||||||
const serverPermissions = await UserService.getUserPermissions({ | ||||||
permissionIds: serverPermissionsFromRules | ||||||
}, token); | ||||||
const appPermissions = prepareAppPermissions(serverPermissions); | ||||||
|
||||||
// Checking if the user has permission to access the app | ||||||
// If there is no configuration, the permission check is not enabled | ||||||
if (permissionId) { | ||||||
// As the token is not yet set in the state passing token headers explicitly | ||||||
// TODO Abstract this out, how token is handled should be part of the method not the callee | ||||||
const hasPermission = appPermissions.some((appPermissionId: any) => appPermissionId === permissionId ); | ||||||
// If there are any errors or permission check fails do not allow user to login | ||||||
if (hasPermission) { | ||||||
const permissionError = 'You do not have permission to access the app.'; | ||||||
showToast(translate(permissionError)); | ||||||
console.error("error", permissionError); | ||||||
return Promise.reject(new Error(permissionError)); | ||||||
} | ||||||
} | ||||||
|
||||||
// Getting user profile | ||||||
const userProfile = await UserService.getUserProfile(token); | ||||||
userProfile.stores = await UserService.getEComStores(token, userProfile.partyId); | ||||||
// Getting user preferred store | ||||||
let preferredStore = userProfile.stores[0]; | ||||||
const preferredStoreId = await UserService.getPreferredStore(token); | ||||||
if (preferredStoreId) { | ||||||
const store = userProfile.stores.find((store: any) => store.productStoreId === preferredStoreId); | ||||||
store && (preferredStore = store) | ||||||
} | ||||||
// Getting user profile | ||||||
const userProfile = await UserService.getUserProfile(token); | ||||||
userProfile.stores = await UserService.getEComStores(token, userProfile.partyId); | ||||||
|
||||||
// Getting user preferred store | ||||||
let preferredStore = userProfile.stores[0]; | ||||||
const preferredStoreId = await UserService.getPreferredStore(token); | ||||||
if (preferredStoreId) { | ||||||
const store = userProfile.stores.find((store: any) => store.productStoreId === preferredStoreId); | ||||||
store && (preferredStore = store) | ||||||
} | ||||||
|
||||||
setPermissions(appPermissions); | ||||||
if (userProfile.userTimeZone) { | ||||||
Settings.defaultZone = userProfile.userTimeZone; | ||||||
} | ||||||
setPermissions(appPermissions); | ||||||
if (userProfile.userTimeZone) { | ||||||
Settings.defaultZone = userProfile.userTimeZone; | ||||||
} | ||||||
|
||||||
// TODO user single mutation | ||||||
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, preferredStore); | ||||||
commit(types.USER_INFO_UPDATED, userProfile); | ||||||
commit(types.USER_TOKEN_CHANGED, { newToken: token }); | ||||||
commit(types.USER_PERMISSIONS_UPDATED, appPermissions); | ||||||
updateToken(token); | ||||||
// TODO user single mutation | ||||||
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, preferredStore); | ||||||
commit(types.USER_INFO_UPDATED, userProfile); | ||||||
commit(types.USER_TOKEN_CHANGED, { newToken: token }); | ||||||
commit(types.USER_PERMISSIONS_UPDATED, appPermissions); | ||||||
updateToken(token); | ||||||
|
||||||
// Get product identification from api using dxp-component and set the state if eComStore is defined | ||||||
if (preferredStoreId){ | ||||||
await useProductIdentificationStore().getIdentificationPref(preferredStoreId) | ||||||
.catch((error) => console.error(error)); | ||||||
} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can move this logic above, where we are checking for preferredStoreId. |
||||||
} | ||||||
} catch (err: any) { | ||||||
showToast(translate('Something went wrong')); | ||||||
console.error("error", err); | ||||||
|
@@ -152,6 +158,12 @@ const actions: ActionTree<UserState, RootState> = { | |||||
'userPrefTypeId': 'SELECTED_BRAND', | ||||||
'userPrefValue': payload.eComStore.productStoreId | ||||||
}); | ||||||
|
||||||
// Get product identification from api using dxp-component and set the state if eComStore is defined | ||||||
if (payload.eComStore.productStoreId) { | ||||||
await useProductIdentificationStore().getIdentificationPref(payload.eComStore.productStoreId) | ||||||
.catch((error) => console.error(error)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
}, | ||||||
|
||||||
/** | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,8 @@ | |
|
||
<div class="product-info" v-if="Object.keys(currentVariant).length"> | ||
<div class="ion-padding"> | ||
<h4>{{ currentVariant.parentProductName }}</h4> | ||
<p>{{ currentVariant.sku }}</p> | ||
<h4>{{ getProductIdentificationValue(productIdentificationPref.primaryId, currentVariant) }}</h4> | ||
<p>{{ getProductIdentificationValue(productIdentificationPref.secondaryId, currentVariant) }}</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check if these changes are required or not. |
||
</div> | ||
|
||
<div class="product-features"> | ||
|
@@ -388,7 +388,7 @@ import { | |
IonRow, | ||
popoverController, | ||
} from "@ionic/vue"; | ||
import { defineComponent } from "vue"; | ||
import { computed, defineComponent } from "vue"; | ||
import { | ||
alertCircleOutline, | ||
checkmarkCircleOutline, | ||
|
@@ -397,7 +397,7 @@ import { | |
shirtOutline | ||
} from "ionicons/icons"; | ||
import { useStore } from "@/store"; | ||
import { ShopifyImg } from "@hotwax/dxp-components"; | ||
import { getProductIdentificationValue, ShopifyImg, useProductIdentificationStore } from "@hotwax/dxp-components"; | ||
import { mapGetters } from "vuex"; | ||
import { showToast, getFeature, hasError } from "@/utils"; | ||
import { translate } from "@/i18n"; | ||
|
@@ -436,7 +436,7 @@ export default defineComponent({ | |
IonToggle, | ||
IonToolbar, | ||
IonTitle, | ||
IonRow, | ||
IonRow | ||
}, | ||
data() { | ||
return { | ||
|
@@ -1125,13 +1125,18 @@ export default defineComponent({ | |
setup() { | ||
const store = useStore(); | ||
const router = useRouter(); | ||
const productIdentificationStore = useProductIdentificationStore(); | ||
let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) | ||
|
||
return { | ||
alertCircleOutline, | ||
Actions, | ||
checkmarkCircleOutline, | ||
chevronForwardOutline, | ||
copyOutline, | ||
getProductIdentificationValue, | ||
hasPermission, | ||
productIdentificationPref, | ||
router, | ||
shirtOutline, | ||
store | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,7 +120,7 @@ | |
<ShopifyImg :src="getProduct(item.productId).mainImageUrl" size="small"></ShopifyImg> | ||
</ion-thumbnail> | ||
<ion-label> | ||
<h2>{{ item.parentProductName ? item.parentProductName :item.productName }}</h2> | ||
<h2>{{ getProductIdentificationValue(productIdentificationPref.primaryId, item) }}</h2> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if the selected primaryId is not available on the product? |
||
<p v-if="$filters.getFeature(getProduct(item.productId).featureHierarchy, '1/COLOR/')">{{ $t("Color") }} : {{ $filters.getFeature(getProduct(item.productId).featureHierarchy, '1/COLOR/') }}</p> | ||
<p v-if="$filters.getFeature(getProduct(item.productId).featureHierarchy, '1/SIZE/')">{{ $t("Size") }} : {{ $filters.getFeature(getProduct(item.productId).featureHierarchy, '1/SIZE/') }}</p> | ||
</ion-label> | ||
|
@@ -202,7 +202,7 @@ import { | |
modalController, | ||
popoverController, | ||
} from "@ionic/vue"; | ||
import { defineComponent } from "vue"; | ||
import { computed, defineComponent } from "vue"; | ||
import WarehouseModal from "./warehouse-modal.vue"; | ||
import BackgroundJobModal from "./background-job-modal.vue"; | ||
import PromiseDateModal from "./promise-date-modal.vue"; | ||
|
@@ -222,7 +222,7 @@ import { useStore } from "@/store"; | |
import { mapGetters } from "vuex"; | ||
import { showToast } from '@/utils' | ||
import { Plugins } from '@capacitor/core'; | ||
import { ShopifyImg } from "@hotwax/dxp-components"; | ||
import { getProductIdentificationValue, ShopifyImg, useProductIdentificationStore } from "@hotwax/dxp-components"; | ||
import emitter from "@/event-bus"; | ||
|
||
const { Clipboard } = Plugins; | ||
|
@@ -475,17 +475,22 @@ export default defineComponent({ | |
}, | ||
setup() { | ||
const store = useStore(); | ||
const productIdentificationStore = useProductIdentificationStore(); | ||
let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) | ||
|
||
return { | ||
store, | ||
pricetag, | ||
ribbon, | ||
ellipsisVertical, | ||
send, | ||
business, | ||
calendar, | ||
close, | ||
closeCircle, | ||
ellipsisVertical, | ||
getProductIdentificationValue, | ||
hourglass, | ||
close, | ||
pricetag, | ||
productIdentificationPref, | ||
ribbon, | ||
send, | ||
store | ||
}; | ||
}, | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,8 @@ | |
</div> | ||
|
||
<section> | ||
<ProductIdentifier /> | ||
|
||
<ion-card> | ||
<ion-card-header> | ||
<ion-card-title> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.