From c12536c0849fcd84a026c058414d0d45ed31213e Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Mon, 16 Jan 2023 11:49:12 +0100 Subject: [PATCH] change(ui) - project id check on login --- frontend/app/duck/site.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/app/duck/site.js b/frontend/app/duck/site.js index 4ce55bba5..967429806 100644 --- a/frontend/app/duck/site.js +++ b/frontend/app/duck/site.js @@ -61,11 +61,12 @@ const reducer = (state = initialState, action = {}) => { return state.setIn([ 'instance', 'gdpr' ], gdpr); case FETCH_LIST_SUCCESS: let siteId = state.get("siteId"); - const siteExists = action.data.map(s => s.projectId).includes(siteId); - if (action.siteIdFromPath) { + const siteIds = action.data.map(s => parseInt(s.projectId)) + const siteExists = siteIds.includes(siteId); + if (action.siteIdFromPath && siteIds.includes(parseInt(action.siteIdFromPath))) { siteId = action.siteIdFromPath; } else if (!siteId || !siteExists) { - siteId = !!action.data.find(s => s.projectId === parseInt(storedSiteId)) + siteId = siteIds.includes(parseInt(storedSiteId)) ? storedSiteId : action.data[0].projectId; }