-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle organization null in frontend
- Loading branch information
Showing
17 changed files
with
270 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,6 @@ export async function bootstrapCore( | |
isUserInitiallyLoggedIn, | ||
jwtClaimByUserKey, | ||
"user": { | ||
"organization": "DINUM", | ||
"email": "[email protected]", | ||
"id": "xxxxx" | ||
} | ||
|
@@ -150,7 +149,8 @@ export async function bootstrapCore( | |
dispatch(usecases.externalDataOrigin.protectedThunks.initialize()), | ||
dispatch(usecases.softwareCatalog.protectedThunks.initialize()), | ||
dispatch(usecases.generalStats.protectedThunks.initialize()), | ||
dispatch(usecases.redirect.protectedThunks.initialize()) | ||
dispatch(usecases.redirect.protectedThunks.initialize()), | ||
dispatch(usecases.userAuthentication.protectedThunks.initialize()) | ||
]); | ||
|
||
return { core }; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./state"; | ||
export * from "./thunks"; | ||
export * from "./selectors"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { State as RootState } from "core/bootstrap"; | ||
import { name } from "./state"; | ||
|
||
const currentAgent = (rootState: RootState) => { | ||
const state = rootState[name]; | ||
return { currentAgent: state.currentAgent }; | ||
}; | ||
|
||
export const selectors = { currentAgent }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,66 @@ | ||
import { Agent } from "api/dist/src/lib/ApiTypes"; | ||
import { createUsecaseActions } from "redux-clean-architecture"; | ||
import { assert } from "tsafe/assert"; | ||
import { id } from "tsafe/id"; | ||
import { actions as usersAccountManagementActions } from "../userAccountManagement"; | ||
|
||
export const name = "userAuthentication"; | ||
|
||
export const reducer = null; | ||
export type State = State.NotInitialized | State.Ready; | ||
|
||
export namespace State { | ||
export type NotInitialized = { | ||
stateDescription: "not initialized"; | ||
isInitializing: boolean; | ||
currentAgent: null; | ||
}; | ||
|
||
export type Ready = { | ||
stateDescription: "ready"; | ||
currentAgent: Agent | null; | ||
}; | ||
} | ||
|
||
export const { reducer, actions } = createUsecaseActions({ | ||
name, | ||
"initialState": id<State>({ | ||
"stateDescription": "not initialized", | ||
"currentAgent": null, | ||
"isInitializing": false | ||
}), | ||
"reducers": { | ||
"initializationStarted": state => { | ||
assert(state.stateDescription === "not initialized"); | ||
}, | ||
"initialized": (_, action: { payload: { agent: Agent | null } }) => ({ | ||
stateDescription: "ready", | ||
currentAgent: action.payload.agent | ||
}) | ||
}, | ||
extraReducers: builder => { | ||
builder.addCase( | ||
usersAccountManagementActions.updateFieldCompleted, | ||
(state, action) => { | ||
if (!state.currentAgent) return state; | ||
if (action.payload.fieldName === "organization") { | ||
return { | ||
...state, | ||
currentAgent: { | ||
...state.currentAgent, | ||
organization: action.payload.value | ||
} | ||
}; | ||
} | ||
|
||
return { | ||
...state, | ||
currentAgent: { | ||
...state.currentAgent, | ||
about: action.payload.about, | ||
isPublic: action.payload.isPublic | ||
} | ||
}; | ||
} | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.