Skip to content

Commit

Permalink
Implemented: apis to get and set timeZone of the user(dxp/139)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymaheshwari1 committed Mar 22, 2024
1 parent b6c54dd commit 5a31070
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
6 changes: 4 additions & 2 deletions 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 { getTelecomCountryCode, 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, setUserLocale } from './modules'
import { getAvailableTimeZones, getNotificationEnumIds, getNotificationUserPrefTypeIds, getUserFacilities, fetchProducts, fetchProductsGroupedBy, fetchProductsGroupedByParent, fetchProductsStock, fetchProductsStockAtFacility, getOrderDetails, getProductIdentificationPref, getProfile, logout, removeClientRegistrationToken, setProductIdentificationPref, storeClientRegistrationToken, subscribeTopic, unsubscribeTopic, updateOrderStatus, getUserPreference, setUserPreference, setUserLocale, setUserTimeZone } from './modules'

export {
api,
Expand All @@ -11,6 +11,7 @@ export {
fetchProducts,
fetchProductsGroupedBy,
fetchProductsGroupedByParent,
getAvailableTimeZones,
getNotificationEnumIds,
getNotificationUserPrefTypeIds,
getConfig,
Expand Down Expand Up @@ -44,5 +45,6 @@ export {
User,
getUserPreference,
setUserPreference,
setUserLocale
setUserLocale,
setUserTimeZone
}
6 changes: 4 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, setUserLocale } from '../modules/user'
import { getAvailableTimeZones, getProductIdentificationPref, getProfile, getUserFacilities, getUserPreference, logout, setProductIdentificationPref, setUserPreference, setUserLocale, setUserTimeZone } from '../modules/user'
import { getNotificationEnumIds, getNotificationUserPrefTypeIds, removeClientRegistrationToken, storeClientRegistrationToken, subscribeTopic, unsubscribeTopic } from '../modules/notification'
import { fetchProductsStock, fetchProductsStockAtFacility } from '../modules/stock'

Expand All @@ -10,6 +10,7 @@ export {
fetchProductsGroupedByParent,
fetchProductsStock,
fetchProductsStockAtFacility,
getAvailableTimeZones,
getNotificationEnumIds,
getNotificationUserPrefTypeIds,
getOrderDetails,
Expand All @@ -25,5 +26,6 @@ export {
updateOrderStatus,
getUserPreference,
setUserPreference,
setUserLocale
setUserLocale,
setUserTimeZone
}
48 changes: 47 additions & 1 deletion src/modules/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,59 @@ const setUserLocale = async (payload: any): Promise<any> => {
}
}

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

if (!hasError(resp)) {
return Promise.resolve(resp.data)
} else {
throw resp.data
}
} catch (error) {
return Promise.reject({
code: 'error',
message: 'Something went wrong',
serverResponse: error
})
}
}

const getAvailableTimeZones = async (): Promise <any> => {
try {
const resp: any = await api({
url: "getAvailableTimeZones",
method: "get",
cache: true
});

if (!hasError(resp)) {
return Promise.resolve(resp.data)
} else {
throw resp.data
}
} catch (error) {
return Promise.reject({
code: 'error',
message: 'Something went wrong',
serverResponse: error
})
}
}

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

0 comments on commit 5a31070

Please sign in to comment.