From 8968b1b49022ed150440d447a839546f12b8f421 Mon Sep 17 00:00:00 2001 From: k2maan Date: Mon, 9 Oct 2023 19:08:09 +0530 Subject: [PATCH] Implemented: setLocale API --- src/index.ts | 3 ++- src/modules/index.ts | 5 +++-- src/modules/user/index.ts | 21 ++++++++++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index ddb2ae5..6814cd1 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 { 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, @@ -43,4 +43,5 @@ export { User, getUserPreference, setUserPreference, + setUserLocale } \ No newline at end of file diff --git a/src/modules/index.ts b/src/modules/index.ts index 9f11868..a8a1c75 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 } 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' @@ -24,5 +24,6 @@ export { getUserFacilities, updateOrderStatus, getUserPreference, - setUserPreference + setUserPreference, + setUserLocale } \ No newline at end of file diff --git a/src/modules/user/index.ts b/src/modules/user/index.ts index 0e7b02a..2ed3b34 100644 --- a/src/modules/user/index.ts +++ b/src/modules/user/index.ts @@ -272,6 +272,24 @@ async function setUserPreference(payload: any): Promise { } } +const setUserLocale = async (payload: any): Promise => { + 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, @@ -279,5 +297,6 @@ export { getProfile, logout, setProductIdentificationPref, - setUserPreference + setUserPreference, + setUserLocale } \ No newline at end of file