Skip to content

Commit

Permalink
Merge pull request #308 from amansinghbais/#220
Browse files Browse the repository at this point in the history
Implemented: product identifier component and product store selector from the dxp-components (#220)
  • Loading branch information
ymaheshwari1 authored Dec 17, 2024
2 parents 6accaf6 + 56185a3 commit f9da38b
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 33 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"@casl/ability": "^6.0.0",
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.2.6",
"@hotwax/dxp-components": "^1.15.4",
"@hotwax/oms-api": "^1.15.1",
"@hotwax/dxp-components": "^1.16.0",
"@hotwax/oms-api": "^1.16.0",
"@ionic/core": "^7.6.0",
"@ionic/vue": "^7.6.0",
"@ionic/vue-router": "~7.6.0",
Expand Down
9 changes: 8 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import emitter from "@/event-bus"
import { mapGetters, useStore } from 'vuex';
import { initialise, resetConfig } from '@/adapter'
import { showToast } from "@/utils";
import { translate } from "@hotwax/dxp-components";
import { translate, useProductIdentificationStore, useUserStore } from "@hotwax/dxp-components";
import { useRouter } from 'vue-router';
import logger from '@/logger';
export default defineComponent({
name: 'App',
Expand Down Expand Up @@ -100,6 +101,12 @@ export default defineComponent({
emitter.on('presentLoader', this.presentLoader);
emitter.on('dismissLoader', this.dismissLoader);
emitter.on('playAnimation', this.playAnimation);
if(this.userToken) {
const currentEComStore : any = useUserStore().getCurrentEComStore;
await useProductIdentificationStore().getIdentificationPref(currentEComStore.productStoreId)
.catch((error) => logger.error(error));
}
},
created() {
initialise({
Expand Down
16 changes: 14 additions & 2 deletions src/adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import {
api,
client,
getConfig,
getEComStoresByFacility,
getProductIdentificationPref,
getUserPreference,
hasError,
fetchGoodIdentificationTypes,
fetchProducts,
initialise,
logout,
Expand All @@ -12,14 +16,20 @@ import {
updateToken,
updateInstanceUrl,
setUserTimeZone,
getAvailableTimeZones
getAvailableTimeZones,
setProductIdentificationPref,
setUserPreference
} from '@hotwax/oms-api'

export {
api,
client,
getConfig,
getEComStoresByFacility,
getProductIdentificationPref,
getUserPreference,
hasError,
fetchGoodIdentificationTypes,
fetchProducts,
initialise,
logout,
Expand All @@ -29,5 +39,7 @@ export {
updateToken,
updateInstanceUrl,
setUserTimeZone,
getAvailableTimeZones
getAvailableTimeZones,
setProductIdentificationPref,
setUserPreference
}
3 changes: 2 additions & 1 deletion src/authorization/Actions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
'APP_COMMERCE_VIEW': 'APP_COMMERCE_VIEW'
'APP_COMMERCE_VIEW': 'APP_COMMERCE_VIEW',
'APP_PRODUCT_IDENTIFIER_UPDATE': 'APP_PRODUCT_IDENTIFIER_UPDATE',
}
3 changes: 2 additions & 1 deletion src/authorization/Rules.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default {
"APP_INVENTORY_VIEW": "MDM_IMP_INVENTORY_VIEW",
"IMPORT_APP_VIEW": "IMPORT_APP_VIEW",
"APP_COMMERCE_VIEW": "COMMERCEUSER_VIEW"
"APP_COMMERCE_VIEW": "COMMERCEUSER_VIEW",
"APP_PRODUCT_IDENTIFIER_UPDATE":"COMMON_ADMIN",
} as any
12 changes: 9 additions & 3 deletions src/components/PurchaseOrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<DxpShopifyImg :src="item.imageUrl" size="small" />
</ion-thumbnail>
<ion-label class="ion-text-wrap">
<h3>{{ item.pseudoId }}</h3>
<p v-if="item.initialSKU">{{ item.initialSKU }}</p>
<h3>{{ getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(item.pseudoId)) ? getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(item.pseudoId)) : item.pseudoId }}</h3>
<p>{{ getProductIdentificationValue(productIdentificationPref.secondaryId, getProduct(item.pseudoId)) }}</p>
</ion-label>
</ion-item>
<ion-chip outline class="tablet">
Expand Down Expand Up @@ -69,7 +69,8 @@ import { defineComponent } from "@vue/runtime-core";
import { mapGetters, useStore } from "vuex";
import ProductPopover from '@/components/ProductPopover.vue'
import { DateTime } from 'luxon';
import { translate } from "@hotwax/dxp-components";
import { getProductIdentificationValue, translate, useProductIdentificationStore } from "@hotwax/dxp-components";
import { computed } from "vue";
export default defineComponent({
name: "PurchaseOrderDetails",
Expand Down Expand Up @@ -158,10 +159,15 @@ export default defineComponent({
},
setup() {
const store = useStore();
const productIdentificationStore = useProductIdentificationStore();
let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref);
return {
getProductIdentificationValue,
sendOutline,
store,
ellipsisVerticalOutline,
productIdentificationPref,
translate
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"A store represents a company or a unique catalog of products. If your OMS is connected to multiple eCommerce stores selling different collections of products, you may have multiple Product Stores set up in HotWax Commerce.": "A store represents a company or a unique catalog of products. If your OMS is connected to multiple eCommerce stores selling different collections of products, you may have multiple Product Stores set up in HotWax Commerce.",
"All": "All",
"App": "App",
"Apply": "Apply",
Expand All @@ -25,6 +26,7 @@
"Changes to the date time format will cause edits done to your PO to be reverted.": "Changes to the date time format will cause edits done to your PO to be reverted.",
"Configure date time format": "Configure date time format",
"Check sample": "Check sample",
"Choosing a product identifier allows you to view products with your preferred identifiers.": "Choosing a product identifier allows you to view products with your preferred identifiers.",
"Click the backdrop to dismiss.": "Click the backdrop to dismiss.",
"Completed": "Completed",
"Confirm": "Confirm",
Expand Down Expand Up @@ -123,9 +125,12 @@
"Please upload a valid reset inventory csv to continue": "Please upload a valid reset inventory csv to continue",
"PO External Order ID": "PO External Order ID",
"Preorder": "Preorder",
"Primary": "Primary",
"Product Identification": "Product Identification",
"Product Identifier": "Product Identifier",
"Product SKU": "Product SKU",
"Product store": "Product store",
"Product Store": "Product Store",
"Product not found": "Product not found",
"Purchase order": "Purchase order",
"Purchase orders": "Purchase orders",
Expand Down Expand Up @@ -154,12 +159,14 @@
"Search": "Search",
"Search products": "Search products",
"Search time zones": "Search time zones",
"Secondary": "Secondary",
"Seems like uploaded file has missing products, checked with initial records.": "Seems like uploaded file has missing products, checked with initial {initialCount} records.",
"Schedule": "Schedule",
"Select": "Select",
"Select mapping": "Select mapping",
"Select SKU": "Select SKU",
"Select all the fields to continue": "Select all the fields to continue",
"Select store": "Select store",
"Select time zone": "Select time zone",
"Select time": "Select time",
"Select the column index for the following information in the uploaded CSV.": "Select the column index for the following information in the uploaded CSV.",
Expand All @@ -180,6 +187,7 @@
"Shopify product UPC": "Shopify product UPC",
"Start with Ionic": "Start with Ionic",
"STAY": "STAY",
"Store": "Store",
"store name": "store name",
"The inventory has been updated successfully": "The inventory has been updated successfully",
"The PO has been uploaded successfully": "The PO has been uploaded successfully",
Expand Down
9 changes: 7 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ import permissionActions from '@/authorization/Actions';
import logger from './logger';
import { dxpComponents } from '@hotwax/dxp-components'
import { login, logout, loader } from './user-utils';
import { getConfig, initialise } from '@hotwax/oms-api';
import localeMessages from './locales';
import { setUserTimeZone, getAvailableTimeZones} from '@/adapter'
import { fetchGoodIdentificationTypes, getAvailableTimeZones, getConfig, getEComStoresByFacility, getProductIdentificationPref, getUserPreference, initialise, setProductIdentificationPref, setUserPreference, setUserTimeZone } from '@/adapter'

const app = createApp(App)
.use(IonicVue, {
Expand All @@ -57,11 +56,17 @@ const app = createApp(App)
logout,
loader,
appLoginUrl: process.env.VUE_APP_LOGIN_URL as string,
fetchGoodIdentificationTypes,
getConfig,
getEComStoresByFacility,
getProductIdentificationPref,
getUserPreference,
initialise,
localeMessages,
setUserTimeZone,
getAvailableTimeZones,
setProductIdentificationPref,
setUserPreference,
hasPermission
});

Expand Down
28 changes: 28 additions & 0 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { api, client } from '@/adapter'
import store from '@/store';
import { hasError } from '@/adapter';
import logger from '@/logger';

const login = async (username: string, password: string): Promise <any> => {
return api({
Expand Down Expand Up @@ -141,10 +142,37 @@ const getUserPermissions = async (payload: any, token: any): Promise<any> => {
}
}

async function getEComStores(): Promise<any> {
const params = {
"viewSize": 200,
"fieldList": ["productStoreId", "storeName"],
"entityName": "ProductStore",
"distinct": "Y",
"noConditionFind": "Y"
};

try {
const resp = await api({
url: "performFind",
method: "get",
params
}) as any;
if(!hasError(resp)) {
return Promise.resolve(resp.data.docs?.length ? resp.data.docs : []);
} else {
throw resp.data
}
} catch(error) {
logger.error(error)
return Promise.resolve([])
}
}

export const UserService = {
createFieldMapping,
deleteFieldMapping,
login,
getEComStores,
getFieldMappings,
getProfile,
getUserPermissions,
Expand Down
10 changes: 9 additions & 1 deletion src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'
import { logout, updateInstanceUrl, updateToken, resetConfig } from '@/adapter'
import logger from "@/logger";
import { useAuthStore, translate } from '@hotwax/dxp-components';
import { useAuthStore, translate, useUserStore, useProductIdentificationStore } from '@hotwax/dxp-components';
import emitter from '@/event-bus'
import {
getServerPermissionsFromRules,
Expand Down Expand Up @@ -62,6 +62,14 @@ const actions: ActionTree<UserState, RootState> = {

await dispatch('getProfile')
dispatch('setPreferredDateTimeFormat', process.env.VUE_APP_DATE_FORMAT ? process.env.VUE_APP_DATE_FORMAT : 'MM/dd/yyyy');

const ecomStores = await UserService.getEComStores()
useUserStore().eComStores = ecomStores
await useUserStore().getEComStorePreference("SELECTED_BRAND")
const preferredStore: any = useUserStore().getCurrentEComStore

await useProductIdentificationStore().getIdentificationPref(preferredStore.productStoreId)
.catch((error) => logger.error(error));
}
} catch (err: any) {
showToast(translate('Something went wrong'));
Expand Down
14 changes: 9 additions & 5 deletions src/views/InventoryReview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
<DxpShopifyImg :src="item.imageUrl" size="small" />
</ion-thumbnail>
<ion-label class="ion-text-wrap">
<h3>{{ item.pseudoId }}</h3>
<p v-if="item.initialSKU">{{ item.initialSKU }}</p>
<h3>{{ getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(item.pseudoId)) ? getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(item.pseudoId)) : item.pseudoId }}</h3>
<p>{{ getProductIdentificationValue(productIdentificationPref.secondaryId, getProduct(item.pseudoId)) }}</p>
</ion-label>
</ion-item>

Expand Down Expand Up @@ -95,10 +95,10 @@
</template>
<script lang="ts">
import { UploadService } from "@/services/UploadService";
import { DxpShopifyImg, translate } from "@hotwax/dxp-components";
import { DxpShopifyImg, getProductIdentificationValue, translate, useProductIdentificationStore } from "@hotwax/dxp-components";
import ProductPopover from '@/components/ProductPopover.vue'
import MissingFacilitiesModal from '@/components/MissingFacilitiesModal.vue'
import { defineComponent } from 'vue';
import { computed, defineComponent } from 'vue';
import { mapGetters, useStore } from "vuex";
import { useRouter } from 'vue-router';
import { jsonToCsv, showToast } from '@/utils';
Expand Down Expand Up @@ -323,21 +323,25 @@ export default defineComponent({
setup() {
const router = useRouter();
const store = useStore();
const productIdentificationStore = useProductIdentificationStore();
let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref);
return {
businessOutline,
calculatorOutline,
chevronForwardOutline,
checkboxOutline,
ellipsisVerticalOutline,
getProductIdentificationValue,
locationOutline,
arrowUndoOutline,
shirtOutline,
cloudUploadOutline,
warningOutline,
productIdentificationPref,
router,
store,
translate
translate
}
}
});
Expand Down
Loading

0 comments on commit f9da38b

Please sign in to comment.