Skip to content

Commit

Permalink
Merge pull request #75 from k2maan/preference-services
Browse files Browse the repository at this point in the history
Implemented: usage of setLocale API
  • Loading branch information
ravilodhi authored Oct 12, 2023
2 parents caee0fb + 8968b1b commit eaae916
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { events, Product, Response, Stock, Order, OrderItem, OrderPart, OPERATOR, User } from './types'
import api, { client, getConfig, init, initialise, resetConfig, updateToken, updateInstanceUrl } from './api'
import { hasError, isError } from './util'
import { getNotificationEnumIds, getNotificationUserPrefTypeIds, getUserFacilities, fetchProducts, fetchProductsGroupedBy, fetchProductsGroupedByParent, fetchProductsStock, fetchProductsStockAtFacility, getOrderDetails, getProductIdentificationPref, getProfile, logout, removeClientRegistrationToken, setProductIdentificationPref, storeClientRegistrationToken, subscribeTopic, unsubscribeTopic, updateOrderStatus, getUserPreference, setUserPreference } from './modules'
import { getNotificationEnumIds, getNotificationUserPrefTypeIds, getUserFacilities, fetchProducts, fetchProductsGroupedBy, fetchProductsGroupedByParent, fetchProductsStock, fetchProductsStockAtFacility, getOrderDetails, getProductIdentificationPref, getProfile, logout, removeClientRegistrationToken, setProductIdentificationPref, storeClientRegistrationToken, subscribeTopic, unsubscribeTopic, updateOrderStatus, getUserPreference, setUserPreference, setUserLocale } from './modules'

export {
api,
Expand Down Expand Up @@ -43,4 +43,5 @@ export {
User,
getUserPreference,
setUserPreference,
setUserLocale
}
5 changes: 3 additions & 2 deletions src/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getOrderDetails, updateOrderStatus } from '../modules/order'
import { fetchProducts, fetchProductsGroupedBy, fetchProductsGroupedByParent } from '../modules/product'
import { getProductIdentificationPref, getProfile, getUserFacilities, getUserPreference, logout, setProductIdentificationPref, setUserPreference } from '../modules/user'
import { getProductIdentificationPref, getProfile, getUserFacilities, getUserPreference, logout, setProductIdentificationPref, setUserPreference, setUserLocale } from '../modules/user'
import { getNotificationEnumIds, getNotificationUserPrefTypeIds, removeClientRegistrationToken, storeClientRegistrationToken, subscribeTopic, unsubscribeTopic } from '../modules/notification'
import { fetchProductsStock, fetchProductsStockAtFacility } from '../modules/stock'

Expand All @@ -24,5 +24,6 @@ export {
getUserFacilities,
updateOrderStatus,
getUserPreference,
setUserPreference
setUserPreference,
setUserLocale
}
21 changes: 20 additions & 1 deletion src/modules/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,31 @@ async function setUserPreference(payload: any): Promise<any> {
}
}

const setUserLocale = async (payload: any): Promise<any> => {
try {
const resp: any = await api({
url: "setUserLocale",
method: "post",
data: payload
})

if (!hasError(resp)) {
return Promise.resolve(resp.data)
} else {
throw resp.data
}
} catch (error) {
return Promise.reject(error)
}
}

export {
getUserFacilities,
getUserPreference,
getProductIdentificationPref,
getProfile,
logout,
setProductIdentificationPref,
setUserPreference
setUserPreference,
setUserLocale
}

0 comments on commit eaae916

Please sign in to comment.