1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { Dispatch } from "redux";
6 import { RootState } from "~/store/store";
7 import { initialize } from "redux-form";
8 import { ServiceRepository } from "~/services/services";
9 import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions";
10 import { authActions } from "~/store/auth/auth-action";
11 import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions";
13 export const MY_ACCOUNT_FORM = 'myAccountForm';
15 export const loadMyAccountPanel = () =>
16 (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
17 dispatch(setBreadcrumbs([{ label: 'User profile'}]));
20 export const saveEditedUser = (resource: any) =>
21 async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
23 await services.userService.update(resource.uuid, resource);
24 services.authService.saveUser(resource);
25 dispatch(authActions.USER_DETAILS_SUCCESS(resource));
26 dispatch(initialize(MY_ACCOUNT_FORM, resource));
27 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Profile has been updated.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));