Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into #280-i18n-update
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Sourabh committed Mar 21, 2024
2 parents e7610ed + 4ce5bf9 commit 029c445
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 39 deletions.
16 changes: 4 additions & 12 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@capacitor/ios": "^2.5.0",
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.2.6",
"@hotwax/dxp-components": "^1.12.1",
"@hotwax/dxp-components": "^1.12.2",
"@hotwax/oms-api": "^1.13.0",
"@ionic/core": "~7.6.0",
"@ionic/vue": "~7.6.0",
Expand Down
3 changes: 2 additions & 1 deletion src/adapter/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { api, client, getConfig, getProductIdentificationPref, initialise, logout, resetConfig, setProductIdentificationPref, updateInstanceUrl, updateToken } from '@hotwax/oms-api'
import { api, client, getConfig, getProductIdentificationPref, hasError, initialise, logout, resetConfig, setProductIdentificationPref, updateInstanceUrl, updateToken } from '@hotwax/oms-api'

export {
api,
client,
getConfig,
getProductIdentificationPref,
hasError,
initialise,
logout,
resetConfig,
Expand Down
3 changes: 1 addition & 2 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { api, client } from '@/adapter'
import { api, client, hasError } from '@/adapter'
import store from '@/store';
import { hasError } from '@/utils';

const login = async (username: string, password: string): Promise <any> => {
return api({
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/party/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ActionTree } from 'vuex'
import RootState from '@/store/RootState'
import PartyState from './PartyState'
import * as types from './mutation-types'
import { hasError } from '@/utils'
import { hasError } from '@/adapter'


const actions: ActionTree<PartyState, RootState> = {
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/picklist/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import RootState from '@/store/RootState'
import PicklistState from './PicklistState'
import * as types from './mutation-types'
import { PicklistService } from '@/services/PicklistService'
import { hasError, showToast } from '@/utils'
import { showToast } from '@/utils'
import { hasError } from '@/adapter'
import { translate } from '@hotwax/dxp-components'

const actions: ActionTree<PicklistState, RootState> = {
Expand Down
14 changes: 4 additions & 10 deletions src/store/modules/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import RootState from '@/store/RootState'
import ProductState from './ProductState'
import * as types from './mutation-types'
import { ProductService } from '@/services/ProductService'
import { hasError } from '@/utils'
import { hasError } from '@/adapter'

const actions: ActionTree<ProductState, RootState> = {

Expand All @@ -12,15 +12,9 @@ const actions: ActionTree<ProductState, RootState> = {
*/
async fetchProducts ( { commit, state }, { productIds }) {
const cachedProductIds = Object.keys(state.cached);
const productIdFilter= productIds.reduce((filter: string, productId: any) => {
if (filter !== '') filter += ' OR '
// If product already exist in cached products skip
if (cachedProductIds.includes(productId)) {
return filter;
} else {
return filter += productId;
}
}, '');
const remainingProductIds = productIds.filter((productId: any) => !cachedProductIds.includes(productId))

const productIdFilter = remainingProductIds.join(' OR ')

// If there are no products skip the API call
if (productIdFilter === '') return;
Expand Down
7 changes: 3 additions & 4 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { ActionTree } from 'vuex'
import RootState from '@/store/RootState'
import UserState from './UserState'
import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'
import { translate } from '@hotwax/dxp-components'
import { showToast } from '@/utils'
import { Settings } from 'luxon';
import { logout, updateInstanceUrl, updateToken, resetConfig } from '@/adapter'
import { useAuthStore, useProductIdentificationStore } from '@hotwax/dxp-components'
import { hasError, logout, updateInstanceUrl, updateToken, resetConfig } from '@/adapter'
import { useAuthStore, useProductIdentificationStore, translate} from '@hotwax/dxp-components'
import emitter from '@/event-bus'
import router from '@/router';

Expand Down
7 changes: 1 addition & 6 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import { DateTime } from "luxon";

// TODO Use separate files for specific utilities

// TODO Remove it when HC APIs are fully REST compliant
const hasError = (response: any) => {
return !!response.data._ERROR_MESSAGE_ || !!response.data._ERROR_MESSAGE_LIST_;
}

const showToast = async (message: string) => {
const toast = await toastController
.create({
Expand All @@ -26,4 +21,4 @@ const handleDateTimeInput = (dateTimeValue: any) => {
return DateTime.fromISO(dateTime).toMillis()
}

export { showToast, hasError, handleDateTimeInput }
export { showToast, handleDateTimeInput }
2 changes: 1 addition & 1 deletion src/views/TimezoneModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import { defineComponent } from "vue";
import { close, save } from "ionicons/icons";
import { useStore } from "@/store";
import { UserService } from "@/services/UserService";
import { hasError } from '@/utils'
import { hasError } from '@/adapter';
import { DateTime } from 'luxon';
import { translate } from "@hotwax/dxp-components";
Expand Down

0 comments on commit 029c445

Please sign in to comment.