diff --git a/src/api/index.ts b/src/api/index.ts index ded8246..4d84262 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -15,6 +15,7 @@ axios.interceptors.request.use((config: any) => { return config; }); +// TODO: need to update this as per the changes in the Moqui response format, if required. axios.interceptors.response.use(function (response) { // Any status code that lie within the range of 2xx cause this function to trigger // Do something with response data @@ -69,7 +70,7 @@ const api = async (customConfig: any) => { } const baseURL = store.getters["user/getInstanceUrl"]; - if (baseURL) config.baseURL = `https://${baseURL}.hotwax.io/api/`; + if (baseURL) config.baseURL = `https://${baseURL}.hotwax.io/rest/s1/order-routing/`; if(customConfig.cache) config.adapter = axiosCache.adapter; const networkStatus = await OfflineHelper.getNetworkStatus(); if (customConfig.queue && !networkStatus.connected) { diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 0071445..6f61ac5 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -6,18 +6,12 @@ const login = async (username: string, password: string): Promise => { url: "login", method: "post", data: { - "USERNAME": username, - "PASSWORD": password + username, + password } }); } -const getProfile = async (): Promise => { - return api({ - url: "user-profile", - method: "get", - }); -} const getAvailableTimeZones = async (): Promise => { return api({ url: "getAvailableTimeZones", @@ -47,7 +41,6 @@ const checkPermission = async (payload: any): Promise => { export const UserService = { login, getAvailableTimeZones, - getProfile, setUserTimeZone, checkPermission } \ No newline at end of file diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 88c42f9..c5a2f04 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -11,42 +11,16 @@ const actions: ActionTree = { /** * Login user and return token */ - async login ({ commit, dispatch }, { username, password }) { + async login({ commit }, { username, password }) { try { + // TODO: implement support for fetching user-profile + // TODO: implement support for permission check + // TODO: implement support for fetching product stores for user const resp = await UserService.login(username, password) if (resp.status === 200 && resp.data) { if (resp.data.token) { - const permissionId = process.env.VUE_APP_PERMISSION_ID; - if (permissionId) { - const checkPermissionResponse = await UserService.checkPermission({ - data: { - permissionId - }, - headers: { - Authorization: "Bearer " + resp.data.token, - "Content-Type": "application/json" - } - }); - - if (checkPermissionResponse.status === 200 && !hasError(checkPermissionResponse) && checkPermissionResponse.data && checkPermissionResponse.data.hasPermission) { - commit(types.USER_TOKEN_CHANGED, { newToken: resp.data.token }) - dispatch("getProfile") - if (resp.data._EVENT_MESSAGE_ && resp.data._EVENT_MESSAGE_.startsWith("Alert:")) { - // TODO Internationalise text - showToast(translate(resp.data._EVENT_MESSAGE_)); - } - return resp.data; - } else { - const permissionError = "You do not have permission to access the app."; - showToast(translate(permissionError)); - console.error("error", permissionError); - return Promise.reject(new Error(permissionError)); - } - } else { - commit(types.USER_TOKEN_CHANGED, { newToken: resp.data.token }) - dispatch("getProfile") - return resp.data; - } + commit(types.USER_TOKEN_CHANGED, { newToken: resp.data.token }) + return resp.data; } else if (hasError(resp)) { showToast(translate("Sorry, your username or password is incorrect. Please try again.")); console.error("error", resp.data._ERROR_MESSAGE_); @@ -74,16 +48,6 @@ const actions: ActionTree = { }, - /** - * Get User profile - */ - async getProfile ( { commit }) { - const resp = await UserService.getProfile() - if (resp.status === 200) { - commit(types.USER_INFO_UPDATED, resp.data); - } - }, - /** * update current facility information */ @@ -107,7 +71,7 @@ const actions: ActionTree = { /** * Set User Instance Url */ - setUserInstanceUrl ({ state, commit }, payload){ + setUserInstanceUrl ({ commit }, payload){ commit(types.USER_INSTANCE_URL_UPDATED, payload) } } diff --git a/src/views/Login.vue b/src/views/Login.vue index 49f3359..4e317b7 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -6,16 +6,13 @@ - {{ $t("OMS") }} - + - {{ $t("Username") }} - + - {{ $t("Password") }} - +
@@ -33,8 +30,8 @@ import { IonContent, IonInput, IonItem, - IonLabel, - IonPage } from "@ionic/vue"; + IonPage +} from "@ionic/vue"; import { defineComponent } from "vue"; import { useRouter } from "vue-router"; import { useStore } from "@/store"; @@ -48,7 +45,6 @@ export default defineComponent({ IonContent, IonInput, IonItem, - IonLabel, IonPage, Logo },