15088: Updates state to account for both types of linking and adds UI
[arvados-workbench2.git] / src / store / link-account-panel / link-account-panel-reducer.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { linkAccountPanelActions, LinkAccountPanelAction } from "~/store/link-account-panel/link-account-panel-actions";
6 import { UserResource, User } from "~/models/user";
7
8 export interface LinkAccountPanelState {
9     user: UserResource | undefined;
10     userToLink: UserResource | undefined;
11 }
12
13 const initialState = {
14     user: undefined,
15     userToLink: undefined
16 };
17
18 export const linkAccountPanelReducer = (state: LinkAccountPanelState = initialState, action: LinkAccountPanelAction) =>
19     linkAccountPanelActions.match(action, {
20         default: () => state,
21         LOAD_LINKING: ({ userToLink, user }) => ({ ...state, user, userToLink }),
22         REMOVE_LINKING: () => ({ ...state, user: undefined, userToLink: undefined })
23     });