diff --git a/src/index.ts b/src/index.ts index 0ee3ef4..deefcb6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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, @@ -11,6 +11,7 @@ export { fetchProducts, fetchProductsGroupedBy, fetchProductsGroupedByParent, + getAvailableTimeZones, getNotificationEnumIds, getNotificationUserPrefTypeIds, getConfig, @@ -44,5 +45,6 @@ export { User, getUserPreference, setUserPreference, - setUserLocale + setUserLocale, + setUserTimeZone } \ No newline at end of file diff --git a/src/modules/index.ts b/src/modules/index.ts index a8a1c75..839fc53 100644 --- a/src/modules/index.ts +++ b/src/modules/index.ts @@ -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' @@ -10,6 +10,7 @@ export { fetchProductsGroupedByParent, fetchProductsStock, fetchProductsStockAtFacility, + getAvailableTimeZones, getNotificationEnumIds, getNotificationUserPrefTypeIds, getOrderDetails, @@ -25,5 +26,6 @@ export { updateOrderStatus, getUserPreference, setUserPreference, - setUserLocale + setUserLocale, + setUserTimeZone } \ No newline at end of file diff --git a/src/modules/user/index.ts b/src/modules/user/index.ts index 464cd7e..9397c66 100644 --- a/src/modules/user/index.ts +++ b/src/modules/user/index.ts @@ -314,7 +314,52 @@ const setUserLocale = async (payload: any): Promise => { } } +const setUserTimeZone = async (payload: any): Promise => { + 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 => { + 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, @@ -322,5 +367,6 @@ export { logout, setProductIdentificationPref, setUserPreference, - setUserLocale + setUserLocale, + setUserTimeZone } \ No newline at end of file