updated occupant and employee login completed
This commit is contained in:
@@ -37,8 +37,10 @@ const setActiveSelectionToRedis = async (selectionObject: any) => {
|
||||
activeSelection: selectionObject
|
||||
}
|
||||
})
|
||||
console.log("oldData", oldData)
|
||||
if (oldData.online.userType.toUpperCase() === "EMPLOYEE") {
|
||||
await loginSelectEmployee({ uuid: selectionObject.uuid });
|
||||
console.log("selectionObject", selectionObject)
|
||||
await loginSelectEmployee({ uuid: selectionObject.uu_id });
|
||||
} else if (oldData.online.userType.toUpperCase() === "OCCUPANT") {
|
||||
await loginSelectOccupant({ uuid: selectionObject.build_living_space_uu_id });
|
||||
}
|
||||
|
||||
@@ -25,10 +25,6 @@ async function logoutActiveSession() {
|
||||
|
||||
async function initRedis(loginRespone: any, firstSelection: any, accessToken: string, redisKey: string) {
|
||||
let alreadyAtRedis = null
|
||||
console.log("loginRespone", loginRespone)
|
||||
console.log("firstSelection", firstSelection)
|
||||
console.log("accessToken", accessToken)
|
||||
console.log("redisKey", redisKey)
|
||||
if (!alreadyAtRedis) {
|
||||
if (loginRespone.user_type.toUpperCase() === "EMPLOYEE") {
|
||||
const loginObjectToRedis = {
|
||||
@@ -64,7 +60,7 @@ async function initRedis(loginRespone: any, firstSelection: any, accessToken: st
|
||||
|
||||
async function initFirstSelection(firstSelection: any, userType: string) {
|
||||
if (userType === "EMPLOYEE") {
|
||||
const uuid = firstSelection.uuid;
|
||||
const uuid = firstSelection.uu_id;
|
||||
await loginSelectEmployee({ uuid });
|
||||
} else if (userType === "OCCUPANT") {
|
||||
const uuid = firstSelection.build_living_space_uu_id;
|
||||
@@ -87,13 +83,10 @@ async function loginViaAccessKeys(payload: LoginViaAccessKeys) {
|
||||
);
|
||||
await deleteAllCookies()
|
||||
if (response.status === 200 || response.status === 202) {
|
||||
|
||||
const loginRespone: any = response?.data;
|
||||
|
||||
let firstSelection = null
|
||||
|
||||
if (loginRespone.user_type.toUpperCase() === "EMPLOYEE") {
|
||||
firstSelection = loginRespone.selection_list.find((item: any) => item.uu_id === loginRespone.selection_list[0].uu_id);
|
||||
firstSelection = loginRespone.selection_list[0];
|
||||
} else if (loginRespone.user_type.toUpperCase() === "OCCUPANT") {
|
||||
const firstKeyOfSelectionList = Object.keys(loginRespone.selection_list)[0];
|
||||
firstSelection = loginRespone.selection_list[firstKeyOfSelectionList].occupants[0];
|
||||
@@ -165,6 +158,7 @@ async function loginViaAccessKeys(payload: LoginViaAccessKeys) {
|
||||
}
|
||||
|
||||
async function loginSelectEmployee(payload: LoginSelect) {
|
||||
console.log("payload", payload)
|
||||
const employeeUUID = payload.uuid;
|
||||
const selectResponse: any = await fetchDataWithToken(urlLoginSelectEndpoint, { uuid: employeeUUID }, "POST", false);
|
||||
console.log("selectResponse", selectResponse)
|
||||
|
||||
Reference in New Issue
Block a user