Skip to content

Commit

Permalink
Implemented: added changes to render primary and secondary preference…
Browse files Browse the repository at this point in the history
… using DXP(hotwax#220)
  • Loading branch information
Ridwan6947 committed Aug 7, 2024
1 parent 5c83674 commit d0e14b8
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ VUE_APP_MAPPING_PO={"orderId": { "label": "Order ID", "required": true }, "produ
VUE_APP_MAPPING_RSTINV={"productIdentification": { "label": "Product Identification", "required": true }, "quantity": { "label": "Quantity", "required": true }, "facility": { "label": "Facility ID", "required": true }}
VUE_APP_MAPPING_RSTSTK={"productIdentification": { "label": "Product Identification", "required": true }, "restockQuantity": { "label": "Restock quantity", "required": true }}
VUE_APP_DEFAULT_LOG_LEVEL="error"
VUE_APP_LOGIN_URL="http://launchpad.hotwax.io/login"
VUE_APP_LOGIN_URL="http://launchpad.hotwax.io/login"
1 change: 1 addition & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default defineComponent({
emitter.on('playAnimation', this.playAnimation);
if(this.userToken) {
// Get product identification from api using dxp-component
await useProductIdentificationStore().getIdentificationPref(this.currentEComStore?.productStoreId)
.catch((error) => console.log(error));
}
Expand Down
6 changes: 4 additions & 2 deletions src/components/PurchaseOrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
<DxpShopifyImg :src="item.imageUrl" size="small" />
</ion-thumbnail>
<ion-label class="ion-text-wrap">
{{ getProduct.state.cached(item.productId)}}
<h2>{{ getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(item.productId)) ? getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(item.productId)) : getProduct(item.productId).productName }}</h2>
{{ productIdentificationPref.primaryId }} {{ getProduct(item.pseudoId) }}
<h2>{{ getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(item.pseudoId)) }}</h2>
<p>{{ getProductIdentificationValue(productIdentificationPref.secondaryId, getProduct(item.pseudoId)) }}</p>
</ion-label>
</ion-item>
<ion-chip outline class="tablet">
Expand Down Expand Up @@ -161,6 +162,7 @@ export default defineComponent({
const store = useStore();
const productIdentificationStore = useProductIdentificationStore();
let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref);
console.log("productIdentificationPref" , productIdentificationPref.value)
return {
sendOutline,
store,
Expand Down
32 changes: 31 additions & 1 deletion src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ const getCurrentEComStore = async (token: any, facilityId: any): Promise<any> =>
}
}

const getUserProfile = async (token: any): Promise<any> => {
const baseURL = store.getters['user/getBaseUrl'];
try {
const resp = await client({
url: "user-profile",
method: "get",
baseURL,
headers: {
Authorization: 'Bearer ' + token,
'Content-Type': 'application/json'
}
});
if(hasError(resp)) return Promise.reject("Error getting user profile");
return Promise.resolve(resp.data)
} catch(error: any) {
return Promise.reject(error)
}
}


const getProfile = async (): Promise <any> => {
return api({
url: "user-profile",
Expand All @@ -76,6 +96,14 @@ const updateFieldMapping = async (payload: any): Promise <any> => {
});
}

const setUserPreference = async (payload: any): Promise<any> => {
return api({
url: "service/setUserPreference",
method: "post",
data: payload
});
}

const deleteFieldMapping = async (payload: any): Promise <any> => {
return api({
url: "/service/deleteDataManagerMapping",
Expand Down Expand Up @@ -189,5 +217,7 @@ export const UserService = {
getProfile,
getUserPermissions,
updateFieldMapping,
getCurrentEComStore
getCurrentEComStore,
getUserProfile,
setUserPreference
}
1 change: 0 additions & 1 deletion src/store/modules/product/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import RootState from "../../RootState";
const getters: GetterTree<ProductState, RootState> = {
getProduct: (state) => (productId: string) => {
// Returning empty object so that it doesn't breaks the UI
console.log(state.cached)
return state.cached[productId] ? state.cached[productId] : {};
},
};
Expand Down
15 changes: 4 additions & 11 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const actions: ActionTree<UserState, RootState> = {
try {
const { token, oms } = payload;
dispatch("setUserInstanceUrl", oms);

if(token) {
const permissionId = process.env.VUE_APP_PERMISSION_ID;

Expand Down Expand Up @@ -52,7 +51,6 @@ const actions: ActionTree<UserState, RootState> = {
return Promise.reject(new Error(permissionError));
}
}

updateToken(token)
setPermissions(appPermissions);

Expand Down Expand Up @@ -149,23 +147,18 @@ const actions: ActionTree<UserState, RootState> = {
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, currentEComStore);

// Get product identification from api using dxp-component
await useProductIdentificationStore().getIdentificationPref(currentEComStore?.productStoreId)
const productIdentificationStore = useProductIdentificationStore();
await productIdentificationStore.getIdentificationPref(currentEComStore?.productStoreId)
.catch((error) => console.error(error));
console.log('productIdentificationStore', productIdentificationStore)
}
},

/**
* update current facility information
*/
async setFacility ({ commit, state }, payload) {
async setFacility ({ commit }, payload) {
commit(types.USER_CURRENT_FACILITY_UPDATED, payload.facility);

// get and set current ecom store in state
const currentEComStore = await UserService.getCurrentEComStore(state.token, payload.facility.facilityId);
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, currentEComStore);

await useProductIdentificationStore().getIdentificationPref(currentEComStore?.productStoreId)
.catch((error) => console.error(error));
},


Expand Down

0 comments on commit d0e14b8

Please sign in to comment.